@neo4j-cypher/react-codemirror 2.0.0-next.2 → 2.0.0-next.20

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 (155) hide show
  1. package/CHANGELOG.md +166 -0
  2. package/dist/{types/CypherEditor.d.ts → CypherEditor.d.ts} +82 -3
  3. package/dist/CypherEditor.js +326 -0
  4. package/dist/CypherEditor.js.map +1 -0
  5. package/dist/CypherEditor.test.js +151 -0
  6. package/dist/CypherEditor.test.js.map +1 -0
  7. package/dist/constants.d.ts +1 -0
  8. package/dist/constants.js +2 -0
  9. package/dist/constants.js.map +1 -0
  10. package/dist/e2e_tests/autoCompletion.spec.js +318 -0
  11. package/dist/e2e_tests/autoCompletion.spec.js.map +1 -0
  12. package/dist/e2e_tests/configuration.spec.js +83 -0
  13. package/dist/e2e_tests/configuration.spec.js.map +1 -0
  14. package/dist/e2e_tests/debounce.spec.js +66 -0
  15. package/dist/e2e_tests/debounce.spec.js.map +1 -0
  16. package/dist/{types/e2e_tests/e2e-utils.d.ts → e2e_tests/e2eUtils.d.ts} +1 -0
  17. package/dist/e2e_tests/e2eUtils.js +71 -0
  18. package/dist/e2e_tests/e2eUtils.js.map +1 -0
  19. package/dist/e2e_tests/extraKeybindings.spec.js +43 -0
  20. package/dist/e2e_tests/extraKeybindings.spec.js.map +1 -0
  21. package/dist/e2e_tests/historyNavigation.spec.js +227 -0
  22. package/dist/e2e_tests/historyNavigation.spec.js.map +1 -0
  23. package/dist/e2e_tests/performanceTest.spec.d.ts +6 -0
  24. package/dist/e2e_tests/performanceTest.spec.js +97 -0
  25. package/dist/e2e_tests/performanceTest.spec.js.map +1 -0
  26. package/dist/e2e_tests/sanityChecks.spec.js +53 -0
  27. package/dist/e2e_tests/sanityChecks.spec.js.map +1 -0
  28. package/dist/e2e_tests/signatureHelp.spec.js +228 -0
  29. package/dist/e2e_tests/signatureHelp.spec.js.map +1 -0
  30. package/dist/e2e_tests/snippets.spec.js +62 -0
  31. package/dist/e2e_tests/snippets.spec.js.map +1 -0
  32. package/dist/e2e_tests/syntaxHighlighting.spec.d.ts +1 -0
  33. package/dist/e2e_tests/syntaxHighlighting.spec.js +90 -0
  34. package/dist/e2e_tests/syntaxHighlighting.spec.js.map +1 -0
  35. package/dist/e2e_tests/syntaxValidation.spec.d.ts +1 -0
  36. package/dist/e2e_tests/syntaxValidation.spec.js +116 -0
  37. package/dist/e2e_tests/syntaxValidation.spec.js.map +1 -0
  38. package/dist/historyNavigation.js +163 -0
  39. package/dist/historyNavigation.js.map +1 -0
  40. package/dist/{types/icons.d.ts → icons.d.ts} +1 -1
  41. package/dist/icons.js +62 -0
  42. package/dist/icons.js.map +1 -0
  43. package/dist/index.d.ts +4 -0
  44. package/dist/index.js +5 -0
  45. package/dist/index.js.map +1 -0
  46. package/dist/lang-cypher/autocomplete.d.ts +6 -0
  47. package/dist/lang-cypher/autocomplete.js +115 -0
  48. package/dist/lang-cypher/autocomplete.js.map +1 -0
  49. package/dist/{types/lang-cypher → lang-cypher}/constants.d.ts +11 -0
  50. package/dist/lang-cypher/constants.js +69 -0
  51. package/dist/lang-cypher/constants.js.map +1 -0
  52. package/dist/lang-cypher/contants.test.d.ts +1 -0
  53. package/dist/lang-cypher/contants.test.js +103 -0
  54. package/dist/lang-cypher/contants.test.js.map +1 -0
  55. package/dist/lang-cypher/createCypherTheme.js +182 -0
  56. package/dist/lang-cypher/createCypherTheme.js.map +1 -0
  57. package/dist/lang-cypher/langCypher.d.ts +14 -0
  58. package/dist/lang-cypher/langCypher.js +23 -0
  59. package/dist/lang-cypher/langCypher.js.map +1 -0
  60. package/dist/lang-cypher/lintWorker.d.ts +12 -0
  61. package/dist/lang-cypher/lintWorker.js +14 -0
  62. package/dist/lang-cypher/lintWorker.js.map +1 -0
  63. package/dist/lang-cypher/parser-adapter.d.ts +19 -0
  64. package/dist/lang-cypher/parser-adapter.js +113 -0
  65. package/dist/lang-cypher/parser-adapter.js.map +1 -0
  66. package/dist/lang-cypher/signatureHelp.d.ts +4 -0
  67. package/dist/lang-cypher/signatureHelp.js +109 -0
  68. package/dist/lang-cypher/signatureHelp.js.map +1 -0
  69. package/dist/{types/lang-cypher/syntax-validation.d.ts → lang-cypher/syntaxValidation.d.ts} +2 -1
  70. package/dist/lang-cypher/syntaxValidation.js +52 -0
  71. package/dist/lang-cypher/syntaxValidation.js.map +1 -0
  72. package/dist/lang-cypher/themeIcons.js +22 -0
  73. package/dist/lang-cypher/themeIcons.js.map +1 -0
  74. package/dist/lang-cypher/utils.d.ts +2 -0
  75. package/dist/lang-cypher/utils.js +10 -0
  76. package/dist/lang-cypher/utils.js.map +1 -0
  77. package/dist/ndlTokensCopy.d.ts +570 -0
  78. package/dist/ndlTokensCopy.js +571 -0
  79. package/dist/ndlTokensCopy.js.map +1 -0
  80. package/dist/ndlTokensCopy.test.d.ts +1 -0
  81. package/dist/ndlTokensCopy.test.js +12 -0
  82. package/dist/ndlTokensCopy.test.js.map +1 -0
  83. package/dist/neo4jSetup.d.ts +6 -0
  84. package/dist/neo4jSetup.js +120 -0
  85. package/dist/neo4jSetup.js.map +1 -0
  86. package/dist/{types/themes.d.ts → themes.d.ts} +1 -1
  87. package/dist/themes.js +93 -0
  88. package/dist/themes.js.map +1 -0
  89. package/dist/tsconfig.tsbuildinfo +1 -0
  90. package/package.json +32 -34
  91. package/src/CypherEditor.test.tsx +200 -0
  92. package/src/CypherEditor.tsx +311 -41
  93. package/src/constants.ts +1 -0
  94. package/src/e2e_tests/autoCompletion.spec.tsx +546 -0
  95. package/src/e2e_tests/configuration.spec.tsx +111 -0
  96. package/src/e2e_tests/debounce.spec.tsx +106 -0
  97. package/src/e2e_tests/{e2e-utils.ts → e2eUtils.ts} +24 -2
  98. package/src/e2e_tests/{extra-keybindings.spec.tsx → extraKeybindings.spec.tsx} +1 -3
  99. package/src/e2e_tests/{history-navigation.spec.tsx → historyNavigation.spec.tsx} +137 -18
  100. package/src/e2e_tests/performanceTest.spec.tsx +163 -0
  101. package/src/e2e_tests/{sanity-checks.spec.tsx → sanityChecks.spec.tsx} +7 -22
  102. package/src/e2e_tests/signatureHelp.spec.tsx +445 -0
  103. package/src/e2e_tests/snippets.spec.tsx +92 -0
  104. package/src/e2e_tests/{syntax-highlighting.spec.tsx → syntaxHighlighting.spec.tsx} +26 -24
  105. package/src/e2e_tests/{syntax-validation.spec.tsx → syntaxValidation.spec.tsx} +97 -10
  106. package/src/{history-navigation.ts → historyNavigation.ts} +1 -1
  107. package/src/icons.ts +3 -0
  108. package/src/index.ts +2 -2
  109. package/src/lang-cypher/autocomplete.ts +100 -18
  110. package/src/lang-cypher/constants.ts +27 -0
  111. package/src/lang-cypher/contants.test.ts +6 -2
  112. package/src/lang-cypher/{create-cypher-theme.ts → createCypherTheme.ts} +44 -2
  113. package/src/lang-cypher/langCypher.ts +43 -0
  114. package/src/lang-cypher/lintWorker.ts +31 -0
  115. package/src/lang-cypher/parser-adapter.ts +145 -0
  116. package/src/lang-cypher/signatureHelp.ts +151 -0
  117. package/src/lang-cypher/syntaxValidation.ts +66 -0
  118. package/src/lang-cypher/utils.ts +9 -0
  119. package/src/{ndl-tokens-copy.test.ts → ndlTokensCopy.test.ts} +2 -1
  120. package/src/ndlTokensCopy.ts +570 -0
  121. package/src/{neo4j-setup.tsx → neo4jSetup.tsx} +78 -17
  122. package/src/themes.ts +45 -70
  123. package/src/viteEnv.d.ts +1 -0
  124. package/dist/cjs/index.cjs +0 -1440
  125. package/dist/cjs/index.cjs.map +0 -7
  126. package/dist/esm/index.mjs +0 -1463
  127. package/dist/esm/index.mjs.map +0 -7
  128. package/dist/types/e2e_tests/mock-data.d.ts +0 -3779
  129. package/dist/types/index.d.ts +0 -4
  130. package/dist/types/lang-cypher/ParserAdapter.d.ts +0 -14
  131. package/dist/types/lang-cypher/autocomplete.d.ts +0 -3
  132. package/dist/types/lang-cypher/lang-cypher.d.ts +0 -7
  133. package/dist/types/ndl-tokens-copy.d.ts +0 -379
  134. package/dist/types/neo4j-setup.d.ts +0 -2
  135. package/dist/types/tsconfig.tsbuildinfo +0 -1
  136. package/src/e2e_tests/auto-completion.spec.tsx +0 -232
  137. package/src/e2e_tests/mock-data.ts +0 -4310
  138. package/src/e2e_tests/performance-test.spec.tsx +0 -71
  139. package/src/lang-cypher/ParserAdapter.ts +0 -92
  140. package/src/lang-cypher/lang-cypher.ts +0 -32
  141. package/src/lang-cypher/syntax-validation.ts +0 -24
  142. package/src/ndl-tokens-copy.ts +0 -379
  143. /package/dist/{types/e2e_tests/auto-completion.spec.d.ts → CypherEditor.test.d.ts} +0 -0
  144. /package/dist/{types/e2e_tests/extra-keybindings.spec.d.ts → e2e_tests/autoCompletion.spec.d.ts} +0 -0
  145. /package/dist/{types/e2e_tests/history-navigation.spec.d.ts → e2e_tests/configuration.spec.d.ts} +0 -0
  146. /package/dist/{types/e2e_tests/performance-test.spec.d.ts → e2e_tests/debounce.spec.d.ts} +0 -0
  147. /package/dist/{types/e2e_tests/sanity-checks.spec.d.ts → e2e_tests/extraKeybindings.spec.d.ts} +0 -0
  148. /package/dist/{types/e2e_tests/syntax-highlighting.spec.d.ts → e2e_tests/historyNavigation.spec.d.ts} +0 -0
  149. /package/dist/{types/e2e_tests/syntax-validation.spec.d.ts → e2e_tests/sanityChecks.spec.d.ts} +0 -0
  150. /package/dist/{types/lang-cypher/contants.test.d.ts → e2e_tests/signatureHelp.spec.d.ts} +0 -0
  151. /package/dist/{types/ndl-tokens-copy.test.d.ts → e2e_tests/snippets.spec.d.ts} +0 -0
  152. /package/dist/{types/history-navigation.d.ts → historyNavigation.d.ts} +0 -0
  153. /package/dist/{types/lang-cypher/create-cypher-theme.d.ts → lang-cypher/createCypherTheme.d.ts} +0 -0
  154. /package/dist/{types/lang-cypher/theme-icons.d.ts → lang-cypher/themeIcons.d.ts} +0 -0
  155. /package/src/lang-cypher/{theme-icons.ts → themeIcons.ts} +0 -0
