@@ -927,6 +927,7 @@ function completionInfoFromData(
927
927
/*replacementToken*/ undefined ,
928
928
contextToken ,
929
929
location ,
930
+ position ,
930
931
sourceFile ,
931
932
host ,
932
933
program ,
@@ -1316,6 +1317,7 @@ function createCompletionEntry(
1316
1317
replacementToken : Node | undefined ,
1317
1318
contextToken : Node | undefined ,
1318
1319
location : Node ,
1320
+ position : number ,
1319
1321
sourceFile : SourceFile ,
1320
1322
host : LanguageServiceHost ,
1321
1323
program : Program ,
@@ -1406,7 +1408,8 @@ function createCompletionEntry(
1406
1408
completionKind === CompletionKind . MemberLike &&
1407
1409
isClassLikeMemberCompletion ( symbol , location , sourceFile ) ) {
1408
1410
let importAdder ;
1409
- ( { insertText, isSnippet, importAdder, replacementSpan } = getEntryForMemberCompletion ( host , program , options , preferences , name , symbol , location , contextToken , formatContext ) ) ;
1411
+ ( { insertText, isSnippet, importAdder, replacementSpan } =
1412
+ getEntryForMemberCompletion ( host , program , options , preferences , name , symbol , location , position , contextToken , formatContext ) ) ;
1410
1413
sortText = SortText . ClassMemberSnippets ; // sortText has to be lower priority than the sortText for keywords. See #47852.
1411
1414
if ( importAdder ?. hasFixes ( ) ) {
1412
1415
hasAction = true ;
@@ -1545,6 +1548,7 @@ function getEntryForMemberCompletion(
1545
1548
name : string ,
1546
1549
symbol : Symbol ,
1547
1550
location : Node ,
1551
+ position : number ,
1548
1552
contextToken : Node | undefined ,
1549
1553
formatContext : formatting . FormatContext | undefined ,
1550
1554
) : { insertText : string , isSnippet ?: true , importAdder ?: codefix . ImportAdder , replacementSpan ?: TextSpan } {
@@ -1586,7 +1590,7 @@ function getEntryForMemberCompletion(
1586
1590
let modifiers = ModifierFlags . None ;
1587
1591
// Whether the suggested member should be abstract.
1588
1592
// e.g. in `abstract class C { abstract | }`, we should offer abstract method signatures at position `|`.
1589
- const { modifiers : presentModifiers , span : modifiersSpan } = getPresentModifiers ( contextToken ) ;
1593
+ const { modifiers : presentModifiers , span : modifiersSpan } = getPresentModifiers ( contextToken , sourceFile , position ) ;
1590
1594
const isAbstract = ! ! ( presentModifiers & ModifierFlags . Abstract ) ;
1591
1595
const completionNodes : Node [ ] = [ ] ;
1592
1596
codefix . addNewNodeForMemberSymbol (
@@ -1650,8 +1654,13 @@ function getEntryForMemberCompletion(
1650
1654
return { insertText, isSnippet, importAdder, replacementSpan } ;
1651
1655
}
1652
1656
1653
- function getPresentModifiers ( contextToken : Node | undefined ) : { modifiers : ModifierFlags , span ?: TextSpan } {
1654
- if ( ! contextToken ) {
1657
+ function getPresentModifiers (
1658
+ contextToken : Node | undefined ,
1659
+ sourceFile : SourceFile ,
1660
+ position : number ) : { modifiers : ModifierFlags , span ?: TextSpan } {
1661
+ if ( ! contextToken ||
1662
+ getLineAndCharacterOfPosition ( sourceFile , position ) . line
1663
+ > getLineAndCharacterOfPosition ( sourceFile , contextToken . getEnd ( ) ) . line ) {
1655
1664
return { modifiers : ModifierFlags . None } ;
1656
1665
}
1657
1666
let modifiers = ModifierFlags . None ;
@@ -2086,6 +2095,7 @@ export function getCompletionEntriesFromSymbols(
2086
2095
replacementToken : Node | undefined ,
2087
2096
contextToken : Node | undefined ,
2088
2097
location : Node ,
2098
+ position : number ,
2089
2099
sourceFile : SourceFile ,
2090
2100
host : LanguageServiceHost ,
2091
2101
program : Program ,
@@ -2132,6 +2142,7 @@ export function getCompletionEntriesFromSymbols(
2132
2142
replacementToken ,
2133
2143
contextToken ,
2134
2144
location ,
2145
+ position ,
2135
2146
sourceFile ,
2136
2147
host ,
2137
2148
program ,
@@ -2471,6 +2482,7 @@ function getCompletionEntryCodeActionsAndSourceDisplay(
2471
2482
name ,
2472
2483
symbol ,
2473
2484
location ,
2485
+ position ,
2474
2486
contextToken ,
2475
2487
formatContext ) ;
2476
2488
if ( importAdder ) {
0 commit comments