@neo4j-cypher/language-server 2.0.0-next.30 → 2.0.0-next.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -0
- package/dist/cypher-language-server +229 -228
- package/dist/server.js +15 -9
- package/package.json +25 -25
- package/src/autocompletion.ts +9 -7
- package/src/linting.ts +5 -8
- package/src/server.ts +14 -12
- package/src/signatureHelp.ts +3 -3
- package/src/{syntaxColouring.ts → syntaxHighlighting.ts} +4 -6
package/dist/server.js
CHANGED
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.languageService = void 0;
|
|
6
7
|
const node_1 = require("vscode-languageserver/node");
|
|
7
8
|
const vscode_languageserver_textdocument_1 = require("vscode-languageserver-textdocument");
|
|
8
9
|
const language_support_1 = require("@neo4j-cypher/language-support");
|
|
@@ -11,12 +12,15 @@ const autocompletion_1 = require("./autocompletion");
|
|
|
11
12
|
const formatting_1 = require("./formatting");
|
|
12
13
|
const linting_1 = require("./linting");
|
|
13
14
|
const signatureHelp_1 = require("./signatureHelp");
|
|
14
|
-
const
|
|
15
|
+
const syntaxHighlighting_1 = require("./syntaxHighlighting");
|
|
15
16
|
const workerpool_1 = __importDefault(require("workerpool"));
|
|
16
17
|
const lint_worker_1 = require("@neo4j-cypher/lint-worker");
|
|
17
18
|
const path_1 = require("path");
|
|
18
19
|
const defaultWorkerPath = (0, path_1.join)(__dirname, 'lintWorker.cjs');
|
|
19
20
|
let workerPath = defaultWorkerPath;
|
|
21
|
+
exports.languageService = new language_support_1.CypherLanguageService({
|
|
22
|
+
consoleCommandsEnabled: false,
|
|
23
|
+
});
|
|
20
24
|
class SymbolFetcher {
|
|
21
25
|
processing = false;
|
|
22
26
|
nextJob;
|
|
@@ -53,7 +57,7 @@ class SymbolFetcher {
|
|
|
53
57
|
//if this.nextJob has new doc, our result is no longer valid
|
|
54
58
|
result.symbolTables &&
|
|
55
59
|
!(this.nextJob && this.nextJob.uri != docUri)) {
|
|
56
|
-
|
|
60
|
+
exports.languageService.setSymbolsInfo({
|
|
57
61
|
query,
|
|
58
62
|
symbolTables: result.symbolTables,
|
|
59
63
|
}, async (symbolTables) => await connection.sendNotification('symbolTableDone', {
|
|
@@ -61,7 +65,7 @@ class SymbolFetcher {
|
|
|
61
65
|
}));
|
|
62
66
|
}
|
|
63
67
|
}
|
|
64
|
-
catch
|
|
68
|
+
catch {
|
|
65
69
|
//eslint-disable-next-line
|
|
66
70
|
console.log('Symbol table calculation failed');
|
|
67
71
|
}
|
|
@@ -104,11 +108,11 @@ connection.onInitialize(() => {
|
|
|
104
108
|
// Tell the client what features does the server support
|
|
105
109
|
completionProvider: {
|
|
106
110
|
resolveProvider: false,
|
|
107
|
-
triggerCharacters: ['.', ':', '{', '$', ')', ' ', ']'],
|
|
111
|
+
triggerCharacters: ['.', ':', '{', '$', ')', ' ', ']', '-', '<'],
|
|
108
112
|
},
|
|
109
113
|
semanticTokensProvider: {
|
|
110
114
|
documentSelector: [{ language: 'cypher' }],
|
|
111
|
-
legend: language_support_1.
|
|
115
|
+
legend: language_support_1.syntaxHighlightingLegend,
|
|
112
116
|
range: false,
|
|
113
117
|
full: {
|
|
114
118
|
delta: false,
|
|
@@ -128,7 +132,7 @@ connection.onInitialized(() => {
|
|
|
128
132
|
});
|
|
129
133
|
const registrationOptions = {
|
|
130
134
|
documentSelector: [{ language: 'cypher' }],
|
|
131
|
-
legend: language_support_1.
|
|
135
|
+
legend: language_support_1.syntaxHighlightingLegend,
|
|
132
136
|
range: false,
|
|
133
137
|
full: {
|
|
134
138
|
delta: false,
|
|
@@ -142,8 +146,8 @@ connection.onDidChangeConfiguration((params) => {
|
|
|
142
146
|
relintAllDocuments();
|
|
143
147
|
});
|
|
144
148
|
documents.onDidChangeContent((change) => lintSingleDocument(change.document));
|
|
145
|
-
// Trigger the syntax
|
|
146
|
-
connection.languages.semanticTokens.on((0,
|
|
149
|
+
// Trigger the syntax highlighting
|
|
150
|
+
connection.languages.semanticTokens.on((0, syntaxHighlighting_1.highlightSyntaxForDocument)(documents));
|
|
147
151
|
// Trigger the signature help, providing info about functions / procedures
|
|
148
152
|
connection.onSignatureHelp((0, signatureHelp_1.doSignatureHelp)(documents, neo4jSchemaPoller));
|
|
149
153
|
// Trigger the auto completion
|
|
@@ -165,7 +169,9 @@ connection.onNotification('connectionUpdated', (connectionSettings) => {
|
|
|
165
169
|
neo4jSchemaPoller.events.once('schemaFetched', relintAllDocuments);
|
|
166
170
|
});
|
|
167
171
|
connection.onNotification('fetchSymbolTable', (params) => {
|
|
168
|
-
neo4jSchemaPoller.events.once('schemaFetched',
|
|
172
|
+
neo4jSchemaPoller.events.once('schemaFetched',
|
|
173
|
+
// oxlint-disable-next-line typescript-eslint/no-meaningless-void-operator
|
|
174
|
+
void symbolFetcher.queueSymbolJob(params.query, params.uri, params.schema));
|
|
169
175
|
});
|
|
170
176
|
connection.onNotification('updateParameters', (parameters) => {
|
|
171
177
|
neo4jSchemaPoller.setParameters(parameters);
|
package/package.json
CHANGED
|
@@ -1,8 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neo4j-cypher/language-server",
|
|
3
|
+
"version": "2.0.0-next.32",
|
|
3
4
|
"description": "Cypher Language Server",
|
|
4
|
-
"
|
|
5
|
+
"keywords": [
|
|
6
|
+
"cypher",
|
|
7
|
+
"language server",
|
|
8
|
+
"neo4j"
|
|
9
|
+
],
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/neo4j/cypher-language-support/issues"
|
|
12
|
+
},
|
|
5
13
|
"license": "Apache-2.0",
|
|
14
|
+
"author": "Neo4j Inc.",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git://github.com/neo4j/cypher-language-support.git"
|
|
18
|
+
},
|
|
19
|
+
"bin": {
|
|
20
|
+
"cypher-language-server": "./dist/cypher-language-server"
|
|
21
|
+
},
|
|
6
22
|
"files": [
|
|
7
23
|
"./dist/cypher-language-server",
|
|
8
24
|
"./src",
|
|
@@ -11,43 +27,27 @@
|
|
|
11
27
|
"LICENSE.md",
|
|
12
28
|
"CHANGELOG.md"
|
|
13
29
|
],
|
|
14
|
-
"keywords": [
|
|
15
|
-
"neo4j",
|
|
16
|
-
"cypher",
|
|
17
|
-
"language server"
|
|
18
|
-
],
|
|
19
|
-
"version": "2.0.0-next.30",
|
|
20
30
|
"main": "./dist/server.js",
|
|
21
31
|
"types": "src/server.ts",
|
|
22
|
-
"repository": {
|
|
23
|
-
"type": "git",
|
|
24
|
-
"url": "git://github.com/neo4j/cypher-language-support.git"
|
|
25
|
-
},
|
|
26
|
-
"bugs": {
|
|
27
|
-
"url": "https://github.com/neo4j/cypher-language-support/issues"
|
|
28
|
-
},
|
|
29
|
-
"engineStrict": true,
|
|
30
|
-
"engines": {
|
|
31
|
-
"node": ">=24.11.1"
|
|
32
|
-
},
|
|
33
|
-
"bin": {
|
|
34
|
-
"cypher-language-server": "./dist/cypher-language-server"
|
|
35
|
-
},
|
|
36
32
|
"dependencies": {
|
|
33
|
+
"axios": "^1.9.0",
|
|
37
34
|
"lodash.debounce": "^4.0.8",
|
|
38
35
|
"neo4j-driver": "6.0.1",
|
|
39
36
|
"vscode-languageserver": "^8.1.0",
|
|
40
37
|
"vscode-languageserver-textdocument": "^1.0.8",
|
|
41
38
|
"workerpool": "^9.3.3",
|
|
42
|
-
"
|
|
43
|
-
"@neo4j-cypher/
|
|
44
|
-
"@neo4j-cypher/
|
|
45
|
-
"@neo4j-cypher/lint-worker": "1.10.1-next.6"
|
|
39
|
+
"@neo4j-cypher/language-support": "2.0.0-next.31",
|
|
40
|
+
"@neo4j-cypher/query-tools": "2.0.0-next.31",
|
|
41
|
+
"@neo4j-cypher/lint-worker": "1.10.1-next.8"
|
|
46
42
|
},
|
|
47
43
|
"devDependencies": {
|
|
48
44
|
"@types/lodash.debounce": "^4.0.9",
|
|
49
45
|
"copyfiles": "^2.4.1"
|
|
50
46
|
},
|
|
47
|
+
"engines": {
|
|
48
|
+
"node": ">=24.11.1"
|
|
49
|
+
},
|
|
50
|
+
"engineStrict": true,
|
|
51
51
|
"scripts": {
|
|
52
52
|
"build": "tsc -b && pnpm bundle && pnpm make-executable && pnpm copy-lint-worker",
|
|
53
53
|
"copy-lint-worker": "copyfiles -u 4 ../lint-worker/dist/cjs/lintWorker.cjs dist/",
|
package/src/autocompletion.ts
CHANGED
|
@@ -6,12 +6,10 @@ import {
|
|
|
6
6
|
} from 'vscode-languageserver/node';
|
|
7
7
|
|
|
8
8
|
import type { CompletionItem } from '@neo4j-cypher/language-support';
|
|
9
|
-
import {
|
|
10
|
-
autocomplete,
|
|
11
|
-
shouldAutoCompleteYield,
|
|
12
|
-
} from '@neo4j-cypher/language-support';
|
|
9
|
+
import { shouldAutoCompleteYield } from '@neo4j-cypher/language-support';
|
|
13
10
|
import { Neo4jSchemaPoller } from '@neo4j-cypher/query-tools';
|
|
14
11
|
import { TextDocument } from 'vscode-languageserver-textdocument';
|
|
12
|
+
import { languageService } from './server';
|
|
15
13
|
|
|
16
14
|
export function doAutoCompletion(
|
|
17
15
|
documents: TextDocuments<TextDocument>,
|
|
@@ -30,11 +28,15 @@ export function doAutoCompletion(
|
|
|
30
28
|
const manualOrCharacterOrInwordTriggered =
|
|
31
29
|
completionParams.context?.triggerCharacter !== ' ';
|
|
32
30
|
if (yieldTriggered || manualOrCharacterOrInwordTriggered) {
|
|
33
|
-
const completions: CompletionItem[] = autocomplete(
|
|
31
|
+
const completions: CompletionItem[] = languageService.autocomplete(
|
|
34
32
|
textDocument.getText(),
|
|
35
33
|
neo4j.metadata?.dbSchema ?? {},
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
{
|
|
35
|
+
caretPosition: offset,
|
|
36
|
+
manual:
|
|
37
|
+
completionParams.context.triggerKind ===
|
|
38
|
+
CompletionTriggerKind.Invoked,
|
|
39
|
+
},
|
|
38
40
|
);
|
|
39
41
|
|
|
40
42
|
const result = completions.map((item) => {
|
package/src/linting.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
_internalFeatureFlags,
|
|
3
2
|
clampUnsafePositions,
|
|
4
|
-
parserWrapper,
|
|
5
3
|
SymbolTable,
|
|
6
4
|
} from '@neo4j-cypher/language-support';
|
|
7
5
|
import { Neo4jSchemaPoller } from '@neo4j-cypher/query-tools';
|
|
@@ -15,6 +13,7 @@ import {
|
|
|
15
13
|
LinterTask,
|
|
16
14
|
LintWorker,
|
|
17
15
|
} from '@neo4j-cypher/lint-worker';
|
|
16
|
+
import { languageService } from './server';
|
|
18
17
|
|
|
19
18
|
const defaultWorkerPath = join(__dirname, 'lintWorker.cjs');
|
|
20
19
|
|
|
@@ -59,11 +58,9 @@ async function rawLintDocument(
|
|
|
59
58
|
const proxyWorker = (await pool.proxy()) as unknown as LintWorker;
|
|
60
59
|
|
|
61
60
|
const fixedDbSchema = convertDbSchema(dbSchema, linterVersion);
|
|
62
|
-
lastSemanticJob = proxyWorker.lintCypherQuery(
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
_internalFeatureFlags,
|
|
66
|
-
);
|
|
61
|
+
lastSemanticJob = proxyWorker.lintCypherQuery(query, fixedDbSchema, {
|
|
62
|
+
consoleCommands: false,
|
|
63
|
+
});
|
|
67
64
|
const result = await lastSemanticJob;
|
|
68
65
|
|
|
69
66
|
//marks the entire text if any position is negative
|
|
@@ -74,7 +71,7 @@ async function rawLintDocument(
|
|
|
74
71
|
|
|
75
72
|
// Pass the computed symbol tables to the parser
|
|
76
73
|
if (result.symbolTables) {
|
|
77
|
-
|
|
74
|
+
languageService.setSymbolsInfo(
|
|
78
75
|
{
|
|
79
76
|
query,
|
|
80
77
|
symbolTables: result.symbolTables,
|
package/src/server.ts
CHANGED
|
@@ -13,16 +13,16 @@ import {
|
|
|
13
13
|
import { TextDocument } from 'vscode-languageserver-textdocument';
|
|
14
14
|
import {
|
|
15
15
|
DbSchema,
|
|
16
|
-
parserWrapper,
|
|
17
16
|
SymbolTable,
|
|
18
|
-
|
|
17
|
+
syntaxHighlightingLegend,
|
|
18
|
+
CypherLanguageService,
|
|
19
19
|
} from '@neo4j-cypher/language-support';
|
|
20
20
|
import { Neo4jSchemaPoller } from '@neo4j-cypher/query-tools';
|
|
21
21
|
import { doAutoCompletion } from './autocompletion';
|
|
22
22
|
import { formatDocument } from './formatting';
|
|
23
23
|
import { cleanupWorkers, lintDocument, setLintWorker } from './linting';
|
|
24
24
|
import { doSignatureHelp } from './signatureHelp';
|
|
25
|
-
import {
|
|
25
|
+
import { highlightSyntaxForDocument } from './syntaxHighlighting';
|
|
26
26
|
import {
|
|
27
27
|
LintWorkerSettings,
|
|
28
28
|
Neo4jConnectionSettings,
|
|
@@ -35,6 +35,9 @@ import { join } from 'path';
|
|
|
35
35
|
|
|
36
36
|
const defaultWorkerPath: string = join(__dirname, 'lintWorker.cjs');
|
|
37
37
|
let workerPath = defaultWorkerPath;
|
|
38
|
+
export const languageService = new CypherLanguageService({
|
|
39
|
+
consoleCommandsEnabled: false,
|
|
40
|
+
});
|
|
38
41
|
|
|
39
42
|
class SymbolFetcher {
|
|
40
43
|
private processing = false;
|
|
@@ -86,7 +89,7 @@ class SymbolFetcher {
|
|
|
86
89
|
result.symbolTables &&
|
|
87
90
|
!(this.nextJob && this.nextJob.uri != docUri)
|
|
88
91
|
) {
|
|
89
|
-
|
|
92
|
+
languageService.setSymbolsInfo(
|
|
90
93
|
{
|
|
91
94
|
query,
|
|
92
95
|
symbolTables: result.symbolTables,
|
|
@@ -97,7 +100,7 @@ class SymbolFetcher {
|
|
|
97
100
|
}),
|
|
98
101
|
);
|
|
99
102
|
}
|
|
100
|
-
} catch
|
|
103
|
+
} catch {
|
|
101
104
|
//eslint-disable-next-line
|
|
102
105
|
console.log('Symbol table calculation failed');
|
|
103
106
|
}
|
|
@@ -154,11 +157,11 @@ connection.onInitialize(() => {
|
|
|
154
157
|
// Tell the client what features does the server support
|
|
155
158
|
completionProvider: {
|
|
156
159
|
resolveProvider: false,
|
|
157
|
-
triggerCharacters: ['.', ':', '{', '$', ')', ' ', ']'],
|
|
160
|
+
triggerCharacters: ['.', ':', '{', '$', ')', ' ', ']', '-', '<'],
|
|
158
161
|
},
|
|
159
162
|
semanticTokensProvider: {
|
|
160
163
|
documentSelector: [{ language: 'cypher' }],
|
|
161
|
-
legend:
|
|
164
|
+
legend: syntaxHighlightingLegend,
|
|
162
165
|
range: false,
|
|
163
166
|
full: {
|
|
164
167
|
delta: false,
|
|
@@ -181,7 +184,7 @@ connection.onInitialized(() => {
|
|
|
181
184
|
|
|
182
185
|
const registrationOptions: SemanticTokensRegistrationOptions = {
|
|
183
186
|
documentSelector: [{ language: 'cypher' }],
|
|
184
|
-
legend:
|
|
187
|
+
legend: syntaxHighlightingLegend,
|
|
185
188
|
range: false,
|
|
186
189
|
full: {
|
|
187
190
|
delta: false,
|
|
@@ -201,10 +204,8 @@ connection.onDidChangeConfiguration((params) => {
|
|
|
201
204
|
|
|
202
205
|
documents.onDidChangeContent((change) => lintSingleDocument(change.document));
|
|
203
206
|
|
|
204
|
-
// Trigger the syntax
|
|
205
|
-
connection.languages.semanticTokens.on(
|
|
206
|
-
applySyntaxColouringForDocument(documents),
|
|
207
|
-
);
|
|
207
|
+
// Trigger the syntax highlighting
|
|
208
|
+
connection.languages.semanticTokens.on(highlightSyntaxForDocument(documents));
|
|
208
209
|
|
|
209
210
|
// Trigger the signature help, providing info about functions / procedures
|
|
210
211
|
connection.onSignatureHelp(doSignatureHelp(documents, neo4jSchemaPoller));
|
|
@@ -245,6 +246,7 @@ connection.onNotification(
|
|
|
245
246
|
}) => {
|
|
246
247
|
neo4jSchemaPoller.events.once(
|
|
247
248
|
'schemaFetched',
|
|
249
|
+
// oxlint-disable-next-line typescript-eslint/no-meaningless-void-operator
|
|
248
250
|
void symbolFetcher.queueSymbolJob(
|
|
249
251
|
params.query,
|
|
250
252
|
params.uri,
|
package/src/signatureHelp.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { signatureHelp } from '@neo4j-cypher/language-support';
|
|
2
1
|
import {
|
|
3
2
|
SignatureHelp,
|
|
4
3
|
SignatureHelpParams,
|
|
@@ -7,6 +6,7 @@ import {
|
|
|
7
6
|
|
|
8
7
|
import { Neo4jSchemaPoller } from '@neo4j-cypher/query-tools';
|
|
9
8
|
import { TextDocument } from 'vscode-languageserver-textdocument';
|
|
9
|
+
import { languageService } from './server';
|
|
10
10
|
|
|
11
11
|
export const emptyResult: SignatureHelp = {
|
|
12
12
|
signatures: [],
|
|
@@ -26,10 +26,10 @@ export function doSignatureHelp(
|
|
|
26
26
|
const position = params.position;
|
|
27
27
|
const offset = textDocument.offsetAt(position);
|
|
28
28
|
|
|
29
|
-
return
|
|
29
|
+
return languageService.getSignatureHelp(
|
|
30
30
|
textDocument.getText(),
|
|
31
31
|
neo4j.metadata?.dbSchema ?? {},
|
|
32
|
-
offset,
|
|
32
|
+
{ caretPosition: offset },
|
|
33
33
|
);
|
|
34
34
|
};
|
|
35
35
|
}
|
|
@@ -1,22 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
applySyntaxColouring,
|
|
3
|
-
mapCypherToSemanticTokenIndex,
|
|
4
|
-
} from '@neo4j-cypher/language-support';
|
|
1
|
+
import { mapCypherToSemanticTokenIndex } from '@neo4j-cypher/language-support';
|
|
5
2
|
import {
|
|
6
3
|
SemanticTokensBuilder,
|
|
7
4
|
SemanticTokensParams,
|
|
8
5
|
TextDocument,
|
|
9
6
|
TextDocuments,
|
|
10
7
|
} from 'vscode-languageserver';
|
|
8
|
+
import { languageService } from './server';
|
|
11
9
|
|
|
12
|
-
export function
|
|
10
|
+
export function highlightSyntaxForDocument(
|
|
13
11
|
documents: TextDocuments<TextDocument>,
|
|
14
12
|
) {
|
|
15
13
|
return (params: SemanticTokensParams) => {
|
|
16
14
|
const textDocument = documents.get(params.textDocument.uri);
|
|
17
15
|
if (textDocument === undefined) return { data: [] };
|
|
18
16
|
|
|
19
|
-
const tokens =
|
|
17
|
+
const tokens = languageService.highlightSyntax(textDocument.getText());
|
|
20
18
|
|
|
21
19
|
const builder = new SemanticTokensBuilder();
|
|
22
20
|
|