@neo4j-cypher/react-codemirror 2.0.0-next.4 → 2.0.0-next.6

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.
Files changed (123) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/{types/CypherEditor.d.ts → CypherEditor.d.ts} +10 -1
  3. package/dist/CypherEditor.js +206 -0
  4. package/dist/CypherEditor.js.map +1 -0
  5. package/dist/e2e_tests/autoCompletion.spec.js +133 -0
  6. package/dist/e2e_tests/autoCompletion.spec.js.map +1 -0
  7. package/dist/e2e_tests/e2eUtils.js +52 -0
  8. package/dist/e2e_tests/e2eUtils.js.map +1 -0
  9. package/dist/e2e_tests/extraKeybindings.spec.js +44 -0
  10. package/dist/e2e_tests/extraKeybindings.spec.js.map +1 -0
  11. package/dist/e2e_tests/historyNavigation.spec.js +136 -0
  12. package/dist/e2e_tests/historyNavigation.spec.js.map +1 -0
  13. package/dist/e2e_tests/performanceTest.spec.d.ts +6 -0
  14. package/dist/e2e_tests/performanceTest.spec.js +96 -0
  15. package/dist/e2e_tests/performanceTest.spec.js.map +1 -0
  16. package/dist/e2e_tests/sanityChecks.spec.js +65 -0
  17. package/dist/e2e_tests/sanityChecks.spec.js.map +1 -0
  18. package/dist/e2e_tests/signatureHelp.spec.js +151 -0
  19. package/dist/e2e_tests/signatureHelp.spec.js.map +1 -0
  20. package/dist/e2e_tests/syntaxHighlighting.spec.js +91 -0
  21. package/dist/e2e_tests/syntaxHighlighting.spec.js.map +1 -0
  22. package/dist/e2e_tests/syntaxValidation.spec.js +79 -0
  23. package/dist/e2e_tests/syntaxValidation.spec.js.map +1 -0
  24. package/dist/historyNavigation.js +163 -0
  25. package/dist/historyNavigation.js.map +1 -0
  26. package/dist/{types/icons.d.ts → icons.d.ts} +1 -1
  27. package/dist/icons.js +62 -0
  28. package/dist/icons.js.map +1 -0
  29. package/dist/index.d.ts +4 -0
  30. package/dist/index.js +5 -0
  31. package/dist/index.js.map +1 -0
  32. package/dist/{types/lang-cypher → lang-cypher}/autocomplete.d.ts +1 -1
  33. package/dist/lang-cypher/autocomplete.js +56 -0
  34. package/dist/lang-cypher/autocomplete.js.map +1 -0
  35. package/dist/{types/lang-cypher → lang-cypher}/constants.d.ts +9 -0
  36. package/dist/lang-cypher/constants.js +65 -0
  37. package/dist/lang-cypher/constants.js.map +1 -0
  38. package/dist/lang-cypher/contants.test.js +102 -0
  39. package/dist/lang-cypher/contants.test.js.map +1 -0
  40. package/dist/lang-cypher/createCypherTheme.js +144 -0
  41. package/dist/lang-cypher/createCypherTheme.js.map +1 -0
  42. package/dist/{types/lang-cypher/lang-cypher.d.ts → lang-cypher/langCypher.d.ts} +3 -1
  43. package/dist/lang-cypher/langCypher.js +24 -0
  44. package/dist/lang-cypher/langCypher.js.map +1 -0
  45. package/dist/lang-cypher/lintWorker.d.ts +8 -0
  46. package/dist/lang-cypher/lintWorker.js +4 -0
  47. package/dist/lang-cypher/lintWorker.js.map +1 -0
  48. package/dist/lang-cypher/parser-adapter.d.ts +19 -0
  49. package/dist/lang-cypher/parser-adapter.js +113 -0
  50. package/dist/lang-cypher/parser-adapter.js.map +1 -0
  51. package/dist/lang-cypher/signatureHelp.d.ts +4 -0
  52. package/dist/lang-cypher/signatureHelp.js +77 -0
  53. package/dist/lang-cypher/signatureHelp.js.map +1 -0
  54. package/dist/lang-cypher/syntaxValidation.d.ts +5 -0
  55. package/dist/lang-cypher/syntaxValidation.js +71 -0
  56. package/dist/lang-cypher/syntaxValidation.js.map +1 -0
  57. package/dist/lang-cypher/themeIcons.js +22 -0
  58. package/dist/lang-cypher/themeIcons.js.map +1 -0
  59. package/dist/ndlTokensCopy.js +380 -0
  60. package/dist/ndlTokensCopy.js.map +1 -0
  61. package/dist/ndlTokensCopy.test.js +11 -0
  62. package/dist/ndlTokensCopy.test.js.map +1 -0
  63. package/dist/neo4jSetup.js +86 -0
  64. package/dist/neo4jSetup.js.map +1 -0
  65. package/dist/{types/themes.d.ts → themes.d.ts} +1 -1
  66. package/dist/themes.js +114 -0
  67. package/dist/themes.js.map +1 -0
  68. package/dist/tsconfig.tsbuildinfo +1 -0
  69. package/package.json +15 -18
  70. package/src/CypherEditor.tsx +34 -8
  71. package/src/e2e_tests/{auto-completion.spec.tsx → autoCompletion.spec.tsx} +8 -4
  72. package/src/e2e_tests/{extra-keybindings.spec.tsx → extraKeybindings.spec.tsx} +1 -1
  73. package/src/e2e_tests/{history-navigation.spec.tsx → historyNavigation.spec.tsx} +1 -1
  74. package/src/e2e_tests/performanceTest.spec.tsx +158 -0
  75. package/src/e2e_tests/{sanity-checks.spec.tsx → sanityChecks.spec.tsx} +8 -3
  76. package/src/e2e_tests/signatureHelp.spec.tsx +312 -0
  77. package/src/e2e_tests/{syntax-highlighting.spec.tsx → syntaxHighlighting.spec.tsx} +1 -1
  78. package/src/e2e_tests/{syntax-validation.spec.tsx → syntaxValidation.spec.tsx} +3 -3
  79. package/src/icons.ts +3 -0
  80. package/src/index.ts +2 -2
  81. package/src/lang-cypher/autocomplete.ts +7 -2
  82. package/src/lang-cypher/constants.ts +23 -0
  83. package/src/lang-cypher/{create-cypher-theme.ts → createCypherTheme.ts} +5 -1
  84. package/src/lang-cypher/{lang-cypher.ts → langCypher.ts} +16 -7
  85. package/src/lang-cypher/lintWorker.ts +14 -0
  86. package/src/lang-cypher/parser-adapter.ts +145 -0
  87. package/src/lang-cypher/signatureHelp.ts +102 -0
  88. package/src/lang-cypher/syntaxValidation.ts +99 -0
  89. package/src/{ndl-tokens-copy.test.ts → ndlTokensCopy.test.ts} +1 -1
  90. package/src/themes.ts +4 -2
  91. package/dist/cjs/index.cjs +0 -1441
  92. package/dist/cjs/index.cjs.map +0 -7
  93. package/dist/esm/index.mjs +0 -1464
  94. package/dist/esm/index.mjs.map +0 -7
  95. package/dist/types/e2e_tests/mock-data.d.ts +0 -3779
  96. package/dist/types/index.d.ts +0 -4
  97. package/dist/types/lang-cypher/ParserAdapter.d.ts +0 -14
  98. package/dist/types/lang-cypher/syntax-validation.d.ts +0 -3
  99. package/dist/types/tsconfig.tsbuildinfo +0 -1
  100. package/src/e2e_tests/mock-data.ts +0 -4310
  101. package/src/e2e_tests/performance-test.spec.tsx +0 -71
  102. package/src/lang-cypher/ParserAdapter.ts +0 -92
  103. package/src/lang-cypher/syntax-validation.ts +0 -24
  104. /package/dist/{types/e2e_tests/auto-completion.spec.d.ts → e2e_tests/autoCompletion.spec.d.ts} +0 -0
  105. /package/dist/{types/e2e_tests/e2e-utils.d.ts → e2e_tests/e2eUtils.d.ts} +0 -0
  106. /package/dist/{types/e2e_tests/extra-keybindings.spec.d.ts → e2e_tests/extraKeybindings.spec.d.ts} +0 -0
  107. /package/dist/{types/e2e_tests/history-navigation.spec.d.ts → e2e_tests/historyNavigation.spec.d.ts} +0 -0
  108. /package/dist/{types/e2e_tests/performance-test.spec.d.ts → e2e_tests/sanityChecks.spec.d.ts} +0 -0
  109. /package/dist/{types/e2e_tests/sanity-checks.spec.d.ts → e2e_tests/signatureHelp.spec.d.ts} +0 -0
  110. /package/dist/{types/e2e_tests/syntax-highlighting.spec.d.ts → e2e_tests/syntaxHighlighting.spec.d.ts} +0 -0
  111. /package/dist/{types/e2e_tests/syntax-validation.spec.d.ts → e2e_tests/syntaxValidation.spec.d.ts} +0 -0
  112. /package/dist/{types/history-navigation.d.ts → historyNavigation.d.ts} +0 -0
  113. /package/dist/{types/lang-cypher → lang-cypher}/contants.test.d.ts +0 -0
  114. /package/dist/{types/lang-cypher/create-cypher-theme.d.ts → lang-cypher/createCypherTheme.d.ts} +0 -0
  115. /package/dist/{types/lang-cypher/theme-icons.d.ts → lang-cypher/themeIcons.d.ts} +0 -0
  116. /package/dist/{types/ndl-tokens-copy.d.ts → ndlTokensCopy.d.ts} +0 -0
  117. /package/dist/{types/ndl-tokens-copy.test.d.ts → ndlTokensCopy.test.d.ts} +0 -0
  118. /package/dist/{types/neo4j-setup.d.ts → neo4jSetup.d.ts} +0 -0
  119. /package/src/e2e_tests/{e2e-utils.ts → e2eUtils.ts} +0 -0
  120. /package/src/{history-navigation.ts → historyNavigation.ts} +0 -0
  121. /package/src/lang-cypher/{theme-icons.ts → themeIcons.ts} +0 -0
  122. /package/src/{ndl-tokens-copy.ts → ndlTokensCopy.ts} +0 -0
  123. /package/src/{neo4j-setup.tsx → neo4jSetup.tsx} +0 -0
