@neo4j-cypher/react-codemirror 2.0.0-next.3 → 2.0.0-next.5
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 +19 -0
- package/dist/{types/CypherEditor.d.ts → CypherEditor.d.ts} +10 -1
- package/dist/CypherEditor.js +206 -0
- package/dist/CypherEditor.js.map +1 -0
- package/dist/e2e_tests/auto-completion.spec.js +129 -0
- package/dist/e2e_tests/auto-completion.spec.js.map +1 -0
- package/dist/e2e_tests/e2e-utils.js +52 -0
- package/dist/e2e_tests/e2e-utils.js.map +1 -0
- package/dist/e2e_tests/extra-keybindings.spec.js +44 -0
- package/dist/e2e_tests/extra-keybindings.spec.js.map +1 -0
- package/dist/e2e_tests/history-navigation.spec.js +136 -0
- package/dist/e2e_tests/history-navigation.spec.js.map +1 -0
- package/dist/e2e_tests/performance-test.spec.d.ts +6 -0
- package/dist/e2e_tests/performance-test.spec.js +96 -0
- package/dist/e2e_tests/performance-test.spec.js.map +1 -0
- package/dist/e2e_tests/sanity-checks.spec.js +65 -0
- package/dist/e2e_tests/sanity-checks.spec.js.map +1 -0
- package/dist/e2e_tests/signature-help.spec.js +151 -0
- package/dist/e2e_tests/signature-help.spec.js.map +1 -0
- package/dist/e2e_tests/syntax-highlighting.spec.js +91 -0
- package/dist/e2e_tests/syntax-highlighting.spec.js.map +1 -0
- package/dist/e2e_tests/syntax-validation.spec.js +79 -0
- package/dist/e2e_tests/syntax-validation.spec.js.map +1 -0
- package/dist/history-navigation.js +163 -0
- package/dist/history-navigation.js.map +1 -0
- package/dist/{types/icons.d.ts → icons.d.ts} +1 -1
- package/dist/icons.js +62 -0
- package/dist/icons.js.map +1 -0
- package/dist/{types/index.d.ts → index.d.ts} +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/lang-cypher/autocomplete.js +56 -0
- package/dist/lang-cypher/autocomplete.js.map +1 -0
- package/dist/{types/lang-cypher → lang-cypher}/constants.d.ts +9 -0
- package/dist/lang-cypher/constants.js +65 -0
- package/dist/lang-cypher/constants.js.map +1 -0
- package/dist/lang-cypher/contants.test.js +102 -0
- package/dist/lang-cypher/contants.test.js.map +1 -0
- package/dist/lang-cypher/create-cypher-theme.js +144 -0
- package/dist/lang-cypher/create-cypher-theme.js.map +1 -0
- package/dist/{types/lang-cypher → lang-cypher}/lang-cypher.d.ts +3 -1
- package/dist/lang-cypher/lang-cypher.js +24 -0
- package/dist/lang-cypher/lang-cypher.js.map +1 -0
- package/dist/lang-cypher/lint-worker.d.ts +8 -0
- package/dist/lang-cypher/lint-worker.js +4 -0
- package/dist/lang-cypher/lint-worker.js.map +1 -0
- package/dist/lang-cypher/parser-adapter.d.ts +19 -0
- package/dist/lang-cypher/parser-adapter.js +113 -0
- package/dist/lang-cypher/parser-adapter.js.map +1 -0
- package/dist/lang-cypher/signature-help.d.ts +4 -0
- package/dist/lang-cypher/signature-help.js +77 -0
- package/dist/lang-cypher/signature-help.js.map +1 -0
- package/dist/{types/lang-cypher → lang-cypher}/syntax-validation.d.ts +2 -0
- package/dist/lang-cypher/syntax-validation.js +68 -0
- package/dist/lang-cypher/syntax-validation.js.map +1 -0
- package/dist/lang-cypher/theme-icons.js +22 -0
- package/dist/lang-cypher/theme-icons.js.map +1 -0
- package/dist/ndl-tokens-copy.js +380 -0
- package/dist/ndl-tokens-copy.js.map +1 -0
- package/dist/ndl-tokens-copy.test.js +11 -0
- package/dist/ndl-tokens-copy.test.js.map +1 -0
- package/dist/neo4j-setup.js +86 -0
- package/dist/neo4j-setup.js.map +1 -0
- package/dist/themes.js +114 -0
- package/dist/themes.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +15 -18
- package/src/CypherEditor.tsx +38 -6
- package/src/e2e_tests/performance-test.spec.tsx +100 -13
- package/src/e2e_tests/sanity-checks.spec.tsx +8 -3
- package/src/e2e_tests/signature-help.spec.tsx +312 -0
- package/src/icons.ts +3 -0
- package/src/index.ts +1 -1
- package/src/lang-cypher/autocomplete.ts +6 -1
- package/src/lang-cypher/constants.ts +23 -0
- package/src/lang-cypher/create-cypher-theme.ts +4 -0
- package/src/lang-cypher/lang-cypher.ts +16 -7
- package/src/lang-cypher/lint-worker.ts +14 -0
- package/src/lang-cypher/parser-adapter.ts +145 -0
- package/src/lang-cypher/signature-help.ts +102 -0
- package/src/lang-cypher/syntax-validation.ts +70 -4
- package/src/themes.ts +2 -0
- package/dist/cjs/index.cjs +0 -1440
- package/dist/cjs/index.cjs.map +0 -7
- package/dist/esm/index.mjs +0 -1463
- package/dist/esm/index.mjs.map +0 -7
- package/dist/types/e2e_tests/mock-data.d.ts +0 -3779
- package/dist/types/lang-cypher/ParserAdapter.d.ts +0 -14
- package/dist/types/tsconfig.tsbuildinfo +0 -1
- package/src/e2e_tests/mock-data.ts +0 -4310
- package/src/lang-cypher/ParserAdapter.ts +0 -92
- /package/dist/{types/e2e_tests → e2e_tests}/auto-completion.spec.d.ts +0 -0
- /package/dist/{types/e2e_tests → e2e_tests}/e2e-utils.d.ts +0 -0
- /package/dist/{types/e2e_tests → e2e_tests}/extra-keybindings.spec.d.ts +0 -0
- /package/dist/{types/e2e_tests → e2e_tests}/history-navigation.spec.d.ts +0 -0
- /package/dist/{types/e2e_tests → e2e_tests}/sanity-checks.spec.d.ts +0 -0
- /package/dist/{types/e2e_tests/performance-test.spec.d.ts → e2e_tests/signature-help.spec.d.ts} +0 -0
- /package/dist/{types/e2e_tests → e2e_tests}/syntax-highlighting.spec.d.ts +0 -0
- /package/dist/{types/e2e_tests → e2e_tests}/syntax-validation.spec.d.ts +0 -0
- /package/dist/{types/history-navigation.d.ts → history-navigation.d.ts} +0 -0
- /package/dist/{types/lang-cypher → lang-cypher}/autocomplete.d.ts +0 -0
- /package/dist/{types/lang-cypher → lang-cypher}/contants.test.d.ts +0 -0
- /package/dist/{types/lang-cypher → lang-cypher}/create-cypher-theme.d.ts +0 -0
- /package/dist/{types/lang-cypher → lang-cypher}/theme-icons.d.ts +0 -0
- /package/dist/{types/ndl-tokens-copy.d.ts → ndl-tokens-copy.d.ts} +0 -0
- /package/dist/{types/ndl-tokens-copy.test.d.ts → ndl-tokens-copy.test.d.ts} +0 -0
- /package/dist/{types/neo4j-setup.d.ts → neo4j-setup.d.ts} +0 -0
- /package/dist/{types/themes.d.ts → themes.d.ts} +0 -0
|
@@ -1,15 +1,42 @@
|
|
|
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
4
|
import { CypherEditorPage } from './e2e-utils';
|
|
4
|
-
import { largeQuery, mockSchema } from './mock-data';
|
|
5
5
|
|
|
6
6
|
test.use({ viewport: { width: 1000, height: 500 } });
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
declare global {
|
|
8
|
+
interface Window {
|
|
9
|
+
longtasks: number[];
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
test('benchmarking & performance test session', async ({ mount, page }) => {
|
|
14
|
+
const client = await page.context().newCDPSession(page);
|
|
15
|
+
if (process.env.BENCHMARKING === 'true') {
|
|
16
|
+
test.setTimeout(1000000);
|
|
17
|
+
await client.send('Performance.enable');
|
|
18
|
+
await client.send('Emulation.setCPUThrottlingRate', { rate: 4 });
|
|
19
|
+
await client.send('Overlay.setShowFPSCounter', { show: true });
|
|
20
|
+
|
|
21
|
+
await page.evaluate(() => {
|
|
22
|
+
window.longtasks = [];
|
|
23
|
+
const observer = new PerformanceObserver((list) => {
|
|
24
|
+
window.longtasks.push(...list.getEntries().map((e) => e.duration));
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
observer.observe({ entryTypes: ['longtask'] });
|
|
28
|
+
});
|
|
29
|
+
} else {
|
|
30
|
+
test.setTimeout(30 * 1000);
|
|
31
|
+
}
|
|
10
32
|
const editorPage = new CypherEditorPage(page);
|
|
11
33
|
const component = await mount(
|
|
12
|
-
<CypherEditor
|
|
34
|
+
<CypherEditor
|
|
35
|
+
prompt="neo4j>"
|
|
36
|
+
theme="dark"
|
|
37
|
+
lint
|
|
38
|
+
schema={testData.mockSchema}
|
|
39
|
+
/>,
|
|
13
40
|
);
|
|
14
41
|
|
|
15
42
|
// pressSequentially is less efficient -> we want to test the performance of the editor
|
|
@@ -20,27 +47,33 @@ test('performance test session ', async ({ mount, page }) => {
|
|
|
20
47
|
|
|
21
48
|
// set and unset large query a few times
|
|
22
49
|
await component.update(
|
|
23
|
-
<CypherEditor value={largeQuery} schema={mockSchema} />,
|
|
50
|
+
<CypherEditor value={testData.largeQuery} schema={testData.mockSchema} />,
|
|
51
|
+
);
|
|
52
|
+
await component.update(
|
|
53
|
+
<CypherEditor value="" schema={testData.mockSchema} />,
|
|
24
54
|
);
|
|
25
|
-
await component.update(<CypherEditor value="" schema={mockSchema} />);
|
|
26
55
|
|
|
27
56
|
await component.update(
|
|
28
|
-
<CypherEditor value={largeQuery} schema={mockSchema} />,
|
|
57
|
+
<CypherEditor value={testData.largeQuery} schema={testData.mockSchema} />,
|
|
29
58
|
);
|
|
30
59
|
await component.update(<CypherEditor value="" />);
|
|
31
60
|
|
|
32
61
|
await component.update(
|
|
33
|
-
<CypherEditor value={largeQuery} schema={mockSchema} />,
|
|
62
|
+
<CypherEditor value={testData.largeQuery} schema={testData.mockSchema} />,
|
|
63
|
+
);
|
|
64
|
+
await component.update(
|
|
65
|
+
<CypherEditor value="" schema={testData.mockSchema} />,
|
|
34
66
|
);
|
|
35
|
-
await component.update(<CypherEditor value="" schema={mockSchema} />);
|
|
36
67
|
|
|
37
68
|
await component.update(
|
|
38
|
-
<CypherEditor value={largeQuery} schema={mockSchema} />,
|
|
69
|
+
<CypherEditor value={testData.largeQuery} schema={testData.mockSchema} />,
|
|
70
|
+
);
|
|
71
|
+
await component.update(
|
|
72
|
+
<CypherEditor value="" schema={testData.mockSchema} />,
|
|
39
73
|
);
|
|
40
|
-
await component.update(<CypherEditor value="" schema={mockSchema} />);
|
|
41
74
|
|
|
42
75
|
await component.update(
|
|
43
|
-
<CypherEditor value={largeQuery} schema={mockSchema} />,
|
|
76
|
+
<CypherEditor value={testData.largeQuery} schema={testData.mockSchema} />,
|
|
44
77
|
);
|
|
45
78
|
|
|
46
79
|
await editorPage.getEditor().pressSequentially(`
|
|
@@ -68,4 +101,58 @@ test('performance test session ', async ({ mount, page }) => {
|
|
|
68
101
|
await editorPage
|
|
69
102
|
.getEditor()
|
|
70
103
|
.pressSequentially('veryveryveryverylongvariable');
|
|
104
|
+
|
|
105
|
+
if (process.env.BENCHMARKING === 'true') {
|
|
106
|
+
const longtasks = await page.evaluate(() => window.longtasks);
|
|
107
|
+
const sortedLongTasks = longtasks.sort((a, b) => a - b);
|
|
108
|
+
const medianLongTask =
|
|
109
|
+
sortedLongTasks[Math.floor(sortedLongTasks.length / 2)];
|
|
110
|
+
const averageLongTask =
|
|
111
|
+
sortedLongTasks.reduce((a, b) => a + b, 0) / sortedLongTasks.length;
|
|
112
|
+
const over500 = sortedLongTasks.filter((t) => t > 500).length;
|
|
113
|
+
const nintyninethPercentile =
|
|
114
|
+
sortedLongTasks[Math.floor(sortedLongTasks.length * 0.99)];
|
|
115
|
+
const longTaskCount = longtasks.length;
|
|
116
|
+
const totalLongTaskTime = longtasks.reduce((a, b) => a + b, 0);
|
|
117
|
+
|
|
118
|
+
const USER_ID = 1226722;
|
|
119
|
+
const API_KEY = process.env.GRAFANA_API_KEY;
|
|
120
|
+
if (!API_KEY) {
|
|
121
|
+
throw new Error('Missing grafana api key');
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const metrics = {
|
|
125
|
+
medianLongTask,
|
|
126
|
+
averageLongTask,
|
|
127
|
+
over500,
|
|
128
|
+
nintyninethPercentile,
|
|
129
|
+
longTaskCount,
|
|
130
|
+
totalLongTaskTime,
|
|
131
|
+
};
|
|
132
|
+
const body = Object.entries(metrics)
|
|
133
|
+
.map(
|
|
134
|
+
([key, value]) =>
|
|
135
|
+
`benchmark,bar_label=${key},source=playwright metric=${value}`,
|
|
136
|
+
)
|
|
137
|
+
.join('\n');
|
|
138
|
+
|
|
139
|
+
await fetch(
|
|
140
|
+
'https://influx-prod-39-prod-eu-north-0.grafana.net/api/v1/push/influx/write',
|
|
141
|
+
{
|
|
142
|
+
method: 'post',
|
|
143
|
+
body,
|
|
144
|
+
headers: {
|
|
145
|
+
Authorization: `Bearer ${USER_ID}:${API_KEY}`,
|
|
146
|
+
'Content-Type': 'text/plain',
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
).then((res) => {
|
|
150
|
+
if (res.ok) {
|
|
151
|
+
// eslint-disable-next-line no-console
|
|
152
|
+
console.log('Metrics pushed to grafana successfully');
|
|
153
|
+
} else {
|
|
154
|
+
throw new Error(`Failed to push metrics to grafana: ${res.statusText}`);
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
}
|
|
71
158
|
});
|
|
@@ -22,7 +22,7 @@ test('the editors text can be externally controlled ', async ({ mount }) => {
|
|
|
22
22
|
await expect(component).toContainText(newValue);
|
|
23
23
|
});
|
|
24
24
|
|
|
25
|
-
test('the
|
|
25
|
+
test('the editor can report changes to the text ', async ({ mount, page }) => {
|
|
26
26
|
const intitialValue = 'MATCH (n) ';
|
|
27
27
|
|
|
28
28
|
let editorValueCopy = intitialValue;
|
|
@@ -36,11 +36,16 @@ test('the editors can report changes to the text ', async ({ mount, page }) => {
|
|
|
36
36
|
|
|
37
37
|
await textField.fill('RETURN 12');
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
// editor update is debounced, retry wait for debounced
|
|
40
|
+
await expect(() => {
|
|
41
|
+
expect(editorValueCopy).toBe('RETURN 12');
|
|
42
|
+
}).toPass({ intervals: [300, 300, 1000] });
|
|
40
43
|
|
|
41
44
|
await page.keyboard.type('34');
|
|
42
45
|
|
|
43
|
-
expect(
|
|
46
|
+
await expect(() => {
|
|
47
|
+
expect(editorValueCopy).toBe('RETURN 12');
|
|
48
|
+
}).toPass({ intervals: [300, 300, 1000] });
|
|
44
49
|
});
|
|
45
50
|
|
|
46
51
|
test('can complete RETURN', async ({ page, mount }) => {
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import { testData } from '@neo4j-cypher/language-support';
|
|
2
|
+
import { expect, test } from '@playwright/experimental-ct-react';
|
|
3
|
+
import { Locator } from 'playwright/test';
|
|
4
|
+
import { CypherEditor } from '../CypherEditor';
|
|
5
|
+
|
|
6
|
+
test.use({ viewport: { width: 1000, height: 500 } });
|
|
7
|
+
|
|
8
|
+
type TooltipExpectations = {
|
|
9
|
+
includes?: string[];
|
|
10
|
+
excludes?: string[];
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
function testTooltip(tooltip: Locator, expectations: TooltipExpectations) {
|
|
14
|
+
const includes = expectations.includes ?? [];
|
|
15
|
+
const excludes = expectations.excludes ?? [];
|
|
16
|
+
|
|
17
|
+
const included = Promise.all(
|
|
18
|
+
includes.map((text) => {
|
|
19
|
+
return expect(tooltip).toContainText(text, {
|
|
20
|
+
timeout: 2000,
|
|
21
|
+
});
|
|
22
|
+
}),
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
const excluded = Promise.all(
|
|
26
|
+
excludes.map((text) => {
|
|
27
|
+
return expect(tooltip).not.toContainText(text, {
|
|
28
|
+
timeout: 2000,
|
|
29
|
+
});
|
|
30
|
+
}),
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
return Promise.all([included, excluded]);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
test('Signature help works for functions', async ({ page, mount }) => {
|
|
37
|
+
const query = 'RETURN abs(';
|
|
38
|
+
|
|
39
|
+
await mount(
|
|
40
|
+
<CypherEditor
|
|
41
|
+
value={query}
|
|
42
|
+
schema={testData.mockSchema}
|
|
43
|
+
autofocus={true}
|
|
44
|
+
/>,
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
await expect(page.locator('.cm-tooltip-signature-help').last()).toBeVisible({
|
|
48
|
+
timeout: 2000,
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test('Signature help works for procedures', async ({ page, mount }) => {
|
|
53
|
+
const query = 'CALL apoc.import.csv(';
|
|
54
|
+
|
|
55
|
+
await mount(
|
|
56
|
+
<CypherEditor
|
|
57
|
+
value={query}
|
|
58
|
+
schema={testData.mockSchema}
|
|
59
|
+
autofocus={true}
|
|
60
|
+
/>,
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
await expect(page.locator('.cm-tooltip-signature-help').last()).toBeVisible({
|
|
64
|
+
timeout: 2000,
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
test('Signature help shows the description for the first argument', async ({
|
|
69
|
+
page,
|
|
70
|
+
mount,
|
|
71
|
+
}) => {
|
|
72
|
+
const query = 'CALL apoc.import.csv(';
|
|
73
|
+
|
|
74
|
+
await mount(
|
|
75
|
+
<CypherEditor
|
|
76
|
+
value={query}
|
|
77
|
+
schema={testData.mockSchema}
|
|
78
|
+
autofocus={true}
|
|
79
|
+
/>,
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
const tooltip = page.locator('.cm-tooltip-signature-help').last();
|
|
83
|
+
|
|
84
|
+
await testTooltip(tooltip, {
|
|
85
|
+
includes: [
|
|
86
|
+
'nodes :: LIST<MAP>',
|
|
87
|
+
'Imports `NODE` and `RELATIONSHIP` values with the given labels and types from the provided CSV file',
|
|
88
|
+
],
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
test('Signature help shows the description for the first argument when the cursor is at that position', async ({
|
|
93
|
+
page,
|
|
94
|
+
mount,
|
|
95
|
+
}) => {
|
|
96
|
+
const query = 'CALL apoc.import.csv()';
|
|
97
|
+
|
|
98
|
+
await mount(
|
|
99
|
+
<CypherEditor value={query} schema={testData.mockSchema} offset={21} />,
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
const tooltip = page.locator('.cm-tooltip-signature-help').last();
|
|
103
|
+
|
|
104
|
+
await testTooltip(tooltip, {
|
|
105
|
+
includes: [
|
|
106
|
+
'nodes :: LIST<MAP>',
|
|
107
|
+
'Imports `NODE` and `RELATIONSHIP` values with the given labels and types from the provided CSV file',
|
|
108
|
+
],
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
test('Signature help shows the description for the second argument', async ({
|
|
113
|
+
page,
|
|
114
|
+
mount,
|
|
115
|
+
}) => {
|
|
116
|
+
const query = 'CALL apoc.import.csv(nodes,';
|
|
117
|
+
|
|
118
|
+
await mount(
|
|
119
|
+
<CypherEditor
|
|
120
|
+
value={query}
|
|
121
|
+
schema={testData.mockSchema}
|
|
122
|
+
autofocus={true}
|
|
123
|
+
/>,
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
const tooltip = page.locator('.cm-tooltip-signature-help').last();
|
|
127
|
+
|
|
128
|
+
await testTooltip(tooltip, {
|
|
129
|
+
includes: [
|
|
130
|
+
'rels :: LIST<MAP>',
|
|
131
|
+
'Imports `NODE` and `RELATIONSHIP` values with the given labels and types from the provided CSV file',
|
|
132
|
+
],
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
test('Signature help shows the description for the second argument when the cursor is at that position', async ({
|
|
137
|
+
page,
|
|
138
|
+
mount,
|
|
139
|
+
}) => {
|
|
140
|
+
const query = 'CALL apoc.import.csv(nodes,)';
|
|
141
|
+
|
|
142
|
+
await mount(
|
|
143
|
+
<CypherEditor value={query} schema={testData.mockSchema} offset={27} />,
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
const tooltip = page.locator('.cm-tooltip-signature-help').last();
|
|
147
|
+
|
|
148
|
+
await testTooltip(tooltip, {
|
|
149
|
+
includes: [
|
|
150
|
+
'rels :: LIST<MAP>',
|
|
151
|
+
'Imports `NODE` and `RELATIONSHIP` values with the given labels and types from the provided CSV file',
|
|
152
|
+
],
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
test('Signature help shows the description for the second argument when the cursor is at that position, even after whitespaces', async ({
|
|
157
|
+
page,
|
|
158
|
+
mount,
|
|
159
|
+
}) => {
|
|
160
|
+
const query = 'CALL apoc.import.csv(nodes, )';
|
|
161
|
+
|
|
162
|
+
await mount(
|
|
163
|
+
<CypherEditor value={query} schema={testData.mockSchema} offset={28} />,
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
const tooltip = page.locator('.cm-tooltip-signature-help').last();
|
|
167
|
+
|
|
168
|
+
await testTooltip(tooltip, {
|
|
169
|
+
includes: [
|
|
170
|
+
'rels :: LIST<MAP>',
|
|
171
|
+
'Imports `NODE` and `RELATIONSHIP` values with the given labels and types from the provided CSV file',
|
|
172
|
+
],
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
test('Signature help shows description for arguments with a space following a separator', async ({
|
|
177
|
+
page,
|
|
178
|
+
mount,
|
|
179
|
+
}) => {
|
|
180
|
+
const query = 'CALL apoc.import.csv(nodes, ';
|
|
181
|
+
|
|
182
|
+
await mount(
|
|
183
|
+
<CypherEditor
|
|
184
|
+
value={query}
|
|
185
|
+
schema={testData.mockSchema}
|
|
186
|
+
autofocus={true}
|
|
187
|
+
/>,
|
|
188
|
+
);
|
|
189
|
+
|
|
190
|
+
const tooltip = page.locator('.cm-tooltip-signature-help').last();
|
|
191
|
+
|
|
192
|
+
await testTooltip(tooltip, {
|
|
193
|
+
includes: [
|
|
194
|
+
'rels :: LIST<MAP>',
|
|
195
|
+
'Imports `NODE` and `RELATIONSHIP` values with the given labels and types from the provided CSV file',
|
|
196
|
+
],
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
test('Signature help shows the description for the third argument', async ({
|
|
201
|
+
page,
|
|
202
|
+
mount,
|
|
203
|
+
}) => {
|
|
204
|
+
const query = 'CALL apoc.import.csv(nodes, rels,';
|
|
205
|
+
|
|
206
|
+
await mount(
|
|
207
|
+
<CypherEditor
|
|
208
|
+
value={query}
|
|
209
|
+
schema={testData.mockSchema}
|
|
210
|
+
autofocus={true}
|
|
211
|
+
/>,
|
|
212
|
+
);
|
|
213
|
+
|
|
214
|
+
const tooltip = page.locator('.cm-tooltip-signature-help').last();
|
|
215
|
+
|
|
216
|
+
await testTooltip(tooltip, {
|
|
217
|
+
includes: [
|
|
218
|
+
'config :: MAP',
|
|
219
|
+
'Imports `NODE` and `RELATIONSHIP` values with the given labels and types from the provided CSV file',
|
|
220
|
+
],
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
test('Signature help works on multiline queries', async ({ page, mount }) => {
|
|
225
|
+
const query = `CALL apoc.import.csv(
|
|
226
|
+
nodes,
|
|
227
|
+
rels,
|
|
228
|
+
`;
|
|
229
|
+
|
|
230
|
+
await mount(
|
|
231
|
+
<CypherEditor
|
|
232
|
+
value={query}
|
|
233
|
+
schema={testData.mockSchema}
|
|
234
|
+
autofocus={true}
|
|
235
|
+
/>,
|
|
236
|
+
);
|
|
237
|
+
|
|
238
|
+
const tooltip = page.locator('.cm-tooltip-signature-help').last();
|
|
239
|
+
|
|
240
|
+
await testTooltip(tooltip, {
|
|
241
|
+
includes: [
|
|
242
|
+
'config :: MAP',
|
|
243
|
+
'Imports `NODE` and `RELATIONSHIP` values with the given labels and types from the provided CSV file',
|
|
244
|
+
],
|
|
245
|
+
});
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
test('Signature help only shows the description past the last argument', async ({
|
|
249
|
+
page,
|
|
250
|
+
mount,
|
|
251
|
+
}) => {
|
|
252
|
+
const query = 'CALL apoc.import.csv(nodes, rels, config,';
|
|
253
|
+
|
|
254
|
+
await mount(
|
|
255
|
+
<CypherEditor
|
|
256
|
+
value={query}
|
|
257
|
+
schema={testData.mockSchema}
|
|
258
|
+
autofocus={true}
|
|
259
|
+
/>,
|
|
260
|
+
);
|
|
261
|
+
|
|
262
|
+
const tooltip = page.locator('.cm-tooltip-signature-help').last();
|
|
263
|
+
|
|
264
|
+
await testTooltip(tooltip, {
|
|
265
|
+
includes: [
|
|
266
|
+
'Imports `NODE` and `RELATIONSHIP` values with the given labels and types from the provided CSV file',
|
|
267
|
+
],
|
|
268
|
+
excludes: ['config :: MAP'],
|
|
269
|
+
});
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
test('Signature help does not show any help when method finished', async ({
|
|
273
|
+
page,
|
|
274
|
+
mount,
|
|
275
|
+
}) => {
|
|
276
|
+
const query = 'CALL apoc.import.csv(nodes, rels, config)';
|
|
277
|
+
|
|
278
|
+
await mount(
|
|
279
|
+
<CypherEditor
|
|
280
|
+
value={query}
|
|
281
|
+
schema={testData.mockSchema}
|
|
282
|
+
autofocus={true}
|
|
283
|
+
/>,
|
|
284
|
+
);
|
|
285
|
+
|
|
286
|
+
await expect(
|
|
287
|
+
page.locator('.cm-tooltip-signature-help').last(),
|
|
288
|
+
).not.toBeVisible({
|
|
289
|
+
timeout: 2000,
|
|
290
|
+
});
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
test('Signature help does not blow up on empty query', async ({
|
|
294
|
+
page,
|
|
295
|
+
mount,
|
|
296
|
+
}) => {
|
|
297
|
+
const query = '';
|
|
298
|
+
|
|
299
|
+
await mount(
|
|
300
|
+
<CypherEditor
|
|
301
|
+
value={query}
|
|
302
|
+
schema={testData.mockSchema}
|
|
303
|
+
autofocus={true}
|
|
304
|
+
/>,
|
|
305
|
+
);
|
|
306
|
+
|
|
307
|
+
await expect(
|
|
308
|
+
page.locator('.cm-tooltip-signature-help').last(),
|
|
309
|
+
).not.toBeVisible({
|
|
310
|
+
timeout: 2000,
|
|
311
|
+
});
|
|
312
|
+
});
|
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
|
|
1
|
+
export { CypherParser } from '@neo4j-cypher/language-support';
|
|
2
2
|
export { CypherEditor } from './CypherEditor';
|
|
3
3
|
export { cypher } from './lang-cypher/lang-cypher';
|
|
4
4
|
export { darkThemeConstants, lightThemeConstants } from './themes';
|
|
@@ -28,7 +28,8 @@ const completionKindToCodemirrorIcon = (c: CompletionItemKind) => {
|
|
|
28
28
|
[CompletionItemKind.EnumMember]: 'EnumMember',
|
|
29
29
|
[CompletionItemKind.Constant]: 'Constant',
|
|
30
30
|
[CompletionItemKind.Struct]: 'Struct',
|
|
31
|
-
|
|
31
|
+
// we're missuing the enum here as there is no `Console` kind in the predefined list
|
|
32
|
+
[CompletionItemKind.Event]: 'Console',
|
|
32
33
|
[CompletionItemKind.Operator]: 'Operator',
|
|
33
34
|
[CompletionItemKind.TypeParameter]: 'TypeParameter',
|
|
34
35
|
};
|
|
@@ -49,6 +50,10 @@ export const cypherAutocomplete: (config: CypherConfig) => CompletionSource =
|
|
|
49
50
|
const shouldTriggerCompletion =
|
|
50
51
|
inWord || context.explicit || triggerCharacters.includes(lastCharacter);
|
|
51
52
|
|
|
53
|
+
if (config.useLightVersion && !context.explicit) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
|
|
52
57
|
if (!shouldTriggerCompletion) {
|
|
53
58
|
return null;
|
|
54
59
|
}
|
|
@@ -31,8 +31,30 @@ 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' }),
|
|
34
43
|
});
|
|
35
44
|
|
|
45
|
+
export type PrismSpecificTokenType =
|
|
46
|
+
| 'class-name'
|
|
47
|
+
| 'identifier'
|
|
48
|
+
| 'string'
|
|
49
|
+
| 'relationship'
|
|
50
|
+
| 'boolean'
|
|
51
|
+
| 'number';
|
|
52
|
+
|
|
53
|
+
export type CodemirrorParseTokenType =
|
|
54
|
+
| CypherTokenType
|
|
55
|
+
| PrismSpecificTokenType
|
|
56
|
+
| 'topNode';
|
|
57
|
+
|
|
36
58
|
export type HighlightedCypherTokenTypes = Exclude<CypherTokenType, 'none'>;
|
|
37
59
|
export const tokenTypeToStyleTag: Record<HighlightedCypherTokenTypes, Tag> = {
|
|
38
60
|
comment: tags.comment,
|
|
@@ -55,6 +77,7 @@ export const tokenTypeToStyleTag: Record<HighlightedCypherTokenTypes, Tag> = {
|
|
|
55
77
|
bracket: tags.bracket,
|
|
56
78
|
punctuation: tags.punctuation,
|
|
57
79
|
separator: tags.separator,
|
|
80
|
+
consoleCommand: tags.macroName,
|
|
58
81
|
};
|
|
59
82
|
|
|
60
83
|
export const parserAdapterNodeSet = (nodes: Record<string, NodeType>) =>
|
|
@@ -80,6 +80,9 @@ export const createCypherTheme = ({
|
|
|
80
80
|
'& .cm-selectionMatch': {
|
|
81
81
|
backgroundColor: settings.textMatchingSelection,
|
|
82
82
|
},
|
|
83
|
+
'& .cm-bold': {
|
|
84
|
+
fontWeight: 'bold',
|
|
85
|
+
},
|
|
83
86
|
'& .cm-panels': {
|
|
84
87
|
backgroundColor: settings.searchPanel.background,
|
|
85
88
|
fontFamily: 'Fira Code, Menlo, Monaco, Lucida Console, monospace',
|
|
@@ -198,6 +201,7 @@ export const createCypherTheme = ({
|
|
|
198
201
|
([token, color]: [HighlightedCypherTokenTypes, string]): TagStyle => ({
|
|
199
202
|
tag: tokenTypeToStyleTag[token],
|
|
200
203
|
color,
|
|
204
|
+
class: token === 'consoleCommand' ? 'cm-bold' : undefined,
|
|
201
205
|
}),
|
|
202
206
|
);
|
|
203
207
|
const highlightStyle = HighlightStyle.define(styles);
|
|
@@ -3,30 +3,39 @@ import {
|
|
|
3
3
|
Language,
|
|
4
4
|
LanguageSupport,
|
|
5
5
|
} from '@codemirror/language';
|
|
6
|
-
import
|
|
6
|
+
import {
|
|
7
|
+
setConsoleCommandsEnabled,
|
|
8
|
+
type DbSchema,
|
|
9
|
+
} from '@neo4j-cypher/language-support';
|
|
7
10
|
import { cypherAutocomplete } from './autocomplete';
|
|
8
|
-
import { ParserAdapter } from './
|
|
9
|
-
import {
|
|
11
|
+
import { ParserAdapter } from './parser-adapter';
|
|
12
|
+
import { signatureHelpTooltip } from './signature-help';
|
|
13
|
+
import { cypherLinter, semanticAnalysisLinter } from './syntax-validation';
|
|
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
|
+
};
|