@valtzu/codemirror-lang-el 0.1.13 → 0.2.1
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/README.md +23 -6
- package/dist/index.cjs +9 -13
- package/dist/index.d.cts +10 -2
- package/dist/index.d.ts +10 -2
- package/dist/index.js +9 -13
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,18 +1,35 @@
|
|
|
1
1
|
# Symfony Expression Language support for CodeMirror
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
### Example
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
```html
|
|
9
|
+
<div id="editor"></div>
|
|
10
|
+
<script type="importmap">
|
|
11
|
+
{
|
|
12
|
+
"imports": {
|
|
13
|
+
"codemirror": "https://esm.sh/codemirror@6.0.1",
|
|
14
|
+
"@codemirror/autocomplete": "https://esm.sh/@codemirror/autocomplete@6.9.0",
|
|
15
|
+
"@codemirror/view": "https://esm.sh/@codemirror/view@6.17.1",
|
|
16
|
+
"@valtzu/codemirror-lang-el": "https://esm.sh/@valtzu/codemirror-lang-el@0.1.13"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
</script>
|
|
20
|
+
<script type="module">
|
|
4
21
|
import {EditorView, basicSetup} from "codemirror";
|
|
5
22
|
import { expressionlanguage } from "@valtzu/codemirror-lang-el";
|
|
6
23
|
import {acceptCompletion} from "@codemirror/autocomplete";
|
|
7
|
-
import {keymap} from "@codemirror/view"
|
|
24
|
+
import {keymap} from "@codemirror/view";
|
|
8
25
|
|
|
9
26
|
let editor = new EditorView({
|
|
10
27
|
extensions: [
|
|
11
|
-
keymap.of([{key: "Tab", run: acceptCompletion}]),
|
|
12
28
|
basicSetup,
|
|
29
|
+
keymap.of([{key: "Tab", run: acceptCompletion}]),
|
|
13
30
|
expressionlanguage({ identifiers: ['foo', 'bar'], functions: {'smh': [], smash_my_head: ['object']} })
|
|
14
|
-
],
|
|
15
|
-
parent: document.
|
|
31
|
+
],
|
|
32
|
+
parent: document.getElementById('editor'),
|
|
16
33
|
});
|
|
17
|
-
|
|
34
|
+
</script>
|
|
18
35
|
```
|
package/dist/index.cjs
CHANGED
|
@@ -20,7 +20,7 @@ const parser = lr.LRParser.deserialize({
|
|
|
20
20
|
],
|
|
21
21
|
skippedNodes: [0],
|
|
22
22
|
repeatNodeCount: 2,
|
|
23
|
-
tokenData: "
|
|
23
|
+
tokenData: "By~R!QXY$XYZ$X]^$Xpq$Xqr$jrs%Puv$zvw&{wx'Txy(xyz(}z{)S{|$z|})[}!O$z!O!P)a!P!Q$z!Q![*r![!],R!^!_$r!_!`,Y!`!a$r!a!b,`!c!},u!}#O-Y#P#Q-_#Q#R$z#R#S,u#T#U-d#U#V,u#V#W.}#W#X,u#X#Y2q#Y#Z5e#Z#],u#]#^8P#^#a,u#a#b8j#b#c;Y#c#d>s#d#g,u#g#h?^#h#iAc#i#o,u#o#pBg#p#qBl#q#rBt#r#s$z~$^Sf~XY$XYZ$X]^$Xpq$X~$oPV~!_!`$r~$wPV~!_!`$z~%POV~R%SXOr%Prs%os#O%P#O#P%v#P;'S%P;'S;=`&u<%l~%P~O%P~~%oR%vO]QSPR%yRO;'S%P;'S;=`&S;=`O%PR&VYOr%Prs%os#O%P#O#P%v#P;'S%P;'S;=`&u;=`<%l%P<%l~%P~O%P~~%oR&xP;=`<%l%P~'QPV~vw$zR'WXOw'Twx%ox#O'T#O#P's#P;'S'T;'S;=`(r<%l~'T~O'T~~%oR'vRO;'S'T;'S;=`(P;=`O'TR(SYOw'Twx%ox#O'T#O#P's#P;'S'T;'S;=`(r;=`<%l'T<%l~'T~O'T~~%oR(uP;=`<%l'T~(}O`~~)SO_~~)XPV~z{$z~)aOk~~)fQXP!O!P$z!Q![)l~)qSQ~!Q![)l!g!h)}#R#S*l#X#Y)}~*QR{|*Z}!O*Z!Q![*a~*^P!Q![*a~*fQQ~!Q![*a#R#S*Z~*oP!Q![)l~*wTQ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#o,uR8WU]QRP!Q![,u!c!},u#R#S,u#T#b,u#b#c.h#c#o,uR8qT]QRP!Q![,u!c!},u#R#S,u#T#U9Q#U#o,uR9XU]QRP!Q![,u!c!},u#R#S,u#T#h,u#h#i9k#i#o,uR9rU]QRP!Q![,u!c!},u#R#S,u#T#V,u#V#W:U#W#o,uR:]U]QRP!Q![,u!c!},u#R#S,u#T#[,u#[#]:o#]#o,uR:vU]QRP!Q![,u!c!},u#R#S,u#T#X,u#X#Y2W#Y#o,uR;aW]QRP!Q![,u!c!},u#R#S,u#T#c,u#c#d;y#d#i,u#i#j=Y#j#o,uR<QU]QRP!Q![,u!c!},u#R#S,u#T#h,u#h#i<d#i#o,uR<mT]QWPRPpq<|!Q![,u!c!},u#R#S,u#T#o,uP=PP#]#^=SP=VP#b#c5`R=aU]QRP!Q![,u!c!},u#R#S,u#T#`,u#`#a=s#a#o,uR=zU]QRP!Q![,u!c!},u#R#S,u#T#`,u#`#a>^#a#o,uR>gS]QUPRP!Q![,u!c!},u#R#S,u#T#o,uR>zU]QRP!Q![,u!c!},u#R#S,u#T#f,u#f#g.h#g#o,uR?eU]QRP!Q![,u!c!},u#R#S,u#T#h,u#h#i?w#i#o,uR@OT]QRP!Q![,u!c!},u#R#S,u#T#U@_#U#o,uR@fU]QRP!Q![,u!c!},u#R#S,u#T#f,u#f#g@x#g#o,uRAPU]QRP!Q![,u!c!},u#R#S,u#T#h,u#h#i3u#i#o,uRAjU]QRP!Q![,u!c!},u#R#S,u#T#f,u#f#gA|#g#o,uRBTU]QRP!Q![,u!c!},u#R#S,u#T#i,u#i#j7P#j#o,u~BlOi~~BqPV~#p#q$z~ByOh~",
|
|
24
24
|
tokenizers: [0, 1],
|
|
25
25
|
topRules: {"Program":[0,1]},
|
|
26
26
|
tokenPrec: 118
|
|
@@ -66,16 +66,16 @@ function completeOperatorKeyword(state, config, tree, from, to) {
|
|
|
66
66
|
};
|
|
67
67
|
}
|
|
68
68
|
function completeIdentifier(state, config, tree, from, to) {
|
|
69
|
-
var _a, _b, _c, _d, _e;
|
|
69
|
+
var _a, _b, _c, _d, _e, _f;
|
|
70
70
|
const text = state.sliceDoc(from, to);
|
|
71
|
-
const identifiers = (_b = (_a = config.identifiers) === null || _a === void 0 ? void 0 : _a.filter(
|
|
72
|
-
const functions =
|
|
71
|
+
const identifiers = (_b = (_a = config.identifiers) === null || _a === void 0 ? void 0 : _a.filter(({ name }) => name.startsWith(text))) !== null && _b !== void 0 ? _b : [];
|
|
72
|
+
const functions = (_d = (_c = config.functions) === null || _c === void 0 ? void 0 : _c.filter(({ name }) => name.startsWith(text))) !== null && _d !== void 0 ? _d : [];
|
|
73
73
|
return {
|
|
74
74
|
from,
|
|
75
75
|
to,
|
|
76
76
|
options: [
|
|
77
|
-
...((
|
|
78
|
-
...((
|
|
77
|
+
...((_e = identifiers.map(({ name, info, detail }) => ({ label: name, info, detail, type: 'variable' }))) !== null && _e !== void 0 ? _e : []),
|
|
78
|
+
...((_f = functions.map(({ name, args = [], info }) => ({ label: name, detail: `(${args.join(',')})`, apply: `${name}(${args.length == 0 ? ')' : ''}`, info, type: "function" }))) !== null && _f !== void 0 ? _f : []),
|
|
79
79
|
],
|
|
80
80
|
validFor: identifier,
|
|
81
81
|
};
|
|
@@ -83,13 +83,9 @@ function completeIdentifier(state, config, tree, from, to) {
|
|
|
83
83
|
function expressionLanguageCompletionFor(config, context) {
|
|
84
84
|
let { state, pos } = context;
|
|
85
85
|
let tree = language.syntaxTree(state).resolveInner(pos, -1);
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
// if (!last || !last.type.isError || last.from < last.to) break;
|
|
90
|
-
// around = tree = before;
|
|
91
|
-
// scan = last.from;
|
|
92
|
-
// }
|
|
86
|
+
if (tree.name == 'String') {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
93
89
|
if (tree.prevSibling && !['Operator', 'OperatorKeyword', 'Punctuation', 'NullSafe', 'NullCoalescing'].includes(tree.prevSibling.name)) {
|
|
94
90
|
return completeOperatorKeyword(state, config, tree, tree.from, pos);
|
|
95
91
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import { LRLanguage, LanguageSupport } from "@codemirror/language";
|
|
2
2
|
interface ExpressionLanguageConfig {
|
|
3
|
-
identifiers?: readonly
|
|
4
|
-
|
|
3
|
+
identifiers?: readonly {
|
|
4
|
+
name: string;
|
|
5
|
+
detail?: string;
|
|
6
|
+
info?: string;
|
|
7
|
+
}[];
|
|
8
|
+
functions?: readonly {
|
|
9
|
+
name: string;
|
|
10
|
+
args: string[];
|
|
11
|
+
info?: string;
|
|
12
|
+
}[];
|
|
5
13
|
operatorKeywords?: readonly string[];
|
|
6
14
|
}
|
|
7
15
|
declare const ELLanguage: LRLanguage;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import { LRLanguage, LanguageSupport } from "@codemirror/language";
|
|
2
2
|
interface ExpressionLanguageConfig {
|
|
3
|
-
identifiers?: readonly
|
|
4
|
-
|
|
3
|
+
identifiers?: readonly {
|
|
4
|
+
name: string;
|
|
5
|
+
detail?: string;
|
|
6
|
+
info?: string;
|
|
7
|
+
}[];
|
|
8
|
+
functions?: readonly {
|
|
9
|
+
name: string;
|
|
10
|
+
args: string[];
|
|
11
|
+
info?: string;
|
|
12
|
+
}[];
|
|
5
13
|
operatorKeywords?: readonly string[];
|
|
6
14
|
}
|
|
7
15
|
declare const ELLanguage: LRLanguage;
|
package/dist/index.js
CHANGED
|
@@ -16,7 +16,7 @@ const parser = LRParser.deserialize({
|
|
|
16
16
|
],
|
|
17
17
|
skippedNodes: [0],
|
|
18
18
|
repeatNodeCount: 2,
|
|
19
|
-
tokenData: "
|
|
19
|
+
tokenData: "By~R!QXY$XYZ$X]^$Xpq$Xqr$jrs%Puv$zvw&{wx'Txy(xyz(}z{)S{|$z|})[}!O$z!O!P)a!P!Q$z!Q![*r![!],R!^!_$r!_!`,Y!`!a$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#i#o,uR<mT]QWPRPpq<|!Q![,u!c!},u#R#S,u#T#o,uP=PP#]#^=SP=VP#b#c5`R=aU]QRP!Q![,u!c!},u#R#S,u#T#`,u#`#a=s#a#o,uR=zU]QRP!Q![,u!c!},u#R#S,u#T#`,u#`#a>^#a#o,uR>gS]QUPRP!Q![,u!c!},u#R#S,u#T#o,uR>zU]QRP!Q![,u!c!},u#R#S,u#T#f,u#f#g.h#g#o,uR?eU]QRP!Q![,u!c!},u#R#S,u#T#h,u#h#i?w#i#o,uR@OT]QRP!Q![,u!c!},u#R#S,u#T#U@_#U#o,uR@fU]QRP!Q![,u!c!},u#R#S,u#T#f,u#f#g@x#g#o,uRAPU]QRP!Q![,u!c!},u#R#S,u#T#h,u#h#i3u#i#o,uRAjU]QRP!Q![,u!c!},u#R#S,u#T#f,u#f#gA|#g#o,uRBTU]QRP!Q![,u!c!},u#R#S,u#T#i,u#i#j7P#j#o,u~BlOi~~BqPV~#p#q$z~ByOh~",
|
|
20
20
|
tokenizers: [0, 1],
|
|
21
21
|
topRules: {"Program":[0,1]},
|
|
22
22
|
tokenPrec: 118
|
|
@@ -62,16 +62,16 @@ function completeOperatorKeyword(state, config, tree, from, to) {
|
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
64
|
function completeIdentifier(state, config, tree, from, to) {
|
|
65
|
-
var _a, _b, _c, _d, _e;
|
|
65
|
+
var _a, _b, _c, _d, _e, _f;
|
|
66
66
|
const text = state.sliceDoc(from, to);
|
|
67
|
-
const identifiers = (_b = (_a = config.identifiers) === null || _a === void 0 ? void 0 : _a.filter(
|
|
68
|
-
const functions =
|
|
67
|
+
const identifiers = (_b = (_a = config.identifiers) === null || _a === void 0 ? void 0 : _a.filter(({ name }) => name.startsWith(text))) !== null && _b !== void 0 ? _b : [];
|
|
68
|
+
const functions = (_d = (_c = config.functions) === null || _c === void 0 ? void 0 : _c.filter(({ name }) => name.startsWith(text))) !== null && _d !== void 0 ? _d : [];
|
|
69
69
|
return {
|
|
70
70
|
from,
|
|
71
71
|
to,
|
|
72
72
|
options: [
|
|
73
|
-
...((
|
|
74
|
-
...((
|
|
73
|
+
...((_e = identifiers.map(({ name, info, detail }) => ({ label: name, info, detail, type: 'variable' }))) !== null && _e !== void 0 ? _e : []),
|
|
74
|
+
...((_f = functions.map(({ name, args = [], info }) => ({ label: name, detail: `(${args.join(',')})`, apply: `${name}(${args.length == 0 ? ')' : ''}`, info, type: "function" }))) !== null && _f !== void 0 ? _f : []),
|
|
75
75
|
],
|
|
76
76
|
validFor: identifier,
|
|
77
77
|
};
|
|
@@ -79,13 +79,9 @@ function completeIdentifier(state, config, tree, from, to) {
|
|
|
79
79
|
function expressionLanguageCompletionFor(config, context) {
|
|
80
80
|
let { state, pos } = context;
|
|
81
81
|
let tree = syntaxTree(state).resolveInner(pos, -1);
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
// if (!last || !last.type.isError || last.from < last.to) break;
|
|
86
|
-
// around = tree = before;
|
|
87
|
-
// scan = last.from;
|
|
88
|
-
// }
|
|
82
|
+
if (tree.name == 'String') {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
89
85
|
if (tree.prevSibling && !['Operator', 'OperatorKeyword', 'Punctuation', 'NullSafe', 'NullCoalescing'].includes(tree.prevSibling.name)) {
|
|
90
86
|
return completeOperatorKeyword(state, config, tree, tree.from, pos);
|
|
91
87
|
}
|
package/package.json
CHANGED