-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: interfaces implementing interfaces for the LSP #1742
Conversation
f1a4751
to
82d0e18
Compare
Codecov Report
@@ Coverage Diff @@
## main #1742 +/- ##
==========================================
+ Coverage 66.79% 66.97% +0.18%
==========================================
Files 87 87
Lines 4873 4906 +33
Branches 1343 1351 +8
==========================================
+ Hits 3255 3286 +31
- Misses 1383 1385 +2
Partials 235 235
Continue to review full report at Codecov.
|
@@ -320,6 +324,56 @@ function getSuggestionsForInputValues( | |||
return []; | |||
} | |||
|
|||
function getSuggestionsForImplements( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@IvanGoncharov here is the working implementation so far!
@yoshiakis so I've gotten this working in I decided to do what we discussed a while ago, and made so far, just this is working for all but one test: import {
getAutocompleteSuggestions,
} from 'graphql-language-service-interface';
CodeMirror.registerHelper('hint', 'graphql', (editor, options) => {
const schema = options.schema;
if (!schema) {
return;
}
const cur = editor.getCursor();
const token = editor.getTokenAt(cur);
const rawResults = getAutocompleteSuggestions(
schema,
editor.getValue(),
token,
);
const tokenStart =
token.type !== null && /"|\w/.test(token.string[0])
? token.start
: token.end;
const results = {
list: rawResults.map(item => ({
text: item.label,
type: item.type ? String(item.type) : String(item.detail),
description: item.documentation,
isDeprecated: item.isDeprecated,
deprecationReason: item.deprecationReason,
})),
from: { line: cur.line, column: tokenStart },
to: { line: cur.line, column: token.end },
};
if (results && results.list && results.list.length > 0) {
results.from = CodeMirror.Pos(results.from.line, results.from.column);
results.to = CodeMirror.Pos(results.to.line, results.to.column);
CodeMirror.signal(editor, 'hasCompletion', editor, results, token);
}
return results;
}); it seems this would significantly reduce the effort of introducing new language features to |
I got it! It makes sense to do so. Though in that case, I think we should change this part so that |
@acao Why do you want to change the type of |
this is what caused certain tests to pass, it seems to be that the tests expect type to be a string |
9c068df
to
e9e74ac
Compare
@yoshiakis - Just to be clear, the only impact this PR has on Then, in the next PR we can add autocomplete, and simplify the codemirror mode in the process (as per the comment) hopefully! |
merging this without |
Features
This introduces a few new language features for
implements
syntax, including the new(ish)&
operator, both for interfaces & types.Parsing & Highlighting
This implements support for & in the parser, which means highlighting support for codemirror graphql
Autocompletion
Previously there was no autocompletion for any of this
and
now we have
Inline Autocompletion
it will also autocomplete for inline interfaces that may not be in the schema yet, for writing SDL files for example.
Where this feature works
graphql-language-service-server
vscode-graphql
monaco-graphql
codemirror-graphql
highlighting for & syntax works because of the parser implementation in this PRHTD
(netlify)
(manual)
To see how this will impact graphiql, run yarn start-graphiql, and you’ll see the highlighting/parsing work for & syntax now.
What's Next
codemirror-graphql
has an additional step for implementing these new autocompletion features. @yoshiakis and I found that codemirror-graphql’s hint.js is mostly a dupe ofgetAutocompleteSuggestions
. So in the next PR, we will be able to replace most of whats in hint.js for codemirror withgetAutocompleteSuggestions
. This will make feature parity between monaco-graphql and codemirror-graphql much easier to maintain