@neo4j-cypher/language-server 2.0.0-next.31 → 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 +20 -0
- package/dist/cypher-language-server +204 -202
- package/dist/server.js +10 -6
- package/package.json +4 -4
- package/src/autocompletion.ts +9 -7
- package/src/linting.ts +5 -8
- package/src/server.ts +11 -10
- 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', {
|
|
@@ -108,7 +112,7 @@ connection.onInitialize(() => {
|
|
|
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
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neo4j-cypher/language-server",
|
|
3
|
-
"version": "2.0.0-next.
|
|
3
|
+
"version": "2.0.0-next.32",
|
|
4
4
|
"description": "Cypher Language Server",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cypher",
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
"vscode-languageserver": "^8.1.0",
|
|
37
37
|
"vscode-languageserver-textdocument": "^1.0.8",
|
|
38
38
|
"workerpool": "^9.3.3",
|
|
39
|
-
"@neo4j-cypher/
|
|
40
|
-
"@neo4j-cypher/
|
|
41
|
-
"@neo4j-cypher/lint-worker": "1.10.1-next.
|
|
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"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/lodash.debounce": "^4.0.9",
|
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,
|
|
@@ -158,7 +161,7 @@ connection.onInitialize(() => {
|
|
|
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));
|
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
|
|