codemirror-lang-glimmer 0.0.0-beta.4 → 0.0.0
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/.eslintrc.cjs +2 -2
- package/.turbo/turbo-build.log +5 -21
- package/.turbo/turbo-lint$colon$js$colon$fix.log +7 -0
- package/.turbo/turbo-lint$colon$js.log +7 -0
- package/.turbo/turbo-lint$colon$prettier$colon$fix.log +15 -0
- package/.turbo/turbo-lint$colon$prettier.log +9 -0
- package/.turbo/turbo-lint$colon$types.log +5 -0
- package/CHANGELOG.md +8 -0
- package/LICENSE +21 -0
- package/dev/.eslintcache +1 -0
- package/dev/.eslintrc.cjs +2 -2
- package/dev/CHANGELOG.md +3 -0
- package/dev/index.html +1 -1
- package/dev/index.ts +43 -3
- package/dev/node_modules/.bin/eslint +4 -4
- package/dev/node_modules/.bin/prettier +4 -4
- package/dev/node_modules/.bin/tsc +4 -4
- package/dev/node_modules/.bin/tsserver +4 -4
- package/dev/node_modules/.bin/vite +4 -4
- package/dev/package.json +27 -15
- package/dev/watch.cjs +3 -3
- package/dist/index.cjs +287 -386
- package/dist/index.d.cts +22 -4
- package/dist/index.d.ts +22 -4
- package/dist/index.js +287 -388
- package/package.json +42 -26
- package/src/auto-close.ts +91 -0
- package/src/glimmer.ts +79 -0
- package/src/index.ts +3 -132
- package/src/language.ts +176 -0
- package/src/snippets.ts +48 -0
- package/tsconfig.json +2 -1
- package/.eslintignore +0 -2
- package/.prettierignore +0 -2
- package/.prettierrc.cjs +0 -20
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/src/highlight.ts +0 -57
- package/src/syntax.grammar +0 -139
- package/src/syntax.grammar.d.ts +0 -3
- package/src/syntax.grammar.terms.d.ts +0 -14
- package/src/tokens.ts +0 -277
- package/tests/.eslintrc.cjs +0 -5
- package/tests/comments.txt +0 -116
- package/tests/complex.txt +0 -24
- package/tests/expression.txt +0 -95
- package/tests/literals.txt +0 -78
- package/tests/node_modules/.bin/eslint +0 -17
- package/tests/node_modules/.bin/prettier +0 -17
- package/tests/node_modules/.bin/tsc +0 -17
- package/tests/node_modules/.bin/tsserver +0 -17
- package/tests/numbers.txt +0 -88
- package/tests/package.json +0 -25
- package/tests/property-paths.txt +0 -79
- package/tests/strings.txt +0 -64
package/dist/index.cjs
CHANGED
|
@@ -1,407 +1,308 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var autocomplete = require('@codemirror/autocomplete');
|
|
4
|
+
var langCss = require('@codemirror/lang-css');
|
|
3
5
|
var langHtml = require('@codemirror/lang-html');
|
|
6
|
+
var langJavascript = require('@codemirror/lang-javascript');
|
|
4
7
|
var language = require('@codemirror/language');
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
8
|
+
var state = require('@codemirror/state');
|
|
9
|
+
var lezerGlimmerExpression = require('@glimdown/lezer-glimmer-expression');
|
|
10
|
+
var view = require('@codemirror/view');
|
|
11
|
+
var lezerGlimmer = require('lezer-glimmer');
|
|
9
12
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
13
|
+
const defaultNesting = [
|
|
14
|
+
{
|
|
15
|
+
tag: 'script',
|
|
16
|
+
attrs: (attrs) => attrs['type'] === 'text/typescript' || attrs['lang'] === 'ts',
|
|
17
|
+
parser: langJavascript.typescriptLanguage.parser,
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
tag: 'script',
|
|
21
|
+
attrs(attrs) {
|
|
22
|
+
return (!attrs['type'] ||
|
|
23
|
+
/^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i.test(attrs['type']));
|
|
24
|
+
},
|
|
25
|
+
parser: langJavascript.javascriptLanguage.parser,
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
tag: 'style',
|
|
29
|
+
attrs( /* attrs */) {
|
|
30
|
+
return true;
|
|
31
|
+
// Always use CSS. We can add varying support later
|
|
32
|
+
// return (
|
|
33
|
+
// (!attrs['lang'] || attrs['lang'] === 'css' || attrs['lang'] === 'scss') &&
|
|
34
|
+
// (!attrs['type'] || /^(text\/)?(x-)?(stylesheet|css|scss)$/i.test(attrs['type']))
|
|
35
|
+
// );
|
|
36
|
+
},
|
|
37
|
+
parser: langCss.cssLanguage.parser,
|
|
38
|
+
},
|
|
39
|
+
];
|
|
40
|
+
const glimmerPlain = language.LRLanguage.define({
|
|
41
|
+
parser: lezerGlimmer.glimmerParser.configure({
|
|
42
|
+
props: [
|
|
43
|
+
language.indentNodeProp.add({
|
|
44
|
+
Element: (context) => {
|
|
45
|
+
let after = /^(\s*)(<\/)?/.exec(context.textAfter);
|
|
46
|
+
if (!after)
|
|
47
|
+
return null;
|
|
48
|
+
if (context.node.to <= context.pos + after[0].length)
|
|
49
|
+
return context.continue();
|
|
50
|
+
return context.lineIndent(context.node.from) + (after[2] ? 0 : context.unit);
|
|
51
|
+
},
|
|
52
|
+
Block: (context) => {
|
|
53
|
+
const node = context.node;
|
|
54
|
+
const text = context.textAfter.trim();
|
|
55
|
+
if (text.startsWith('{/')) {
|
|
56
|
+
const name = node.name;
|
|
57
|
+
if ((name === 'IfBlock' && text.startsWith('{/if')) ||
|
|
58
|
+
(name === 'UnlessBlock' && text.startsWith('{/unless')) ||
|
|
59
|
+
(name === 'InElementBlock' && text.startsWith('{/in-element')) ||
|
|
60
|
+
(name === 'EachBlock' && text.startsWith('{/each')) ||
|
|
61
|
+
(name === 'EachInBlock' && text.startsWith('{/each-in')) ||
|
|
62
|
+
(name === 'LetBlock' && text.startsWith('{/let'))) {
|
|
63
|
+
return context.lineIndent(context.node.from);
|
|
64
|
+
}
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
if (node.name === 'IfBlock' ||
|
|
68
|
+
node.name === 'EachBlock' ||
|
|
69
|
+
node.name === 'EachInBlock' ||
|
|
70
|
+
node.name === 'UnlessBlock') {
|
|
71
|
+
if (text.startsWith('{{:else'))
|
|
72
|
+
return context.lineIndent(node.from);
|
|
73
|
+
if (text.startsWith('{{else'))
|
|
74
|
+
return context.lineIndent(node.from);
|
|
75
|
+
}
|
|
76
|
+
// not sure if this needed to be duplicated
|
|
77
|
+
let after = /^(\s*)(<\/)?/.exec(context.textAfter);
|
|
78
|
+
if (!after)
|
|
79
|
+
return null;
|
|
80
|
+
if (context.node.to <= context.pos + after[0].length)
|
|
81
|
+
return context.continue();
|
|
82
|
+
return context.lineIndent(context.node.from) + (after[2] ? 0 : context.unit);
|
|
83
|
+
},
|
|
84
|
+
'BlockOpen BlockClose BlockInline': (context) => {
|
|
85
|
+
return context.column(context.node.from) + context.unit;
|
|
86
|
+
},
|
|
87
|
+
'OpenTag CloseTag SelfClosingTag': (context) => {
|
|
88
|
+
return context.column(context.node.from) + context.unit;
|
|
89
|
+
},
|
|
90
|
+
Document: (context) => {
|
|
91
|
+
var _a, _b;
|
|
92
|
+
if (context.pos + (((_b = (_a = /\s*/.exec(context.textAfter)) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.length) || 0) < context.node.to) {
|
|
93
|
+
return context.continue();
|
|
94
|
+
}
|
|
95
|
+
let endElt = null;
|
|
96
|
+
let close;
|
|
97
|
+
for (let cur = context.node;;) {
|
|
98
|
+
let last = cur.lastChild;
|
|
99
|
+
if (!last || last.name != 'Element' || last.to != cur.to)
|
|
100
|
+
break;
|
|
101
|
+
endElt = cur = last;
|
|
102
|
+
}
|
|
103
|
+
if (endElt &&
|
|
104
|
+
!((close = endElt.lastChild) &&
|
|
105
|
+
(close.name === 'CloseTag' || close.name === 'SelfClosingTag'))) {
|
|
106
|
+
return context.lineIndent(endElt.from) + context.unit;
|
|
107
|
+
}
|
|
108
|
+
return null;
|
|
109
|
+
},
|
|
110
|
+
}),
|
|
111
|
+
language.foldNodeProp.add({
|
|
112
|
+
Block: (node) => {
|
|
113
|
+
const open = `${node.name}Open`;
|
|
114
|
+
const close = `${node.name}Close`;
|
|
115
|
+
const first = node.firstChild;
|
|
116
|
+
const last = node.lastChild;
|
|
117
|
+
if (!first || first.name !== open)
|
|
118
|
+
return null;
|
|
119
|
+
return { from: first.to, to: (last === null || last === void 0 ? void 0 : last.name) === close ? last.from : node.to };
|
|
120
|
+
},
|
|
121
|
+
Element: (node) => {
|
|
122
|
+
let first = node.firstChild;
|
|
123
|
+
let last = node.lastChild;
|
|
124
|
+
if (!last)
|
|
125
|
+
return null;
|
|
126
|
+
if (!first || first.name != 'OpenTag')
|
|
127
|
+
return null;
|
|
128
|
+
return { from: first.to, to: last.name === 'CloseTag' ? last.from : node.to };
|
|
129
|
+
},
|
|
130
|
+
}),
|
|
131
|
+
],
|
|
132
|
+
}),
|
|
133
|
+
languageData: {
|
|
134
|
+
commentTokens: {
|
|
135
|
+
block: { open: '<!--', close: '-->' },
|
|
136
|
+
moustacheLong: { open: '{{!--', close: '--}}' },
|
|
137
|
+
},
|
|
138
|
+
indentOnInput: /^\s*((<\/\w+\W)|(\{\{:?(else|then|catch))|(\{\{\/(if|each|each-in|in-element|unless|let)))$/,
|
|
139
|
+
wordChars: '-._',
|
|
140
|
+
},
|
|
77
141
|
});
|
|
78
|
-
const
|
|
79
|
-
|
|
142
|
+
const glimmerLanguage = glimmerPlain.configure({
|
|
143
|
+
wrap: lezerGlimmer.configureNesting(defaultNesting),
|
|
80
144
|
});
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
if (input.next === backslash) {
|
|
93
|
-
inStringIgnoreNext = true;
|
|
94
|
-
return true;
|
|
95
|
-
}
|
|
96
|
-
if (inStringType === 'double' && input.next === quoteDouble) {
|
|
97
|
-
inString = false;
|
|
98
|
-
inStringType = null;
|
|
99
|
-
return true;
|
|
100
|
-
}
|
|
101
|
-
if (inStringType === 'single' && input.next === quoteSingle) {
|
|
102
|
-
inString = false;
|
|
103
|
-
inStringType = null;
|
|
104
|
-
return true;
|
|
105
|
-
}
|
|
106
|
-
if (inStringType === 'template' && input.next === tick) {
|
|
107
|
-
inString = false;
|
|
108
|
-
inStringType = null;
|
|
109
|
-
return true;
|
|
110
|
-
}
|
|
111
|
-
return true;
|
|
112
|
-
}
|
|
113
|
-
if (input.next === quoteDouble) {
|
|
114
|
-
inString = true;
|
|
115
|
-
inStringType = 'double';
|
|
116
|
-
return true;
|
|
117
|
-
}
|
|
118
|
-
if (input.next === quoteSingle) {
|
|
119
|
-
inString = true;
|
|
120
|
-
inStringType = 'single';
|
|
121
|
-
return true;
|
|
122
|
-
}
|
|
123
|
-
if (input.next === tick) {
|
|
124
|
-
inString = true;
|
|
125
|
-
inStringType = 'template';
|
|
126
|
-
return true;
|
|
127
|
-
}
|
|
128
|
-
return false;
|
|
129
|
-
};
|
|
145
|
+
|
|
146
|
+
// unfortunately the HTML language explicitly checks for the language type,
|
|
147
|
+
// so we have to duplicate the entire autoCloseTags extension
|
|
148
|
+
function elementName(doc, tree, max = doc.length) {
|
|
149
|
+
if (!tree)
|
|
150
|
+
return '';
|
|
151
|
+
let tag = tree.firstChild;
|
|
152
|
+
let name = tag &&
|
|
153
|
+
(tag.getChild('TagName') || tag.getChild('ComponentName') || tag.getChild('SvelteElementName'));
|
|
154
|
+
return name ? doc.sliceString(name.from, Math.min(name.to, max)) : '';
|
|
130
155
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
156
|
+
const autoCloseTags = view.EditorView.inputHandler.of((view, from, to, text) => {
|
|
157
|
+
if (view.composing ||
|
|
158
|
+
view.state.readOnly ||
|
|
159
|
+
from != to ||
|
|
160
|
+
(text != '>' && text != '/') ||
|
|
161
|
+
!glimmerLanguage.isActiveAt(view.state, from, -1))
|
|
162
|
+
return false;
|
|
163
|
+
let { state: state$1 } = view;
|
|
164
|
+
const noChanges = { range: undefined, changes: undefined, effects: undefined };
|
|
165
|
+
let changes = state$1.changeByRange((range) => {
|
|
166
|
+
var _a, _b, _c;
|
|
167
|
+
let { head } = range;
|
|
168
|
+
let around = language.syntaxTree(state$1).resolveInner(head, -1);
|
|
169
|
+
let name;
|
|
170
|
+
if (around.name === 'TagName' ||
|
|
171
|
+
around.name === 'ComponentName' ||
|
|
172
|
+
around.name === 'StartTag') {
|
|
173
|
+
if (!around.parent)
|
|
174
|
+
return Object.assign(Object.assign({}, noChanges), { range });
|
|
175
|
+
around = around.parent;
|
|
141
176
|
}
|
|
142
|
-
if (
|
|
143
|
-
if (
|
|
144
|
-
|
|
145
|
-
|
|
177
|
+
if (text === '>' && around.name === 'OpenTag') {
|
|
178
|
+
if (((_b = (_a = around.parent) === null || _a === void 0 ? void 0 : _a.lastChild) === null || _b === void 0 ? void 0 : _b.name) != 'CloseTag' &&
|
|
179
|
+
(name = elementName(state$1.doc, around.parent, head))) {
|
|
180
|
+
let hasRightBracket = view.state.doc.sliceString(head, head + 1) === '>';
|
|
181
|
+
let insert = `${hasRightBracket ? '' : '>'}</${name}>`;
|
|
182
|
+
return {
|
|
183
|
+
range: state.EditorSelection.cursor(head + 1),
|
|
184
|
+
changes: { from: head + (hasRightBracket ? 1 : 0), insert },
|
|
185
|
+
};
|
|
146
186
|
}
|
|
147
|
-
return true;
|
|
148
|
-
}
|
|
149
|
-
if (input.next === slash && input.peek(1) === slash) {
|
|
150
|
-
inLineComment = true;
|
|
151
|
-
return true;
|
|
152
|
-
}
|
|
153
|
-
if (input.next === slash && input.peek(1) === asterisk) {
|
|
154
|
-
inBlockComment = true;
|
|
155
|
-
return true;
|
|
156
187
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
if (idx !== -1) {
|
|
171
|
-
while (stack.length > idx) {
|
|
172
|
-
stack.pop();
|
|
188
|
+
else if (text === '/' && around.name === 'OpenTag') {
|
|
189
|
+
let empty = around.parent, base = empty === null || empty === void 0 ? void 0 : empty.parent;
|
|
190
|
+
if (!empty)
|
|
191
|
+
return Object.assign(Object.assign({}, noChanges), { range });
|
|
192
|
+
if (!base)
|
|
193
|
+
return Object.assign(Object.assign({}, noChanges), { range });
|
|
194
|
+
if (empty.from == head - 1 &&
|
|
195
|
+
((_c = base.lastChild) === null || _c === void 0 ? void 0 : _c.name) != 'CloseTag' &&
|
|
196
|
+
(name = elementName(state$1.doc, base, head))) {
|
|
197
|
+
let hasRightBracket = view.state.doc.sliceString(head, head + 1) === '>';
|
|
198
|
+
let insert = `/${name}${hasRightBracket ? '' : '>'}`;
|
|
199
|
+
let pos = head + insert.length + (hasRightBracket ? 1 : 0);
|
|
200
|
+
return { range: state.EditorSelection.cursor(pos), changes: { from: head, insert } };
|
|
173
201
|
}
|
|
174
202
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
break;
|
|
182
|
-
}
|
|
183
|
-
if (commentHandler() || stringHandler()) {
|
|
184
|
-
input.advance();
|
|
185
|
-
continue;
|
|
186
|
-
}
|
|
187
|
-
if (stack.length === 0 &&
|
|
188
|
-
(input.next === curlyClose || input.next === parenClose || input.next === squareClose)) {
|
|
189
|
-
input.acceptToken(MoustacheExpression);
|
|
190
|
-
break;
|
|
191
|
-
}
|
|
192
|
-
switch (input.next) {
|
|
193
|
-
case parenOpen:
|
|
194
|
-
stack.push('(');
|
|
195
|
-
break;
|
|
196
|
-
case parenClose:
|
|
197
|
-
popIfMatch('(');
|
|
198
|
-
break;
|
|
199
|
-
case squareOpen:
|
|
200
|
-
stack.push('[');
|
|
201
|
-
break;
|
|
202
|
-
case squareClose:
|
|
203
|
-
popIfMatch('[');
|
|
204
|
-
break;
|
|
205
|
-
case curlyOpen:
|
|
206
|
-
stack.push('{');
|
|
207
|
-
break;
|
|
208
|
-
case curlyClose:
|
|
209
|
-
popIfMatch('{');
|
|
210
|
-
break;
|
|
211
|
-
}
|
|
212
|
-
input.advance();
|
|
213
|
-
}
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
const glimmerHighlighting = highlight.styleTags({
|
|
217
|
-
'Text RawText': highlight.tags.content,
|
|
218
|
-
'StartTag StartCloseTag SelfClosingEndTag EndTag': highlight.tags.angleBracket,
|
|
219
|
-
TagName: highlight.tags.tagName,
|
|
220
|
-
'MismatchedCloseTag/TagName': [highlight.tags.tagName, highlight.tags.invalid],
|
|
221
|
-
AttributeName: highlight.tags.attributeName,
|
|
222
|
-
// Glimmer
|
|
223
|
-
TemplateTag: highlight.tags.definition(highlight.tags.annotation),
|
|
224
|
-
'{{ }}': highlight.tags.bracket,
|
|
225
|
-
'( )': highlight.tags.paren,
|
|
226
|
-
Function: highlight.tags.function(highlight.tags.name),
|
|
227
|
-
Splattributes: highlight.tags.derefOperator,
|
|
228
|
-
Comment: highlight.tags.blockComment,
|
|
229
|
-
ShortComment: highlight.tags.blockComment,
|
|
230
|
-
LongComment: highlight.tags.blockComment,
|
|
231
|
-
HtmlComment: highlight.tags.blockComment,
|
|
232
|
-
ArgName: highlight.tags.attributeName,
|
|
233
|
-
Argument: highlight.tags.propertyName,
|
|
234
|
-
NamedBlock: highlight.tags.tagName,
|
|
235
|
-
Is: highlight.tags.definitionOperator,
|
|
236
|
-
Pipe: highlight.tags.definitionOperator,
|
|
237
|
-
as: highlight.tags.definitionOperator,
|
|
238
|
-
let: highlight.tags.function(highlight.tags.definitionOperator),
|
|
239
|
-
this: highlight.tags.self,
|
|
240
|
-
yield: highlight.tags.operatorKeyword,
|
|
241
|
-
outlet: highlight.tags.operatorKeyword,
|
|
242
|
-
component: highlight.tags.function(highlight.tags.definitionKeyword),
|
|
243
|
-
modifier: highlight.tags.function(highlight.tags.definitionKeyword),
|
|
244
|
-
helper: highlight.tags.function(highlight.tags.definitionKeyword),
|
|
245
|
-
hash: highlight.tags.function(highlight.tags.definitionKeyword),
|
|
246
|
-
array: highlight.tags.function(highlight.tags.definitionKeyword),
|
|
247
|
-
on: highlight.tags.function(highlight.tags.definitionKeyword),
|
|
248
|
-
concat: highlight.tags.function(highlight.tags.operatorKeyword),
|
|
249
|
-
'if then catch unless else each each-in': highlight.tags.controlKeyword,
|
|
250
|
-
// TODO:
|
|
251
|
-
UnquotedAttributeValue: highlight.tags.attributeValue,
|
|
252
|
-
'DoubleQuote SingleQuote AttributeValueContent': highlight.tags.attributeValue,
|
|
253
|
-
'EntityReference CharacterReference': highlight.tags.character,
|
|
254
|
-
'[ ]': highlight.tags.squareBracket,
|
|
255
|
-
ComponentName: highlight.tags.className,
|
|
256
|
-
StyleAttributeName: highlight.tags.propertyName,
|
|
257
|
-
BlockType: highlight.tags.controlKeyword,
|
|
258
|
-
BlockPrefix: highlight.tags.typeOperator,
|
|
259
|
-
'UnknownBlock/BlockType': highlight.tags.invalid,
|
|
260
|
-
UnknownBlockContent: highlight.tags.invalid,
|
|
261
|
-
Variable: highlight.tags.variableName,
|
|
262
|
-
Modifier: highlight.tags.modifier,
|
|
263
|
-
ModifierValue: highlight.tags.function(highlight.tags.modifier),
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
// This file was generated by lezer-generator. You probably shouldn't edit it.
|
|
267
|
-
const spec_identifier = {__proto__:null,this:36, as:38, if:40, unless:42, else:44, let:46, and:48, or:50, not:52, eq:54, neq:56, "not-eq":58, gt:60, gte:62, lt:64, lte:66, array:68, concat:70, hash:72, each:74, "each-in":76, on:78, modifier:80, component:82, helper:84, "in-element":86, yield:88, outlet:90};
|
|
268
|
-
const parser = lr.LRParser.deserialize({
|
|
269
|
-
version: 14,
|
|
270
|
-
states: "(dQVQ`OOOwQhO'#C^O!PQaO'#CbO!XQbO'#CcO!aQ`O'#CmO$oOpO'#CeO$vO`O'#CeO${QdO'#CdOOQO'#Ca'#CaOOQO'#D]'#D]O%^Q`O'#D^OOQO'#Dl'#DlOOQO'#D_'#D_QVQ`OOOOQW'#D`'#D`O%cQhO,58xOOQO,58x,58xOOQP'#Da'#DaO%kQaO,58|OOQO,58|,58|OOQQ'#Db'#DbO%sQbO,58}OOQO,58},58}OOQO,59X,59XO(RQ`O'#ChOOOO'#Cg'#CgOOOO'#Dd'#DdO(]OpO,59POOQS,59P,59POOOO'#Dt'#DtO(dOpO,59POOQS'#Dc'#DcO(iQdO,59OOOQO,59O,59OOOQO,59x,59xOOQO-E7]-E7]OOQW-E7^-E7^OOQO1G.d1G.dOOQP-E7_-E7_OOQO1G.h1G.hOOQQ-E7`-E7`OOQO1G.i1G.iOOOO,59S,59SO(zQ`O,59SO)VQ`O,59SOOOO-E7b-E7bOOQS1G.k1G.kOOQS-E7a-E7aOOQO1G.j1G.jO!fQ`O1G.nOOOO1G.n1G.nO)_Q`O1G.nO)dQ`O7+$YO!fQ`O7+$YOOOO<<Gt<<GtO)iQ`O<<GtOOOOAN=`AN=`",
|
|
271
|
-
stateData: ")p~O!_OS~ORPOYTO!aQO!cRO!eVO!gSO!iTO!jUO!lXO!mYO~OS`O!]^O~O!YaO!bcO~O!ZdO!dfO~O!fgO~O]hO^iO`iObmOcmOdmOemOfmOgmOhmOimOjmOkmOlmOmmOnmOomOpmOqmOrmOsmOtmOumOvmOwmOxmOymOzmO{mO|mO}mO!fiO!gSO~O!OlO~P!fO!fnO~OYTO![oO!iTO!jUO!kqO~O!frO~OSuO!]^O~O!YaO!bwO~O!ZdO!dyO~O]hO^iO`iObmOcmOdmOemOfmOgmOhmOimOjmOkmOlmOmmOnmOomOpmOqmOrmOsmOtmOumOvmOwmOxmOymOzmO{mO|mO}mO!gSO~O_zO!f{O~P%{O!O!OO~P!fO!O!OO~OYTO![oO!iTO!jUO!k!QO~O^!RO_ZX!fZX~O_!SO!f!TO~O^!VO~O_!WO~O_!YO~O!_~",
|
|
272
|
-
goto: "$e!iPP!jPP!j!n!n!n!rP!z#XPPPP#`PPPPPPPPPPPPPPPPPPPPPPPPPPPPP!j!j#k#q#w#}$T$ZPPPPPPP$aPPPPPPP#XTZO]TWO]SZO]ToVpSjTkQ|hQ!U!RR!X!VZiThk!R!VSZO]ZiThk!R!VQ]ORs]Q_PRt_QbQRvbQeRRxeQpVR!PpQkTR}kT[O]",
|
|
273
|
-
nodeNames: "⚠ Template GlimmerTemplateTag TemplateTag TemplateTag Comment ShortComment LongComment HtmlComment MoustacheExpression {{ SExpression CallExpression ( Is ) Pipe Argument this as if unless else let and or not eq neq not-eq gt gte lt lte array concat hash each each-in on modifier component helper in-element yield outlet }} Splattributes NamedBlock",
|
|
274
|
-
maxTerm: 75,
|
|
275
|
-
nodeProps: [
|
|
276
|
-
["closedBy", 3,"templateTagEnd",10,"}}",13,"("],
|
|
277
|
-
["openedBy", 4,"templateTagStart",15,")",46,"{{"]
|
|
278
|
-
],
|
|
279
|
-
propSources: [glimmerHighlighting],
|
|
280
|
-
skippedNodes: [0],
|
|
281
|
-
repeatNodeCount: 6,
|
|
282
|
-
tokenData: "+W~RhX^!mpq!mxy#eyz#j|}!m}!O#o!O!P$`![!]&P!^!_&U!_!`)X!b!c)^!c!})c#T#o)c#o#p)q#p#q*t#q#r*y#y#z!m$f$g!m#BY#BZ!m$IS$I_!m$I|$JO!m$JT$JU!m$KV$KW!m&FU&FV!m~!rZ!_~X^!mpq!m|}!m#y#z!m$f$g!m#BY#BZ!m$IS$I_!m$I|$JO!m$JT$JU!m$KV$KW!m&FU&FV!m~#jO]~~#oO_~~#rP}!O#u~#xQ!`!a$O#q#r$T~$TO!k~~$WP#q#r$Z~$`O!d~~$cP!O!P$f~$iP!O!P$l~$oP#T#U$r~$uP#h#i$x~${P#h#i%O~%RP#f#g%U~%XP#]#^%[~%_P#U#V%b~%eP#i#j%h~%kP#h#i%n~%qP#X#Y%t~%wP#g#h%z~&PO!l~~&UO!m~~&XRqr&b!P!Q&s#h#i(Q~&eP}!O&h~&kP}!O&n~&sO!e~~&vP#h#i&y~&|P#X#Y'P~'SP#a#b'V~'YP#d#e']~'`P#`#a'c~'fP#T#U'i~'lP#h#i'o~'rP#X#Y'u~'xP!`!a'{~(QOS~~(TP#X#Y(W~(ZP#a#b(^~(aP#d#e(d~(gP#`#a(j~(mP#T#U(p~(sP#h#i(v~(yP#X#Y(|~)PP!`!a)S~)XOR~~)^O^~~)cO!g~~)hR!f~!Q![)c!c!})c#T#o)c~)tP#o#p)w~)|RY~qr*Vst*j!P!Q*o~*[P!a~}!O*_~*bP}!O*e~*jO!c~~*oO!i~~*tO!j~~*yO`~R*|P#q#r+PR+WO!OQ!bP",
|
|
283
|
-
tokenizers: [shortCommentContent, longCommentContent, htmlCommentContent, templateTagContent, 0, 1],
|
|
284
|
-
topRules: {"Template":[0,1]},
|
|
285
|
-
specialized: [{term: 68, get: value => spec_identifier[value] || -1}],
|
|
286
|
-
tokenPrec: 398
|
|
203
|
+
return { range };
|
|
204
|
+
});
|
|
205
|
+
if (changes.changes.empty)
|
|
206
|
+
return false;
|
|
207
|
+
view.dispatch(changes, { userEvent: 'input.type', scrollIntoView: true });
|
|
208
|
+
return true;
|
|
287
209
|
});
|
|
288
210
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
case 'Comment':
|
|
299
|
-
case 'MoustacheExpression':
|
|
300
|
-
case 'NamedBlock':
|
|
301
|
-
case 'Splattributes':
|
|
302
|
-
case 'Argument':
|
|
303
|
-
return { parser };
|
|
304
|
-
}
|
|
305
|
-
return { parser: html.parser };
|
|
306
|
-
}),
|
|
307
|
-
props: [
|
|
308
|
-
// indentNodeProp.add({
|
|
309
|
-
// Element: (context) => {
|
|
310
|
-
// let after = /^(\s*)(<\/)?/.exec(context.textAfter);
|
|
311
|
-
// if (context.node.to <= context.pos + (after?.[0].length || 0)) return context.continue();
|
|
312
|
-
// return context.lineIndent(context.node.from) + (after?.[2] ? 0 : context.unit);
|
|
313
|
-
// },
|
|
314
|
-
// Block: (context) => {
|
|
315
|
-
// const node = context.node;
|
|
316
|
-
// const text = context.textAfter.trim();
|
|
317
|
-
// if (text.startsWith('{/')) {
|
|
318
|
-
// const name = node.name;
|
|
319
|
-
// if (
|
|
320
|
-
// (name === 'IfBlock' && text.startsWith('{/if')) ||
|
|
321
|
-
// (name === 'EachBlock' && text.startsWith('{/each')) ||
|
|
322
|
-
// (name === 'KeyBlock' && text.startsWith('{/key'))
|
|
323
|
-
// ) {
|
|
324
|
-
// return context.lineIndent(context.node.from);
|
|
325
|
-
// }
|
|
326
|
-
// return null;
|
|
327
|
-
// }
|
|
328
|
-
// if (node.name === 'IfBlock' || node.name === 'EachBlock') {
|
|
329
|
-
// if (text.startsWith('{{:else')) return context.lineIndent(node.from);
|
|
330
|
-
// if (text.startsWith('{{else')) return context.lineIndent(node.from);
|
|
331
|
-
// }
|
|
332
|
-
// // not sure if this needed to be duplicated
|
|
333
|
-
// let after = /^(\s*)(<\/)?/.exec(context.textAfter);
|
|
334
|
-
// if (context.node.to <= context.pos + (after?.[0].length || 0)) return context.continue();
|
|
335
|
-
// return context.lineIndent(context.node.from) + (after?.[2] ? 0 : context.unit);
|
|
336
|
-
// },
|
|
337
|
-
// 'BlockOpen BlockClose BlockInline': (context) => {
|
|
338
|
-
// return context.column(context.node.from) + context.unit;
|
|
339
|
-
// },
|
|
340
|
-
// 'OpenTag CloseTag SelfClosingTag': (context) => {
|
|
341
|
-
// return context.column(context.node.from) + context.unit;
|
|
342
|
-
// },
|
|
343
|
-
// Document: (context) => {
|
|
344
|
-
// if (context.pos + (/\s*/.exec(context.textAfter)?.[0].length || 0) < context.node.to) {
|
|
345
|
-
// return context.continue();
|
|
346
|
-
// }
|
|
347
|
-
// let endElt: SyntaxNode | null = null;
|
|
348
|
-
// let close: SyntaxNode;
|
|
349
|
-
// for (let cur = context.node; ; ) {
|
|
350
|
-
// let last = cur.lastChild;
|
|
351
|
-
// if (!last || last.name != 'Element' || last.to != cur.to) break;
|
|
352
|
-
// endElt = cur = last;
|
|
353
|
-
// }
|
|
354
|
-
// if (
|
|
355
|
-
// endElt?.lastChild &&
|
|
356
|
-
// !(
|
|
357
|
-
// (close = endElt.lastChild) &&
|
|
358
|
-
// (close.name === 'CloseTag' || close.name === 'SelfClosingTag')
|
|
359
|
-
// )
|
|
360
|
-
// ) {
|
|
361
|
-
// return context.lineIndent(endElt.from) + context.unit;
|
|
362
|
-
// }
|
|
363
|
-
// return null;
|
|
364
|
-
// },
|
|
365
|
-
// }),
|
|
366
|
-
// foldNodeProp.add({
|
|
367
|
-
// Block: (node) => {
|
|
368
|
-
// const open = `${node.name}Open`;
|
|
369
|
-
// const close = `${node.name}Close`;
|
|
370
|
-
// const first = node.firstChild;
|
|
371
|
-
// const last = node.lastChild;
|
|
372
|
-
// if (!first || first.name !== open) return null;
|
|
373
|
-
// return {
|
|
374
|
-
// from: first.to,
|
|
375
|
-
// to: last?.name === close ? last.from : node.to,
|
|
376
|
-
// };
|
|
377
|
-
// },
|
|
378
|
-
// Element: (node) => {
|
|
379
|
-
// let first = node.firstChild;
|
|
380
|
-
// let last = node.lastChild;
|
|
381
|
-
// if (!first || first.name != 'OpenTag') return null;
|
|
382
|
-
// return {
|
|
383
|
-
// from: first.to,
|
|
384
|
-
// to: last?.name === 'CloseTag' ? last.from : node.to,
|
|
385
|
-
// };
|
|
386
|
-
// },
|
|
387
|
-
// }),
|
|
388
|
-
],
|
|
211
|
+
/**
|
|
212
|
+
A collection of JavaScript-related
|
|
213
|
+
[snippets](https://codemirror.net/6/docs/ref/#autocomplete.snippet).
|
|
214
|
+
*/
|
|
215
|
+
const snippets = [
|
|
216
|
+
autocomplete.snippetCompletion('#each ${list} as |${item}|}}\n\t${}\n{{/each', {
|
|
217
|
+
label: '#each',
|
|
218
|
+
detail: 'loop',
|
|
219
|
+
type: 'keyword',
|
|
389
220
|
}),
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
}
|
|
221
|
+
autocomplete.snippetCompletion('#each-in ${object} as |${key} ${value}|}}\n\t${}\n{{/each-in', {
|
|
222
|
+
label: '#each-in',
|
|
223
|
+
detail: 'loop',
|
|
224
|
+
type: 'keyword',
|
|
225
|
+
}),
|
|
226
|
+
autocomplete.snippetCompletion('#let ${subExpression} as |${result}|}}\n\t${}\n{{/let', {
|
|
227
|
+
label: '#let',
|
|
228
|
+
detail: 'block',
|
|
229
|
+
type: 'keyword',
|
|
230
|
+
}),
|
|
231
|
+
autocomplete.snippetCompletion('#if ${condition}}}\n\t${}\n{{/if', {
|
|
232
|
+
label: '#if',
|
|
233
|
+
detail: 'block',
|
|
234
|
+
type: 'keyword',
|
|
235
|
+
}),
|
|
236
|
+
autocomplete.snippetCompletion('#in-element ${element}}}\n\t${}\n{{/in-element', {
|
|
237
|
+
label: '#in-element',
|
|
238
|
+
detail: 'block',
|
|
239
|
+
type: 'keyword',
|
|
240
|
+
}),
|
|
241
|
+
autocomplete.snippetCompletion('#unless ${condition}}}\n\t${}\n{{/unless', {
|
|
242
|
+
label: '#unless',
|
|
243
|
+
detail: 'block',
|
|
244
|
+
type: 'keyword',
|
|
245
|
+
}),
|
|
246
|
+
autocomplete.snippetCompletion('#if ${condition}}}\n\t${}\n{{else}}\n\t${}\n{{/if', {
|
|
247
|
+
label: '#if',
|
|
248
|
+
detail: '/ else block',
|
|
249
|
+
type: 'keyword',
|
|
250
|
+
}),
|
|
251
|
+
autocomplete.snippetCompletion('#unless ${condition}}}\n\t${}\n{{else}}\n\t${}\n{{/unless', {
|
|
252
|
+
label: '#unless',
|
|
253
|
+
detail: '/ else block',
|
|
254
|
+
type: 'keyword',
|
|
255
|
+
}),
|
|
256
|
+
];
|
|
257
|
+
|
|
401
258
|
function glimmer() {
|
|
402
|
-
return new language.LanguageSupport(glimmerLanguage, [
|
|
259
|
+
return new language.LanguageSupport(glimmerLanguage, [
|
|
260
|
+
langJavascript.javascript().support,
|
|
261
|
+
langCss.css().support,
|
|
262
|
+
new language.LanguageSupport(language.LRLanguage.define({
|
|
263
|
+
name: 'glimmer-expression',
|
|
264
|
+
parser: lezerGlimmerExpression.parser.configure({}),
|
|
265
|
+
}), []),
|
|
266
|
+
glimmerLanguage.data.of({ autocomplete: snippets }),
|
|
267
|
+
// We may want to swap this with Glimmer-specific tag completion
|
|
268
|
+
glimmerLanguage.data.of({ autocomplete: htmlTagCompletion }),
|
|
269
|
+
autoCloseTags,
|
|
270
|
+
]);
|
|
271
|
+
}
|
|
272
|
+
function htmlTagCompletion(context) {
|
|
273
|
+
let { state, pos } = context, m = /<[:\-.\w\u00b7-\uffff]*$/.exec(state.sliceDoc(pos - 25, pos));
|
|
274
|
+
if (!m)
|
|
275
|
+
return null;
|
|
276
|
+
let tree = language.syntaxTree(state).resolveInner(pos, -1);
|
|
277
|
+
while (tree && !tree.type.isTop) {
|
|
278
|
+
if (tree.name == 'CodeBlock' ||
|
|
279
|
+
tree.name == 'FencedCode' ||
|
|
280
|
+
tree.name == 'ProcessingInstructionBlock' ||
|
|
281
|
+
tree.name == 'CommentBlock' ||
|
|
282
|
+
tree.name == 'Link' ||
|
|
283
|
+
tree.name == 'Image') {
|
|
284
|
+
return null;
|
|
285
|
+
}
|
|
286
|
+
tree = tree.parent;
|
|
287
|
+
}
|
|
288
|
+
return {
|
|
289
|
+
from: pos - m[0].length,
|
|
290
|
+
to: pos,
|
|
291
|
+
options: htmlTagCompletions(),
|
|
292
|
+
validFor: /^<[:\-.\w\u00b7-\uffff]*$/,
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
let _tagCompletions = null;
|
|
296
|
+
const htmlNoMatch = langHtml.html({ matchClosingTags: false });
|
|
297
|
+
function htmlTagCompletions() {
|
|
298
|
+
if (_tagCompletions)
|
|
299
|
+
return _tagCompletions;
|
|
300
|
+
let result = langHtml.htmlCompletionSource(new autocomplete.CompletionContext(state.EditorState.create({ extensions: htmlNoMatch }), 0, true));
|
|
301
|
+
return (_tagCompletions = result ? result.options : []);
|
|
403
302
|
}
|
|
404
303
|
|
|
304
|
+
exports.defaultNesting = defaultNesting;
|
|
405
305
|
exports.glimmer = glimmer;
|
|
406
306
|
exports.glimmerLanguage = glimmerLanguage;
|
|
407
|
-
exports.
|
|
307
|
+
exports.glimmerPlain = glimmerPlain;
|
|
308
|
+
exports.snippets = snippets;
|