Mirror: TypeScript LSP plugin that finds GraphQL documents in your code and provides diagnostics, auto-complete and hover-information.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

moar refactor

+6 -12
+6 -12
packages/graphqlsp/src/autoComplete.ts
··· 1 1 import ts from 'typescript/lib/tsserverlibrary'; 2 2 import { 3 - ScriptElementKind, 4 - isIdentifier, 5 - isNoSubstitutionTemplateLiteral, 6 - isTaggedTemplateExpression, 7 - } from 'typescript'; 8 - import { 9 3 getAutocompleteSuggestions, 10 4 getTokenAtPosition, 11 5 getTypeInfo, ··· 55 49 isCallExpression && 56 50 node.expression.getText() === tagTemplate && 57 51 node.arguments.length > 0 && 58 - isNoSubstitutionTemplateLiteral(node.arguments[0]) 52 + ts.isNoSubstitutionTemplateLiteral(node.arguments[0]) 59 53 ) { 60 54 const foundToken = getToken(node.arguments[0], cursorPosition); 61 55 if (!schema.current || !foundToken) return undefined; ··· 77 71 isNewIdentifierLocation: false, 78 72 entries: items.map(suggestion => ({ 79 73 ...suggestion, 80 - kind: ScriptElementKind.variableElement, 74 + kind: ts.ScriptElementKind.variableElement, 81 75 name: suggestion.label, 82 76 kindModifiers: 'declare', 83 77 sortText: suggestion.sortText || '0', ··· 89 83 }, 90 84 })), 91 85 }; 92 - } else if (isTaggedTemplateExpression(node)) { 86 + } else if (ts.isTaggedTemplateExpression(node)) { 93 87 const { template, tag } = node; 94 88 95 - if (!isIdentifier(tag) || tag.text !== tagTemplate) return undefined; 89 + if (!ts.isIdentifier(tag) || tag.text !== tagTemplate) return undefined; 96 90 97 91 const foundToken = getToken(template, cursorPosition); 98 92 if (!foundToken || !schema.current) return undefined; ··· 128 122 entries: [ 129 123 ...suggestions.map(suggestion => ({ 130 124 ...suggestion, 131 - kind: ScriptElementKind.variableElement, 125 + kind: ts.ScriptElementKind.variableElement, 132 126 name: suggestion.label, 133 127 kindModifiers: 'declare', 134 128 sortText: suggestion.sortText || '0', ··· 141 135 })), 142 136 ...spreadSuggestions.map(suggestion => ({ 143 137 ...suggestion, 144 - kind: ScriptElementKind.variableElement, 138 + kind: ts.ScriptElementKind.variableElement, 145 139 name: suggestion.label, 146 140 insertText: '...' + suggestion.label, 147 141 kindModifiers: 'declare',