@@ -3,30 +3,39 @@ import {
3
3
  Language,
4
4
  LanguageSupport,
5
5
  } from '@codemirror/language';
6
- import type { DbSchema } from '@neo4j-cypher/language-support';
6
+ import {
7
+ setConsoleCommandsEnabled,
8
+ type DbSchema,
9
+ } from '@neo4j-cypher/language-support';
7
10
  import { cypherAutocomplete } from './autocomplete';
8
- import { ParserAdapter } from './ParserAdapter';
9
- import { cypherLinter } from './syntax-validation';
11
+ import { ParserAdapter } from './parser-adapter';
12
+ import { signatureHelpTooltip } from './signatureHelp';
13
+ import { cypherLinter, semanticAnalysisLinter } from './syntaxValidation';
10
14
 
11
15
  const facet = defineLanguageFacet({
12
16
  commentTokens: { block: { open: '/*', close: '*/' }, line: '//' },
13
17
  closeBrackets: { brackets: ['(', '[', '{', "'", '"', '`'] },
14
18
  });
15
19
 
16
- const parserAdapter = new ParserAdapter(facet);
17
-
18
- const cypherLanguage = new Language(facet, parserAdapter, [], 'cypher');
19
-
20
20
  export type CypherConfig = {
21
21
  lint?: boolean;
22
22
  schema?: DbSchema;
23
+ useLightVersion: boolean;
24
+ setUseLightVersion?: (useLightVersion: boolean) => void;
23
25
  };
