@neo4j-cypher/language-support
Advanced tools
Comparing version 2.0.0-canary-7700c71 to 2.0.0-canary-83271c4
export type { ParserRuleContext } from 'antlr4'; | ||
export { autocomplete } from './autocompletion/autocompletion'; | ||
export type { DbSchema } from './dbSchema'; | ||
export { _internalFeatureFlags } from './featureFlags'; | ||
export { antlrUtils } from './helpers'; | ||
export { CypherTokenType, lexerSymbols } from './lexerSymbols'; | ||
export { parse, parserWrapper, setConsoleCommandsEnabled, } from './parserWrapper'; | ||
export { parse, parserWrapper } from './parserWrapper'; | ||
export { signatureHelp, toSignatureInformation } from './signatureHelp'; | ||
@@ -8,0 +9,0 @@ export { applySyntaxColouring, mapCypherToSemanticTokenIndex, syntaxColouringLegend, } from './syntaxColouring/syntaxColouring'; |
@@ -83,5 +83,3 @@ import type { ParserRuleContext, Token } from 'antlr4'; | ||
} | ||
export declare function setConsoleCommandsEnabled(enabled: boolean): void; | ||
export declare function consoleCommandEnabled(): boolean; | ||
export declare const parserWrapper: ParserWrapper; | ||
export {}; |
@@ -21,3 +21,3 @@ { | ||
], | ||
"version": "2.0.0-canary-7700c71", | ||
"version": "2.0.0-canary-83271c4", | ||
"main": "./dist/cjs/index.cjs", | ||
@@ -24,0 +24,0 @@ "module": "./dist/esm/index.mjs", |
@@ -24,3 +24,3 @@ import { Token } from 'antlr4'; | ||
import { consoleCommandEnabled } from '../parserWrapper'; | ||
import { _internalFeatureFlags } from '../featureFlags'; | ||
@@ -350,3 +350,3 @@ const uniq = <T>(arr: T[]) => Array.from(new Set(arr)); | ||
// or collect all console commands like below with symbolicNameString | ||
...(consoleCommandEnabled() | ||
...(_internalFeatureFlags.consoleCommands | ||
? [ | ||
@@ -353,0 +353,0 @@ CypherParser.RULE_useCompletionRule, |
export type { ParserRuleContext } from 'antlr4'; | ||
export { autocomplete } from './autocompletion/autocompletion'; | ||
export type { DbSchema } from './dbSchema'; | ||
export { _internalFeatureFlags } from './featureFlags'; | ||
export { antlrUtils } from './helpers'; | ||
export { CypherTokenType, lexerSymbols } from './lexerSymbols'; | ||
export { | ||
parse, | ||
parserWrapper, | ||
setConsoleCommandsEnabled, | ||
} from './parserWrapper'; | ||
export { parse, parserWrapper } from './parserWrapper'; | ||
export { signatureHelp, toSignatureInformation } from './signatureHelp'; | ||
@@ -27,4 +24,3 @@ export { | ||
export { CypherLexer, CypherParser }; | ||
import CypherLexer from './generated-parser/CypherCmdLexer'; | ||
import CypherParser from './generated-parser/CypherCmdParser'; |
@@ -7,2 +7,3 @@ import type { ParserRuleContext, Token } from 'antlr4'; | ||
import { DiagnosticSeverity, Position } from 'vscode-languageserver-types'; | ||
import { _internalFeatureFlags } from './featureFlags'; | ||
import { | ||
@@ -149,3 +150,3 @@ ClauseContext, | ||
if (!consoleCommandEnabled()) { | ||
if (!_internalFeatureFlags.consoleCommands) { | ||
diagnostics.push(...errorOnNonCypherCommands(collectedCommand)); | ||
@@ -447,18 +448,2 @@ } | ||
/* | ||
Because the parserWrapper is done as a single-ton global variable, the setting for | ||
console commands was also easiest to do as a global variable as it avoid messing with the cache | ||
It would make sense for the client to initialize and own the ParserWrapper, then each editor can have | ||
it's own cache and preference on if console commands are enabled or not. | ||
*/ | ||
let enableConsoleCommands = false; | ||
export function setConsoleCommandsEnabled(enabled: boolean) { | ||
enableConsoleCommands = enabled; | ||
} | ||
export function consoleCommandEnabled() { | ||
return enableConsoleCommands; | ||
} | ||
export const parserWrapper = new ParserWrapper(); |
@@ -73,3 +73,3 @@ import { | ||
exitExpression = (ctx: ExpressionContext) => { | ||
enterExpression = (ctx: ExpressionContext) => { | ||
// If the caret is at ( | ||
@@ -110,3 +110,3 @@ if (this.caretToken.type === CypherParser.LPAREN) { | ||
exitFunctionInvocation = (ctx: FunctionInvocationContext) => { | ||
enterFunctionInvocation = (ctx: FunctionInvocationContext) => { | ||
if ( | ||
@@ -132,3 +132,3 @@ ctx.start.start <= this.caretToken.start && | ||
exitCallClause = (ctx: CallClauseContext) => { | ||
enterCallClause = (ctx: CallClauseContext) => { | ||
if ( | ||
@@ -135,0 +135,0 @@ ctx.start.start <= this.caretToken.start && |
@@ -5,2 +5,3 @@ import { Token } from 'antlr4'; | ||
import { distance } from 'fastest-levenshtein'; | ||
import { _internalFeatureFlags } from '../featureFlags'; | ||
import CypherLexer from '../generated-parser/CypherCmdLexer'; | ||
@@ -14,3 +15,2 @@ import CypherParser from '../generated-parser/CypherCmdParser'; | ||
} from '../lexerSymbols'; | ||
import { consoleCommandEnabled } from '../parserWrapper'; | ||
@@ -51,3 +51,3 @@ /* | ||
// or collect all console commands like below with symbolicNameString | ||
...(consoleCommandEnabled() | ||
...(_internalFeatureFlags.consoleCommands | ||
? { | ||
@@ -54,0 +54,0 @@ [CypherParser.RULE_useCompletionRule]: 'use', |
import { autocomplete } from '../autocompletion/autocompletion'; | ||
import { | ||
ParsedCommandNoPosition, | ||
parserWrapper, | ||
setConsoleCommandsEnabled, | ||
} from '../parserWrapper'; | ||
import { _internalFeatureFlags } from '../featureFlags'; | ||
import { ParsedCommandNoPosition, parserWrapper } from '../parserWrapper'; | ||
import { applySyntaxColouring } from '../syntaxColouring/syntaxColouring'; | ||
@@ -43,6 +40,6 @@ import { testData } from './testData'; | ||
beforeAll(() => { | ||
setConsoleCommandsEnabled(true); | ||
_internalFeatureFlags.consoleCommands = true; | ||
}); | ||
afterAll(() => { | ||
setConsoleCommandsEnabled(false); | ||
_internalFeatureFlags.consoleCommands = false; | ||
}); | ||
@@ -149,6 +146,6 @@ | ||
beforeAll(() => { | ||
setConsoleCommandsEnabled(true); | ||
_internalFeatureFlags.consoleCommands = true; | ||
}); | ||
afterAll(() => { | ||
setConsoleCommandsEnabled(false); | ||
_internalFeatureFlags.consoleCommands = false; | ||
}); | ||
@@ -216,6 +213,6 @@ test('parses without arg', () => { | ||
beforeAll(() => { | ||
setConsoleCommandsEnabled(true); | ||
_internalFeatureFlags.consoleCommands = true; | ||
}); | ||
afterAll(() => { | ||
setConsoleCommandsEnabled(false); | ||
_internalFeatureFlags.consoleCommands = false; | ||
}); | ||
@@ -453,6 +450,6 @@ test('basic param usage', () => { | ||
beforeAll(() => { | ||
setConsoleCommandsEnabled(true); | ||
_internalFeatureFlags.consoleCommands = true; | ||
}); | ||
afterAll(() => { | ||
setConsoleCommandsEnabled(false); | ||
_internalFeatureFlags.consoleCommands = false; | ||
}); | ||
@@ -459,0 +456,0 @@ test('parses cypher', () => { |
@@ -221,2 +221,10 @@ import { SignatureHelp } from 'vscode-languageserver-types'; | ||
}); | ||
test('Provides signature help for procedures when another argument is a function', () => { | ||
testSignatureHelp( | ||
'CALL apoc.do.when(apoc.coll.combinations(coll, something), ', | ||
dbSchema, | ||
expectedArgIndex(1), | ||
); | ||
}); | ||
}); | ||
@@ -393,2 +401,18 @@ | ||
}); | ||
test('Provides signature help for functions inside procedures, first argument', () => { | ||
testSignatureHelp( | ||
'CALL apoc.do.when(apoc.coll.combinations(', | ||
dbSchema, | ||
expectedArgIndex(0), | ||
); | ||
}); | ||
test('Provides signature help for functions inside procedures, second argument', () => { | ||
testSignatureHelp( | ||
'CALL apoc.do.when(apoc.coll.combinations(coll,', | ||
dbSchema, | ||
expectedArgIndex(1), | ||
); | ||
}); | ||
}); |
@@ -1,2 +0,2 @@ | ||
import { setConsoleCommandsEnabled } from '../../parserWrapper'; | ||
import { _internalFeatureFlags } from '../../featureFlags'; | ||
import { testData } from '../testData'; | ||
@@ -1177,3 +1177,3 @@ import { getDiagnosticsForQuery } from './helpers'; | ||
message: | ||
'A pattern expression should only be used in order to test the existence of a pattern. It can no longer be used inside the function size(), an alternative is to replace size() with COUNT {}.', | ||
'A pattern expression should only be used in order to test the existence of a pattern. It should therefore only be used in contexts that evaluate to a boolean, e.g. inside the function exists() or in a WHERE-clause. No other uses are allowed, instead they should be replaced by a pattern comprehension.', | ||
offsets: { | ||
@@ -1256,3 +1256,4 @@ end: 29, | ||
test('gives error on console commands when they are disabled', () => { | ||
setConsoleCommandsEnabled(true); | ||
_internalFeatureFlags.consoleCommands = true; | ||
expect( | ||
@@ -1298,7 +1299,7 @@ getDiagnosticsForQuery({ query: 'RETURN a;:clear; RETURN b;:history;' }), | ||
]); | ||
setConsoleCommandsEnabled(false); | ||
_internalFeatureFlags.consoleCommands = false; | ||
}); | ||
test('Handles multiple cypher statements in a single query', () => { | ||
setConsoleCommandsEnabled(true); | ||
_internalFeatureFlags.consoleCommands = true; | ||
expect(getDiagnosticsForQuery({ query: 'RETURN a; RETURN b;' })).toEqual([ | ||
@@ -1342,7 +1343,7 @@ { | ||
]); | ||
setConsoleCommandsEnabled(false); | ||
_internalFeatureFlags.consoleCommands = false; | ||
}); | ||
test('Handles cypher mixed with client commands', () => { | ||
setConsoleCommandsEnabled(true); | ||
_internalFeatureFlags.consoleCommands = true; | ||
expect( | ||
@@ -1390,7 +1391,7 @@ getDiagnosticsForQuery({ | ||
]); | ||
setConsoleCommandsEnabled(false); | ||
_internalFeatureFlags.consoleCommands = false; | ||
}); | ||
test('Handles cypher mixed with complex client command', () => { | ||
setConsoleCommandsEnabled(true); | ||
_internalFeatureFlags.consoleCommands = true; | ||
expect( | ||
@@ -1426,3 +1427,3 @@ getDiagnosticsForQuery({ | ||
]); | ||
setConsoleCommandsEnabled(false); | ||
_internalFeatureFlags.consoleCommands = false; | ||
}); | ||
@@ -1429,0 +1430,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
141604572
124
149179