@@ -1,6 +1,7 @@
1
+ import { testData } from '@neo4j-cypher/language-support';
1
2
  import { expect, test } from '@playwright/experimental-ct-react';
2
3
  import { CypherEditor } from '../CypherEditor';
3
- import { CypherEditorPage } from './e2e-utils';
4
+ import { CypherEditorPage } from './e2eUtils';
4
5
 
5
6
  test.use({ viewport: { width: 1000, height: 500 } });
6
7
  test('Prop lint set to false disables syntax validation', async ({
@@ -12,27 +13,27 @@ test('Prop lint set to false disables syntax validation', async ({
12
13
  await mount(<CypherEditor value={query} lint={false} />);
13
14
 
14
15
  await expect(page.locator('.cm-lintRange-error').last()).not.toBeVisible({
15
- timeout: 2000,
16
+ timeout: 10000,
16
17
  });
17
18
  });
18
19
 
19
- test.skip('Can turn linting back on', async ({ page, mount }) => {
20
+ test('Can turn linting back on', async ({ page, mount }) => {
20
21
  const editorPage = new CypherEditorPage(page);
21
22
  const query = 'METCH (n) RETURN n';
22
23
 
23
24
  const component = await mount(<CypherEditor value={query} lint={false} />);
24
25
 
25
26
  await expect(page.locator('.cm-lintRange-error').last()).not.toBeVisible({
26
- timeout: 2000,
27
+ timeout: 10000,
27
28
  });
28
29
 
29
- await component.update(<CypherEditor value={query} lint />);
30
+ await component.update(<CypherEditor value={query} lint={true} />);
30
31
 
31
32
  await editorPage.getEditor().fill('METCH (n) RETURN n');
32
33
 
33
34
  await editorPage.checkErrorMessage(
34
35
  'METCH',
35
- 'Unrecognized keyword. Did you mean MATCH?',
36
+ `Invalid input 'METCH': expected 'FOREACH', 'ALTER', 'ORDER BY', 'CALL', 'USING PERIODIC COMMIT', 'CREATE', 'LOAD CSV', 'START DATABASE', 'STOP DATABASE', 'DEALLOCATE', 'DELETE', 'DENY', 'DETACH', 'DROP', 'DRYRUN', 'FINISH', 'GRANT', 'INSERT', 'LIMIT', 'MATCH', 'MERGE', 'NODETACH', 'OFFSET', 'OPTIONAL', 'REALLOCATE', 'REMOVE', 'RENAME', 'RETURN', 'REVOKE', 'ENABLE SERVER', 'SET', 'SHOW', 'SKIP', 'TERMINATE', 'UNWIND', 'USE' or 'WITH'`,
36
37
  );
37
38
  });
38
39
 
@@ -44,10 +45,22 @@ test('Syntactic errors are surfaced', async ({ page, mount }) => {
44
45
 
45
46
  await editorPage.checkErrorMessage(
46
47
  'METCH',
47
- 'Unrecognized keyword. Did you mean MATCH?',
48
+ `Invalid input 'METCH': expected 'FOREACH', 'ALTER', 'ORDER BY', 'CALL', 'USING PERIODIC COMMIT', 'CREATE', 'LOAD CSV', 'START DATABASE', 'STOP DATABASE', 'DEALLOCATE', 'DELETE', 'DENY', 'DETACH', 'DROP', 'DRYRUN', 'FINISH', 'GRANT', 'INSERT', 'LIMIT', 'MATCH', 'MERGE', 'NODETACH', 'OFFSET', 'OPTIONAL', 'REALLOCATE', 'REMOVE', 'RENAME', 'RETURN', 'REVOKE', 'ENABLE SERVER', 'SET', 'SHOW', 'SKIP', 'TERMINATE', 'UNWIND', 'USE' or 'WITH'`,
48
49
  );
49
50
  });
50
51
 
52
+ test('Does not trigger syntax errors for backticked parameters in parameter creation', async ({
53
+ page,
54
+ mount,
55
+ }) => {
56
+ const editorPage = new CypherEditorPage(page);
57
+
58
+ const query = ':param x => "abc"';
59
+ await mount(<CypherEditor value={query} />);
60
+
61
+ await editorPage.checkNoNotificationMessage('error');
62
+ });
63
+
51
64
  test('Errors for undefined labels are surfaced', async ({ page, mount }) => {
52
65
  const editorPage = new CypherEditorPage(page);
53
66
  const query = 'MATCH (n: Person) RETURN n';
@@ -86,6 +99,20 @@ test('Errors for multiline undefined labels are highlighted correctly', async ({
86
99
  await editorPage.checkWarningMessage('Bar`', expectedMsg);
87
100
  });
88
101
 
102
+ test('Semantic errors work in firefox', async ({
103
+ browserName,
104
+ page,
105
+ mount,
106
+ }) => {
107
+ test.skip(browserName !== 'firefox');
108
+ const editorPage = new CypherEditorPage(page);
109
+ const query = 'MATCH (n:OperationalPoint)--(m:OperationalPoint) RETURN s,m,n';
110
+
111
+ await mount(<CypherEditor value={query} schema={testData.mockSchema} />);
112
+
113
+ await editorPage.checkErrorMessage('s,m,n', 'Variable `s` not defined');
114
+ });
115
+
89
116
  test('Semantic errors are surfaced when there are no syntactic errors', async ({
90
117
  page,
91
118
  mount,
@@ -106,7 +133,7 @@ test('Semantic errors are correctly accumulated', async ({ page, mount }) => {
106
133
 
107
134
  await editorPage.checkErrorMessage(
108
135
  'MATCH (n)',
109
- 'Query cannot conclude with MATCH (must be a RETURN clause, an update clause, a unit subquery call, or a procedure call with no YIELD)',
136
+ 'Query cannot conclude with MATCH (must be a RETURN clause, a FINISH clause, an update clause, a unit subquery call, or a procedure call with no YIELD).',
110
137
  );
111
138
 
112
139
  await editorPage.checkErrorMessage(
@@ -126,7 +153,7 @@ test('Multiline errors are correctly placed', async ({ page, mount }) => {
126
153
 
127
154
  await editorPage.checkErrorMessage(
128
155
  'MATCH (n)',
129
- 'Query cannot conclude with MATCH (must be a RETURN clause, an update clause, a unit subquery call, or a procedure call with no YIELD)',
156
+ 'Query cannot conclude with MATCH (must be a RETURN clause, a FINISH clause, an update clause, a unit subquery call, or a procedure call with no YIELD)',
130
157
  );
131
158
 
132
159
  await editorPage.checkErrorMessage(
@@ -146,7 +173,7 @@ test('Validation errors are correctly overlapped', async ({ page, mount }) => {
146
173
 
147
174
  await editorPage.checkErrorMessage(
148
175
  '-1',
149
- 'Query cannot conclude with CALL (must be a RETURN clause, an update clause, a unit subquery call, or a procedure call with no YIELD)',
176
+ 'Query cannot conclude with CALL (must be a RETURN clause, a FINISH clause, an update clause, a unit subquery call, or a procedure call with no YIELD).',
150
177
  );
151
178
 
152
179
  await editorPage.checkErrorMessage(
@@ -154,3 +181,63 @@ test('Validation errors are correctly overlapped', async ({ page, mount }) => {
154
181
  "Invalid input. '-1' is not a valid value. Must be a positive integer",
155
182
  );
156
183
  });
184
+
185
+ test('Strikethroughs are shown for deprecated functions', async ({
186
+ page,
187
+ mount,
188
+ }) => {
189
+ const editorPage = new CypherEditorPage(page);
190
+ const query = `RETURN id()`;
191
+
192
+ await mount(<CypherEditor value={query} schema={testData.mockSchema} />);
193
+ await expect(
194
+ editorPage.page.locator('.cm-deprecated-element').last(),
195
+ ).toBeVisible({ timeout: 10000 });
196
+ await editorPage.checkWarningMessage('id', 'Function id is deprecated.');
197
+ });
198
+
199
+ test('Strikethroughs are shown for deprecated procedures', async ({
200
+ page,
201
+ mount,
202
+ }) => {
203
+ const editorPage = new CypherEditorPage(page);
204
+ const query = `CALL apoc.create.uuids()`;
205
+
206
+ await mount(<CypherEditor value={query} schema={testData.mockSchema} />);
207
+ await expect(
208
+ editorPage.page.locator('.cm-deprecated-element').last(),
209
+ ).toBeVisible({ timeout: 10000 });
210
+
211
+ await editorPage.checkWarningMessage(
212
+ 'apoc.create.uuids',
213
+ 'Procedure apoc.create.uuids is deprecated.',
214
+ );
215
+ });
216
+
217
+ test('Syntax validation depends on the Cypher version', async ({
218
+ page,
219
+ mount,
220
+ }) => {
221
+ await mount(
222
+ <CypherEditor
223
+ schema={testData.mockSchema}
224
+ featureFlags={{ cypher25: true }}
225
+ />,
226
+ );
227
+
228
+ const editorPage = new CypherEditorPage(page);
229
+ const textField = page.getByRole('textbox');
230
+ await textField.fill('CYPHER 5 CALL apoc.create.uuids(5)');
231
+
232
+ await editorPage.checkWarningMessage(
233
+ 'apoc.create.uuids',
234
+ 'Procedure apoc.create.uuids is deprecated.',
235
+ );
236
+
237
+ await textField.fill('CYPHER 25 CALL apoc.create.uuids(5)');
238
+
239
+ await editorPage.checkErrorMessage(
240
+ 'apoc.create.uuids',
241
+ 'Procedure apoc.create.uuids is not present in the database.',
242
+ );
243
+ });
@@ -97,7 +97,7 @@ function navigateHistory(view: EditorView, direction: HistoryNavigation) {
97
97
  view.dispatch(
98
98
  view.state.update({
99
99
  effects: moveInHistory.of(direction),
100
- selection: { anchor: view.state.doc.length },
100
+ selection: { anchor: direction === 'BACK' ? 0 : view.state.doc.length },
101
101
  }),
102
102
  );
103
103
 
package/src/icons.ts CHANGED
@@ -23,6 +23,7 @@ export type CompletionItemIcons =
23
23
  | 'Struct'
24
24
  | 'Event'
25
25
  | 'Operator'
26
+ | 'Console'
26
27
  | 'TypeParameter';
27
28
 
28
29
  export function getIconForType(iconTypeString = 'Text', isDarkTheme = false) {
@@ -51,6 +52,7 @@ export function getIconForType(iconTypeString = 'Text', isDarkTheme = false) {
51
52
  Struct: `<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"> <path fill-rule="evenodd" clip-rule="evenodd" d="M2.00024 2L1.00024 3V6L2.00024 7H14.0002L15.0002 6V3L14.0002 2H2.00024ZM2.00024 3H3.00024H13.0002H14.0002V4V5V6H13.0002H3.00024H2.00024V5V4V3ZM1.00024 10L2.00024 9H5.00024L6.00024 10V13L5.00024 14H2.00024L1.00024 13V10ZM3.00024 10H2.00024V11V12V13H3.00024H4.00024H5.00024V12V11V10H4.00024H3.00024ZM10.0002 10L11.0002 9H14.0002L15.0002 10V13L14.0002 14H11.0002L10.0002 13V10ZM12.0002 10H11.0002V11V12V13H12.0002H13.0002H14.0002V12V11V10H13.0002H12.0002Z" fill="#424242"/> </svg>`,
52
53
  Event: `<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"> <path fill-rule="evenodd" clip-rule="evenodd" d="M7.41379 1.55996L8.31177 1H11.6059L12.4243 2.57465L10.2358 6H12.0176L12.7365 7.69512L5.61967 15L4.01699 13.837L6.11967 10H4.89822L4.00024 8.55996L7.41379 1.55996ZM7.78058 9L4.90078 14.3049L12.0176 7H8.31177L11.6059 2H8.31177L4.89822 9H7.78058Z" fill="#D67E00"/> </svg>`,
53
54
  Operator: `<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"> <path fill-rule="evenodd" clip-rule="evenodd" d="M2.87313 1.10023C3.20793 1.23579 3.4757 1.498 3.61826 1.82988C3.69056 1.99959 3.72699 2.18242 3.72526 2.36688C3.72642 2.54999 3.69 2.7314 3.61826 2.89988C3.51324 3.14567 3.33807 3.35503 3.11466 3.50177C2.89126 3.64851 2.62955 3.72612 2.36226 3.72488C2.17948 3.72592 1.99842 3.68951 1.83026 3.61788C1.58322 3.51406 1.37252 3.33932 1.22478 3.11575C1.07704 2.89219 0.99891 2.62984 1.00026 2.36188C0.999374 2.17921 1.03543 1.99825 1.10626 1.82988C1.24362 1.50314 1.50353 1.24323 1.83026 1.10588C2.16357 0.966692 2.53834 0.964661 2.87313 1.10023ZM2.57526 2.86488C2.70564 2.80913 2.80951 2.70526 2.86526 2.57488C2.89314 2.50838 2.90742 2.43698 2.90726 2.36488C2.90838 2.2654 2.88239 2.1675 2.8321 2.08167C2.7818 1.99584 2.70909 1.92531 2.62176 1.87767C2.53443 1.83002 2.43577 1.80705 2.33638 1.81121C2.23698 1.81537 2.1406 1.8465 2.05755 1.90128C1.97451 1.95606 1.90794 2.03241 1.865 2.12215C1.82205 2.21188 1.80434 2.31161 1.81376 2.41065C1.82319 2.50968 1.85939 2.60428 1.9185 2.6843C1.9776 2.76433 2.05738 2.82675 2.14926 2.86488C2.28574 2.92089 2.43878 2.92089 2.57526 2.86488ZM6.43019 1.1095L1.10992 6.42977L1.79581 7.11567L7.11608 1.7954L6.43019 1.1095ZM11.5002 8.99999H12.5002V11.5H15.0002V12.5H12.5002V15H11.5002V12.5H9.00024V11.5H11.5002V8.99999ZM5.76801 9.52509L6.47512 10.2322L4.70735 12L6.47512 13.7677L5.76801 14.4748L4.00024 12.7071L2.23248 14.4748L1.52537 13.7677L3.29314 12L1.52537 10.2322L2.23248 9.52509L4.00024 11.2929L5.76801 9.52509ZM7.11826 5.32988C7.01466 5.08268 6.83997 4.87183 6.61636 4.72406C6.39275 4.57629 6.13028 4.49826 5.86226 4.49988C5.6796 4.49899 5.49864 4.53505 5.33026 4.60588C5.00353 4.74323 4.74362 5.00314 4.60626 5.32988C4.53612 5.49478 4.49922 5.67191 4.49766 5.8511C4.4961 6.0303 4.52992 6.20804 4.59718 6.37414C4.66443 6.54024 4.76381 6.69143 4.88961 6.81906C5.0154 6.94669 5.16515 7.04823 5.33026 7.11788C5.49892 7.18848 5.67993 7.22484 5.86276 7.22484C6.0456 7.22484 6.22661 7.18848 6.39526 7.11788C6.64225 7.01388 6.85295 6.83913 7.00082 6.61563C7.1487 6.39213 7.22713 6.12987 7.22626 5.86188C7.22679 5.67905 7.19005 5.49803 7.11826 5.32988ZM6.36526 6.07488C6.3379 6.13937 6.29854 6.19808 6.24926 6.24788C6.19932 6.29724 6.14066 6.33691 6.07626 6.36488C6.00878 6.39297 5.93635 6.40725 5.86326 6.40688C5.79015 6.40744 5.71769 6.39315 5.65026 6.36488C5.58565 6.33729 5.52693 6.29757 5.47726 6.24788C5.42715 6.19856 5.38738 6.13975 5.36026 6.07488C5.30425 5.9384 5.30425 5.78536 5.36026 5.64888C5.41561 5.51846 5.51965 5.41477 5.65026 5.35988C5.71761 5.33126 5.79008 5.31663 5.86326 5.31688C5.93642 5.31685 6.00884 5.33147 6.07626 5.35988C6.14062 5.38749 6.19928 5.42682 6.24926 5.47588C6.2981 5.52603 6.33741 5.58465 6.36526 5.64888C6.39364 5.7163 6.40827 5.78872 6.40827 5.86188C6.40827 5.93503 6.39364 6.00745 6.36526 6.07488ZM14.0002 3H10.0002V4H14.0002V3Z" fill="#424242"/> </svg>`,
55
+ Console: `<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"> <path fill-rule="evenodd" clip-rule="evenodd" d="M1.00024 1H15.0002V15H1.00024V1ZM2.00024 14H14.0002V2H2.00024V14ZM4.00032 5.70709L4.70743 4.99999L8.24296 8.53552L7.53585 9.24263L7.53583 9.2426L4.70735 12.0711L4.00024 11.364L6.82872 8.53549L4.00032 5.70709Z" fill="#424242"/> </svg>`,
54
56
  TypeParameter: `<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"> <path fill-rule="evenodd" clip-rule="evenodd" d="M11.0003 6H10.0003V5.5C10.0003 5.22386 9.7764 5 9.50026 5H8.47926V10.5C8.47926 10.7761 8.70312 11 8.97926 11H9.47926V12H6.47926V11H6.97926C7.2554 11 7.47926 10.7761 7.47926 10.5V5H6.50026C6.22412 5 6.00026 5.22386 6.00026 5.5V6H5.00026V4H11.0003V6ZM13.9145 8.0481L12.4522 6.58581L13.1593 5.87871L14.9751 7.69454V8.40165L13.2074 10.1694L12.5003 9.46231L13.9145 8.0481ZM3.54835 9.4623L2.08605 8.00002L3.50026 6.58581L2.79316 5.8787L1.02539 7.64647V8.35357L2.84124 10.1694L3.54835 9.4623Z" fill="#424242"/> </svg>`,
55
57
  };
56
58
 
@@ -79,6 +81,7 @@ export function getIconForType(iconTypeString = 'Text', isDarkTheme = false) {
79
81
  Struct: `<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"> <path fill-rule="evenodd" clip-rule="evenodd" d="M2 2L1 3V6L2 7H14L15 6V3L14 2H2ZM2 3H3H13H14V4V5V6H13H3H2V5V4V3ZM1 10L2 9H5L6 10V13L5 14H2L1 13V10ZM3 10H2V11V12V13H3H4H5V12V11V10H4H3ZM10 10L11 9H14L15 10V13L14 14H11L10 13V10ZM12 10H11V11V12V13H12H13H14V12V11V10H13H12Z" fill="#C5C5C5"/> </svg>`,
80
82
  Event: `<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"> <path fill-rule="evenodd" clip-rule="evenodd" d="M7.41354 1.55996L8.31152 1H11.6056L12.424 2.57465L10.2356 6H12.0174L12.7363 7.69512L5.61943 15L4.01675 13.837L6.11943 10H4.89798L4 8.55996L7.41354 1.55996ZM7.78033 9L4.90054 14.3049L12.0174 7H8.31152L11.6056 2H8.31152L4.89798 9H7.78033Z" fill="#EE9D28"/> </svg>`,
81
83
  Operator: `<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"> <path fill-rule="evenodd" clip-rule="evenodd" d="M2.87289 1.10023C3.20768 1.23579 3.47545 1.498 3.61802 1.82988C3.69032 1.99959 3.72675 2.18242 3.72502 2.36688C3.72617 2.54999 3.68975 2.7314 3.61802 2.89988C3.51299 3.14567 3.33782 3.35503 3.11442 3.50177C2.89102 3.64851 2.6293 3.72612 2.36202 3.72488C2.17924 3.72592 1.99818 3.68951 1.83002 3.61788C1.58298 3.51406 1.37227 3.33932 1.22453 3.11575C1.0768 2.89219 0.998666 2.62984 1.00002 2.36188C0.99913 2.17921 1.03519 1.99825 1.10602 1.82988C1.24337 1.50314 1.50328 1.24323 1.83002 1.10588C2.16332 0.966692 2.53809 0.964661 2.87289 1.10023ZM2.57502 2.86488C2.7054 2.80913 2.80927 2.70526 2.86502 2.57488C2.8929 2.50838 2.90718 2.43698 2.90702 2.36488C2.90813 2.2654 2.88215 2.1675 2.83185 2.08167C2.78156 1.99584 2.70884 1.92531 2.62151 1.87767C2.53418 1.83002 2.43553 1.80705 2.33614 1.81121C2.23674 1.81537 2.14035 1.8465 2.05731 1.90128C1.97426 1.95606 1.9077 2.03241 1.86475 2.12215C1.8218 2.21188 1.80409 2.31161 1.81352 2.41065C1.82294 2.50968 1.85915 2.60428 1.91825 2.6843C1.97736 2.76433 2.05713 2.82675 2.14902 2.86488C2.28549 2.92089 2.43854 2.92089 2.57502 2.86488ZM6.42995 1.1095L1.10967 6.42977L1.79557 7.11567L7.11584 1.7954L6.42995 1.1095ZM11.5 8.99999H12.5V11.5H15V12.5H12.5V15H11.5V12.5H9V11.5H11.5V8.99999ZM5.76777 9.52509L6.47487 10.2322L4.70711 12L6.47487 13.7677L5.76777 14.4748L4 12.7071L2.23223 14.4748L1.52513 13.7677L3.29289 12L1.52513 10.2322L2.23223 9.52509L4 11.2929L5.76777 9.52509ZM7.11802 5.32988C7.01442 5.08268 6.83973 4.87183 6.61612 4.72406C6.3925 4.57629 6.13004 4.49826 5.86202 4.49988C5.67935 4.49899 5.49839 4.53505 5.33002 4.60588C5.00328 4.74323 4.74337 5.00314 4.60602 5.32988C4.53588 5.49478 4.49897 5.67191 4.49741 5.8511C4.49586 6.0303 4.52967 6.20804 4.59693 6.37414C4.66419 6.54024 4.76356 6.69143 4.88936 6.81906C5.01516 6.94669 5.1649 7.04823 5.33002 7.11788C5.49867 7.18848 5.67968 7.22484 5.86252 7.22484C6.04535 7.22484 6.22636 7.18848 6.39502 7.11788C6.64201 7.01388 6.8527 6.83913 7.00058 6.61563C7.14845 6.39213 7.22689 6.12987 7.22602 5.86188C7.22655 5.67905 7.1898 5.49803 7.11802 5.32988ZM6.36502 6.07488C6.33766 6.13937 6.29829 6.19808 6.24902 6.24788C6.19908 6.29724 6.14042 6.33691 6.07602 6.36488C6.00854 6.39297 5.93611 6.40725 5.86302 6.40688C5.78991 6.40744 5.71744 6.39315 5.65002 6.36488C5.58541 6.33729 5.52668 6.29757 5.47702 6.24788C5.42691 6.19856 5.38713 6.13975 5.36002 6.07488C5.30401 5.9384 5.30401 5.78536 5.36002 5.64888C5.41536 5.51846 5.51941 5.41477 5.65002 5.35988C5.71737 5.33126 5.78984 5.31663 5.86302 5.31688C5.93618 5.31685 6.0086 5.33147 6.07602 5.35988C6.14037 5.38749 6.19904 5.42682 6.24902 5.47588C6.29786 5.52603 6.33717 5.58465 6.36502 5.64888C6.3934 5.7163 6.40802 5.78872 6.40802 5.86188C6.40802 5.93503 6.3934 6.00745 6.36502 6.07488ZM14 3H10V4H14V3Z" fill="#C5C5C5"/> </svg>`,
84
+ Console: `<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"> <path fill-rule="evenodd" clip-rule="evenodd" d="M1 1H15V15H1V1ZM2 14H14V2H2V14ZM4.00008 5.70709L4.70718 4.99999L8.24272 8.53552L7.53561 9.24263L7.53558 9.2426L4.70711 12.0711L4 11.364L6.82848 8.53549L4.00008 5.70709Z" fill="#C5C5C5"/> </svg>`,
82
85
  TypeParameter: `<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"> <path fill-rule="evenodd" clip-rule="evenodd" d="M11 6H10V5.5C10 5.22386 9.77616 5 9.50001 5H8.47902V10.5C8.47902 10.7761 8.70288 11 8.97902 11H9.47902V12H6.47902V11H6.97902C7.25516 11 7.47902 10.7761 7.47902 10.5V5H6.50001C6.22387 5 6.00001 5.22386 6.00001 5.5V6H5.00001V4H11V6ZM13.9142 8.0481L12.4519 6.58581L13.159 5.87871L14.9749 7.69454V8.40165L13.2071 10.1694L12.5 9.46231L13.9142 8.0481ZM3.5481 9.4623L2.08581 8.00002L3.50002 6.58581L2.79291 5.8787L1.02515 7.64647V8.35357L2.841 10.1694L3.5481 9.4623Z" fill="#C5C5C5"/> </svg>`,
83
86
  };
84
87
  const iconType = iconTypeString as CompletionItemIcons;
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { CypherParser, parse } from '@neo4j-cypher/language-support';
1
+ export * as LanguageSupport from '@neo4j-cypher/language-support';
2
2
  export { CypherEditor } from './CypherEditor';
3
- export { cypher } from './lang-cypher/lang-cypher';
3
+ export { cypher } from './lang-cypher/langCypher';
4
4
  export { darkThemeConstants, lightThemeConstants } from './themes';
@@ -1,8 +1,19 @@
1
- import { CompletionSource } from '@codemirror/autocomplete';
2
- import { autocomplete } from '@neo4j-cypher/language-support';
3
- import { CompletionItemKind } from 'vscode-languageserver-types';
1
+ import {
2
+ Completion,
3
+ CompletionSource,
4
+ snippet,
5
+ } from '@codemirror/autocomplete';
6
+ import {
7
+ autocomplete,
8
+ shouldAutoCompleteYield,
9
+ } from '@neo4j-cypher/language-support';
10
+ import {
11
+ CompletionItemKind,
12
+ CompletionItemTag,
13
+ } from 'vscode-languageserver-types';
4
14
  import { CompletionItemIcons } from '../icons';
5
- import type { CypherConfig } from './lang-cypher';
15
+ import type { CypherConfig } from './langCypher';
16
+ import { getDocString } from './utils';
6
17
 
7
18
  const completionKindToCodemirrorIcon = (c: CompletionItemKind) => {
8
19
  const map: Record<CompletionItemKind, CompletionItemIcons> = {
@@ -28,7 +39,8 @@ const completionKindToCodemirrorIcon = (c: CompletionItemKind) => {
28
39
  [CompletionItemKind.EnumMember]: 'EnumMember',
29
40
  [CompletionItemKind.Constant]: 'Constant',
30
41
  [CompletionItemKind.Struct]: 'Struct',
31
- [CompletionItemKind.Event]: 'Event',
42
+ // we're miss-using the enum here as there is no `Console` kind in the predefined list
43
+ [CompletionItemKind.Event]: 'Console',
32
44
  [CompletionItemKind.Operator]: 'Operator',
33
45
  [CompletionItemKind.TypeParameter]: 'TypeParameter',
34
46
  };
@@ -36,30 +48,100 @@ const completionKindToCodemirrorIcon = (c: CompletionItemKind) => {
36
48
  return map[c];
37
49
  };
38
50
 
51
+ export const completionStyles: (
52
+ completion: Completion & { deprecated?: boolean },
53
+ ) => string = (completion) => {
54
+ if (completion.deprecated) {
55
+ return 'cm-deprecated-element';
56
+ } else {
57
+ return null;
58
+ }
59
+ };
60
+
39
61
  export const cypherAutocomplete: (config: CypherConfig) => CompletionSource =
40
62
  (config) => (context) => {
41
- const textUntilCursor = context.state.doc.toString().slice(0, context.pos);
42
-
43
- const triggerCharacters = ['.', ':', '{', '$'];
44
- const lastCharacter = textUntilCursor.slice(-1);
45
-
63
+ const documentText = context.state.doc.toString();
64
+ const offset = context.pos;
65
+ const triggerCharacters = ['.', ':', '{', '$', ')'];
66
+ const lastCharacter = documentText.at(offset - 1);
67
+ const yieldTriggered = shouldAutoCompleteYield(documentText, offset);
46
68
  const lastWord = context.matchBefore(/\w*/);
47
69
  const inWord = lastWord.from !== lastWord.to;
48
-
49
70
  const shouldTriggerCompletion =
50
- inWord || context.explicit || triggerCharacters.includes(lastCharacter);
71
+ inWord ||
72
+ context.explicit ||
73
+ triggerCharacters.includes(lastCharacter) ||
74
+ yieldTriggered;
75
+
76
+ if (config.useLightVersion && !context.explicit) {
77
+ return null;
78
+ }
51
79
 
52
80
  if (!shouldTriggerCompletion) {
53
81
  return null;
54
82
  }
55
83
 
56
- const options = autocomplete(textUntilCursor, config.schema ?? {});
84
+ const options = autocomplete(
85
+ // TODO This is a temporary hack because completions are not working well
86
+ documentText.slice(0, offset),
87
+ config.schema ?? {},
88
+ offset,
89
+ context.explicit,
90
+ );
57
91
 
58
92
  return {
59
- from: context.matchBefore(/(\w|\$)*$/).from,
60
- options: options.map((o) => ({
61
- label: o.label,
62
- type: completionKindToCodemirrorIcon(o.kind),
63
- })),
93
+ from: context.matchBefore(/(\w)*$/).from,
94
+ options: options.map((o) => {
95
+ let maybeInfo = {};
96
+ let emptyInfo = true;
97
+ const newDiv = document.createElement('div');
98
+
99
+ if (o.signature) {
100
+ const header = document.createElement('p');
101
+ header.setAttribute('class', 'cm-completionInfo-signature');
102
+ header.textContent = o.signature;
103
+ if (header.textContent.length > 0) {
104
+ emptyInfo = false;
105
+ newDiv.appendChild(header);
106
+ }
107
+ }
108
+
109
+ if (o.documentation) {
110
+ const paragraph = document.createElement('p');
111
+ paragraph.textContent = getDocString(o.documentation);
112
+ if (paragraph.textContent.length > 0) {
113
+ emptyInfo = false;
114
+ newDiv.appendChild(paragraph);
115
+ }
116
+ }
117
+
118
+ if (!emptyInfo) {
119
+ maybeInfo = {
120
+ info: () => Promise.resolve(newDiv),
121
+ };
122
+ }
123
+ const deprecated =
124
+ o.tags?.find((tag) => tag === CompletionItemTag.Deprecated) ?? false;
125
+ // The negative boost moves the deprecation down the list
126
+ // so we offer the user the completions that are
127
+ // deprecated the last
128
+ const maybeDeprecated = deprecated
129
+ ? { boost: -99, deprecated: true }
130
+ : {};
131
+
132
+ return {
133
+ label: o.insertText ? o.insertText : o.label,
134
+ displayLabel: o.label,
135
+ type: completionKindToCodemirrorIcon(o.kind),
136
+ apply:
137
+ o.kind === CompletionItemKind.Snippet
138
+ ? // codemirror requires an empty snippet space to be able to tab out of the completion
139
+ snippet((o.insertText ?? o.label) + '${}')
140
+ : undefined,
141
+ detail: o.detail,
142
+ ...maybeDeprecated,
143
+ ...maybeInfo,
144
+ };
145
+ }),
64
146
  };
65
147
  };
@@ -31,8 +31,32 @@ export const cypherTokenTypeToNode = (facet: Facet<unknown>) => ({
31
31
  none: NodeType.define({ id: 19, name: 'none' }),
32
32
  separator: NodeType.define({ id: 20, name: 'separator' }),
33
33
  punctuation: NodeType.define({ id: 21, name: 'punctuation' }),
34
+ consoleCommand: NodeType.define({ id: 22, name: 'consoleCommand' }),
35
+ // also include prism token types
36
+ 'class-name': NodeType.define({ id: 23, name: 'label' }),
37
+ // this is escaped variables
38
+ identifier: NodeType.define({ id: 24, name: 'variable' }),
39
+ string: NodeType.define({ id: 25, name: 'stringLiteral' }),
40
+ relationship: NodeType.define({ id: 26, name: 'label' }),
41
+ boolean: NodeType.define({ id: 27, name: 'booleanLiteral' }),
42
+ number: NodeType.define({ id: 28, name: 'numberLiteral' }),
43
+ setting: NodeType.define({ id: 29, name: 'setting' }),
44
+ settingValue: NodeType.define({ id: 30, name: 'settingValue' }),
34
45
  });
35
46
 
47
+ export type PrismSpecificTokenType =
48
+ | 'class-name'
49
+ | 'identifier'
50
+ | 'string'
51
+ | 'relationship'
52
+ | 'boolean'
53
+ | 'number';
54
+
55
+ export type CodemirrorParseTokenType =
56
+ | CypherTokenType
57
+ | PrismSpecificTokenType
58
+ | 'topNode';
59
+
36
60
  export type HighlightedCypherTokenTypes = Exclude<CypherTokenType, 'none'>;
37
61
  export const tokenTypeToStyleTag: Record<HighlightedCypherTokenTypes, Tag> = {
38
62
  comment: tags.comment,
@@ -55,6 +79,9 @@ export const tokenTypeToStyleTag: Record<HighlightedCypherTokenTypes, Tag> = {
55
79
  bracket: tags.bracket,
56
80
  punctuation: tags.punctuation,
57
81
  separator: tags.separator,
82
+ consoleCommand: tags.macroName,
83
+ setting: tags.attributeName,
84
+ settingValue: tags.attributeValue,
58
85
  };
59
86
 
60
87
  export const parserAdapterNodeSet = (nodes: Record<string, NodeType>) =>
@@ -1,5 +1,9 @@
1
1
  import { tags } from '@lezer/highlight';
2
- import { applySyntaxColouring } from '@neo4j-cypher/language-support';
2
+ import {
3
+ applySyntaxColouring,
4
+ CypherTokenType,
5
+ } from '@neo4j-cypher/language-support';
6
+ import { expect, test } from 'vitest';
3
7
  import { tokenTypeToStyleTag } from './constants';
4
8
 
5
9
  const cypherQueryWithAllTokenTypes = `MATCH (variable :Label)-[:REL_TYPE]->()
@@ -54,7 +58,7 @@ test('correctly parses all cypher token types to style tags', () => {
54
58
  ]);
55
59
 
56
60
  const styleTags = tokenTypes.map((tokenType) => {
57
- if (tokenType === 'none') return undefined;
61
+ if (tokenType === CypherTokenType.none) return undefined;
58
62
  return tokenTypeToStyleTag[tokenType];
59
63
  });
60
64
  const correctTags = [
@@ -5,6 +5,7 @@ import {
5
5
  } from '@codemirror/language';
6
6
  import { Extension } from '@codemirror/state';
7
7
  import { EditorView } from '@codemirror/view';
8
+ import { CypherTokenType } from '@neo4j-cypher/language-support';
8
9
  import { StyleSpec } from 'style-mod';
9
10
  import { HighlightedCypherTokenTypes, tokenTypeToStyleTag } from './constants';
10
11
  import {
@@ -15,7 +16,7 @@ import {
15
16
  replaceAllSvg,
16
17
  replaceSvg,
17
18
  upArrowSvg,
18
- } from './theme-icons';
19
+ } from './themeIcons';
19
20
 
20
21
  export interface ThemeOptions {
21
22
  dark: boolean;
@@ -53,6 +54,9 @@ export const createCypherTheme = ({
53
54
  color: settings.foreground,
54
55
  fontVariantLigatures: 'none',
55
56
  },
57
+ '& .cm-snippetField': {
58
+ backgroundColor: settings.autoCompletionPanel.selectedColor,
59
+ },
56
60
  '&.cm-focused': {
57
61
  outline: 'none',
58
62
  },
@@ -61,8 +65,9 @@ export const createCypherTheme = ({
61
65
  color: settings.gutterForeground,
62
66
  border: 'none',
63
67
  },
64
- '&.cm-editor .cm-scroller': {
68
+ '&.cm-editor': {
65
69
  fontFamily: 'Fira Code, Menlo, Monaco, Lucida Console, monospace',
70
+ height: '100%',
66
71
  },
67
72
  '.cm-content': {
68
73
  caretColor: settings.cursor,
@@ -80,6 +85,9 @@ export const createCypherTheme = ({
80
85
  '& .cm-selectionMatch': {
81
86
  backgroundColor: settings.textMatchingSelection,
82
87
  },
88
+ '& .cm-bold': {
89
+ fontWeight: 'bold',
90
+ },
83
91
  '& .cm-panels': {
84
92
  backgroundColor: settings.searchPanel.background,
85
93
  fontFamily: 'Fira Code, Menlo, Monaco, Lucida Console, monospace',
@@ -93,7 +101,40 @@ export const createCypherTheme = ({
93
101
  color: settings.autoCompletionPanel.matchingTextColor,
94
102
  textDecoration: 'none',
95
103
  },
104
+ '& .cm-signature-help-panel': {
105
+ backgroundColor: settings.autoCompletionPanel.backgroundColor,
106
+ maxWidth: '700px',
107
+ maxHeight: '250px',
108
+ fontFamily: 'Fira Code, Menlo, Monaco, Lucida Console, monospace',
109
+ },
110
+ '& .cm-signature-help-panel-contents': {
111
+ overflow: 'auto',
112
+ maxHeight: '250px',
113
+ },
114
+ '& .cm-signature-help-panel-current-argument': {
115
+ color: settings.autoCompletionPanel.matchingTextColor,
116
+ fontWeight: 'bold',
117
+ },
118
+ '& .cm-signature-help-panel-separator': {
119
+ borderBottom: '1px solid #ccc',
120
+ },
121
+ '& .cm-signature-help-panel-name': {
122
+ padding: '5px',
123
+ },
124
+ '& .cm-signature-help-panel-arg-description': {
125
+ padding: '5px',
126
+ },
127
+ '& .cm-signature-help-panel-description': {
128
+ padding: '5px',
129
+ },
130
+ '.cm-completionInfo-signature': {
131
+ color: 'darkgrey',
132
+ },
133
+ '.cm-deprecated-element': {
134
+ 'text-decoration': 'line-through',
135
+ },
96
136
  '.cm-tooltip-autocomplete': {
137
+ maxWidth: '430px',
97
138
  '& > ul > li[aria-selected]': {
98
139
  backgroundColor: settings.autoCompletionPanel.selectedColor,
99
140
  color: settings.foreground,
@@ -198,6 +239,7 @@ export const createCypherTheme = ({
198
239
  ([token, color]: [HighlightedCypherTokenTypes, string]): TagStyle => ({
199
240
  tag: tokenTypeToStyleTag[token],
200
241
  color,
242
+ class: token === CypherTokenType.consoleCommand ? 'cm-bold' : undefined,
201
243
  }),
202
244
  );
203
245
  const highlightStyle = HighlightStyle.define(styles);
@@ -0,0 +1,43 @@
1
+ import { autocompletion } from '@codemirror/autocomplete';
2
+ import {
3
+ defineLanguageFacet,
4
+ Language,
5
+ LanguageSupport,
6
+ } from '@codemirror/language';
7
+ import { type DbSchema } from '@neo4j-cypher/language-support';
8
+ import { completionStyles, cypherAutocomplete } from './autocomplete';
9
+ import { ParserAdapter } from './parser-adapter';
10
+ import { signatureHelpTooltip } from './signatureHelp';
11
+ import { cypherLinter } from './syntaxValidation';
12
+
13
+ const facet = defineLanguageFacet({
14
+ commentTokens: { block: { open: '/*', close: '*/' }, line: '//' },
15
+ closeBrackets: { brackets: ['(', '[', '{', "'", '"', '`'] },
16
+ });
17
+
18
+ export type CypherConfig = {
19
+ lint?: boolean;
20
+ showSignatureTooltipBelow?: boolean;
21
+ featureFlags?: {
22
+ consoleCommands?: boolean;
23
+ cypher25?: boolean;
24
+ };
25
+ schema?: DbSchema;
26
+ useLightVersion: boolean;
27
+ setUseLightVersion?: (useLightVersion: boolean) => void;
28
+ };
29
+
30
+ export function cypher(config: CypherConfig) {
31
+ const parserAdapter = new ParserAdapter(facet, config);
32
+
33
+ const cypherLanguage = new Language(facet, parserAdapter, [], 'cypher');
34
+
35
+ return new LanguageSupport(cypherLanguage, [
36
+ autocompletion({
37
+ override: [cypherAutocomplete(config)],
38
+ optionClass: completionStyles,
39
+ }),
40
+ cypherLinter(config),
41
+ signatureHelpTooltip(config),
42
+ ]);
43
+ }
@@ -0,0 +1,31 @@
1
+ import {
2
+ DbSchema,
3
+ lintCypherQuery as _lintCypherQuery,
4
+ _internalFeatureFlags,
5
+ } from '@neo4j-cypher/language-support';
6
+ import workerpool from 'workerpool';
7
+
8
+ function lintCypherQuery(
9
+ query: string,
10
+ dbSchema: DbSchema,
11
+ featureFlags: { consoleCommands?: boolean; cypher25?: boolean } = {},
12
+ ) {
13
+ // We allow to override the consoleCommands feature flag
14
+ if (featureFlags.consoleCommands !== undefined) {
15
+ _internalFeatureFlags.consoleCommands = featureFlags.consoleCommands;
16
+ }
17
+ if (featureFlags.cypher25 !== undefined) {
18
+ _internalFeatureFlags.cypher25 = featureFlags.cypher25;
19
+ }
20
+ return _lintCypherQuery(query, dbSchema);
21
+ }
22
+
23
+ workerpool.worker({ lintCypherQuery });
24
+
25
+ type LinterArgs = Parameters<typeof lintCypherQuery>;
26
+
27
+ export type LinterTask = workerpool.Promise<ReturnType<typeof lintCypherQuery>>;
28
+
29
+ export type LintWorker = {
30
+ lintCypherQuery: (...args: LinterArgs) => LinterTask;
31
+ };