|
1 | | -export default (position: number, node: ts.Node | undefined, sourceFile: ts.SourceFile, program: ts.Program, languageService: ts.LanguageService) => { |
| 1 | +import { sharedCompletionContext } from './sharedContext' |
| 2 | +import { buildStringCompletion } from '../utils' |
| 3 | + |
| 4 | +export default () => { |
| 5 | + const { node, program } = sharedCompletionContext |
2 | 6 | if (!node) return |
3 | 7 | function isBinaryExpression(node: ts.Node): node is ts.BinaryExpression { |
4 | 8 | return node.kind === ts.SyntaxKind.BinaryExpression |
5 | 9 | } |
6 | 10 | const typeChecker = program.getTypeChecker() |
7 | | - // TODO info diagnostic if used that doesn't exist |
8 | 11 | if ( |
9 | 12 | ts.isStringLiteralLike(node) && |
10 | 13 | isBinaryExpression(node.parent) && |
@@ -48,14 +51,15 @@ export default (position: number, node: ts.Node | undefined, sourceFile: ts.Sour |
48 | 51 | .map(([originaName, { insertText, usingDisplayIndexes, documentations }], i) => { |
49 | 52 | const name = types.length > 1 && usingDisplayIndexes.length === 1 ? `☆${originaName}` : originaName |
50 | 53 | docPerCompletion[name] = documentations.join('\n\n') |
51 | | - return { |
| 54 | + return buildStringCompletion(node, { |
52 | 55 | // ⚀ ⚁ ⚂ ⚃ ⚄ ⚅ |
53 | 56 | name, |
54 | | - kind: ts.ScriptElementKind.string, |
| 57 | + labelDetails: { |
| 58 | + description: usingDisplayIndexes.join(', '), |
| 59 | + }, |
55 | 60 | insertText, |
56 | | - sourceDisplay: [{ kind: 'text', text: usingDisplayIndexes.join(', ') }], |
57 | 61 | sortText: `${maxUsingDisplayIndex - usingDisplayIndexes.length}_${i}`, |
58 | | - } |
| 62 | + }) |
59 | 63 | }) |
60 | 64 | .sort((a, b) => a.sortText.localeCompare(b.sortText)) |
61 | 65 | return { |
|
0 commit comments