提交 bcc789e6 编写于 作者: B Benjamin Pasero

bye bye strings.replaceAll()

上级 2a121edd
......@@ -299,7 +299,7 @@ function matchExpression(expression: IExpression, path: string, siblings?: strin
}
let clause = <SiblingClause>value;
let clausePattern = strings.replaceAll(clause.when, '$(basename)', basename);
let clausePattern = clause.when.replace('$(basename)', basename);
if (siblings.some((sibling) => sibling === clausePattern)) {
return pattern;
} else {
......
......@@ -65,13 +65,6 @@ export function escapeRegExpCharacters(value: string): string {
return value.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g, '\\$&');
}
/**
* Searches for all occurrences of needle in haystack and replaces them with replacement.
*/
export function replaceAll(haystack: string, needle: string, replacement: string): string {
return haystack.replace(new RegExp(escapeRegExpCharacters(needle.toString()), 'g'), replacement);
}
/**
* Removes all occurrences of needle from the beginning and end of haystack.
* @param haystack string to trim
......@@ -145,7 +138,7 @@ export function convertSimple2RegExpPattern(pattern: string): string {
}
export function stripWildcards(pattern: string): string {
return replaceAll(pattern, '*', '');
return pattern.replace(/\*/g, '');
}
/**
......
......@@ -105,7 +105,7 @@ export class OutputWorker {
while ((match = pattern.exec(line)) !== null) {
// Convert the relative path information to a resource that we can use in links
let workspaceRelativePath = strings.replaceAll(strings.rtrim(match[1], '.'), '\\', '/'); // remove trailing "." that likely indicate end of sentence
let workspaceRelativePath = strings.rtrim(match[1], '.').replace(/\\/g, '/'); // remove trailing "." that likely indicate end of sentence
let resource:string;
try {
resource = contextService.toResource(workspaceRelativePath).toString();
......
......@@ -6,7 +6,6 @@
'use strict';
import * as assert from 'assert';
import {replaceAll} from 'vs/base/common/strings';
import URI from 'vs/base/common/uri';
import {isMacintosh, isLinux} from 'vs/base/common/platform';
import {OutputWorker} from 'vs/workbench/parts/output/common/outputWorker';
......@@ -14,7 +13,7 @@ import {TestContextService} from 'vs/workbench/test/browser/servicesTestUtils';
function toOSPath(p: string): string {
if (isMacintosh || isLinux) {
return replaceAll(p, '\\', '/');
return p.replace(/\\/g, '/');
}
return p;
......
......@@ -45,7 +45,7 @@ export class FileWalker {
this.isLimitHit = false;
if (this.filePattern) {
this.filePattern = strings.replaceAll(this.filePattern, '\\', '/'); // Normalize file patterns to forward slashes
this.filePattern = this.filePattern.replace(/\\/g, '/'); // Normalize file patterns to forward slashes
this.normalizedFilePatternLowercase = strings.stripWildcards(this.filePattern).toLowerCase();
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册