|
1 | 1 | /* @internal */ |
2 | 2 | namespace ts.Completions { |
3 | 3 | export enum SortText { |
4 | | - LocationPriority = "0", |
5 | | - OptionalMember = "1", |
6 | | - MemberDeclaredBySpreadAssignment = "2", |
7 | | - SuggestedClassMembers = "3", |
8 | | - GlobalsOrKeywords = "4", |
9 | | - AutoImportSuggestions = "5", |
10 | | - JavascriptIdentifiers = "6" |
| 4 | + LocalDeclarationPriority = "0", |
| 5 | + LocationPriority = "1", |
| 6 | + OptionalMember = "2", |
| 7 | + MemberDeclaredBySpreadAssignment = "3", |
| 8 | + SuggestedClassMembers = "4", |
| 9 | + GlobalsOrKeywords = "5", |
| 10 | + AutoImportSuggestions = "6", |
| 11 | + JavascriptIdentifiers = "7" |
11 | 12 | } |
12 | 13 | export type Log = (message: string) => void; |
13 | 14 |
|
@@ -1270,7 +1271,7 @@ namespace ts.Completions { |
1270 | 1271 | else { |
1271 | 1272 | for (const symbol of type.getApparentProperties()) { |
1272 | 1273 | if (typeChecker.isValidPropertyAccessForCompletions(propertyAccess, type, symbol)) { |
1273 | | - addPropertySymbol(symbol, /*insertAwait*/ false, insertQuestionDot); |
| 1274 | + addPropertySymbol(symbol, /* insertAwait */ false, insertQuestionDot); |
1274 | 1275 | } |
1275 | 1276 | } |
1276 | 1277 | } |
@@ -1307,14 +1308,22 @@ namespace ts.Completions { |
1307 | 1308 | } |
1308 | 1309 | else if (preferences.includeCompletionsWithInsertText) { |
1309 | 1310 | addSymbolOriginInfo(symbol); |
| 1311 | + addSymbolSortInfo(symbol); |
1310 | 1312 | symbols.push(symbol); |
1311 | 1313 | } |
1312 | 1314 | } |
1313 | 1315 | else { |
1314 | 1316 | addSymbolOriginInfo(symbol); |
| 1317 | + addSymbolSortInfo(symbol); |
1315 | 1318 | symbols.push(symbol); |
1316 | 1319 | } |
1317 | 1320 |
|
| 1321 | + function addSymbolSortInfo(symbol: Symbol) { |
| 1322 | + if (isStaticProperty(symbol)) { |
| 1323 | + symbolToSortTextMap[getSymbolId(symbol)] = SortText.LocalDeclarationPriority; |
| 1324 | + } |
| 1325 | + } |
| 1326 | + |
1318 | 1327 | function addSymbolOriginInfo(symbol: Symbol) { |
1319 | 1328 | if (preferences.includeCompletionsWithInsertText) { |
1320 | 1329 | if (insertAwait && !symbolToOriginInfoMap[getSymbolId(symbol)]) { |
@@ -2817,4 +2826,8 @@ namespace ts.Completions { |
2817 | 2826 | } |
2818 | 2827 | return false; |
2819 | 2828 | } |
| 2829 | + |
| 2830 | + function isStaticProperty(symbol: Symbol) { |
| 2831 | + return !!(symbol.valueDeclaration && getEffectiveModifierFlags(symbol.valueDeclaration) & ModifierFlags.Static && isClassLike(symbol.valueDeclaration.parent)); |
| 2832 | + } |
2820 | 2833 | } |
0 commit comments