@neo4j-cypher/react-codemirror 2.0.0-alpha.0 → 2.0.0-canary-a1ed8f3

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 (122) hide show
  1. package/CHANGELOG.md +68 -0
  2. package/LICENSE.md +201 -0
  3. package/README.md +27 -4
  4. package/dist/CypherEditor.d.ts +153 -0
  5. package/dist/CypherEditor.js +242 -0
  6. package/dist/CypherEditor.js.map +1 -0
  7. package/dist/e2e_tests/autoCompletion.spec.d.ts +1 -0
  8. package/dist/e2e_tests/autoCompletion.spec.js +133 -0
  9. package/dist/e2e_tests/autoCompletion.spec.js.map +1 -0
  10. package/dist/e2e_tests/configuration.spec.d.ts +1 -0
  11. package/dist/e2e_tests/configuration.spec.js +73 -0
  12. package/dist/e2e_tests/configuration.spec.js.map +1 -0
  13. package/dist/e2e_tests/e2eUtils.d.ts +12 -0
  14. package/dist/e2e_tests/e2eUtils.js +60 -0
  15. package/dist/e2e_tests/e2eUtils.js.map +1 -0
  16. package/dist/e2e_tests/extraKeybindings.spec.d.ts +1 -0
  17. package/dist/e2e_tests/extraKeybindings.spec.js +44 -0
  18. package/dist/e2e_tests/extraKeybindings.spec.js.map +1 -0
  19. package/dist/e2e_tests/historyNavigation.spec.d.ts +1 -0
  20. package/dist/e2e_tests/historyNavigation.spec.js +136 -0
  21. package/dist/e2e_tests/historyNavigation.spec.js.map +1 -0
  22. package/dist/e2e_tests/performanceTest.spec.d.ts +6 -0
  23. package/dist/e2e_tests/performanceTest.spec.js +96 -0
  24. package/dist/e2e_tests/performanceTest.spec.js.map +1 -0
  25. package/dist/e2e_tests/sanityChecks.spec.d.ts +1 -0
  26. package/dist/e2e_tests/sanityChecks.spec.js +56 -0
  27. package/dist/e2e_tests/sanityChecks.spec.js.map +1 -0
  28. package/dist/e2e_tests/signatureHelp.spec.d.ts +1 -0
  29. package/dist/e2e_tests/signatureHelp.spec.js +152 -0
  30. package/dist/e2e_tests/signatureHelp.spec.js.map +1 -0
  31. package/dist/e2e_tests/snippets.spec.d.ts +1 -0
  32. package/dist/e2e_tests/snippets.spec.js +63 -0
  33. package/dist/e2e_tests/snippets.spec.js.map +1 -0
  34. package/dist/e2e_tests/syntaxHighlighting.spec.d.ts +1 -0
  35. package/dist/e2e_tests/syntaxHighlighting.spec.js +91 -0
  36. package/dist/e2e_tests/syntaxHighlighting.spec.js.map +1 -0
  37. package/dist/e2e_tests/syntaxValidation.spec.d.ts +1 -0
  38. package/dist/e2e_tests/syntaxValidation.spec.js +79 -0
  39. package/dist/e2e_tests/syntaxValidation.spec.js.map +1 -0
  40. package/dist/historyNavigation.d.ts +7 -0
  41. package/dist/historyNavigation.js +163 -0
  42. package/dist/historyNavigation.js.map +1 -0
  43. package/dist/icons.d.ts +2 -0
  44. package/dist/icons.js +62 -0
  45. package/dist/icons.js.map +1 -0
  46. package/dist/index.d.ts +4 -0
  47. package/dist/index.js +5 -0
  48. package/dist/index.js.map +1 -0
  49. package/dist/lang-cypher/autocomplete.d.ts +3 -0
  50. package/dist/lang-cypher/autocomplete.js +62 -0
  51. package/dist/lang-cypher/autocomplete.js.map +1 -0
  52. package/dist/lang-cypher/constants.d.ts +40 -0
  53. package/dist/lang-cypher/constants.js +65 -0
  54. package/dist/lang-cypher/constants.js.map +1 -0
  55. package/dist/lang-cypher/contants.test.d.ts +1 -0
  56. package/dist/lang-cypher/contants.test.js +102 -0
  57. package/dist/lang-cypher/contants.test.js.map +1 -0
  58. package/dist/lang-cypher/createCypherTheme.d.ts +26 -0
  59. package/dist/lang-cypher/createCypherTheme.js +172 -0
  60. package/dist/lang-cypher/createCypherTheme.js.map +1 -0
  61. package/dist/lang-cypher/langCypher.d.ts +9 -0
  62. package/dist/lang-cypher/langCypher.js +24 -0
  63. package/dist/lang-cypher/langCypher.js.map +1 -0
  64. package/dist/lang-cypher/lintWorker.d.ts +8 -0
  65. package/dist/lang-cypher/lintWorker.js +4 -0
  66. package/dist/lang-cypher/lintWorker.js.map +1 -0
  67. package/dist/lang-cypher/parser-adapter.d.ts +19 -0
  68. package/dist/lang-cypher/parser-adapter.js +113 -0
  69. package/dist/lang-cypher/parser-adapter.js.map +1 -0
  70. package/dist/lang-cypher/signatureHelp.d.ts +4 -0
  71. package/dist/lang-cypher/signatureHelp.js +93 -0
  72. package/dist/lang-cypher/signatureHelp.js.map +1 -0
  73. package/dist/lang-cypher/syntaxValidation.d.ts +5 -0
  74. package/dist/lang-cypher/syntaxValidation.js +71 -0
  75. package/dist/lang-cypher/syntaxValidation.js.map +1 -0
  76. package/dist/lang-cypher/themeIcons.d.ts +7 -0
  77. package/dist/lang-cypher/themeIcons.js +22 -0
  78. package/dist/lang-cypher/themeIcons.js.map +1 -0
  79. package/dist/ndlTokensCopy.d.ts +379 -0
  80. package/dist/ndlTokensCopy.js +380 -0
  81. package/dist/ndlTokensCopy.js.map +1 -0
  82. package/dist/ndlTokensCopy.test.d.ts +1 -0
  83. package/dist/ndlTokensCopy.test.js +11 -0
  84. package/dist/ndlTokensCopy.test.js.map +1 -0
  85. package/dist/neo4jSetup.d.ts +2 -0
  86. package/dist/neo4jSetup.js +120 -0
  87. package/dist/neo4jSetup.js.map +1 -0
  88. package/dist/themes.d.ts +11 -0
  89. package/dist/themes.js +114 -0
  90. package/dist/themes.js.map +1 -0
  91. package/dist/tsconfig.tsbuildinfo +1 -0
  92. package/package.json +46 -16
  93. package/src/CypherEditor.tsx +461 -0
  94. package/src/e2e_tests/autoCompletion.spec.tsx +236 -0
  95. package/src/e2e_tests/configuration.spec.tsx +97 -0
  96. package/src/e2e_tests/e2eUtils.ts +85 -0
  97. package/src/e2e_tests/extraKeybindings.spec.tsx +57 -0
  98. package/src/e2e_tests/historyNavigation.spec.tsx +196 -0
  99. package/src/e2e_tests/performanceTest.spec.tsx +158 -0
  100. package/src/e2e_tests/sanityChecks.spec.tsx +78 -0
  101. package/src/e2e_tests/signatureHelp.spec.tsx +309 -0
  102. package/src/e2e_tests/snippets.spec.tsx +94 -0
  103. package/src/e2e_tests/syntaxHighlighting.spec.tsx +198 -0
  104. package/src/e2e_tests/syntaxValidation.spec.tsx +156 -0
  105. package/src/historyNavigation.ts +191 -0
  106. package/{esm/index.mjs → src/icons.ts} +37 -1283
  107. package/src/index.ts +4 -0
  108. package/src/lang-cypher/autocomplete.ts +81 -0
  109. package/src/lang-cypher/constants.ts +84 -0
  110. package/src/lang-cypher/contants.test.ts +104 -0
  111. package/src/lang-cypher/createCypherTheme.ts +240 -0
  112. package/src/lang-cypher/langCypher.ts +41 -0
  113. package/src/lang-cypher/lintWorker.ts +14 -0
  114. package/src/lang-cypher/parser-adapter.ts +145 -0
  115. package/src/lang-cypher/signatureHelp.ts +131 -0
  116. package/src/lang-cypher/syntaxValidation.ts +99 -0
  117. package/src/lang-cypher/themeIcons.ts +27 -0
  118. package/src/ndlTokensCopy.test.ts +11 -0
  119. package/src/ndlTokensCopy.ts +379 -0
  120. package/src/neo4jSetup.tsx +179 -0
  121. package/src/themes.ts +132 -0
  122. package/dist/index.cjs +0 -1330
