@neo4j-cypher/react-codemirror 2.0.0-next.4 → 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 +11 -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 +31 -5
- 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 -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/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,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
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/{types/e2e_tests/performance-test.spec.d.ts → e2e_tests/signature-help.spec.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
|
|
File without changes
|
|
File without changes
|