@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.
- package/CHANGELOG.md +18 -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/autoCompletion.spec.js +133 -0
- package/dist/e2e_tests/autoCompletion.spec.js.map +1 -0
- package/dist/e2e_tests/e2eUtils.js +52 -0
- package/dist/e2e_tests/e2eUtils.js.map +1 -0
- package/dist/e2e_tests/extraKeybindings.spec.js +44 -0
- package/dist/e2e_tests/extraKeybindings.spec.js.map +1 -0
- package/dist/e2e_tests/historyNavigation.spec.js +136 -0
- package/dist/e2e_tests/historyNavigation.spec.js.map +1 -0
- package/dist/e2e_tests/performanceTest.spec.d.ts +6 -0
- package/dist/e2e_tests/performanceTest.spec.js +96 -0
- package/dist/e2e_tests/performanceTest.spec.js.map +1 -0
- package/dist/e2e_tests/sanityChecks.spec.js +65 -0
- package/dist/e2e_tests/sanityChecks.spec.js.map +1 -0
- package/dist/e2e_tests/signatureHelp.spec.js +151 -0
- package/dist/e2e_tests/signatureHelp.spec.js.map +1 -0
- package/dist/e2e_tests/syntaxHighlighting.spec.js +91 -0
- package/dist/e2e_tests/syntaxHighlighting.spec.js.map +1 -0
- package/dist/e2e_tests/syntaxValidation.spec.js +79 -0
- package/dist/e2e_tests/syntaxValidation.spec.js.map +1 -0
- package/dist/historyNavigation.js +163 -0
- package/dist/historyNavigation.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/index.d.ts +4 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/{types/lang-cypher → lang-cypher}/autocomplete.d.ts +1 -1
- 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/createCypherTheme.js +144 -0
- package/dist/lang-cypher/createCypherTheme.js.map +1 -0
- package/dist/{types/lang-cypher/lang-cypher.d.ts → lang-cypher/langCypher.d.ts} +3 -1
- package/dist/lang-cypher/langCypher.js +24 -0
- package/dist/lang-cypher/langCypher.js.map +1 -0
- package/dist/lang-cypher/lintWorker.d.ts +8 -0
- package/dist/lang-cypher/lintWorker.js +4 -0
- package/dist/lang-cypher/lintWorker.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/signatureHelp.d.ts +4 -0
- package/dist/lang-cypher/signatureHelp.js +77 -0
- package/dist/lang-cypher/signatureHelp.js.map +1 -0
- package/dist/lang-cypher/syntaxValidation.d.ts +5 -0
- package/dist/lang-cypher/syntaxValidation.js +71 -0
- package/dist/lang-cypher/syntaxValidation.js.map +1 -0
- package/dist/lang-cypher/themeIcons.js +22 -0
- package/dist/lang-cypher/themeIcons.js.map +1 -0
- package/dist/ndlTokensCopy.js +380 -0
- package/dist/ndlTokensCopy.js.map +1 -0
- package/dist/ndlTokensCopy.test.js +11 -0
- package/dist/ndlTokensCopy.test.js.map +1 -0
- package/dist/neo4jSetup.js +86 -0
- package/dist/neo4jSetup.js.map +1 -0
- package/dist/{types/themes.d.ts → themes.d.ts} +1 -1
- 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 +34 -8
- package/src/e2e_tests/{auto-completion.spec.tsx → autoCompletion.spec.tsx} +8 -4
- package/src/e2e_tests/{extra-keybindings.spec.tsx → extraKeybindings.spec.tsx} +1 -1
- package/src/e2e_tests/{history-navigation.spec.tsx → historyNavigation.spec.tsx} +1 -1
- package/src/e2e_tests/performanceTest.spec.tsx +158 -0
- package/src/e2e_tests/{sanity-checks.spec.tsx → sanityChecks.spec.tsx} +8 -3
- package/src/e2e_tests/signatureHelp.spec.tsx +312 -0
- package/src/e2e_tests/{syntax-highlighting.spec.tsx → syntaxHighlighting.spec.tsx} +1 -1
- package/src/e2e_tests/{syntax-validation.spec.tsx → syntaxValidation.spec.tsx} +3 -3
- package/src/icons.ts +3 -0
- package/src/index.ts +2 -2
- package/src/lang-cypher/autocomplete.ts +7 -2
- package/src/lang-cypher/constants.ts +23 -0
- package/src/lang-cypher/{create-cypher-theme.ts → createCypherTheme.ts} +5 -1
- package/src/lang-cypher/{lang-cypher.ts → langCypher.ts} +16 -7
- package/src/lang-cypher/lintWorker.ts +14 -0
- package/src/lang-cypher/parser-adapter.ts +145 -0
- package/src/lang-cypher/signatureHelp.ts +102 -0
- package/src/lang-cypher/syntaxValidation.ts +99 -0
- package/src/{ndl-tokens-copy.test.ts → ndlTokensCopy.test.ts} +1 -1
- package/src/themes.ts +4 -2
- package/dist/cjs/index.cjs +0 -1441
- package/dist/cjs/index.cjs.map +0 -7
- package/dist/esm/index.mjs +0 -1464
- package/dist/esm/index.mjs.map +0 -7
- package/dist/types/e2e_tests/mock-data.d.ts +0 -3779
- package/dist/types/index.d.ts +0 -4
- package/dist/types/lang-cypher/ParserAdapter.d.ts +0 -14
- package/dist/types/lang-cypher/syntax-validation.d.ts +0 -3
- package/dist/types/tsconfig.tsbuildinfo +0 -1
- package/src/e2e_tests/mock-data.ts +0 -4310
- package/src/e2e_tests/performance-test.spec.tsx +0 -71
- package/src/lang-cypher/ParserAdapter.ts +0 -92
- package/src/lang-cypher/syntax-validation.ts +0 -24
- /package/dist/{types/e2e_tests/auto-completion.spec.d.ts → e2e_tests/autoCompletion.spec.d.ts} +0 -0
- /package/dist/{types/e2e_tests/e2e-utils.d.ts → e2e_tests/e2eUtils.d.ts} +0 -0
- /package/dist/{types/e2e_tests/extra-keybindings.spec.d.ts → e2e_tests/extraKeybindings.spec.d.ts} +0 -0
- /package/dist/{types/e2e_tests/history-navigation.spec.d.ts → e2e_tests/historyNavigation.spec.d.ts} +0 -0
- /package/dist/{types/e2e_tests/performance-test.spec.d.ts → e2e_tests/sanityChecks.spec.d.ts} +0 -0
- /package/dist/{types/e2e_tests/sanity-checks.spec.d.ts → e2e_tests/signatureHelp.spec.d.ts} +0 -0
- /package/dist/{types/e2e_tests/syntax-highlighting.spec.d.ts → e2e_tests/syntaxHighlighting.spec.d.ts} +0 -0
- /package/dist/{types/e2e_tests/syntax-validation.spec.d.ts → e2e_tests/syntaxValidation.spec.d.ts} +0 -0
- /package/dist/{types/history-navigation.d.ts → historyNavigation.d.ts} +0 -0
- /package/dist/{types/lang-cypher → lang-cypher}/contants.test.d.ts +0 -0
- /package/dist/{types/lang-cypher/create-cypher-theme.d.ts → lang-cypher/createCypherTheme.d.ts} +0 -0
- /package/dist/{types/lang-cypher/theme-icons.d.ts → lang-cypher/themeIcons.d.ts} +0 -0
- /package/dist/{types/ndl-tokens-copy.d.ts → ndlTokensCopy.d.ts} +0 -0
- /package/dist/{types/ndl-tokens-copy.test.d.ts → ndlTokensCopy.test.d.ts} +0 -0
- /package/dist/{types/neo4j-setup.d.ts → neo4jSetup.d.ts} +0 -0
- /package/src/e2e_tests/{e2e-utils.ts → e2eUtils.ts} +0 -0
- /package/src/{history-navigation.ts → historyNavigation.ts} +0 -0
- /package/src/lang-cypher/{theme-icons.ts → themeIcons.ts} +0 -0
- /package/src/{ndl-tokens-copy.ts → ndlTokensCopy.ts} +0 -0
- /package/src/{neo4j-setup.tsx → neo4jSetup.tsx} +0 -0
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { expect, test } from '@playwright/experimental-ct-react';
|
|
2
|
-
import { CypherEditor } from '../CypherEditor';
|
|
3
|
-
import { CypherEditorPage } from './e2e-utils';
|
|
4
|
-
import { largeQuery, mockSchema } from './mock-data';
|
|
5
|
-
|
|
6
|
-
test.use({ viewport: { width: 1000, height: 500 } });
|
|
7
|
-
|
|
8
|
-
test('performance test session ', async ({ mount, page }) => {
|
|
9
|
-
test.setTimeout(30 * 1000);
|
|
10
|
-
const editorPage = new CypherEditorPage(page);
|
|
11
|
-
const component = await mount(
|
|
12
|
-
<CypherEditor prompt="neo4j>" theme="dark" lint schema={mockSchema} />,
|
|
13
|
-
);
|
|
14
|
-
|
|
15
|
-
// pressSequentially is less efficient -> we want to test the performance of the editor
|
|
16
|
-
await editorPage.getEditor().pressSequentially(`
|
|
17
|
-
MATCH (n:Person) RETURN m;`);
|
|
18
|
-
|
|
19
|
-
await editorPage.checkErrorMessage('m', 'Variable `m` not defined');
|
|
20
|
-
|
|
21
|
-
// set and unset large query a few times
|
|
22
|
-
await component.update(
|
|
23
|
-
<CypherEditor value={largeQuery} schema={mockSchema} />,
|
|
24
|
-
);
|
|
25
|
-
await component.update(<CypherEditor value="" schema={mockSchema} />);
|
|
26
|
-
|
|
27
|
-
await component.update(
|
|
28
|
-
<CypherEditor value={largeQuery} schema={mockSchema} />,
|
|
29
|
-
);
|
|
30
|
-
await component.update(<CypherEditor value="" />);
|
|
31
|
-
|
|
32
|
-
await component.update(
|
|
33
|
-
<CypherEditor value={largeQuery} schema={mockSchema} />,
|
|
34
|
-
);
|
|
35
|
-
await component.update(<CypherEditor value="" schema={mockSchema} />);
|
|
36
|
-
|
|
37
|
-
await component.update(
|
|
38
|
-
<CypherEditor value={largeQuery} schema={mockSchema} />,
|
|
39
|
-
);
|
|
40
|
-
await component.update(<CypherEditor value="" schema={mockSchema} />);
|
|
41
|
-
|
|
42
|
-
await component.update(
|
|
43
|
-
<CypherEditor value={largeQuery} schema={mockSchema} />,
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
await editorPage.getEditor().pressSequentially(`
|
|
47
|
-
MATCH (n:P`);
|
|
48
|
-
|
|
49
|
-
await expect(
|
|
50
|
-
page.locator('.cm-tooltip-autocomplete').getByText('Person'),
|
|
51
|
-
).toBeVisible();
|
|
52
|
-
|
|
53
|
-
await page.locator('.cm-tooltip-autocomplete').getByText('Person').click();
|
|
54
|
-
|
|
55
|
-
await expect(page.locator('.cm-tooltip-autocomplete')).not.toBeVisible();
|
|
56
|
-
|
|
57
|
-
await expect(component).toContainText('MATCH (n:Person');
|
|
58
|
-
|
|
59
|
-
await editorPage.getEditor().pressSequentially(') RETRN my');
|
|
60
|
-
|
|
61
|
-
await expect(component).toContainText('MATCH (n:Person) RETRN m');
|
|
62
|
-
|
|
63
|
-
await editorPage.checkErrorMessage(
|
|
64
|
-
'RETRN',
|
|
65
|
-
'Unexpected token. Did you mean RETURN?',
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
await editorPage
|
|
69
|
-
.getEditor()
|
|
70
|
-
.pressSequentially('veryveryveryverylongvariable');
|
|
71
|
-
});
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { Facet } from '@codemirror/state';
|
|
2
|
-
import { Input, NodeType, Parser, PartialParse, Tree } from '@lezer/common';
|
|
3
|
-
import {
|
|
4
|
-
applySyntaxColouring,
|
|
5
|
-
CypherTokenType,
|
|
6
|
-
ParsedCypherToken,
|
|
7
|
-
} from '@neo4j-cypher/language-support';
|
|
8
|
-
import { cypherTokenTypeToNode, parserAdapterNodeSet } from './constants';
|
|
9
|
-
|
|
10
|
-
const DEFAULT_NODE_GROUP_SIZE = 4;
|
|
11
|
-
|
|
12
|
-
export class ParserAdapter extends Parser {
|
|
13
|
-
cypherTokenTypeToNode: Record<CypherTokenType, NodeType> & {
|
|
14
|
-
topNode: NodeType;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
constructor(facet: Facet<unknown>) {
|
|
18
|
-
super();
|
|
19
|
-
this.cypherTokenTypeToNode = cypherTokenTypeToNode(facet);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
private createBufferForTokens(tokens: ParsedCypherToken[]) {
|
|
23
|
-
return tokens.map((token) => {
|
|
24
|
-
const nodeTypeId = this.cypherTokenTypeToNode[token.tokenType].id;
|
|
25
|
-
const startOffset = token.position.startOffset;
|
|
26
|
-
const endOffset = token.position.startOffset + token.length;
|
|
27
|
-
|
|
28
|
-
return [nodeTypeId, startOffset, endOffset, DEFAULT_NODE_GROUP_SIZE];
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
private addTopNodeToBuffer(buffer: number[][], document: string) {
|
|
33
|
-
const id = this.cypherTokenTypeToNode.topNode.id;
|
|
34
|
-
const startOffset = 0;
|
|
35
|
-
const endOffset = document.length;
|
|
36
|
-
const totalBufferLength = buffer.length * DEFAULT_NODE_GROUP_SIZE;
|
|
37
|
-
|
|
38
|
-
buffer.push([
|
|
39
|
-
id,
|
|
40
|
-
startOffset,
|
|
41
|
-
endOffset,
|
|
42
|
-
totalBufferLength + DEFAULT_NODE_GROUP_SIZE,
|
|
43
|
-
]);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
private buildTree(document: string) {
|
|
47
|
-
const tokens = applySyntaxColouring(document);
|
|
48
|
-
|
|
49
|
-
if (tokens.length < 1) {
|
|
50
|
-
return Tree.build({
|
|
51
|
-
buffer: [
|
|
52
|
-
this.cypherTokenTypeToNode.topNode.id,
|
|
53
|
-
0,
|
|
54
|
-
document.length,
|
|
55
|
-
DEFAULT_NODE_GROUP_SIZE,
|
|
56
|
-
],
|
|
57
|
-
nodeSet: parserAdapterNodeSet(this.cypherTokenTypeToNode),
|
|
58
|
-
topID: this.cypherTokenTypeToNode.topNode.id,
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const buffer = this.createBufferForTokens(tokens);
|
|
63
|
-
this.addTopNodeToBuffer(buffer, document);
|
|
64
|
-
|
|
65
|
-
return Tree.build({
|
|
66
|
-
buffer: buffer.flat(),
|
|
67
|
-
nodeSet: parserAdapterNodeSet(this.cypherTokenTypeToNode),
|
|
68
|
-
topID: this.cypherTokenTypeToNode.topNode.id,
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
createParse(input: Input): PartialParse {
|
|
73
|
-
return this.startParse(input);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/* There are more arguments, but since we don't do any incremental parsing, they are not useful */
|
|
77
|
-
startParse(input: string | Input): PartialParse {
|
|
78
|
-
const document =
|
|
79
|
-
typeof input === 'string' ? input : input.read(0, input.length);
|
|
80
|
-
|
|
81
|
-
const tree = this.buildTree(document);
|
|
82
|
-
|
|
83
|
-
return {
|
|
84
|
-
stoppedAt: input.length,
|
|
85
|
-
parsedPos: input.length,
|
|
86
|
-
stopAt: () => {
|
|
87
|
-
return undefined;
|
|
88
|
-
},
|
|
89
|
-
advance: () => tree,
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { linter } from '@codemirror/lint';
|
|
2
|
-
import { Extension } from '@codemirror/state';
|
|
3
|
-
import { validateSyntax } from '@neo4j-cypher/language-support';
|
|
4
|
-
import { DiagnosticSeverity } from 'vscode-languageserver-types';
|
|
5
|
-
import type { CypherConfig } from './lang-cypher';
|
|
6
|
-
|
|
7
|
-
export const cypherLinter: (config: CypherConfig) => Extension = (config) =>
|
|
8
|
-
linter((view) => {
|
|
9
|
-
if (!config.lint) {
|
|
10
|
-
return [];
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
return validateSyntax(view.state.doc.toString(), config.schema).map(
|
|
14
|
-
(diagnostic) => ({
|
|
15
|
-
from: diagnostic.offsets.start,
|
|
16
|
-
to: diagnostic.offsets.end,
|
|
17
|
-
severity:
|
|
18
|
-
diagnostic.severity === DiagnosticSeverity.Error
|
|
19
|
-
? 'error'
|
|
20
|
-
: 'warning',
|
|
21
|
-
message: diagnostic.message,
|
|
22
|
-
}),
|
|
23
|
-
);
|
|
24
|
-
});
|
/package/dist/{types/e2e_tests/auto-completion.spec.d.ts → e2e_tests/autoCompletion.spec.d.ts}
RENAMED
|
File without changes
|
|
File without changes
|
/package/dist/{types/e2e_tests/extra-keybindings.spec.d.ts → e2e_tests/extraKeybindings.spec.d.ts}
RENAMED
|
File without changes
|
/package/dist/{types/e2e_tests/history-navigation.spec.d.ts → e2e_tests/historyNavigation.spec.d.ts}
RENAMED
|
File without changes
|
/package/dist/{types/e2e_tests/performance-test.spec.d.ts → e2e_tests/sanityChecks.spec.d.ts}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/{types/e2e_tests/syntax-validation.spec.d.ts → e2e_tests/syntaxValidation.spec.d.ts}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/{types/lang-cypher/create-cypher-theme.d.ts → lang-cypher/createCypherTheme.d.ts}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|