From 2c5a0544c7e214e787c1eed03e93be2a6586cb8f Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Thu, 16 Nov 2017 11:01:24 +0100 Subject: [PATCH] remove some unused bits, #38414 --- src/vs/base/common/strings.ts | 33 ------------------------- src/vs/base/common/uuid.ts | 6 ----- src/vs/base/test/common/strings.test.ts | 30 ---------------------- src/vs/base/test/common/uuid.test.ts | 7 +++--- 4 files changed, 3 insertions(+), 73 deletions(-) diff --git a/src/vs/base/common/strings.ts b/src/vs/base/common/strings.ts index 1245bef3ca4..536eabdbbea 100644 --- a/src/vs/base/common/strings.ts +++ b/src/vs/base/common/strings.ts @@ -618,20 +618,6 @@ export function isFullWidthCharacter(charCode: number): boolean { ); } -/** - * Returns an array in which every entry is the offset of a - * line. There is always one entry which is zero. - */ -export function computeLineStarts(text: string): number[] { - let regexp = /\r\n|\r|\n/g, - ret: number[] = [0], - match: RegExpExecArray; - while ((match = regexp.exec(text))) { - ret.push(regexp.lastIndex); - } - return ret; -} - /** * Given a string and a max length returns a shorted version. Shorting * happens at favorable positions - such as whitespace or punctuation characters. @@ -683,25 +669,6 @@ export function stripUTF8BOM(str: string): string { return startsWithUTF8BOM(str) ? str.substr(1) : str; } -/** - * Appends two strings. If the appended result is longer than maxLength, - * trims the start of the result and replaces it with '...'. - */ -export function appendWithLimit(first: string, second: string, maxLength: number): string { - const newLength = first.length + second.length; - if (newLength > maxLength) { - first = '...' + first.substr(newLength - maxLength); - } - if (second.length > maxLength) { - first += second.substr(second.length - maxLength); - } else { - first += second; - } - - return first; -} - - export function safeBtoa(str: string): string { return btoa(encodeURIComponent(str)); // we use encodeURIComponent because btoa fails for non Latin 1 values } diff --git a/src/vs/base/common/uuid.ts b/src/vs/base/common/uuid.ts index 89c97bbb432..704882a545c 100644 --- a/src/vs/base/common/uuid.ts +++ b/src/vs/base/common/uuid.ts @@ -13,8 +13,6 @@ export interface UUID { * @returns the canonical representation in sets of hexadecimal numbers separated by dashes. */ asHex(): string; - - equals(other: UUID): boolean; } class ValueUUID implements UUID { @@ -26,10 +24,6 @@ class ValueUUID implements UUID { public asHex(): string { return this._value; } - - public equals(other: UUID): boolean { - return this.asHex() === other.asHex(); - } } class V4UUID extends ValueUUID { diff --git a/src/vs/base/test/common/strings.test.ts b/src/vs/base/test/common/strings.test.ts index 9212cce234f..fb413969ce8 100644 --- a/src/vs/base/test/common/strings.test.ts +++ b/src/vs/base/test/common/strings.test.ts @@ -103,29 +103,6 @@ suite('Strings', () => { assert.equal(strings.overlap('full', 'full'), 4); assert.equal(strings.overlap('full', 'fulloverlap'), 4); }); - - test('computeLineStarts', function () { - function assertLineStart(text: string, ...offsets: number[]): void { - const actual = strings.computeLineStarts(text); - assert.equal(actual.length, offsets.length); - if (actual.length !== offsets.length) { - return; - } - while (offsets.length > 0) { - assert.equal(actual.pop(), offsets.pop()); - } - } - - assertLineStart('', 0); - assertLineStart('farboo', 0); - assertLineStart('far\nboo', 0, 4); - assertLineStart('far\rboo', 0, 4); - assertLineStart('far\r\nboo', 0, 5); - assertLineStart('far\n\rboo', 0, 4, 5); - assertLineStart('far\n \rboo', 0, 4, 6); - assertLineStart('far\nboo\nfar', 0, 4, 8); - }); - test('lcut', () => { assert.strictEqual(strings.lcut('foo bar', 0), ''); assert.strictEqual(strings.lcut('foo bar', 1), 'bar'); @@ -218,13 +195,6 @@ suite('Strings', () => { assert.strictEqual(' '.trim(), ''); }); - test('appendWithLimit', function () { - assert.strictEqual(strings.appendWithLimit('ab', 'cd', 100), 'abcd'); - assert.strictEqual(strings.appendWithLimit('ab', 'cd', 2), '...cd'); - assert.strictEqual(strings.appendWithLimit('ab', 'cdefgh', 4), '...efgh'); - assert.strictEqual(strings.appendWithLimit('abcdef', 'ghijk', 7), '...efghijk'); - }); - test('repeat', () => { assert.strictEqual(strings.repeat(' ', 4), ' '); assert.strictEqual(strings.repeat(' ', 1), ' '); diff --git a/src/vs/base/test/common/uuid.test.ts b/src/vs/base/test/common/uuid.test.ts index c9c37174276..eaa4ed3dbf0 100644 --- a/src/vs/base/test/common/uuid.test.ts +++ b/src/vs/base/test/common/uuid.test.ts @@ -12,14 +12,13 @@ suite('UUID', () => { var asHex = uuid.v4().asHex(); assert.equal(asHex.length, 36); assert.equal(asHex[14], '4'); - assert(asHex[19] === '8' || asHex[19] === '9' || asHex[19] === 'a' || asHex[19] === 'b'); + assert.ok(asHex[19] === '8' || asHex[19] === '9' || asHex[19] === 'a' || asHex[19] === 'b'); }); test('parse', () => { var id = uuid.v4(); var asHext = id.asHex(); var id2 = uuid.parse(asHext); - assert(id.equals(id2)); - assert(id2.equals(id)); + assert.equal(id.asHex(), id2.asHex()); }); -}); \ No newline at end of file +}); -- GitLab