24
26
 
25
27
  export function cypher(config: CypherConfig) {
28
+ setConsoleCommandsEnabled(true);
29
+ const parserAdapter = new ParserAdapter(facet, config);
30
+
31
+ const cypherLanguage = new Language(facet, parserAdapter, [], 'cypher');
32
+
26
33
  return new LanguageSupport(cypherLanguage, [
27
34
  cypherLanguage.data.of({
28
35
  autocomplete: cypherAutocomplete(config),
29
36
  }),
30
37
  cypherLinter(config),
38
+ semanticAnalysisLinter(config),
39
+ signatureHelpTooltip(config),
31
40
  ]);
32
41
  }
@@ -0,0 +1,14 @@
1
+ import { validateSemantics } from '@neo4j-cypher/language-support';
2
+ import workerpool from 'workerpool';
3
+
4
+ workerpool.worker({ validateSemantics });
5
+
6
+ type LinterArgs = Parameters<typeof validateSemantics>;
7
+
8
+ export type LinterTask = workerpool.Promise<
9
+ ReturnType<typeof validateSemantics>
10
+ >;
11
+
12
+ export type LintWorker = {
13
+ validateSemantics: (...args: LinterArgs) => LinterTask;
14
+ };
@@ -0,0 +1,145 @@
1
+ import { Facet } from '@codemirror/state';
2
+ import { Input, NodeType, Parser, PartialParse, Tree } from '@lezer/common';
3
+ import {
4
+ applySyntaxColouring,
5
+ ParsedCypherToken,
6
+ } from '@neo4j-cypher/language-support';
7
+
8
+ import Prism from 'prismjs';
9
+ import {
10
+ CodemirrorParseTokenType,
11
+ cypherTokenTypeToNode,
12
+ parserAdapterNodeSet,
13
+ } from './constants';
14
+ // This import will load the cypher support in prisma
15
+ import 'prismjs/components/prism-cypher';
16
+ import { CypherConfig } from './langCypher';
17
+
18
+ const DEFAULT_NODE_GROUP_SIZE = 4;
19
+ Prism.manual = true;
20
+
21
+ export class ParserAdapter extends Parser {
22
+ cypherTokenTypeToNode: Record<CodemirrorParseTokenType, NodeType>;
23
+
24
+ constructor(facet: Facet<unknown>, private config: CypherConfig) {
25
+ super();
26
+ this.cypherTokenTypeToNode = cypherTokenTypeToNode(facet);
27
+ }
28
+
29
+ createParse(input: Input): PartialParse {
30
+ return this.startParse(input);
31
+ }
32
+
33
+ /* There are more arguments, but since we don't do any incremental parsing, they are not useful */
34
+ startParse(input: string | Input): PartialParse {
35
+ const document =
36
+ typeof input === 'string' ? input : input.read(0, input.length);
37
+
38
+ const tree = this.buildTree(document);
39
+
40
+ return {
41
+ stoppedAt: input.length,
42
+ parsedPos: input.length,
43
+ stopAt: () => {
44
+ return undefined;
45
+ },
46
+ advance: () => tree,
47
+ };
48
+ }
49
+
50
+ private buildTree(document: string) {
51
+ const parse = this.config.useLightVersion
52
+ ? this.prismParse(document)
53
+ : this.antlrParse(document);
54
+
55
+ if (parse.tokens.length === 0) {
56
+ return this.createEmptyTree(document);
57
+ }
58
+
59
+ const buffer =
60
+ parse.type === 'prism'
61
+ ? this.createBufferForPrismTokens(parse.tokens)
62
+ : this.createBufferForAntlrTokens(parse.tokens);
63
+
64
+ this.addTopNodeToBuffer(buffer, document);
65
+
66
+ return Tree.build({
67
+ buffer: buffer.flat(),
68
+ nodeSet: parserAdapterNodeSet(this.cypherTokenTypeToNode),
69
+ topID: this.cypherTokenTypeToNode.topNode.id,
70
+ });
71
+ }
72
+
73
+ private antlrParse(document: string) {
74
+ const startTime = performance.now();
75
+ const tokens = applySyntaxColouring(document);
76
+ const timeTaken = performance.now() - startTime;
77
+ if (timeTaken > 300) {
78
+ this.config.setUseLightVersion?.(true);
79
+ }
80
+ return { type: 'antlr' as const, tokens };
81
+ }
82
+
83
+ private prismParse(document: string) {
84
+ if (document.length === 0) {
85
+ this.config.setUseLightVersion?.(false);
86
+ }
87
+ const tokens = Prism.tokenize(document, Prism.languages.cypher);
88
+ return {
89
+ type: 'prism' as const,
90
+ tokens,
91
+ };
92
+ }
93
+ private createBufferForAntlrTokens(tokens: ParsedCypherToken[]) {
94
+ return tokens.map((token) => {
95
+ const nodeTypeId = this.cypherTokenTypeToNode[token.tokenType].id;
96
+ const startOffset = token.position.startOffset;
97
+ const endOffset = token.position.startOffset + token.length;
98
+
99
+ return [nodeTypeId, startOffset, endOffset, DEFAULT_NODE_GROUP_SIZE];
100
+ });
101
+ }
102
+
103
+ private createBufferForPrismTokens(tokens: (string | Prism.Token)[]) {
104
+ let totalOffset = 0;
105
+ return tokens.map((token) => {
106
+ const tokenType = (
107
+ typeof token === 'string' ? 'variable' : token.type
108
+ ) as CodemirrorParseTokenType;
109
+
110
+ const nodeTypeId = this.cypherTokenTypeToNode[tokenType].id;
111
+ const startOffset = totalOffset;
112
+ const endOffset = startOffset + token.length;
113
+ totalOffset = endOffset;
114
+
115
+ return [nodeTypeId, startOffset, endOffset, DEFAULT_NODE_GROUP_SIZE];
116
+ });
117
+ }
118
+
119
+ private createEmptyTree(document: string) {
120
+ return Tree.build({
121
+ buffer: [
122
+ this.cypherTokenTypeToNode.topNode.id,
123
+ 0,
124
+ document.length,
125
+ DEFAULT_NODE_GROUP_SIZE,
126
+ ],
127
+ nodeSet: parserAdapterNodeSet(this.cypherTokenTypeToNode),
128
+ topID: this.cypherTokenTypeToNode.topNode.id,
129
+ });
130
+ }
131
+
132
+ private addTopNodeToBuffer(buffer: number[][], document: string) {
133
+ const id = this.cypherTokenTypeToNode.topNode.id;
134
+ const startOffset = 0;
135
+ const endOffset = document.length;
136
+ const totalBufferLength = buffer.length * DEFAULT_NODE_GROUP_SIZE;
137
+
138
+ buffer.push([
139
+ id,
140
+ startOffset,
141
+ endOffset,
142
+ totalBufferLength + DEFAULT_NODE_GROUP_SIZE,
143
+ ]);
144
+ }
145
+ }
@@ -0,0 +1,102 @@
1
+ import { EditorState, StateField } from '@codemirror/state';
2
+ import { showTooltip, Tooltip } from '@codemirror/view';
3
+ import { signatureHelp } from '@neo4j-cypher/language-support';
4
+ import { CypherConfig } from './langCypher';
5
+
6
+ function getTriggerCharacter(query: string, caretPosition: number) {
7
+ let i = caretPosition - 1;
8
+ let triggerCharacter = query.at(i);
9
+
10
+ // Discard all space characters. Note that a space can be more than just a ' '
11
+ while (/\s/.test(triggerCharacter) && i > 0) {
12
+ i -= 1;
13
+ triggerCharacter = query.at(i);
14
+ }
15
+
16
+ return triggerCharacter;
17
+ }
18
+
19
+ function getSignatureHelpTooltip(
20
+ state: EditorState,
21
+ config: CypherConfig,
22
+ ): Tooltip[] {
23
+ let result: Tooltip[] = [];
24
+ const schema = config.schema;
25
+ const ranges = state.selection.ranges;
26
+ const range = ranges.at(0);
27
+
28
+ if (schema && ranges.length === 1 && range.from === range.to) {
29
+ const caretPosition = range.from;
30
+ const query = state.doc.toString();
31
+
32
+ const triggerCharacter = getTriggerCharacter(query, caretPosition);
33
+
34
+ if (triggerCharacter === '(' || triggerCharacter === ',') {
35
+ const signatureHelpInfo = signatureHelp(query, schema, caretPosition);
36
+ const activeSignature = signatureHelpInfo.activeSignature;
37
+ const signatures = signatureHelpInfo.signatures;
38
+ const activeParameter = signatureHelpInfo.activeParameter;
39
+
40
+ if (
41
+ activeSignature !== undefined &&
42
+ activeSignature >= 0 &&
43
+ activeSignature < signatures.length &&
44
+ signatures[activeSignature].documentation !== undefined
45
+ ) {
46
+ const signature = signatures[activeSignature];
47
+ const parameters = signature.parameters;
48
+ let doc = signature.documentation.toString();
49
+
50
+ if (
51
+ activeParameter >= 0 &&
52
+ activeParameter <
53
+ (signatures[activeSignature].parameters?.length ?? 0)
54
+ ) {
55
+ doc =
56
+ parameters[activeParameter].documentation.toString() + '\n\n' + doc;
57
+ }
58
+
59
+ result = [
60
+ {
61
+ pos: caretPosition,
62
+ above: true,
63
+ strictSide: true,
64
+ arrow: true,
65
+ create: () => {
66
+ const div = document.createElement('div');
67
+ const methodName = document.createElement('div');
68
+ const argPlusDescription = document.createElement('div');
69
+ const separator = document.createElement('hr');
70
+ const lineBreak = document.createElement('br');
71
+
72
+ div.append(
73
+ ...[methodName, separator, lineBreak, argPlusDescription],
74
+ );
75
+ div.className = 'cm-tooltip-signature-help';
76
+
77
+ methodName.innerText = signature.label;
78
+ argPlusDescription.innerText = doc;
79
+
80
+ return { dom: div };
81
+ },
82
+ },
83
+ ];
84
+ }
85
+ }
86
+ }
87
+
88
+ return result;
89
+ }
90
+
91
+ export function signatureHelpTooltip(config: CypherConfig) {
92
+ return StateField.define<readonly Tooltip[]>({
93
+ create: (state) => getSignatureHelpTooltip(state, config),
94
+
95
+ update(tooltips, tr) {
96
+ if (!tr.docChanged && !tr.selection) return tooltips;
97
+ return getSignatureHelpTooltip(tr.state, config);
98
+ },
99
+
100
+ provide: (f) => showTooltip.computeN([f], (state) => state.field(f)),
101
+ });
102
+ }
@@ -0,0 +1,99 @@
1
+ import { Diagnostic, linter } from '@codemirror/lint';
2
+ import { Extension } from '@codemirror/state';
3
+ import { parserWrapper, validateSyntax } from '@neo4j-cypher/language-support';
4
+ import { DiagnosticSeverity } from 'vscode-languageserver-types';
5
+ import workerpool from 'workerpool';
6
+ import type { CypherConfig } from './langCypher';
7
+ import type { LinterTask, LintWorker } from './lintWorker';
8
+
9
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
10
+ // @ts-ignore ignore: https://v3.vitejs.dev/guide/features.html#import-with-query-suffixes
11
+ import WorkerURL from './lintWorker?url&worker';
12
+
13
+ const pool = workerpool.pool(WorkerURL as string, {
14
+ minWorkers: 2,
15
+ workerOpts: { type: 'module' },
16
+ workerTerminateTimeout: 2000,
17
+ });
18
+
19
+ let lastSemanticJob: LinterTask | undefined;
20
+
21
+ export const cypherLinter: (config: CypherConfig) => Extension = (config) =>
22
+ linter((view) => {
23
+ if (!config.lint) {
24
+ return [];
25
+ }
26
+
27
+ const query = view.state.doc.toString();
28
+ const syntaxErrors = validateSyntax(query, config.schema ?? {});
29
+
30
+ return syntaxErrors.map(
31
+ (diagnostic): Diagnostic => ({
32
+ from: diagnostic.offsets.start,
33
+ to: diagnostic.offsets.end,
34
+ severity:
35
+ diagnostic.severity === DiagnosticSeverity.Error
36
+ ? 'error'
37
+ : 'warning',
38
+ message: diagnostic.message,
39
+ }),
40
+ );
41
+ });
42
+
43
+ export const semanticAnalysisLinter: (config: CypherConfig) => Extension = (
44
+ config,
45
+ ) =>
46
+ linter(async (view) => {
47
+ if (!config.lint) {
48
+ return [];
49
+ }
50
+
51
+ const query = view.state.doc.toString();
52
+ if (query.length === 0) {
53
+ return [];
54
+ }
55
+
56
+ // we want to avoid the ANTLR4 reparse in the worker thread, this should hit our main thread cache
57
+ const parse = parserWrapper.parse(query);
58
+ const statements = parse.statementsParsing;
59
+
60
+ const anySyntacticError =
61
+ statements.filter((statement) => statement.diagnostics.length !== 0)
62
+ .length > 0;
63
+
64
+ if (anySyntacticError) {
65
+ return [];
66
+ }
67
+
68
+ try {
69
+ if (lastSemanticJob !== undefined && !lastSemanticJob.resolved) {
70
+ void lastSemanticJob.cancel();
71
+ }
72
+
73
+ const proxyWorker = (await pool.proxy()) as unknown as LintWorker;
74
+ lastSemanticJob = proxyWorker.validateSemantics(
75
+ query,
76
+ config.schema ?? {},
77
+ );
78
+ const result = await lastSemanticJob;
79
+
80
+ return result.map((diag) => {
81
+ return {
82
+ from: diag.offsets.start,
83
+ to: diag.offsets.end,
84
+ severity:
85
+ diag.severity === DiagnosticSeverity.Error ? 'error' : 'warning',
86
+ message: diag.message,
87
+ };
88
+ });
89
+ } catch (err) {
90
+ if (!(err instanceof workerpool.Promise.CancellationError)) {
91
+ console.error(String(err) + ' ' + query);
92
+ }
93
+ }
94
+ return [];
95
+ });
96
+
97
+ export const cleanupWorkers = () => {
98
+ void pool.terminate();
99
+ };
@@ -1,5 +1,5 @@
1
1
  import { tokens } from '@neo4j-ndl/base';
