Skip to content

Commit 43ef0ce

Browse files
authored
Move splitParent from string.ts into tests folder (microsoft#3989)
1 parent e8b2bdd commit 43ef0ce

4 files changed

Lines changed: 23 additions & 52 deletions

File tree

news/3 Code Health/3988.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Move `splitParent` from `string.ts` into tests folder.

src/client/common/utils/string.ts

Lines changed: 0 additions & 26 deletions
This file was deleted.

src/test/common/utils/string.unit.test.ts

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/test/languageServers/jedi/symbolProvider.unit.test.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import {
1414
} from 'vscode';
1515
import { LanguageClient } from 'vscode-languageclient';
1616
import { IFileSystem } from '../../../client/common/platform/types';
17-
import { splitParent } from '../../../client/common/utils/string';
1817
import { parseRange } from '../../../client/common/utils/text';
1918
import { IServiceContainer } from '../../../client/ioc/types';
2019
import { JediFactory } from '../../../client/languageServices/jediProxyFactory';
@@ -462,3 +461,25 @@ function normalizeSymbols(uri: Uri, raw: any[]): SymbolInformation[] {
462461
}
463462
return symbols;
464463
}
464+
465+
/**
466+
* Return [parent name, name] for the given qualified (dotted) name.
467+
*
468+
* Examples:
469+
* 'x.y' -> ['x', 'y']
470+
* 'x' -> ['', 'x']
471+
* 'x.y.z' -> ['x.y', 'z']
472+
* '' -> ['', '']
473+
*/
474+
export function splitParent(fullName: string): [string, string] {
475+
if (fullName.length === 0) {
476+
return ['', ''];
477+
}
478+
const pos = fullName.lastIndexOf('.');
479+
if (pos < 0) {
480+
return ['', fullName];
481+
}
482+
const parentName = fullName.slice(0, pos);
483+
const name = fullName.slice(pos + 1);
484+
return [parentName, name];
485+
}

0 commit comments

Comments
 (0)