-
Notifications
You must be signed in to change notification settings - Fork 11
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
Console command support (:use, :params, :clear, history) #165
Conversation
@@ -47,7 +47,7 @@ | |||
"vscode-languageserver-types": "^3.17.3" | |||
}, | |||
"scripts": { | |||
"gen-parser": "antlr4 -Dlanguage=TypeScript -visitor src/antlr-grammar/CypherParser.g4 src/antlr-grammar/CypherLexer.g4 -o src/generated-parser/ -Xexact-output-dir", | |||
"gen-parser": "antlr4 -Dlanguage=TypeScript -visitor src/antlr-grammar/CommandLexer.g4 src/antlr-grammar/CommandParser.g4 -o src/generated-parser/ -Xexact-output-dir", |
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.
This is a nitpick but could we find another name for the files? CypherCmdParser?
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.
Yea, also not super happy about the name. Let's go with CypherCmdParser
unless we think of a better name
|
||
historyCmd: HISTORY; | ||
|
||
useCmd: useCompletionRule symbolicAliasName?; |
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.
Right now this rule is different from the USE
one in the database:
useClause:
USE (GRAPH expression | expression);
I suppose that's expected and we want to change that useClause
instead?
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.
Yes! But also because the semantics are different. USE in the database allows USE graph.byName('myComposite.myConstituent')
which we don't allow in :use
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.
We also allow running it without passing an argument, which switches you to the default database
[CompletionItemKind.Event]: 'Event', | ||
// we're missuing the enum here as there is no Console command in the item kind list | ||
// deceide which one we want to use - for vscode we can't control the icon | ||
[CompletionItemKind.Event]: 'Console', |
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.
Didn't know where to leave the comment, but there's something not working correctly here, certain things after the :param
disappear when writing them or it just places the cursor incorrectly:
bug.mov
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.
I think it's related to the issue you see in the vscode with parameters
as well. Thanks for finding it, I'll give it a look and see what I can do
@@ -169,21 +175,30 @@ export function validateSyntax( | |||
const parsingResult = parserWrapper.parse(wholeFileText); | |||
diagnostics = parsingResult.diagnostics; | |||
|
|||
// semantic anaylsis doesn't handle multi statements | |||
// we break the file into statements and run semantic analysis on each | |||
// then mapp the postions back to the original file |
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.
*Typo: map
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.
I updated/rephrased the comment all together
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.
I also find a bit strange that in VSCode we give you an error saying you need to complete with a console command, not help you in the auto-completion but then error saying you cannot use these type of commands here.
I think it would make more sense to show the error you cannot use console commands here, but still give you the auto-completion:


Either that or show the error when you've just opened :
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.
@ncordon the odd behavior you saw in vsocde/codemirror was caused by the Is it fine to leave in the issue of the error message suggesting a keyword on |
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.
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.
After discussing with Oskar we agreed on improving the error message in the case :PARAM MATCH (n)
to still show you cannot use console commands in VSCode.
Good work 💃 !
I introduce a new grammar that extends the
CypherParser
with more client side commands like:param x => 23
and:use foo
. It can be toggled on/off, and I've added proper errors, completions, highlighting for the client side commands. See the new test cases for a fuller pictureThis PR also fixes semantic analysis for multi-statement queries, like
RETURN a; RETURN b;
since I had to split the string into parts to avoid sending the client commands regardless.