@neo4j-cypher/language-server 2.0.0-next.37 → 2.0.0-next.39

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/dist/server.js CHANGED
@@ -16,6 +16,7 @@ const syntaxHighlighting_1 = require("./syntaxHighlighting");
16
16
  const workerpool_1 = __importDefault(require("workerpool"));
17
17
  const lint_worker_1 = require("@neo4j-cypher/lint-worker");
18
18
  const path_1 = require("path");
19
+ const hoverInfo_js_1 = require("./hoverInfo.js");
19
20
  const defaultWorkerPath = (0, path_1.join)(__dirname, 'lintWorker.cjs');
20
21
  let workerPath = defaultWorkerPath;
21
22
  exports.languageService = new language_support_1.CypherLanguageService({
@@ -121,6 +122,7 @@ connection.onInitialize(() => {
121
122
  signatureHelpProvider: {
122
123
  triggerCharacters: ['(', ',', ')'],
123
124
  },
125
+ hoverProvider: true,
124
126
  documentFormattingProvider: true,
125
127
  },
126
128
  };
@@ -141,7 +143,6 @@ connection.onInitialized(() => {
141
143
  void connection.client.register(node_1.SemanticTokensRegistrationType.type, registrationOptions);
142
144
  });
143
145
  connection.onDidChangeConfiguration((params) => {
144
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
145
146
  settings = params.settings?.neo4j;
146
147
  relintAllDocuments();
147
148
  });
@@ -168,6 +169,9 @@ connection.onNotification('connectionUpdated', (connectionSettings) => {
168
169
  changeConnection(connectionSettings);
169
170
  neo4jSchemaPoller.events.once('schemaFetched', relintAllDocuments);
170
171
  });
172
+ connection.onHover((params) => {
173
+ return (0, hoverInfo_js_1.doHoverInfo)(documents, neo4jSchemaPoller, params);
174
+ });
171
175
  connection.onNotification('fetchSymbolTable', (params) => {
172
176
  neo4jSchemaPoller.events.once('schemaFetched', () => symbolFetcher.queueSymbolJob(params.query, params.uri, params.schema));
173
177
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neo4j-cypher/language-server",
3
- "version": "2.0.0-next.37",
3
+ "version": "2.0.0-next.39",
4
4
  "description": "Cypher Language Server",
5
5
  "keywords": [
6
6
  "cypher",
@@ -30,15 +30,13 @@
30
30
  "main": "./dist/server.js",
31
31
  "types": "src/server.ts",
32
32
  "dependencies": {
33
- "axios": "^1.15.2",
34
33
  "lodash.debounce": "^4.0.8",
35
- "neo4j-driver": "6.0.1",
36
34
  "vscode-languageserver": "^8.1.0",
37
35
  "vscode-languageserver-textdocument": "^1.0.8",
38
36
  "workerpool": "^9.3.3",
39
- "@neo4j-cypher/lint-worker": "1.10.1-next.13",
40
- "@neo4j-cypher/language-support": "2.0.0-next.36",
41
- "@neo4j-cypher/query-tools": "2.0.0-next.36"
37
+ "@neo4j-cypher/language-support": "2.0.0-next.38",
38
+ "@neo4j-cypher/query-tools": "2.0.0-next.38",
39
+ "@neo4j-cypher/lint-worker": "1.10.1-next.15"
42
40
  },
43
41
  "devDependencies": {
44
42
  "@types/lodash.debounce": "^4.0.9",
@@ -53,6 +51,6 @@
53
51
  "bundle": "esbuild ./src/server.ts --bundle --format=cjs --platform=node --outfile=dist/cypher-language-server.js --minify --conditions=require",
54
52
  "dev": "tsc --watch",
55
53
  "make-executable": "cd dist && echo '#!/usr/bin/env node' > cypher-language-server && cat cypher-language-server.js >> cypher-language-server",
56
- "clean": "rm -rf {dist,tsconfig.tsbuildinfo}"
54
+ "clean": "rm -rf dist tsconfig*.tsbuildinfo"
57
55
  }
58
56
  }
@@ -1,21 +1,21 @@
1
- import {
1
+ import type {
2
2
  CompletionParams,
3
- CompletionTriggerKind,
4
3
  Position,
5
4
  TextDocuments,
6
5
  } from 'vscode-languageserver/node';
6
+ import { CompletionTriggerKind } from 'vscode-languageserver/node';
7
7
 
8
8
  import type { CompletionItem } from '@neo4j-cypher/language-support';
9
9
  import { shouldAutoCompleteYield } from '@neo4j-cypher/language-support';
10
- import { Neo4jSchemaPoller } from '@neo4j-cypher/query-tools';
11
- import { TextDocument } from 'vscode-languageserver-textdocument';
10
+ import type { Neo4jSchemaPoller } from '@neo4j-cypher/query-tools';
11
+ import type { TextDocument } from 'vscode-languageserver-textdocument';
12
12
  import { languageService } from './server';
13
13
 
14
14
  export function doAutoCompletion(
15
15
  documents: TextDocuments<TextDocument>,
16
16
  neo4j: Neo4jSchemaPoller,
17
17
  ) {
18
- return (completionParams: CompletionParams) => {
18
+ return (completionParams: CompletionParams): CompletionItem[] | undefined => {
19
19
  const textDocument = documents.get(completionParams.textDocument.uri);
20
20
  if (textDocument === undefined) return [];
21
21
 
@@ -53,5 +53,6 @@ export function doAutoCompletion(
53
53
 
54
54
  return result;
55
55
  }
56
+ return undefined;
56
57
  };
57
58
  }
package/src/formatting.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import { formatQuery } from '@neo4j-cypher/language-support';
2
- import { TextDocument } from 'vscode-languageserver-textdocument';
3
- import {
2
+ import type { TextDocument } from 'vscode-languageserver-textdocument';
3
+ import type {
4
4
  DocumentFormattingParams,
5
5
  TextDocuments,
6
- TextEdit,
7
6
  } from 'vscode-languageserver/node';
7
+ import { TextEdit } from 'vscode-languageserver/node';
8
8
 
9
9
  export const formatDocument = (
10
10
  params: DocumentFormattingParams,
@@ -0,0 +1,20 @@
1
+ import type { Hover, HoverParams, TextDocuments } from 'vscode-languageserver';
2
+ import type { TextDocument } from 'vscode-languageserver-textdocument';
3
+ import { languageService } from './server.js';
4
+ import type { Neo4jSchemaPoller } from '@neo4j-cypher/query-tools';
5
+
6
+ export function doHoverInfo(
7
+ documents: TextDocuments<TextDocument>,
8
+ neo4jSchemaPoller: Neo4jSchemaPoller,
9
+ params: HoverParams,
10
+ ): Hover | null {
11
+ const textDocument = documents.get(params.textDocument.uri);
12
+ if (textDocument === undefined) return null;
13
+ const position = params.position;
14
+ const offset = textDocument.offsetAt(position);
15
+ const hoverInfo = languageService.hoverInfo(textDocument.getText(), {
16
+ caretPosition: offset,
17
+ dbSchema: neo4jSchemaPoller.metadata?.dbSchema ?? {},
18
+ });
19
+ return hoverInfo ? hoverInfo : null;
20
+ }
package/src/linting.ts CHANGED
@@ -1,20 +1,19 @@
1
+ import type {
2
+ SymbolTable,
3
+ SyntaxDiagnostic,
4
+ } from '@neo4j-cypher/language-support';
1
5
  import {
2
6
  clampUnsafePositions,
3
7
  isNotParamError,
4
- SymbolTable,
5
- SyntaxDiagnostic,
6
8
  } from '@neo4j-cypher/language-support';
7
- import { Neo4jSchemaPoller } from '@neo4j-cypher/query-tools';
9
+ import type { Neo4jSchemaPoller } from '@neo4j-cypher/query-tools';
8
10
  import debounce from 'lodash.debounce';
9
11
  import { join } from 'path';
10
- import { Diagnostic } from 'vscode-languageserver';
11
- import { TextDocument } from 'vscode-languageserver-textdocument';
12
+ import type { Diagnostic } from 'vscode-languageserver';
13
+ import type { TextDocument } from 'vscode-languageserver-textdocument';
12
14
  import workerpool from 'workerpool';
13
- import {
14
- convertDbSchema,
15
- LinterTask,
16
- LintWorker,
17
- } from '@neo4j-cypher/lint-worker';
15
+ import type { LinterTask, LintWorker } from '@neo4j-cypher/lint-worker';
16
+ import { convertDbSchema } from '@neo4j-cypher/lint-worker';
18
17
  import { languageService } from './server';
19
18
 
20
19
  const defaultWorkerPath = join(__dirname, 'lintWorker.cjs');
package/src/server.ts CHANGED
@@ -1,19 +1,22 @@
1
+ import type {
2
+ Diagnostic,
3
+ Hover,
4
+ HoverParams,
5
+ InitializeResult,
6
+ SemanticTokensRegistrationOptions,
7
+ } from 'vscode-languageserver/node';
1
8
  import {
2
9
  createConnection,
3
- Diagnostic,
4
10
  DidChangeConfigurationNotification,
5
- InitializeResult,
6
11
  ProposedFeatures,
7
- SemanticTokensRegistrationOptions,
8
12
  SemanticTokensRegistrationType,
9
13
  TextDocuments,
10
14
  TextDocumentSyncKind,
11
15
  } from 'vscode-languageserver/node';
12
16
 
13
17
  import { TextDocument } from 'vscode-languageserver-textdocument';
18
+ import type { DbSchema, SymbolTable } from '@neo4j-cypher/language-support';
14
19
  import {
15
- DbSchema,
16
- SymbolTable,
17
20
  syntaxHighlightingLegend,
18
21
  CypherLanguageService,
19
22
  } from '@neo4j-cypher/language-support';
@@ -23,15 +26,17 @@ import { formatDocument } from './formatting';
23
26
  import { cleanupWorkers, lintDocument, setLintWorker } from './linting';
24
27
  import { doSignatureHelp } from './signatureHelp';
25
28
  import { highlightSyntaxForDocument } from './syntaxHighlighting';
26
- import {
29
+ import type {
27
30
  LintWorkerSettings,
28
31
  Neo4jConnectionSettings,
29
32
  Neo4jParameters,
30
33
  Neo4jSettings,
31
34
  } from './types';
32
35
  import workerpool from 'workerpool';
33
- import { convertDbSchema, LintWorker } from '@neo4j-cypher/lint-worker';
36
+ import type { LintWorker } from '@neo4j-cypher/lint-worker';
37
+ import { convertDbSchema } from '@neo4j-cypher/lint-worker';
34
38
  import { join } from 'path';
39
+ import { doHoverInfo } from './hoverInfo.js';
35
40
 
36
41
  const defaultWorkerPath: string = join(__dirname, 'lintWorker.cjs');
37
42
  let workerPath = defaultWorkerPath;
@@ -172,6 +177,7 @@ connection.onInitialize(() => {
172
177
  signatureHelpProvider: {
173
178
  triggerCharacters: ['(', ',', ')'],
174
179
  },
180
+ hoverProvider: true,
175
181
  documentFormattingProvider: true,
176
182
  },
177
183
  };
@@ -199,7 +205,6 @@ connection.onInitialized(() => {
199
205
  });
200
206
 
201
207
  connection.onDidChangeConfiguration((params) => {
202
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
203
208
  settings = params.settings?.neo4j as Neo4jSettings;
204
209
  relintAllDocuments();
205
210
  });
@@ -238,6 +243,10 @@ connection.onNotification(
238
243
  },
239
244
  );
240
245
 
246
+ connection.onHover((params: HoverParams): Hover | null => {
247
+ return doHoverInfo(documents, neo4jSchemaPoller, params);
248
+ });
249
+
241
250
  connection.onNotification(
242
251
  'fetchSymbolTable',
243
252
  (params: {
@@ -1,14 +1,14 @@
1
- import {
1
+ import type {
2
2
  SignatureHelp,
3
3
  SignatureHelpParams,
4
4
  TextDocuments,
5
5
  } from 'vscode-languageserver/node';
6
6
 
7
- import { Neo4jSchemaPoller } from '@neo4j-cypher/query-tools';
8
- import { TextDocument } from 'vscode-languageserver-textdocument';
7
+ import type { Neo4jSchemaPoller } from '@neo4j-cypher/query-tools';
8
+ import type { TextDocument } from 'vscode-languageserver-textdocument';
9
9
  import { languageService } from './server';
10
10
 
11
- export const emptyResult: SignatureHelp = {
11
+ const emptyResult: SignatureHelp = {
12
12
  signatures: [],
13
13
  activeSignature: undefined,
14
14
  activeParameter: undefined,
@@ -1,10 +1,10 @@
1
1
  import { mapCypherToSemanticTokenIndex } from '@neo4j-cypher/language-support';
2
- import {
3
- SemanticTokensBuilder,
2
+ import type {
4
3
  SemanticTokensParams,
5
4
  TextDocument,
6
5
  TextDocuments,
7
6
  } from 'vscode-languageserver';
7
+ import { SemanticTokensBuilder } from 'vscode-languageserver';
8
8
  import { languageService } from './server';
9
9
 
10
10
  export function highlightSyntaxForDocument(
package/src/types.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { DbSchema } from '@neo4j-cypher/language-support';
1
+ import type { DbSchema } from '@neo4j-cypher/language-support';
2
2
 
3
3
  // These settings are defined in the package.json
4
4
  export type Neo4jConnectionSettings = {