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

moar refactor

Changed files
+6 -12
packages
graphqlsp
+6 -12
packages/graphqlsp/src/autoComplete.ts
···
import ts from 'typescript/lib/tsserverlibrary';
import {
-
ScriptElementKind,
-
isIdentifier,
-
isNoSubstitutionTemplateLiteral,
-
isTaggedTemplateExpression,
-
} from 'typescript';
-
import {
getAutocompleteSuggestions,
getTokenAtPosition,
getTypeInfo,
···
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;
···
isNewIdentifierLocation: false,
entries: items.map(suggestion => ({
...suggestion,
-
kind: ScriptElementKind.variableElement,
+
kind: ts.ScriptElementKind.variableElement,
name: suggestion.label,
kindModifiers: 'declare',
sortText: suggestion.sortText || '0',
···
},
})),
};
-
} 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;
···
entries: [
...suggestions.map(suggestion => ({
...suggestion,
-
kind: ScriptElementKind.variableElement,
+
kind: ts.ScriptElementKind.variableElement,
name: suggestion.label,
kindModifiers: 'declare',
sortText: suggestion.sortText || '0',
···
})),
...spreadSuggestions.map(suggestion => ({
...suggestion,
-
kind: ScriptElementKind.variableElement,
+
kind: ts.ScriptElementKind.variableElement,
name: suggestion.label,
insertText: '...' + suggestion.label,
kindModifiers: 'declare',