Skip to content

Commit 1b1a8c1

Browse files
committed
fix clash between auto keyword and auto console command
1 parent 79e32ab commit 1b1a8c1

6 files changed

Lines changed: 14 additions & 7 deletions

File tree

packages/language-support/src/antlr-grammar/CypherCmdLexer.g4

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,3 @@ PLAY: P L A Y;
2525
ACCESSMODE: A C C E S S '-' M O D E;
2626

2727
HELP: H E L P;
28-
29-
AUTO: A U T O;

packages/language-support/src/antlr-grammar/CypherCmdParser.g4

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ accessModeCmd: ACCESSMODE accessModeArgs?;
5959

6060
helpCmd: HELP;
6161

62-
autoCmd: AUTO statement;
62+
autoCmd: autoCompletionRule statement;
6363

6464
// These rules are needed to distinguish cypher <-> commands, for example `USE` and `:use` in autocompletion
6565
listCompletionRule: LIST;
@@ -72,6 +72,8 @@ readCompletionRule: READ;
7272

7373
writeCompletionRule: WRITE;
7474

75+
autoCompletionRule: AUTO;
76+
7577
// This rule overrides the identifiers adding EXPLAIN, PROFILE, etc
7678
unescapedSymbolicNameString:
7779
preparserKeyword

packages/language-support/src/autocompletion/completionCoreCompletions.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,7 @@ export function completionCoreCompletion(
525525
CypherParser.RULE_serverCompletionRule,
526526
CypherParser.RULE_readCompletionRule,
527527
CypherParser.RULE_writeCompletionRule,
528+
CypherParser.RULE_autoCompletionRule,
528529
]
529530
: [CypherParser.RULE_consoleCommand]),
530531

@@ -778,6 +779,10 @@ export function completionCoreCompletion(
778779
return [{ label: 'write', kind: CompletionItemKind.Event }];
779780
}
780781

782+
if (ruleNumber === CypherParser.RULE_autoCompletionRule) {
783+
return [{ label: 'auto', kind: CompletionItemKind.Event }];
784+
}
785+
781786
return [];
782787
},
783788
);

packages/language-support/src/syntaxHighlighting/syntaxHighlighting.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { ParseTreeWalker, TerminalNode, Token } from 'antlr4';
33
import {
44
AccessModeArgsContext,
55
ArrowLineContext,
6-
AutoCmdContext,
6+
AutoCompletionRuleContext,
77
BooleanLiteralContext,
88
ConsoleCommandContext,
99
CypherOptionNameContext,
@@ -277,7 +277,8 @@ class SyntaxHighlighter extends CypherParserListener {
277277
);
278278
};
279279

280-
exitAutoCmd = (ctx: AutoCmdContext) => {
280+
// console commands that clash with cypher keywords
281+
exitAutoCompletionRule = (ctx: AutoCompletionRuleContext) => {
281282
const auto = ctx.AUTO();
282283

283284
this.addToken(auto.symbol, CypherTokenType.consoleCommand, auto.getText());

packages/language-support/src/syntaxValidation/completionCoreErrors.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export function completionCoreErrormessage(
5353
[CypherParser.RULE_serverCompletionRule]: 'server',
5454
[CypherParser.RULE_readCompletionRule]: 'read',
5555
[CypherParser.RULE_writeCompletionRule]: 'write',
56+
[CypherParser.RULE_autoCompletionRule]: 'auto',
5657
}
5758
: { [CypherParser.RULE_consoleCommand]: null }),
5859
};

packages/language-support/src/tests/consoleCommands.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,9 @@ describe('sanity checks', () => {
247247

248248
test('completes basic console cmds on :', () => {
249249
expect(autocomplete(':', {})).toEqual([
250+
{ kind: 23, label: 'auto' },
250251
{ kind: 23, label: 'server' },
251252
{ kind: 23, label: 'use' },
252-
{ kind: 23, label: 'auto' },
253253
{ kind: 23, label: 'help' },
254254
{ kind: 23, label: 'access-mode' },
255255
{ kind: 23, label: 'play' },
@@ -297,7 +297,7 @@ describe('sanity checks', () => {
297297
test('handles misspelled or non-existing command', () => {
298298
expectErrorMessage(
299299
':foo',
300-
'Expected any of auto, help, access-mode, play, style, sysinfo, welcome, disconnect, connect, param, history, clear, server or use',
300+
'Expected any of help, access-mode, play, style, sysinfo, welcome, disconnect, connect, param, history, clear, auto, server or use',
301301
);
302302

303303
expectErrorMessage(':clea', 'Unexpected token. Did you mean clear?');

0 commit comments

Comments
 (0)