mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-16 05:58:32 -06:00
More comments
This commit is contained in:
parent
8f883b9417
commit
1f7b6e6a31
@ -1015,7 +1015,9 @@ namespace ts {
|
||||
return path.replace(/\\/g, "/");
|
||||
}
|
||||
|
||||
// Returns length of path root (i.e. length of "/", "x:/", "//server/share/, file:///user/files")
|
||||
/**
|
||||
* Returns length of path root (i.e. length of "/", "x:/", "//server/share/, file:///user/files")
|
||||
*/
|
||||
export function getRootLength(path: string): number {
|
||||
if (path.charCodeAt(0) === CharacterCodes.slash) {
|
||||
if (path.charCodeAt(1) !== CharacterCodes.slash) return 1;
|
||||
@ -1074,7 +1076,7 @@ namespace ts {
|
||||
|
||||
export function normalizePath(path: string): string {
|
||||
path = normalizeSlashes(path);
|
||||
const rootLength = getRootLength(path);
|
||||
const rootLength = getRootLength(path); // TODO: this expects un-slash-normalized strings. eg: 'x:\\...'
|
||||
const root = path.substr(0, rootLength);
|
||||
const normalized = getNormalizedParts(path, rootLength);
|
||||
if (normalized.length) {
|
||||
@ -1091,6 +1093,11 @@ namespace ts {
|
||||
return path.charCodeAt(path.length - 1) === directorySeparatorCharCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the path except for its basename. Eg:
|
||||
*
|
||||
* /path/to/file.ext -> /path/to
|
||||
*/
|
||||
export function getDirectoryPath(path: Path): Path;
|
||||
export function getDirectoryPath(path: string): string;
|
||||
export function getDirectoryPath(path: string): any {
|
||||
|
||||
@ -322,10 +322,22 @@ namespace ts.Completions {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a path ending at a directory, gets the completions for the path.
|
||||
*/
|
||||
function getCompletionEntriesForDirectoryFragment(fragment: string, scriptPath: string, extensions: string[], includeExtensions: boolean, span: TextSpan, exclude?: string, result: CompletionEntry[] = []): CompletionEntry[] {
|
||||
/*Debug.assert(fragment !== undefined);
|
||||
|
||||
if (fragment === "") {
|
||||
fragment = ".";
|
||||
} else {
|
||||
fragment = getDirectoryPath(fragment);
|
||||
}
|
||||
*/
|
||||
|
||||
fragment = getDirectoryPath(fragment); // TODO: modify fragment so it respects our internal path representation?
|
||||
if (!fragment) {
|
||||
fragment = "." + directorySeparator;
|
||||
fragment = ".";
|
||||
}
|
||||
else {
|
||||
fragment = ensureTrailingDirectorySeparator(fragment); // TODO: why is this necessary?
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user