@@ -362,7 +362,7 @@ namespace ts.server {
362
362
...outputReferencedSymbol . definition ,
363
363
textSpan : createTextSpan ( mappedDefinitionFile . pos , outputReferencedSymbol . definition . textSpan . length ) ,
364
364
fileName : mappedDefinitionFile . fileName ,
365
- declarationSpan : getMappedDeclarationSpan ( outputReferencedSymbol . definition , project )
365
+ contextSpan : getMappedContextSpan ( outputReferencedSymbol . definition , project )
366
366
} ;
367
367
368
368
let symbolToAddTo = find ( outputs , o => documentSpansEqual ( o . definition , definition ) ) ;
@@ -501,22 +501,22 @@ namespace ts.server {
501
501
} ,
502
502
originalFileName : documentSpan . fileName ,
503
503
originalTextSpan : documentSpan . textSpan ,
504
- declarationSpan : getMappedDeclarationSpan ( documentSpan , project ) ,
505
- originalDeclarationSpan : documentSpan . declarationSpan
504
+ contextSpan : getMappedContextSpan ( documentSpan , project ) ,
505
+ originalContextSpan : documentSpan . contextSpan
506
506
} ;
507
507
}
508
508
509
- function getMappedDeclarationSpan ( documentSpan : DocumentSpan , project : Project ) : TextSpan | undefined {
510
- const declarationSpanStart = documentSpan . declarationSpan && getMappedLocation (
511
- { fileName : documentSpan . fileName , pos : documentSpan . declarationSpan . start } ,
509
+ function getMappedContextSpan ( documentSpan : DocumentSpan , project : Project ) : TextSpan | undefined {
510
+ const contextSpanStart = documentSpan . contextSpan && getMappedLocation (
511
+ { fileName : documentSpan . fileName , pos : documentSpan . contextSpan . start } ,
512
512
project
513
513
) ;
514
- const declarationSpanEnd = documentSpan . declarationSpan && getMappedLocation (
515
- { fileName : documentSpan . fileName , pos : documentSpan . declarationSpan . start + documentSpan . declarationSpan . length } ,
514
+ const contextSpanEnd = documentSpan . contextSpan && getMappedLocation (
515
+ { fileName : documentSpan . fileName , pos : documentSpan . contextSpan . start + documentSpan . contextSpan . length } ,
516
516
project
517
517
) ;
518
- return declarationSpanStart && declarationSpanEnd ?
519
- { start : declarationSpanStart . pos , length : declarationSpanEnd . pos - declarationSpanStart . pos } :
518
+ return contextSpanStart && contextSpanEnd ?
519
+ { start : contextSpanStart . pos , length : contextSpanEnd . pos - contextSpanStart . pos } :
520
520
undefined ;
521
521
}
522
522
@@ -971,7 +971,7 @@ namespace ts.server {
971
971
: diagnostics . map ( d => formatDiag ( file , project , d ) ) ;
972
972
}
973
973
974
- private getDefinition ( args : protocol . FileLocationRequestArgs , simplifiedResult : boolean ) : ReadonlyArray < protocol . DeclarationFileSpan > | ReadonlyArray < DefinitionInfo > {
974
+ private getDefinition ( args : protocol . FileLocationRequestArgs , simplifiedResult : boolean ) : ReadonlyArray < protocol . FileSpanWithContext > | ReadonlyArray < DefinitionInfo > {
975
975
const { file, project } = this . getFileAndProject ( args ) ;
976
976
const position = this . getPositionInFile ( args , file ) ;
977
977
const definitions = this . mapDefinitionInfoLocations ( project . getLanguageService ( ) . getDefinitionAtPosition ( file , position ) || emptyArray , project ) ;
@@ -1026,8 +1026,8 @@ namespace ts.server {
1026
1026
return project . getLanguageService ( ) . getEmitOutput ( file ) ;
1027
1027
}
1028
1028
1029
- private mapDefinitionInfo ( definitions : ReadonlyArray < DefinitionInfo > , project : Project ) : ReadonlyArray < protocol . DeclarationFileSpan > {
1030
- return definitions . map ( def => this . toDeclarationFileSpan ( def . fileName , def . textSpan , def . declarationSpan , project ) ) ;
1029
+ private mapDefinitionInfo ( definitions : ReadonlyArray < DefinitionInfo > , project : Project ) : ReadonlyArray < protocol . FileSpanWithContext > {
1030
+ return definitions . map ( def => this . toFileSpanWithContext ( def . fileName , def . textSpan , def . contextSpan , project ) ) ;
1031
1031
}
1032
1032
1033
1033
/*
@@ -1046,8 +1046,8 @@ namespace ts.server {
1046
1046
textSpan : def . originalTextSpan ,
1047
1047
targetFileName : def . fileName ,
1048
1048
targetTextSpan : def . textSpan ,
1049
- declarationSpan : def . originalDeclarationSpan ,
1050
- targetDeclarationSpan : def . declarationSpan
1049
+ contextSpan : def . originalContextSpan ,
1050
+ targetContextSpan : def . contextSpan
1051
1051
} ;
1052
1052
}
1053
1053
return def ;
@@ -1065,15 +1065,15 @@ namespace ts.server {
1065
1065
} ;
1066
1066
}
1067
1067
1068
- private toDeclarationFileSpan ( fileName : string , textSpan : TextSpan , declarationSpan : TextSpan | undefined , project : Project ) : protocol . DeclarationFileSpan {
1068
+ private toFileSpanWithContext ( fileName : string , textSpan : TextSpan , contextSpan : TextSpan | undefined , project : Project ) : protocol . FileSpanWithContext {
1069
1069
const fileSpan = this . toFileSpan ( fileName , textSpan , project ) ;
1070
- const declaration = declarationSpan && this . toFileSpan ( fileName , declarationSpan , project ) ;
1071
- return declaration ?
1072
- { ...fileSpan , declarationStart : declaration . start , declarationEnd : declaration . end } :
1070
+ const context = contextSpan && this . toFileSpan ( fileName , contextSpan , project ) ;
1071
+ return context ?
1072
+ { ...fileSpan , contextStart : context . start , contextEnd : context . end } :
1073
1073
fileSpan ;
1074
1074
}
1075
1075
1076
- private getTypeDefinition ( args : protocol . FileLocationRequestArgs ) : ReadonlyArray < protocol . DeclarationFileSpan > {
1076
+ private getTypeDefinition ( args : protocol . FileLocationRequestArgs ) : ReadonlyArray < protocol . FileSpanWithContext > {
1077
1077
const { file, project } = this . getFileAndProject ( args ) ;
1078
1078
const position = this . getPositionInFile ( args , file ) ;
1079
1079
@@ -1092,12 +1092,12 @@ namespace ts.server {
1092
1092
} ) ;
1093
1093
}
1094
1094
1095
- private getImplementation ( args : protocol . FileLocationRequestArgs , simplifiedResult : boolean ) : ReadonlyArray < protocol . DeclarationFileSpan > | ReadonlyArray < ImplementationLocation > {
1095
+ private getImplementation ( args : protocol . FileLocationRequestArgs , simplifiedResult : boolean ) : ReadonlyArray < protocol . FileSpanWithContext > | ReadonlyArray < ImplementationLocation > {
1096
1096
const { file, project } = this . getFileAndProject ( args ) ;
1097
1097
const position = this . getPositionInFile ( args , file ) ;
1098
1098
const implementations = this . mapImplementationLocations ( project . getLanguageService ( ) . getImplementationAtPosition ( file , position ) || emptyArray , project ) ;
1099
1099
return simplifiedResult ?
1100
- implementations . map ( ( { fileName, textSpan, declarationSpan } ) => this . toDeclarationFileSpan ( fileName , textSpan , declarationSpan , project ) ) :
1100
+ implementations . map ( ( { fileName, textSpan, contextSpan } ) => this . toFileSpanWithContext ( fileName , textSpan , contextSpan , project ) ) :
1101
1101
implementations . map ( Session . mapToOriginalLocation ) ;
1102
1102
}
1103
1103
@@ -1107,10 +1107,10 @@ namespace ts.server {
1107
1107
const occurrences = project . getLanguageService ( ) . getOccurrencesAtPosition ( file , position ) ;
1108
1108
return occurrences ?
1109
1109
occurrences . map < protocol . OccurrencesResponseItem > ( occurrence => {
1110
- const { fileName, isWriteAccess, textSpan, isInString, declarationSpan } = occurrence ;
1110
+ const { fileName, isWriteAccess, textSpan, isInString, contextSpan } = occurrence ;
1111
1111
const scriptInfo = project . getScriptInfo ( fileName ) ! ;
1112
1112
return {
1113
- ...toProtocolDeclarationTextSpan ( textSpan , declarationSpan , scriptInfo ) ,
1113
+ ...toProtocolTextSpanWithContext ( textSpan , contextSpan , scriptInfo ) ,
1114
1114
file : fileName ,
1115
1115
isWriteAccess,
1116
1116
...( isInString ? { isInString } : undefined )
@@ -1166,8 +1166,8 @@ namespace ts.server {
1166
1166
const scriptInfo = project . getScriptInfo ( fileName ) ! ;
1167
1167
return {
1168
1168
file : fileName ,
1169
- highlightSpans : highlightSpans . map ( ( { textSpan, kind, declarationSpan } ) => ( {
1170
- ...toProtocolDeclarationTextSpan ( textSpan , declarationSpan , scriptInfo ) ,
1169
+ highlightSpans : highlightSpans . map ( ( { textSpan, kind, contextSpan } ) => ( {
1170
+ ...toProtocolTextSpanWithContext ( textSpan , contextSpan , scriptInfo ) ,
1171
1171
kind
1172
1172
} ) )
1173
1173
} ;
@@ -1273,11 +1273,11 @@ namespace ts.server {
1273
1273
1274
1274
private toSpanGroups ( locations : ReadonlyArray < RenameLocation > ) : ReadonlyArray < protocol . SpanGroup > {
1275
1275
const map = createMap < protocol . SpanGroup > ( ) ;
1276
- for ( const { fileName, textSpan, declarationSpan , originalDeclarationSpan : _2 , originalTextSpan : _ , originalFileName : _1 , ...prefixSuffixText } of locations ) {
1276
+ for ( const { fileName, textSpan, contextSpan , originalContextSpan : _2 , originalTextSpan : _ , originalFileName : _1 , ...prefixSuffixText } of locations ) {
1277
1277
let group = map . get ( fileName ) ;
1278
1278
if ( ! group ) map . set ( fileName , group = { file : fileName , locs : [ ] } ) ;
1279
1279
const scriptInfo = Debug . assertDefined ( this . projectService . getScriptInfo ( fileName ) ) ;
1280
- group . locs . push ( { ...toProtocolDeclarationTextSpan ( textSpan , declarationSpan , scriptInfo ) , ...prefixSuffixText } ) ;
1280
+ group . locs . push ( { ...toProtocolTextSpanWithContext ( textSpan , contextSpan , scriptInfo ) , ...prefixSuffixText } ) ;
1281
1281
}
1282
1282
return arrayFrom ( map . values ( ) ) ;
1283
1283
}
@@ -1302,9 +1302,9 @@ namespace ts.server {
1302
1302
const symbolStartOffset = nameSpan ? scriptInfo . positionToLineOffset ( nameSpan . start ) . offset : 0 ;
1303
1303
const symbolName = nameSpan ? scriptInfo . getSnapshot ( ) . getText ( nameSpan . start , textSpanEnd ( nameSpan ) ) : "" ;
1304
1304
const refs : ReadonlyArray < protocol . ReferencesResponseItem > = flatMap ( references , referencedSymbol =>
1305
- referencedSymbol . references . map ( ( { fileName, textSpan, declarationSpan , isWriteAccess, isDefinition } ) : protocol . ReferencesResponseItem => {
1305
+ referencedSymbol . references . map ( ( { fileName, textSpan, contextSpan , isWriteAccess, isDefinition } ) : protocol . ReferencesResponseItem => {
1306
1306
const scriptInfo = Debug . assertDefined ( this . projectService . getScriptInfo ( fileName ) ) ;
1307
- const span = toProtocolDeclarationTextSpan ( textSpan , declarationSpan , scriptInfo ) ;
1307
+ const span = toProtocolTextSpanWithContext ( textSpan , contextSpan , scriptInfo ) ;
1308
1308
const lineSpan = scriptInfo . lineToTextSpan ( span . start . line - 1 ) ;
1309
1309
const lineText = scriptInfo . getSnapshot ( ) . getText ( lineSpan . start , textSpanEnd ( lineSpan ) ) . replace ( / \r | \n / g, "" ) ;
1310
1310
return {
@@ -2565,11 +2565,11 @@ namespace ts.server {
2565
2565
} ;
2566
2566
}
2567
2567
2568
- function toProtocolDeclarationTextSpan ( span : TextSpan , declarationSpan : TextSpan | undefined , scriptInfo : ScriptInfo ) : protocol . DeclarationTextSpan {
2568
+ function toProtocolTextSpanWithContext ( span : TextSpan , contextSpan : TextSpan | undefined , scriptInfo : ScriptInfo ) : protocol . TextSpanWithContext {
2569
2569
const textSpan = toProcolTextSpan ( span , scriptInfo ) ;
2570
- const declarationTextSpan = declarationSpan && toProcolTextSpan ( declarationSpan , scriptInfo ) ;
2571
- return declarationTextSpan ?
2572
- { ...textSpan , declarationStart : declarationTextSpan . start , declarationEnd : declarationTextSpan . end } :
2570
+ const contextTextSpan = contextSpan && toProcolTextSpan ( contextSpan , scriptInfo ) ;
2571
+ return contextTextSpan ?
2572
+ { ...textSpan , contextStart : contextTextSpan . start , contextEnd : contextTextSpan . end } :
2573
2573
textSpan ;
2574
2574
}
2575
2575
0 commit comments