@neo4j-cypher/language-server 2.0.0-next.32 → 2.0.0-next.34

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
@@ -46,11 +46,11 @@ class SymbolFetcher {
46
46
  this.processing = true;
47
47
  while (this.nextJob) {
48
48
  try {
49
- const proxyWorker = (await this.symbolTablePool.proxy());
50
49
  const query = this.nextJob.query;
51
50
  const dbSchema = this.nextJob.schema;
52
51
  const docUri = this.nextJob.uri;
53
52
  this.nextJob = undefined;
53
+ const proxyWorker = (await this.symbolTablePool.proxy());
54
54
  const fixedDbSchema = (0, lint_worker_1.convertDbSchema)(dbSchema, this.linterVersion);
55
55
  const result = await proxyWorker.lintCypherQuery(query, fixedDbSchema);
56
56
  if (
@@ -169,9 +169,7 @@ connection.onNotification('connectionUpdated', (connectionSettings) => {
169
169
  neo4jSchemaPoller.events.once('schemaFetched', relintAllDocuments);
170
170
  });
171
171
  connection.onNotification('fetchSymbolTable', (params) => {
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));
172
+ neo4jSchemaPoller.events.once('schemaFetched', () => symbolFetcher.queueSymbolJob(params.query, params.uri, params.schema));
175
173
  });
176
174
  connection.onNotification('updateParameters', (parameters) => {
177
175
  neo4jSchemaPoller.setParameters(parameters);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neo4j-cypher/language-server",
3
- "version": "2.0.0-next.32",
3
+ "version": "2.0.0-next.34",
4
4
  "description": "Cypher Language Server",
5
5
  "keywords": [
6
6
  "cypher",
@@ -30,15 +30,15 @@
30
30
  "main": "./dist/server.js",
31
31
  "types": "src/server.ts",
32
32
  "dependencies": {
33
- "axios": "^1.9.0",
33
+ "axios": "^1.15.2",
34
34
  "lodash.debounce": "^4.0.8",
35
35
  "neo4j-driver": "6.0.1",
36
36
  "vscode-languageserver": "^8.1.0",
37
37
  "vscode-languageserver-textdocument": "^1.0.8",
38
38
  "workerpool": "^9.3.3",
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"
39
+ "@neo4j-cypher/lint-worker": "1.10.1-next.10",
40
+ "@neo4j-cypher/query-tools": "2.0.0-next.33",
41
+ "@neo4j-cypher/language-support": "2.0.0-next.33"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@types/lodash.debounce": "^4.0.9",
package/src/linting.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  import {
2
2
  clampUnsafePositions,
3
+ isNotParamError,
3
4
  SymbolTable,
5
+ SyntaxDiagnostic,
4
6
  } from '@neo4j-cypher/language-support';
5
7
  import { Neo4jSchemaPoller } from '@neo4j-cypher/query-tools';
6
8
  import debounce from 'lodash.debounce';
@@ -63,12 +65,6 @@ async function rawLintDocument(
63
65
  });
64
66
  const result = await lastSemanticJob;
65
67
 
66
- //marks the entire text if any position is negative
67
- const positionSafeResult = clampUnsafePositions(
68
- result.diagnostics,
69
- document,
70
- );
71
-
72
68
  // Pass the computed symbol tables to the parser
73
69
  if (result.symbolTables) {
74
70
  languageService.setSymbolsInfo(
@@ -80,7 +76,13 @@ async function rawLintDocument(
80
76
  );
81
77
  }
82
78
 
83
- sendDiagnostics(positionSafeResult);
79
+ sendDiagnostics(
80
+ filterLintResult(
81
+ result.diagnostics,
82
+ dbSchema?.databaseNames?.length ? false : true,
83
+ document,
84
+ ),
85
+ );
84
86
  } catch (err) {
85
87
  if (!(err instanceof workerpool.Promise.CancellationError)) {
86
88
  console.error(err);
@@ -88,6 +90,16 @@ async function rawLintDocument(
88
90
  }
89
91
  }
90
92
 
93
+ function filterLintResult(
94
+ diagnostics: SyntaxDiagnostic[],
95
+ dontWarnOnParams: boolean,
96
+ document: TextDocument,
97
+ ) {
98
+ return dontWarnOnParams
99
+ ? clampUnsafePositions(diagnostics.filter(isNotParamError), document)
100
+ : clampUnsafePositions(diagnostics, document);
101
+ }
102
+
91
103
  export const lintDocument: typeof rawLintDocument = debounce(
92
104
  rawLintDocument,
93
105
  600,
package/src/server.ts CHANGED
@@ -41,11 +41,13 @@ export const languageService = new CypherLanguageService({
41
41
 
42
42
  class SymbolFetcher {
43
43
  private processing = false;
44
- private nextJob: {
45
- query: string;
46
- uri: string;
47
- schema: DbSchema;
48
- };
44
+ private nextJob:
45
+ | {
46
+ query: string;
47
+ uri: string;
48
+ schema: DbSchema;
49
+ }
50
+ | undefined;
49
51
  private symbolTablePool = workerpool.pool(defaultWorkerPath, {
50
52
  maxWorkers: 1,
51
53
  workerTerminateTimeout: 0,
@@ -74,12 +76,12 @@ class SymbolFetcher {
74
76
  this.processing = true;
75
77
  while (this.nextJob) {
76
78
  try {
77
- const proxyWorker =
78
- (await this.symbolTablePool.proxy()) as unknown as LintWorker;
79
79
  const query = this.nextJob.query;
80
80
  const dbSchema = this.nextJob.schema;
81
81
  const docUri = this.nextJob.uri;
82
82
  this.nextJob = undefined;
83
+ const proxyWorker =
84
+ (await this.symbolTablePool.proxy()) as unknown as LintWorker;
83
85
  const fixedDbSchema = convertDbSchema(dbSchema, this.linterVersion);
84
86
 
85
87
  const result = await proxyWorker.lintCypherQuery(query, fixedDbSchema);
@@ -244,14 +246,8 @@ connection.onNotification(
244
246
  version: number;
245
247
  schema: DbSchema;
246
248
  }) => {
247
- neo4jSchemaPoller.events.once(
248
- 'schemaFetched',
249
- // oxlint-disable-next-line typescript-eslint/no-meaningless-void-operator
250
- void symbolFetcher.queueSymbolJob(
251
- params.query,
252
- params.uri,
253
- params.schema,
254
- ),
249
+ neo4jSchemaPoller.events.once('schemaFetched', () =>
250
+ symbolFetcher.queueSymbolJob(params.query, params.uri, params.schema),
255
251
  );
256
252
  },
257
253
  );