2
- import { tokens as tokensCopy } from './ndl-tokens-copy';
2
+ import { tokens as tokensCopy } from './ndlTokensCopy';
3
3
 
4
4
  /*
5
5
  * Needle has some odd package configuration that made playwright stop working
package/src/themes.ts CHANGED
@@ -3,8 +3,8 @@ import { light, mirage } from 'ayu';
3
3
  import {
4
4
  createCypherTheme,
5
5
  ThemeOptions,
6
- } from './lang-cypher/create-cypher-theme';
7
- import { tokens } from './ndl-tokens-copy';
6
+ } from './lang-cypher/createCypherTheme';
7
+ import { tokens } from './ndlTokensCopy';
8
8
 
9
9
  /* ndl exports most tokens as hex colors but some tokens are exported as rgb colors, in the form of "10, 20, 30"
10
10
  This should be fixed in version 2 of ndl.
@@ -60,6 +60,7 @@ export const lightThemeConstants: ThemeOptions = {
60
60
  paramDollar: light.syntax.regexp.hex(),
61
61
  paramValue: light.syntax.regexp.hex(),
62
62
  namespace: light.syntax.special.hex(),
63
+ consoleCommand: light.editor.fg.hex(),
63
64
  },
64
65
  };
65
66
 
@@ -101,6 +102,7 @@ export const darkThemeConstants: ThemeOptions = {
101
102
  paramDollar: mirage.syntax.regexp.hex(),
102
103
  paramValue: mirage.syntax.regexp.hex(),
103
104
  namespace: mirage.syntax.special.hex(),
105
+ consoleCommand: mirage.editor.fg.hex(),
104
106
  },
105
107
  };
106
108