Moving some utility functions around

This commit is contained in:
Richard Knoll 2016-08-08 11:04:17 -07:00
parent e11d5e9de6
commit 8a976f1100
2 changed files with 26 additions and 26 deletions

View file

@ -2063,9 +2063,6 @@ namespace ts {
sourceMapText?: string; sourceMapText?: string;
} }
// Matches the beginning of a triple slash directive
const tripleSlashDirectivePrefixRegex = /^\/\/\/\s*</;
/** /**
* Matches a triple slash reference directive with an incomplete string literal for its path. Used * Matches a triple slash reference directive with an incomplete string literal for its path. Used
* to determine if the caret is currently within the string literal and capture the literal fragment * to determine if the caret is currently within the string literal and capture the literal fragment
@ -2940,15 +2937,6 @@ namespace ts {
} }
} }
function isInReferenceComment(sourceFile: SourceFile, position: number): boolean {
return isInCommentHelper(sourceFile, position, isReferenceComment);
function isReferenceComment(c: CommentRange): boolean {
const commentText = sourceFile.text.substring(c.pos, c.end);
return tripleSlashDirectivePrefixRegex.test(commentText);
}
}
const enum SemanticMeaning { const enum SemanticMeaning {
None = 0x0, None = 0x0,
Value = 0x1, Value = 0x1,
@ -6914,15 +6902,6 @@ namespace ts {
return result[index]; return result[index];
} }
function isInNonReferenceComment(sourceFile: SourceFile, position: number): boolean {
return isInCommentHelper(sourceFile, position, isNonReferenceComment);
function isNonReferenceComment(c: CommentRange): boolean {
const commentText = sourceFile.text.substring(c.pos, c.end);
return !tripleSlashDirectivePrefixRegex.test(commentText);
}
}
} }
function getReferencesForSuperKeyword(superKeyword: Node): ReferencedSymbol[] { function getReferencesForSuperKeyword(superKeyword: Node): ReferencedSymbol[] {

View file

@ -1,6 +1,9 @@
// These utilities are common to multiple language service features. // These utilities are common to multiple language service features.
/* @internal */ /* @internal */
namespace ts { namespace ts {
// Matches the beginning of a triple slash directive
const tripleSlashDirectivePrefixRegex = /^\/\/\/\s*</;
export interface ListItemInfo { export interface ListItemInfo {
listItemIndex: number; listItemIndex: number;
list: Node; list: Node;
@ -704,6 +707,29 @@ namespace ts {
return false; return false;
} }
export function hasTrailingDirectorySeparator(path: string) {
const lastCharacter = path.charAt(path.length - 1);
return lastCharacter === "/" || lastCharacter === "\\";
}
export function isInReferenceComment(sourceFile: SourceFile, position: number): boolean {
return isInCommentHelper(sourceFile, position, isReferenceComment);
function isReferenceComment(c: CommentRange): boolean {
const commentText = sourceFile.text.substring(c.pos, c.end);
return tripleSlashDirectivePrefixRegex.test(commentText);
}
}
export function isInNonReferenceComment(sourceFile: SourceFile, position: number): boolean {
return isInCommentHelper(sourceFile, position, isNonReferenceComment);
function isNonReferenceComment(c: CommentRange): boolean {
const commentText = sourceFile.text.substring(c.pos, c.end);
return !tripleSlashDirectivePrefixRegex.test(commentText);
}
}
} }
// Display-part writer helpers // Display-part writer helpers
@ -925,9 +951,4 @@ namespace ts {
} }
return ensureScriptKind(fileName, scriptKind); return ensureScriptKind(fileName, scriptKind);
} }
export function hasTrailingDirectorySeparator(path: string) {
const lastCharacter = path.charAt(path.length - 1);
return lastCharacter === "/" || lastCharacter === "\\";
}
} }