@@ -0,0 +1,62 @@
1
+ import { snippet } from '@codemirror/autocomplete';
2
+ import { autocomplete } from '@neo4j-cypher/language-support';
3
+ import { CompletionItemKind } from 'vscode-languageserver-types';
4
+ const completionKindToCodemirrorIcon = (c) => {
5
+ const map = {
6
+ [CompletionItemKind.Text]: 'Text',
7
+ [CompletionItemKind.Method]: 'Method',
8
+ [CompletionItemKind.Function]: 'Function',
9
+ [CompletionItemKind.Constructor]: 'Constructor',
10
+ [CompletionItemKind.Field]: 'Field',
11
+ [CompletionItemKind.Variable]: 'Variable',
12
+ [CompletionItemKind.Class]: 'Class',
13
+ [CompletionItemKind.Interface]: 'Interface',
14
+ [CompletionItemKind.Module]: 'Module',
15
+ [CompletionItemKind.Property]: 'Property',
16
+ [CompletionItemKind.Unit]: 'Unit',
17
+ [CompletionItemKind.Value]: 'Value',
18
+ [CompletionItemKind.Enum]: 'Enum',
19
+ [CompletionItemKind.Keyword]: 'Keyword',
20
+ [CompletionItemKind.Snippet]: 'Snippet',
21
+ [CompletionItemKind.Color]: 'Color',
22
+ [CompletionItemKind.File]: 'File',
23
+ [CompletionItemKind.Reference]: 'Reference',
24
+ [CompletionItemKind.Folder]: 'Folder',
25
+ [CompletionItemKind.EnumMember]: 'EnumMember',
26
+ [CompletionItemKind.Constant]: 'Constant',
27
+ [CompletionItemKind.Struct]: 'Struct',
28
+ // we're miss-using the enum here as there is no `Console` kind in the predefined list
29
+ [CompletionItemKind.Event]: 'Console',
30
+ [CompletionItemKind.Operator]: 'Operator',
31
+ [CompletionItemKind.TypeParameter]: 'TypeParameter',
32
+ };
33
+ return map[c];
34
+ };
35
+ export const cypherAutocomplete = (config) => (context) => {
36
+ const textUntilCursor = context.state.doc.toString().slice(0, context.pos);
37
+ const triggerCharacters = ['.', ':', '{', '$', ')'];
38
+ const lastCharacter = textUntilCursor.slice(-1);
39
+ const lastWord = context.matchBefore(/\w*/);
40
+ const inWord = lastWord.from !== lastWord.to;
41
+ const shouldTriggerCompletion = inWord || context.explicit || triggerCharacters.includes(lastCharacter);
42
+ if (config.useLightVersion && !context.explicit) {
43
+ return null;
44
+ }
45
+ if (!shouldTriggerCompletion) {
46
+ return null;
47
+ }
48
+ const options = autocomplete(textUntilCursor, config.schema ?? {}, undefined, context.explicit);
49
+ return {
50
+ from: context.matchBefore(/(\w|\$)*$/).from,
51
+ options: options.map((o) => ({
52
+ label: o.label,
53
+ type: completionKindToCodemirrorIcon(o.kind),
54
+ apply: o.kind === CompletionItemKind.Snippet
55
+ ? // codemirror requires an empty snippet space to be able to tab out of the completion
56
+ snippet((o.insertText ?? o.label) + '${}')
57
+ : undefined,
58
+ detail: o.detail,
59
+ })),
60
+ };
61
+ };
62
+ //# sourceMappingURL=autocomplete.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"autocomplete.js","sourceRoot":"","sources":["../../src/lang-cypher/autocomplete.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,OAAO,EAAE,M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ACnB,SAAS,EACT,OAAO,CAAC,QAAQ,CACjB,CAAC;IAEF,OAAO;QACL,IAAI,EAAE,OAAO,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,IAAI;QAC3C,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YAC3B,KAAK,EAAE,CAAC,CAAC,KAAK;YACd,IAAI,EAAE,8BAA8B,CAAC,CAAC,CAAC,IAAI,CAAC;YAC5C,KAAK,EACH,CAAC,CAAC,IAAI,KAAK,kBAAkB,CAAC,OAAO;gBACnC,CAAC,CAAC,qFAAqF;oBACrF,OAAO,CAAC,CAAC,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC;gBAC5C,CAAC,CAAC,SAAS;YACf,MAAM,EAAE,CAAC,CAAC,MAAM;SACjB,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,40 @@
1
+ import type { Facet } from '@codemirror/state';
2
+ import { NodeSet, NodeType } from '@lezer/common';
3
+ import { Tag } from '@lezer/highlight';
4
+ import { CypherTokenType } from '@neo4j-cypher/language-support';
5
+ export declare const cypherTokenTypeToNode: (facet: Facet<unknown>) => {
6
+ topNode: NodeType;
7
+ comment: NodeType;
8
+ keyword: NodeType;
9
+ label: NodeType;
10
+ predicateFunction: NodeType;
11
+ function: NodeType;
12
+ procedure: NodeType;
13
+ variable: NodeType;
14
+ paramDollar: NodeType;
15
+ paramValue: NodeType;
16
+ symbolicName: NodeType;
17
+ operator: NodeType;
18
+ stringLiteral: NodeType;
19
+ numberLiteral: NodeType;
20
+ booleanLiteral: NodeType;
21
+ keywordLiteral: NodeType;
22
+ property: NodeType;
23
+ namespace: NodeType;
24
+ bracket: NodeType;
25
+ none: NodeType;
26
+ separator: NodeType;
27
+ punctuation: NodeType;
28
+ consoleCommand: NodeType;
29
+ 'class-name': NodeType;
30
+ identifier: NodeType;
31
+ string: NodeType;
32
+ relationship: NodeType;
33
+ boolean: NodeType;
34
+ number: NodeType;
35
+ };
36
+ export type PrismSpecificTokenType = 'class-name' | 'identifier' | 'string' | 'relationship' | 'boolean' | 'number';
37
+ export type CodemirrorParseTokenType = CypherTokenType | PrismSpecificTokenType | 'topNode';
38
+ export type HighlightedCypherTokenTypes = Exclude<CypherTokenType, 'none'>;
39
+ export declare const tokenTypeToStyleTag: Record<HighlightedCypherTokenTypes, Tag>;
40
+ export declare const parserAdapterNodeSet: (nodes: Record<string, NodeType>) => NodeSet;
@@ -0,0 +1,65 @@
1
+ import { languageDataProp } from '@codemirror/language';
2
+ import { NodeSet, NodeType } from '@lezer/common';
3
+ import { styleTags, tags } from '@lezer/highlight';
4
+ export const cypherTokenTypeToNode = (facet) => ({
5
+ topNode: NodeType.define({
6
+ id: 0,
7
+ name: 'topNode',
8
+ props: [languageDataProp.add({ topNode: facet })],
9
+ }),
10
+ comment: NodeType.define({ id: 1, name: 'comment' }),
11
+ keyword: NodeType.define({ id: 2, name: 'keyword' }),
12
+ label: NodeType.define({ id: 3, name: 'label' }),
13
+ predicateFunction: NodeType.define({ id: 4, name: 'predicateFunction' }),
14
+ function: NodeType.define({ id: 5, name: 'function' }),
15
+ procedure: NodeType.define({ id: 6, name: 'procedure' }),
16
+ variable: NodeType.define({ id: 7, name: 'variable' }),
17
+ paramDollar: NodeType.define({ id: 8, name: 'paramDollar' }),
18
+ paramValue: NodeType.define({ id: 9, name: 'paramValue' }),
19
+ symbolicName: NodeType.define({ id: 10, name: 'symbolicName' }),
20
+ operator: NodeType.define({ id: 11, name: 'operator' }),
21
+ stringLiteral: NodeType.define({ id: 12, name: 'stringLiteral' }),
22
+ numberLiteral: NodeType.define({ id: 13, name: 'numberLiteral' }),
23
+ booleanLiteral: NodeType.define({ id: 14, name: 'booleanLiteral' }),
24
+ keywordLiteral: NodeType.define({ id: 15, name: 'keywordLiteral' }),
25
+ property: NodeType.define({ id: 16, name: 'property' }),
26
+ namespace: NodeType.define({ id: 17, name: 'namespace' }),
27
+ bracket: NodeType.define({ id: 18, name: 'bracket' }),
28
+ none: NodeType.define({ id: 19, name: 'none' }),
29
+ separator: NodeType.define({ id: 20, name: 'separator' }),
30
+ punctuation: NodeType.define({ id: 21, name: 'punctuation' }),
31
+ consoleCommand: NodeType.define({ id: 22, name: 'consoleCommand' }),
32
+ // also include prism token types
33
+ 'class-name': NodeType.define({ id: 23, name: 'label' }),
34
+ // this is escaped variables
35
+ identifier: NodeType.define({ id: 24, name: 'variable' }),
36
+ string: NodeType.define({ id: 25, name: 'stringLiteral' }),
37
+ relationship: NodeType.define({ id: 26, name: 'label' }),
38
+ boolean: NodeType.define({ id: 27, name: 'booleanLiteral' }),
39
+ number: NodeType.define({ id: 28, name: 'numberLiteral' }),
40
+ });
41
+ export const tokenTypeToStyleTag = {
42
+ comment: tags.comment,
43
+ keyword: tags.keyword,
44
+ label: tags.typeName,
45
+ predicateFunction: tags.function(tags.variableName),
46
+ function: tags.function(tags.variableName),
47
+ procedure: tags.function(tags.variableName),
48
+ variable: tags.variableName,
49
+ paramDollar: tags.atom,
50
+ paramValue: tags.atom,
51
+ symbolicName: tags.variableName,
52
+ operator: tags.operator,
53
+ stringLiteral: tags.string,
54
+ numberLiteral: tags.number,
55
+ booleanLiteral: tags.bool,
56
+ keywordLiteral: tags.operatorKeyword,
57
+ property: tags.propertyName,
58
+ namespace: tags.namespace,
59
+ bracket: tags.bracket,
60
+ punctuation: tags.punctuation,
61
+ separator: tags.separator,
62
+ consoleCommand: tags.macroName,
63
+ };
64
+ export const parserAdapterNodeSet = (nodes) => new NodeSet(Object.values(nodes)).extend(styleTags(tokenTypeToStyleTag));
65
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/lang-cypher/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,OAAO,EAAE,OAAO,EAAE,QA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AC3C,QAAQ,EAAE,IAAI,CAAC,YAAY;IAC3B,WAAW,EAAE,IAAI,CAAC,IAAI;IACtB,UAAU,EAAE,IAAI,CAAC,IAAI;IACrB,YAAY,EAAE,IAAI,CAAC,YAAY;IAC/B,QAAQ,EAAE,IAAI,CAAC,QAAQ;IACvB,aAAa,EAAE,IAAI,CAAC,MAAM;IAC1B,aAAa,EAAE,IAAI,CAAC,MAAM;IAC1B,cAAc,EAAE,IAAI,CAAC,IAAI;IACzB,cAAc,EAAE,IAAI,CAAC,eAAe;IACpC,QAAQ,EAAE,IAAI,CAAC,YAAY;IAC3B,SAAS,EAAE,IAAI,CAAC,SAAS;IACzB,OAAO,EAAE,IAAI,CAAC,OAAO;IACrB,WAAW,EAAE,IAAI,CAAC,WAAW;IAC7B,SAAS,EAAE,IAAI,CAAC,SAAS;IACzB,cAAc,EAAE,IAAI,CAAC,SAAS;CAC/B,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,KAA+B,EAAE,EAAE,CACtE,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,mBAAmB,CAAC,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,102 @@
1
+ import { tags } from '@lezer/highlight';
2
+ import { applySyntaxColouring } from '@neo4j-cypher/language-support';
3
+ import { tokenTypeToStyleTag } from './constants';
4
+ const cypherQueryWithAllTokenTypes = `MATCH (variable :Label)-[:REL_TYPE]->()
5
+ WHERE variable.property = "String"
6
+ OR namespaced.function() = false
7
+ // comment
8
+ OR $parameter > 2
9
+ RETURN variable;`;
10
+ test('correctly parses all cypher token types to style tags', () => {
11
+ const tokens = applySyntaxColouring(cypherQueryWithAllTokenTypes);
12
+ const tokenTypes = tokens.map((token) => token.tokenType);
13
+ expect(tokenTypes).toEqual([
14
+ 'keyword',
15
+ 'bracket',
16
+ 'variable',
17
+ 'operator',
18
+ 'label',
19
+ 'bracket',
20
+ 'separator',
21
+ 'bracket',
22
+ 'operator',
23
+ 'label',
24
+ 'bracket',
25
+ 'separator',
26
+ 'separator',
27
+ 'bracket',
28
+ 'bracket',
29
+ 'keyword',
30
+ 'variable',
31
+ 'operator',
32
+ 'property',
33
+ 'operator',
34
+ 'stringLiteral',
35
+ 'keyword',
36
+ 'function',
37
+ 'operator',
38
+ 'function',
39
+ 'bracket',
40
+ 'bracket',
41
+ 'operator',
42
+ 'booleanLiteral',
43
+ 'comment',
44
+ 'keyword',
45
+ 'paramDollar',
46
+ 'paramValue',
47
+ 'operator',
48
+ 'numberLiteral',
49
+ 'keyword',
50
+ 'variable',
51
+ 'punctuation',
52
+ ]);
53
+ const styleTags = tokenTypes.map((tokenType) => {
54
+ if (tokenType === 'none')
55
+ return undefined;
56
+ return tokenTypeToStyleTag[tokenType];
57
+ });
58
+ const correctTags = [
59
+ tags.keyword,
60
+ tags.bracket,
61
+ tags.variableName,
62
+ tags.operator,
63
+ tags.typeName,
64
+ tags.bracket,
65
+ tags.separator,
66
+ tags.bracket,
67
+ tags.operator,
68
+ tags.typeName,
69
+ tags.bracket,
70
+ tags.separator,
71
+ tags.separator,
72
+ tags.bracket,
73
+ tags.bracket,
74
+ tags.keyword,
75
+ tags.variableName,
76
+ tags.operator,
77
+ tags.propertyName,
78
+ tags.operator,
79
+ tags.string,
80
+ tags.keyword,
81
+ tags.function(tags.variableName),
82
+ tags.operator,
83
+ tags.function(tags.variableName),
84
+ tags.bracket,
85
+ tags.bracket,
86
+ tags.operator,
87
+ tags.bool,
88
+ tags.comment,
89
+ tags.keyword,
90
+ tags.atom,
91
+ tags.atom,
92
+ tags.operator,
93
+ tags.number,
94
+ tags.keyword,
95
+ tags.variableName,
96
+ tags.punctuation,
97
+ ];
98
+ styleTags.forEach((styleTag, index) => {
99
+ expect(styleTag).toEqual(correctTags[index]);
100
+ });
101
+ });
102
+ //# sourceMappingURL=contants.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contants.test.js","sourceRoot":"","sources":["../../src/lang-cypher/contants.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAElD,MAAM,4BAA4B,GAAG;;;;;iBAKpB,CAAC;AAElB,IAAI,CAAC,uDAAuD,EAAE,GAAG,EAAE;IACjE,MAAM,MAAM,GAAG,oBAAoB,CAAC,4BAA4B,CAAC,CAAC;IAClE,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAC1D,MAAM,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC;QACzB,SAAS;QACT,SAAS;QACT,UAAU;QACV,UAAU;QACV,OAAO;QACP,SAAS;QACT,WAAW;QACX,SAAS;QACT,UAAU;QACV,OAAO;QACP,SAAS;QACT,WAAW;QACX,WAAW;QACX,SAAS;QACT,SAAS;QACT,SAAS;QACT,UAAU;QACV,UAAU;QACV,UAAU;QACV,UAAU;QACV,eAAe;QACf,SAAS;QACT,UAAU;QACV,UAAU;QACV,UAAU;QACV,SAAS;QACT,SAAS;QACT,UAAU;QACV,gBAAgB;QAChB,SAAS;QACT,SAAS;QACT,aAAa;QACb,YAAY;QACZ,UAAU;QACV,eAAe;QACf,SAAS;QACT,UAAU;QACV,aAAa;KACd,CAAC,CAAC;IAEH,MAAM,SAAS,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE;QAC7C,IAAI,SAAS,KAAK,MAAM;YAAE,OAAO,SAAS,CAAC;QAC3C,OAAO,mBAAmB,CAAC,SAAS,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;IACH,MAAM,WAAW,GAAG;QAClB,IAAI,CAAC,OAAO;QACZ,IAAI,CAAC,OAAO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4
+ dark: boolean;
5
+ editorSettings: {
6
+ background: string;
7
+ foreground: string;
8
+ gutterForeground: string;
9
+ cursor: string;
10
+ selection: string;
11
+ textMatchingSelection: string;
12
+ searchPanel: {
13
+ background: string;
14
+ text: string;
15
+ buttonHoverBackground: string;
16
+ };
17
+ autoCompletionPanel: {
18
+ selectedColor: string;
19
+ backgroundColor: string;
20
+ matchingTextColor: string;
21
+ };
22
+ };
23
+ highlightStyles: Partial<Record<HighlightedCypherTokenTypes, string>>;
24
+ inheritBgColor?: boolean;
25
+ }
26
+ export declare const createCypherTheme: ({ dark, editorSettings: settings, highlightStyles, inheritBgColor, }: ThemeOptions) => Extension;
@@ -0,0 +1,172 @@
1
+ import { HighlightStyle, syntaxHighlighting, } from '@codemirror/language';
2
+ import { EditorView } from '@codemirror/view';
3
+ import { tokenTypeToStyleTag } from './constants';
4
+ import { byWordSvg, caseSensitiveSvg, downArrowSvg, regexSvg, replaceAllSvg, replaceSvg, upArrowSvg, } from './themeIcons';
5
+ export const createCypherTheme = ({ dark, editorSettings: settings, highlightStyles, inheritBgColor, }) => {
6
+ const themeOptions = {
7
+ '&': {
8
+ backgroundColor: inheritBgColor ? 'inherit' : settings.background,
9
+ color: settings.foreground,
10
+ fontVariantLigatures: 'none',
11
+ },
12
+ '& .cm-snippetField': {
13
+ backgroundColor: settings.autoCompletionPanel.selectedColor,
14
+ },
15
+ '&.cm-focused': {
16
+ outline: 'none',
17
+ },
18
+ '.cm-gutters': {
19
+ backgroundColor: inheritBgColor ? 'inherit' : settings.background,
20
+ color: settings.gutterForeground,
21
+ border: 'none',
22
+ },
23
+ '&.cm-editor': {
24
+ fontFamily: 'Fira Code, Menlo, Monaco, Lucida Console, monospace',
25
+ height: '100%',
26
+ },
27
+ '.cm-content': {
28
+ caretColor: settings.cursor,
29
+ },
30
+ '.cm-cursor, .cm-dropCursor': {
31
+ borderLeftColor: settings.cursor,
32
+ },
33
+ '.cm-activeLine ::not(::selection)': {
34
+ backgroundColor: settings.background,
35
+ },
36
+ '&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection ': {
37
+ backgroundColor: settings.selection,
38
+ },
39
+ '& .cm-selectionMatch': {
40
+ backgroundColor: settings.textMatchingSelection,
41
+ },
42
+ '& .cm-bold': {
43
+ fontWeight: 'bold',
44
+ },
45
+ '& .cm-panels': {
46
+ backgroundColor: settings.searchPanel.background,
47
+ fontFamily: 'Fira Code, Menlo, Monaco, Lucida Console, monospace',
48
+ },
49
+ '& .cm-completionLabel': {
50
+ fontFamily: 'Fira Code, Menlo, Monaco, Lucida Console, monospace',
51
+ verticalAlign: 'middle',
52
+ },
53
+ '& .cm-completionMatchedText': {
54
+ fontWeight: 'bold',
55
+ color: settings.autoCompletionPanel.matchingTextColor,
56
+ textDecoration: 'none',
57
+ },
58
+ '& .cm-signature-help-panel': {
59
+ backgroundColor: settings.autoCompletionPanel.backgroundColor,
60
+ maxWidth: '700px',
61
+ maxHeight: '250px',
62
+ fontFamily: 'Fira Code, Menlo, Monaco, Lucida Console, monospace',
63
+ },
64
+ '& .cm-signature-help-panel-contents': {
65
+ overflow: 'auto',
66
+ maxHeight: '100%',
67
+ },
68
+ '& .cm-signature-help-panel-current-argument': {
69
+ color: settings.autoCompletionPanel.matchingTextColor,
70
+ fontWeight: 'bold',
71
+ },
72
+ '& .cm-signature-help-panel-separator': {
73
+ borderBottom: '1px solid #ccc',
74
+ },
75
+ '& .cm-signature-help-panel-name': {
76
+ padding: '5px',
77
+ },
78
+ '& .cm-signature-help-panel-description': {
79
+ padding: '5px',
80
+ },
81
+ '.cm-tooltip-autocomplete': {
82
+ maxWidth: '430px',
83
+ '& > ul > li[aria-selected]': {
84
+ backgroundColor: settings.autoCompletionPanel.selectedColor,
85
+ color: settings.foreground,
86
+ },
87
+ '& > ul': {
88
+ backgroundColor: settings.autoCompletionPanel.backgroundColor,
89
+ color: settings.foreground,
90
+ },
91
+ },
92
+ '& .cm-search.cm-panel': {
93
+ '& input': {
94
+ fontFamily: 'Fira Code, Menlo, Monaco, Lucida Console, monospace',
95
+ },
96
+ backgroundColor: settings.searchPanel.background,
97
+ color: settings.searchPanel.text,
98
+ '& .cm-button[name=select]': { display: 'none' },
99
+ '& .cm-button': {
100
+ backgroundImage: 'none',
101
+ color: settings.searchPanel.text,
102
+ fontSize: 0,
103
+ border: 'none',
104
+ verticalAlign: 'middle',
105
+ '&[name=next]::before': {
106
+ content: `url("data:image/svg+xml;base64,${window.btoa(downArrowSvg)}")`,
107
+ },
108
+ '&[name=prev]::before': {
109
+ content: `url("data:image/svg+xml;base64,${window.btoa(upArrowSvg)}")`,
110
+ },
111
+ '&[name=replace]::before': {
112
+ content: `url("data:image/svg+xml;base64,${window.btoa(replaceSvg)}")`,
113
+ },
114
+ '&[name=replaceAll]::before': {
115
+ content: `url("data:image/svg+xml;base64,${window.btoa(replaceAllSvg)}")`,
116
+ },
117
+ width: '20px',
118
+ height: '20px',
119
+ marginRight: '1px',
120
+ marginLeft: '1px',
121
+ borderRadius: '4px',
122
+ padding: '2px',
123
+ '&:hover': {
124
+ backgroundColor: settings.searchPanel.buttonHoverBackground,
125
+ },
126
+ },
127
+ '& label': {
128
+ fontSize: '0',
129
+ height: '20px',
130
+ width: '20px',
131
+ verticalAlign: 'middle',
132
+ "& input[type='checkbox']": {
133
+ cursor: 'pointer',
134
+ appearance: 'none',
135
+ marginRight: '1px',
136
+ marginLeft: '1px',
137
+ padding: '2px',
138
+ height: '20px',
139
+ width: '20px',
140
+ verticalAlign: 'middle',
141
+ display: 'inline-flex',
142
+ borderRadius: '4px',
143
+ '&[name=case]::before': {
144
+ content: `url("data:image/svg+xml;base64,${window.btoa(caseSensitiveSvg)}")`,
145
+ },
146
+ '&[name=re]::before': {
147
+ content: `url("data:image/svg+xml;base64,${window.btoa(regexSvg)}")`,
148
+ },
149
+ '&[name=word]::before': {
150
+ content: `url("data:image/svg+xml;base64,${window.btoa(byWordSvg)}")`,
151
+ },
152
+ '&:hover': {
153
+ backgroundColor: settings.searchPanel.buttonHoverBackground,
154
+ },
155
+ '&:checked': {
156
+ backgroundColor: settings.searchPanel.buttonHoverBackground,
157
+ },
158
+ },
159
+ },
160
+ },
161
+ };
162
+ const themeExtension = EditorView.theme(themeOptions, { dark });
163
+ const styles = Object.entries(highlightStyles).map(([token, color]) => ({
164
+ tag: tokenTypeToStyleTag[token],
165
+ color,
166
+ class: token === 'consoleCommand' ? 'cm-bold' : undefined,
167
+ }));
168
+ const highlightStyle = HighlightStyle.define(styles);
169
+ const extension = [themeExtension, syntaxHighlighting(highlightStyle)];
170
+ return extension;
171
+ };
172
+ //# sourceMappingURL=createCypherTheme.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createCypherTheme.js","sourceRoot":"","sources":["../../src/lang-cypher/createCypherTheme.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,kBAAkB,GAEnB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAA+B,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAC/E,OAAO,EACL,SAAS,EACT,gBAAgB,EAChB,YAAY,EACZ,QAAQ,EACR,aAAa,EACb,UAAU,EACV,UAAU,GACX,MAAM,cAAc,CAAC;AA0BtB,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,EAChC,IAAI,EACJ,cAAc,EAAE,QAAQ,EACxB,eAAe,EACf,cAAc,GACD,EAAa,EAAE;IAC5B,MAAM,YAAY,GAA8B;QAC9C,GAAG,EAAE;YACH,eAAe,EAAE,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,UAAU;YACjE,KAAK,EAAE,QAAQ,CAAC,UAAU;YAC1B,oBAAoB,EAAE,MAAM;SAC7B;QACD,oBAAoB,EAAE;YACpB,eAAe,EAAE,QAAQ,CAAC,mBAAmB,CAAC,aAAa;SAC5D;QACD,cAAc,EAAE;YAC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,OAAO,CAAC,eAAe,CAAC,CAAC,GAAG,CAChD,CAAC,CAAC,KAAK,EAAE,KAAK,CAAwC,EAAY,EAAE,CAAC,CAAC;QACpE,GAAG,EAAE,mBAAmB,CAAC,KAAK,CAAC;QAC/B,KAAK;QACL,KAAK,EAAE,KAAK,KAAK,gBAAgB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS;KAC1D,CAAC,CACH,CAAC;IACF,MAAM,cAAc,GAAG,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACrD,MAAM,SAAS,GAAG,CAAC,cAAc,EAAE,kBAAkB,CAAC,cAAc,CAAC,CAAC,CAAC;IAEvE,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { LanguageSupport } from '@codemirror/language';
2
+ import { type DbSchema } from '@neo4j-cypher/language-support';
3
+ export type CypherConfig = {
4
+ lint?: boolean;
5
+ schema?: DbSchema;
6
+ useLightVersion: boolean;
7
+ setUseLightVersion?: (useLightVersion: boolean) => void;
8
+ };
9
+ export declare function cypher(config: CypherConfig): LanguageSupport;
@@ -0,0 +1,24 @@
1
+ import { defineLanguageFacet, Language, LanguageSupport, } from '@codemirror/language';
2
+ import { setConsoleCommandsEnabled, } from '@neo4j-cypher/language-support';
3
+ import { cypherAutocomplete } from './autocomplete';
4
+ import { ParserAdapter } from './parser-adapter';
5
+ import { signatureHelpTooltip } from './signatureHelp';
6
+ import { cypherLinter, semanticAnalysisLinter } from './syntaxValidation';
7
+ const facet = defineLanguageFacet({
8
+ commentTokens: { block: { open: '/*', close: '*/' }, line: '//' },
9
+ closeBrackets: { brackets: ['(', '[', '{', "'", '"', '`'] },
10
+ });
11
+ export function cypher(config) {
12
+ setConsoleCommandsEnabled(true);
13
+ const parserAdapter = new ParserAdapter(facet, config);
14
+ const cypherLanguage = new Language(facet, parserAdapter, [], 'cypher');
15
+ return new LanguageSupport(cypherLanguage, [
16
+ cypherLanguage.data.of({
17
+ autocomplete: cypherAutocomplete(config),
18
+ }),
19
+ cypherLinter(config),
20
+ semanticAnalysisLinter(config),
21
+ signatureHelpTooltip(config),
22
+ ]);
23
+ }
24
+ //# sourceMappingURL=langCypher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"langCypher.js","sourceRoot":"","sources":["../../src/lang-cypher/langCypher.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,QAAQ,EACR,eAAe,GAChB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,yBAAyB,GAE1B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAE1E,MAAM,KAAK,GAAG,mBAAmB,CAAC;IAChC,aAAa,EAAE,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE;IACjE,aAAa,EAAE,EAAE,QAAQ,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE;CAC5D,CAAC,CAAC;AASH,MAAM,UAAU,MAAM,CAAC,MAAoB;IACzC,yBAAyB,CAAC,IAAI,CAAC,CAAC;IAChC,MAAM,aAAa,GAAG,IAAI,aAAa,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAEvD,MAAM,cAAc,GAAG,IAAI,QAAQ,CAAC,KAAK,EAAE,aAAa,EAAE,EAAE,EAAE,QAAQ,CAAC,CAAC;IAExE,OAAO,IAAI,eAAe,CAAC,cAAc,EAAE;QACzC,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC;YACrB,YAAY,EAAE,kBAAkB,CAAC,MAAM,CAAC;SACzC,CAAC;QACF,YAAY,CAAC,MAAM,CAAC;QACpB,sBAAsB,CAAC,MAAM,CAAC;QAC9B,oBAAoB,CAAC,MAAM,CAAC;KAC7B,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { validateSemantics } from '@neo4j-cypher/language-support';
2
+ import workerpool from 'workerpool';
3
+ type LinterArgs = Parameters<typeof validateSemantics>;
4
+ export type LinterTask = workerpool.Promise<ReturnType<typeof validateSemantics>>;
5
+ export type LintWorker = {
6
+ validateSemantics: (...args: LinterArgs) => LinterTask;
7
+ };
8
+ export {};
@@ -0,0 +1,4 @@
1
+ import { validateSemantics } from '@neo4j-cypher/language-support';
2
+ import workerpool from 'workerpool';
3
+ workerpool.worker({ validateSemantics });
4
+ //# sourceMappingURL=lintWorker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lintWorker.js","sourceRoot":"","sources":["../../src/lang-cypher/lintWorker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC,UAAU,CAAC,MAAM,CAAC,EAAE,iBAAiB,EAAE,CAAC,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { Facet } from '@codemirror/state';
2
+ import { Input, NodeType, Parser, PartialParse } from '@lezer/common';
3
+ import { CodemirrorParseTokenType } from './constants';
4
+ import 'prismjs/components/prism-cypher';
5
+ import { CypherConfig } from './langCypher';
6
+ export declare class ParserAdapter extends Parser {
7
+ private config;
8
+ cypherTokenTypeToNode: Record<CodemirrorParseTokenType, NodeType>;
9
+ constructor(facet: Facet<unknown>, config: CypherConfig);
10
+ createParse(input: Input): PartialParse;
11
+ startParse(input: string | Input): PartialParse;
12
+ private buildTree;
13
+ private antlrParse;
14
+ private prismParse;
15
+ private createBufferForAntlrTokens;
16
+ private createBufferForPrismTokens;
17
+ private createEmptyTree;
18
+ private addTopNodeToBuffer;
19
+ }