11// These utilities are common to multiple language service features.
22/* @internal */
33namespace 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