Skip to content

Commit 8a976f1

Browse files
committed
Moving some utility functions around
1 parent e11d5e9 commit 8a976f1

File tree

2 files changed

+26
-26
lines changed

2 files changed

+26
-26
lines changed

src/services/services.ts

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2063,9 +2063,6 @@ namespace ts {
20632063
sourceMapText?: string;
20642064
}
20652065

2066-
// Matches the beginning of a triple slash directive
2067-
const tripleSlashDirectivePrefixRegex = /^\/\/\/\s*</;
2068-
20692066
/**
20702067
* Matches a triple slash reference directive with an incomplete string literal for its path. Used
20712068
* to determine if the caret is currently within the string literal and capture the literal fragment
@@ -2940,15 +2937,6 @@ namespace ts {
29402937
}
29412938
}
29422939

2943-
function isInReferenceComment(sourceFile: SourceFile, position: number): boolean {
2944-
return isInCommentHelper(sourceFile, position, isReferenceComment);
2945-
2946-
function isReferenceComment(c: CommentRange): boolean {
2947-
const commentText = sourceFile.text.substring(c.pos, c.end);
2948-
return tripleSlashDirectivePrefixRegex.test(commentText);
2949-
}
2950-
}
2951-
29522940
const enum SemanticMeaning {
29532941
None = 0x0,
29542942
Value = 0x1,
@@ -6914,15 +6902,6 @@ namespace ts {
69146902

69156903
return result[index];
69166904
}
6917-
6918-
function isInNonReferenceComment(sourceFile: SourceFile, position: number): boolean {
6919-
return isInCommentHelper(sourceFile, position, isNonReferenceComment);
6920-
6921-
function isNonReferenceComment(c: CommentRange): boolean {
6922-
const commentText = sourceFile.text.substring(c.pos, c.end);
6923-
return !tripleSlashDirectivePrefixRegex.test(commentText);
6924-
}
6925-
}
69266905
}
69276906

69286907
function getReferencesForSuperKeyword(superKeyword: Node): ReferencedSymbol[] {

src/services/utilities.ts

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
// These utilities are common to multiple language service features.
22
/* @internal */
33
namespace ts {
4+
// Matches the beginning of a triple slash directive
5+
const tripleSlashDirectivePrefixRegex = /^\/\/\/\s*</;
6+
47
export interface ListItemInfo {
58
listItemIndex: number;
69
list: Node;
@@ -704,6 +707,29 @@ namespace ts {
704707

705708
return false;
706709
}
710+
711+
export function hasTrailingDirectorySeparator(path: string) {
712+
const lastCharacter = path.charAt(path.length - 1);
713+
return lastCharacter === "/" || lastCharacter === "\\";
714+
}
715+
716+
export function isInReferenceComment(sourceFile: SourceFile, position: number): boolean {
717+
return isInCommentHelper(sourceFile, position, isReferenceComment);
718+
719+
function isReferenceComment(c: CommentRange): boolean {
720+
const commentText = sourceFile.text.substring(c.pos, c.end);
721+
return tripleSlashDirectivePrefixRegex.test(commentText);
722+
}
723+
}
724+
725+
export function isInNonReferenceComment(sourceFile: SourceFile, position: number): boolean {
726+
return isInCommentHelper(sourceFile, position, isNonReferenceComment);
727+
728+
function isNonReferenceComment(c: CommentRange): boolean {
729+
const commentText = sourceFile.text.substring(c.pos, c.end);
730+
return !tripleSlashDirectivePrefixRegex.test(commentText);
731+
}
732+
}
707733
}
708734

709735
// Display-part writer helpers
@@ -925,9 +951,4 @@ namespace ts {
925951
}
926952
return ensureScriptKind(fileName, scriptKind);
927953
}
928-
929-
export function hasTrailingDirectorySeparator(path: string) {
930-
const lastCharacter = path.charAt(path.length - 1);
931-
return lastCharacter === "/" || lastCharacter === "\\";
932-
}
933954
}

0 commit comments

Comments
 (0)