diff --git a/news/3 Code Health/3988.md b/news/3 Code Health/3988.md new file mode 100644 index 000000000000..f8e0520d36b8 --- /dev/null +++ b/news/3 Code Health/3988.md @@ -0,0 +1 @@ +Move `splitParent` from `string.ts` into tests folder. diff --git a/src/client/common/utils/string.ts b/src/client/common/utils/string.ts deleted file mode 100644 index 00f2e014253e..000000000000 --- a/src/client/common/utils/string.ts +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -'use strict'; - -/** - * Return [parent name, name] for the given qualified (dotted) name. - * - * Examples: - * 'x.y' -> ['x', 'y'] - * 'x' -> ['', 'x'] - * 'x.y.z' -> ['x.y', 'z'] - * '' -> ['', ''] - */ -export function splitParent(fullName: string): [string, string] { - if (fullName.length === 0) { - return ['', '']; - } - const pos = fullName.lastIndexOf('.'); - if (pos < 0) { - return ['', fullName]; - } - const parentName = fullName.slice(0, pos); - const name = fullName.slice(pos + 1); - return [parentName, name]; -} diff --git a/src/test/common/utils/string.unit.test.ts b/src/test/common/utils/string.unit.test.ts deleted file mode 100644 index da0347330cef..000000000000 --- a/src/test/common/utils/string.unit.test.ts +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -'use strict'; - -// tslint:disable:max-func-body-length no-any no-require-imports no-var-requires - -import { expect } from 'chai'; -import { splitParent } from '../../../client/common/utils/string'; - -suite('splitParent()', () => { - test('valid values', async () => { - const tests: [string, [string, string]][] = [ - ['x.y', ['x', 'y']], - ['x', ['', 'x']], - ['x.y.z', ['x.y', 'z']], - ['', ['', '']] - ]; - for (const [raw, expected] of tests) { - const result = splitParent(raw); - - expect(result).to.deep.equal(expected); - } - }); -}); diff --git a/src/test/languageServers/jedi/symbolProvider.unit.test.ts b/src/test/languageServers/jedi/symbolProvider.unit.test.ts index 768b30959028..d48c10e7376a 100644 --- a/src/test/languageServers/jedi/symbolProvider.unit.test.ts +++ b/src/test/languageServers/jedi/symbolProvider.unit.test.ts @@ -14,7 +14,6 @@ import { } from 'vscode'; import { LanguageClient } from 'vscode-languageclient'; import { IFileSystem } from '../../../client/common/platform/types'; -import { splitParent } from '../../../client/common/utils/string'; import { parseRange } from '../../../client/common/utils/text'; import { IServiceContainer } from '../../../client/ioc/types'; import { JediFactory } from '../../../client/languageServices/jediProxyFactory'; @@ -462,3 +461,25 @@ function normalizeSymbols(uri: Uri, raw: any[]): SymbolInformation[] { } return symbols; } + +/** + * Return [parent name, name] for the given qualified (dotted) name. + * + * Examples: + * 'x.y' -> ['x', 'y'] + * 'x' -> ['', 'x'] + * 'x.y.z' -> ['x.y', 'z'] + * '' -> ['', ''] + */ +export function splitParent(fullName: string): [string, string] { + if (fullName.length === 0) { + return ['', '']; + } + const pos = fullName.lastIndexOf('.'); + if (pos < 0) { + return ['', fullName]; + } + const parentName = fullName.slice(0, pos); + const name = fullName.slice(pos + 1); + return [parentName, name]; +}