@@ -1811,7 +1811,7 @@ namespace ts.server {
1811
1811
return ( < protocol . FileLocationRequestArgs > locationOrSpan ) . line !== undefined ;
1812
1812
}
1813
1813
1814
- private extractPositionAndRange ( args : protocol . FileLocationOrRangeRequestArgs , scriptInfo : ScriptInfo ) : { position : number , textRange : TextRange } {
1814
+ private extractPositionOrRange ( args : protocol . FileLocationOrRangeRequestArgs , scriptInfo : ScriptInfo ) : number | TextRange {
1815
1815
let position : number | undefined ;
1816
1816
let textRange : TextRange | undefined ;
1817
1817
if ( this . isLocation ( args ) ) {
@@ -1821,7 +1821,7 @@ namespace ts.server {
1821
1821
const { startPosition, endPosition } = this . getStartAndEndPosition ( args , scriptInfo ) ;
1822
1822
textRange = { pos : startPosition , end : endPosition } ;
1823
1823
}
1824
- return { position : position ! , textRange : textRange ! } ; // TODO: GH#18217
1824
+ return Debug . assertDefined ( position === undefined ? textRange : position ) ;
1825
1825
1826
1826
function getPosition ( loc : protocol . FileLocationRequestArgs ) {
1827
1827
return loc . position !== undefined ? loc . position : scriptInfo . lineOffsetToPosition ( loc . line , loc . offset ) ;
@@ -1831,19 +1831,16 @@ namespace ts.server {
1831
1831
private getApplicableRefactors ( args : protocol . GetApplicableRefactorsRequestArgs ) : protocol . ApplicableRefactorInfo [ ] {
1832
1832
const { file, project } = this . getFileAndProject ( args ) ;
1833
1833
const scriptInfo = project . getScriptInfoForNormalizedPath ( file ) ! ;
1834
- const { position, textRange } = this . extractPositionAndRange ( args , scriptInfo ) ;
1835
- return project . getLanguageService ( ) . getApplicableRefactors ( file , position || textRange , this . getPreferences ( file ) ) ;
1834
+ return project . getLanguageService ( ) . getApplicableRefactors ( file , this . extractPositionOrRange ( args , scriptInfo ) , this . getPreferences ( file ) ) ;
1836
1835
}
1837
1836
1838
1837
private getEditsForRefactor ( args : protocol . GetEditsForRefactorRequestArgs , simplifiedResult : boolean ) : RefactorEditInfo | protocol . RefactorEditInfo {
1839
1838
const { file, project } = this . getFileAndProject ( args ) ;
1840
1839
const scriptInfo = project . getScriptInfoForNormalizedPath ( file ) ! ;
1841
- const { position, textRange } = this . extractPositionAndRange ( args , scriptInfo ) ;
1842
-
1843
1840
const result = project . getLanguageService ( ) . getEditsForRefactor (
1844
1841
file ,
1845
1842
this . getFormatOptions ( file ) ,
1846
- position || textRange ,
1843
+ this . extractPositionOrRange ( args , scriptInfo ) ,
1847
1844
args . refactor ,
1848
1845
args . action ,
1849
1846
this . getPreferences ( file ) ,
0 commit comments