-
Notifications
You must be signed in to change notification settings - Fork 9
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
Adapts procedure registry to depend on the cypher version #331
base: main
Are you sure you want to change the base?
Conversation
… into defaultLanguage
…epending on the version
🦋 Changeset detectedLatest commit: bd075b5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
57c7f5d
to
ff25f9e
Compare
…e cypher versions
…o polling-versioned-procs-fns
if (featureFlags.cypher25 !== undefined) { | ||
_internalFeatureFlags.cypher25 = featureFlags.cypher25; | ||
} |
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 need to pass the feature flags to the lint worker because the _internalFeatureFlags
variable from the outside lives in another thread
if (process.env.CYPHER_25 === 'true') { | ||
_internalFeatureFlags.cypher25 = true; | ||
} |
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 so we can set the feature flag in the language server from the vscode extension
@@ -48,7 +48,7 @@ | |||
"vscode-languageserver-types": "^3.17.3" | |||
}, | |||
"scripts": { | |||
"gen-parser": "antlr4 -Dlanguage=TypeScript -visitor src/antlr-grammar/CypherCmdLexer.g4 src/antlr-grammar/CypherCmdParser.g4 -o src/generated-parser/ -Xexact-output-dir", | |||
"gen-parser": "export ANTLR4_TOOLS_ANTLR_VERSION=4.13.2 && antlr4 -Dlanguage=TypeScript -visitor src/antlr-grammar/CypherCmdLexer.g4 src/antlr-grammar/CypherCmdParser.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 because https://github.com/antlr/antlr4-tools will resolve and download the most up to date version of antlr if this environment variable is not set. But it was failing to contact the relevant url.
This hardcodes the version we want to use. Which we should do in any case, because we wouldn't want to use a different version for generating the parser and for the antlr4 runtime.
procedures?: Partial<Record<CypherVersion, Record<string, Neo4jProcedure>>>; | ||
functions?: Partial<Record<CypherVersion, Record<string, Neo4jFunction>>>; |
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 need a different procedure registry for each version because the same function / procedure could have a different signature in different versions.
At the moment there are not many examples of methods that have different signatures for different versions(just apoc.cypher.runTimeboxed
). But there will be in the future.
const versions: (CypherVersion | undefined)[] = isNewerNeo4j | ||
? cypherVersions | ||
: [undefined]; | ||
|
||
versions.forEach((cypherVersion) => { | ||
const effectiveCypherVersion: CypherVersion = cypherVersion ?? 'cypher 5'; |
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.
If we are not connected to a new neo4j, just poll for cypher 5
, which means we cannot preprend either CYPHER 5
nor CYPHER 25
to the queries
debug: { | ||
module: debugServer, | ||
transport: TransportKind.ipc, | ||
options: { env: { CYPHER_25: 'true' } }, |
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 only affects the server version we use in the tests, not the production one. So we'll have CYPHER_25
support enabled there by default.
diagnostics = vscode.languages | ||
.getDiagnostics() | ||
.filter(([uri]) => uri.scheme === 'untitled') | ||
.flatMap(([, diagnostics]) => diagnostics); |
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 was giving problems when having two documents opened that were temporary and not saved to file, because it would collect the diagnostics for both.
Builds on top of #328.
packages/language-support/src/tests/testData.ts
just adds the new shape for the registry in themockSchema
packages/language-support/src/syntaxValidation/semanticAnalysis.js
brings in the new changes to be able to update either the registry for Cypher 5 or Cypher 25.What
Polls for the procedure registry for both Cypher 5 and Cypher 25 and wires that into the code.
This means for older versions we do
SHOW PROCEDURES
andSHOW FUNCTIONS
and store that under 'cypher 5' in the schema.For newer versions we poll all of the following queries:
Why
Starting from neo4j
2025.01
we will support two concurrent cypher versions, which will mean we could have procedures that were deprecated in Cypher 5 and removed in Cypher 25, or even arguments that were deprecated in Cypher 5 and removed in Cypher 25.