Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/3 Code Health/3988.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Move `splitParent` from `string.ts` into tests folder.
26 changes: 0 additions & 26 deletions src/client/common/utils/string.ts

This file was deleted.

25 changes: 0 additions & 25 deletions src/test/common/utils/string.unit.test.ts

This file was deleted.

23 changes: 22 additions & 1 deletion src/test/languageServers/jedi/symbolProvider.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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];
}