From 5d3ef64432482fcb4298f270d3904cfa1d5c104f Mon Sep 17 00:00:00 2001 From: Jovi De Croock Date: Fri, 24 Nov 2023 19:56:10 +0100 Subject: [PATCH] moar refactor --- packages/graphqlsp/src/autoComplete.ts | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/packages/graphqlsp/src/autoComplete.ts b/packages/graphqlsp/src/autoComplete.ts index 25f099ef..de1bbec0 100644 --- a/packages/graphqlsp/src/autoComplete.ts +++ b/packages/graphqlsp/src/autoComplete.ts @@ -1,10 +1,4 @@ import ts from 'typescript/lib/tsserverlibrary'; -import { - ScriptElementKind, - isIdentifier, - isNoSubstitutionTemplateLiteral, - isTaggedTemplateExpression, -} from 'typescript'; import { getAutocompleteSuggestions, getTokenAtPosition, @@ -55,7 +49,7 @@ export function getGraphQLCompletions( isCallExpression && node.expression.getText() === tagTemplate && node.arguments.length > 0 && - isNoSubstitutionTemplateLiteral(node.arguments[0]) + ts.isNoSubstitutionTemplateLiteral(node.arguments[0]) ) { const foundToken = getToken(node.arguments[0], cursorPosition); if (!schema.current || !foundToken) return undefined; @@ -77,7 +71,7 @@ export function getGraphQLCompletions( isNewIdentifierLocation: false, entries: items.map(suggestion => ({ ...suggestion, - kind: ScriptElementKind.variableElement, + kind: ts.ScriptElementKind.variableElement, name: suggestion.label, kindModifiers: 'declare', sortText: suggestion.sortText || '0', @@ -89,10 +83,10 @@ export function getGraphQLCompletions( }, })), }; - } else if (isTaggedTemplateExpression(node)) { + } else if (ts.isTaggedTemplateExpression(node)) { const { template, tag } = node; - if (!isIdentifier(tag) || tag.text !== tagTemplate) return undefined; + if (!ts.isIdentifier(tag) || tag.text !== tagTemplate) return undefined; const foundToken = getToken(template, cursorPosition); if (!foundToken || !schema.current) return undefined; @@ -128,7 +122,7 @@ export function getGraphQLCompletions( entries: [ ...suggestions.map(suggestion => ({ ...suggestion, - kind: ScriptElementKind.variableElement, + kind: ts.ScriptElementKind.variableElement, name: suggestion.label, kindModifiers: 'declare', sortText: suggestion.sortText || '0', @@ -141,7 +135,7 @@ export function getGraphQLCompletions( })), ...spreadSuggestions.map(suggestion => ({ ...suggestion, - kind: ScriptElementKind.variableElement, + kind: ts.ScriptElementKind.variableElement, name: suggestion.label, insertText: '...' + suggestion.label, kindModifiers: 'declare',