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.js
CHANGED
|
@@ -1,403 +1,302 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { snippetCompletion, CompletionContext } from '@codemirror/autocomplete';
|
|
2
|
+
import { cssLanguage, css } from '@codemirror/lang-css';
|
|
3
|
+
import { html, htmlCompletionSource } from '@codemirror/lang-html';
|
|
4
|
+
import { typescriptLanguage, javascriptLanguage, javascript } from '@codemirror/lang-javascript';
|
|
5
|
+
import { LRLanguage, indentNodeProp, foldNodeProp, syntaxTree, LanguageSupport } from '@codemirror/language';
|
|
6
|
+
import { EditorSelection, EditorState } from '@codemirror/state';
|
|
7
|
+
import { parser } from '@glimdown/lezer-glimmer-expression';
|
|
8
|
+
import { EditorView } from '@codemirror/view';
|
|
9
|
+
import { glimmerParser, configureNesting } from 'lezer-glimmer';
|
|
7
10
|
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
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
|
-
|
|
11
|
+
const defaultNesting = [
|
|
12
|
+
{
|
|
13
|
+
tag: 'script',
|
|
14
|
+
attrs: (attrs) => attrs['type'] === 'text/typescript' || attrs['lang'] === 'ts',
|
|
15
|
+
parser: typescriptLanguage.parser,
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
tag: 'script',
|
|
19
|
+
attrs(attrs) {
|
|
20
|
+
return (!attrs['type'] ||
|
|
21
|
+
/^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i.test(attrs['type']));
|
|
22
|
+
},
|
|
23
|
+
parser: javascriptLanguage.parser,
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
tag: 'style',
|
|
27
|
+
attrs( /* attrs */) {
|
|
28
|
+
return true;
|
|
29
|
+
// Always use CSS. We can add varying support later
|
|
30
|
+
// return (
|
|
31
|
+
// (!attrs['lang'] || attrs['lang'] === 'css' || attrs['lang'] === 'scss') &&
|
|
32
|
+
// (!attrs['type'] || /^(text\/)?(x-)?(stylesheet|css|scss)$/i.test(attrs['type']))
|
|
33
|
+
// );
|
|
34
|
+
},
|
|
35
|
+
parser: cssLanguage.parser,
|
|
36
|
+
},
|
|
37
|
+
];
|
|
38
|
+
const glimmerPlain = /*@__PURE__*/LRLanguage.define({
|
|
39
|
+
parser: /*@__PURE__*/glimmerParser.configure({
|
|
40
|
+
props: [
|
|
41
|
+
/*@__PURE__*/indentNodeProp.add({
|
|
42
|
+
Element: (context) => {
|
|
43
|
+
let after = /^(\s*)(<\/)?/.exec(context.textAfter);
|
|
44
|
+
if (!after)
|
|
45
|
+
return null;
|
|
46
|
+
if (context.node.to <= context.pos + after[0].length)
|
|
47
|
+
return context.continue();
|
|
48
|
+
return context.lineIndent(context.node.from) + (after[2] ? 0 : context.unit);
|
|
49
|
+
},
|
|
50
|
+
Block: (context) => {
|
|
51
|
+
const node = context.node;
|
|
52
|
+
const text = context.textAfter.trim();
|
|
53
|
+
if (text.startsWith('{/')) {
|
|
54
|
+
const name = node.name;
|
|
55
|
+
if ((name === 'IfBlock' && text.startsWith('{/if')) ||
|
|
56
|
+
(name === 'UnlessBlock' && text.startsWith('{/unless')) ||
|
|
57
|
+
(name === 'InElementBlock' && text.startsWith('{/in-element')) ||
|
|
58
|
+
(name === 'EachBlock' && text.startsWith('{/each')) ||
|
|
59
|
+
(name === 'EachInBlock' && text.startsWith('{/each-in')) ||
|
|
60
|
+
(name === 'LetBlock' && text.startsWith('{/let'))) {
|
|
61
|
+
return context.lineIndent(context.node.from);
|
|
62
|
+
}
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
if (node.name === 'IfBlock' ||
|
|
66
|
+
node.name === 'EachBlock' ||
|
|
67
|
+
node.name === 'EachInBlock' ||
|
|
68
|
+
node.name === 'UnlessBlock') {
|
|
69
|
+
if (text.startsWith('{{:else'))
|
|
70
|
+
return context.lineIndent(node.from);
|
|
71
|
+
if (text.startsWith('{{else'))
|
|
72
|
+
return context.lineIndent(node.from);
|
|
73
|
+
}
|
|
74
|
+
// not sure if this needed to be duplicated
|
|
75
|
+
let after = /^(\s*)(<\/)?/.exec(context.textAfter);
|
|
76
|
+
if (!after)
|
|
77
|
+
return null;
|
|
78
|
+
if (context.node.to <= context.pos + after[0].length)
|
|
79
|
+
return context.continue();
|
|
80
|
+
return context.lineIndent(context.node.from) + (after[2] ? 0 : context.unit);
|
|
81
|
+
},
|
|
82
|
+
'BlockOpen BlockClose BlockInline': (context) => {
|
|
83
|
+
return context.column(context.node.from) + context.unit;
|
|
84
|
+
},
|
|
85
|
+
'OpenTag CloseTag SelfClosingTag': (context) => {
|
|
86
|
+
return context.column(context.node.from) + context.unit;
|
|
87
|
+
},
|
|
88
|
+
Document: (context) => {
|
|
89
|
+
var _a, _b;
|
|
90
|
+
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) {
|
|
91
|
+
return context.continue();
|
|
92
|
+
}
|
|
93
|
+
let endElt = null;
|
|
94
|
+
let close;
|
|
95
|
+
for (let cur = context.node;;) {
|
|
96
|
+
let last = cur.lastChild;
|
|
97
|
+
if (!last || last.name != 'Element' || last.to != cur.to)
|
|
98
|
+
break;
|
|
99
|
+
endElt = cur = last;
|
|
100
|
+
}
|
|
101
|
+
if (endElt &&
|
|
102
|
+
!((close = endElt.lastChild) &&
|
|
103
|
+
(close.name === 'CloseTag' || close.name === 'SelfClosingTag'))) {
|
|
104
|
+
return context.lineIndent(endElt.from) + context.unit;
|
|
105
|
+
}
|
|
106
|
+
return null;
|
|
107
|
+
},
|
|
108
|
+
}),
|
|
109
|
+
/*@__PURE__*/foldNodeProp.add({
|
|
110
|
+
Block: (node) => {
|
|
111
|
+
const open = `${node.name}Open`;
|
|
112
|
+
const close = `${node.name}Close`;
|
|
113
|
+
const first = node.firstChild;
|
|
114
|
+
const last = node.lastChild;
|
|
115
|
+
if (!first || first.name !== open)
|
|
116
|
+
return null;
|
|
117
|
+
return { from: first.to, to: (last === null || last === void 0 ? void 0 : last.name) === close ? last.from : node.to };
|
|
118
|
+
},
|
|
119
|
+
Element: (node) => {
|
|
120
|
+
let first = node.firstChild;
|
|
121
|
+
let last = node.lastChild;
|
|
122
|
+
if (!last)
|
|
123
|
+
return null;
|
|
124
|
+
if (!first || first.name != 'OpenTag')
|
|
125
|
+
return null;
|
|
126
|
+
return { from: first.to, to: last.name === 'CloseTag' ? last.from : node.to };
|
|
127
|
+
},
|
|
128
|
+
}),
|
|
129
|
+
],
|
|
130
|
+
}),
|
|
131
|
+
languageData: {
|
|
132
|
+
commentTokens: {
|
|
133
|
+
block: { open: '<!--', close: '-->' },
|
|
134
|
+
moustacheLong: { open: '{{!--', close: '--}}' },
|
|
135
|
+
},
|
|
136
|
+
indentOnInput: /^\s*((<\/\w+\W)|(\{\{:?(else|then|catch))|(\{\{\/(if|each|each-in|in-element|unless|let)))$/,
|
|
137
|
+
wordChars: '-._',
|
|
138
|
+
},
|
|
75
139
|
});
|
|
76
|
-
const
|
|
77
|
-
|
|
140
|
+
const glimmerLanguage = /*@__PURE__*/glimmerPlain.configure({
|
|
141
|
+
wrap: /*@__PURE__*/configureNesting(defaultNesting),
|
|
78
142
|
});
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
if (input.next === backslash) {
|
|
91
|
-
inStringIgnoreNext = true;
|
|
92
|
-
return true;
|
|
93
|
-
}
|
|
94
|
-
if (inStringType === 'double' && input.next === quoteDouble) {
|
|
95
|
-
inString = false;
|
|
96
|
-
inStringType = null;
|
|
97
|
-
return true;
|
|
98
|
-
}
|
|
99
|
-
if (inStringType === 'single' && input.next === quoteSingle) {
|
|
100
|
-
inString = false;
|
|
101
|
-
inStringType = null;
|
|
102
|
-
return true;
|
|
103
|
-
}
|
|
104
|
-
if (inStringType === 'template' && input.next === tick) {
|
|
105
|
-
inString = false;
|
|
106
|
-
inStringType = null;
|
|
107
|
-
return true;
|
|
108
|
-
}
|
|
109
|
-
return true;
|
|
110
|
-
}
|
|
111
|
-
if (input.next === quoteDouble) {
|
|
112
|
-
inString = true;
|
|
113
|
-
inStringType = 'double';
|
|
114
|
-
return true;
|
|
115
|
-
}
|
|
116
|
-
if (input.next === quoteSingle) {
|
|
117
|
-
inString = true;
|
|
118
|
-
inStringType = 'single';
|
|
119
|
-
return true;
|
|
120
|
-
}
|
|
121
|
-
if (input.next === tick) {
|
|
122
|
-
inString = true;
|
|
123
|
-
inStringType = 'template';
|
|
124
|
-
return true;
|
|
125
|
-
}
|
|
126
|
-
return false;
|
|
127
|
-
};
|
|
143
|
+
|
|
144
|
+
// unfortunately the HTML language explicitly checks for the language type,
|
|
145
|
+
// so we have to duplicate the entire autoCloseTags extension
|
|
146
|
+
function elementName(doc, tree, max = doc.length) {
|
|
147
|
+
if (!tree)
|
|
148
|
+
return '';
|
|
149
|
+
let tag = tree.firstChild;
|
|
150
|
+
let name = tag &&
|
|
151
|
+
(tag.getChild('TagName') || tag.getChild('ComponentName') || tag.getChild('SvelteElementName'));
|
|
152
|
+
return name ? doc.sliceString(name.from, Math.min(name.to, max)) : '';
|
|
128
153
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
154
|
+
const autoCloseTags = /*@__PURE__*/EditorView.inputHandler.of((view, from, to, text) => {
|
|
155
|
+
if (view.composing ||
|
|
156
|
+
view.state.readOnly ||
|
|
157
|
+
from != to ||
|
|
158
|
+
(text != '>' && text != '/') ||
|
|
159
|
+
!glimmerLanguage.isActiveAt(view.state, from, -1))
|
|
160
|
+
return false;
|
|
161
|
+
let { state } = view;
|
|
162
|
+
const noChanges = { range: undefined, changes: undefined, effects: undefined };
|
|
163
|
+
let changes = state.changeByRange((range) => {
|
|
164
|
+
var _a, _b, _c;
|
|
165
|
+
let { head } = range;
|
|
166
|
+
let around = syntaxTree(state).resolveInner(head, -1);
|
|
167
|
+
let name;
|
|
168
|
+
if (around.name === 'TagName' ||
|
|
169
|
+
around.name === 'ComponentName' ||
|
|
170
|
+
around.name === 'StartTag') {
|
|
171
|
+
if (!around.parent)
|
|
172
|
+
return Object.assign(Object.assign({}, noChanges), { range });
|
|
173
|
+
around = around.parent;
|
|
139
174
|
}
|
|
140
|
-
if (
|
|
141
|
-
if (
|
|
142
|
-
|
|
143
|
-
|
|
175
|
+
if (text === '>' && around.name === 'OpenTag') {
|
|
176
|
+
if (((_b = (_a = around.parent) === null || _a === void 0 ? void 0 : _a.lastChild) === null || _b === void 0 ? void 0 : _b.name) != 'CloseTag' &&
|
|
177
|
+
(name = elementName(state.doc, around.parent, head))) {
|
|
178
|
+
let hasRightBracket = view.state.doc.sliceString(head, head + 1) === '>';
|
|
179
|
+
let insert = `${hasRightBracket ? '' : '>'}</${name}>`;
|
|
180
|
+
return {
|
|
181
|
+
range: EditorSelection.cursor(head + 1),
|
|
182
|
+
changes: { from: head + (hasRightBracket ? 1 : 0), insert },
|
|
183
|
+
};
|
|
144
184
|
}
|
|
145
|
-
return true;
|
|
146
|
-
}
|
|
147
|
-
if (input.next === slash && input.peek(1) === slash) {
|
|
148
|
-
inLineComment = true;
|
|
149
|
-
return true;
|
|
150
|
-
}
|
|
151
|
-
if (input.next === slash && input.peek(1) === asterisk) {
|
|
152
|
-
inBlockComment = true;
|
|
153
|
-
return true;
|
|
154
185
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
if (idx !== -1) {
|
|
169
|
-
while (stack.length > idx) {
|
|
170
|
-
stack.pop();
|
|
186
|
+
else if (text === '/' && around.name === 'OpenTag') {
|
|
187
|
+
let empty = around.parent, base = empty === null || empty === void 0 ? void 0 : empty.parent;
|
|
188
|
+
if (!empty)
|
|
189
|
+
return Object.assign(Object.assign({}, noChanges), { range });
|
|
190
|
+
if (!base)
|
|
191
|
+
return Object.assign(Object.assign({}, noChanges), { range });
|
|
192
|
+
if (empty.from == head - 1 &&
|
|
193
|
+
((_c = base.lastChild) === null || _c === void 0 ? void 0 : _c.name) != 'CloseTag' &&
|
|
194
|
+
(name = elementName(state.doc, base, head))) {
|
|
195
|
+
let hasRightBracket = view.state.doc.sliceString(head, head + 1) === '>';
|
|
196
|
+
let insert = `/${name}${hasRightBracket ? '' : '>'}`;
|
|
197
|
+
let pos = head + insert.length + (hasRightBracket ? 1 : 0);
|
|
198
|
+
return { range: EditorSelection.cursor(pos), changes: { from: head, insert } };
|
|
171
199
|
}
|
|
172
200
|
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
break;
|
|
180
|
-
}
|
|
181
|
-
if (commentHandler() || stringHandler()) {
|
|
182
|
-
input.advance();
|
|
183
|
-
continue;
|
|
184
|
-
}
|
|
185
|
-
if (stack.length === 0 &&
|
|
186
|
-
(input.next === curlyClose || input.next === parenClose || input.next === squareClose)) {
|
|
187
|
-
input.acceptToken(MoustacheExpression);
|
|
188
|
-
break;
|
|
189
|
-
}
|
|
190
|
-
switch (input.next) {
|
|
191
|
-
case parenOpen:
|
|
192
|
-
stack.push('(');
|
|
193
|
-
break;
|
|
194
|
-
case parenClose:
|
|
195
|
-
popIfMatch('(');
|
|
196
|
-
break;
|
|
197
|
-
case squareOpen:
|
|
198
|
-
stack.push('[');
|
|
199
|
-
break;
|
|
200
|
-
case squareClose:
|
|
201
|
-
popIfMatch('[');
|
|
202
|
-
break;
|
|
203
|
-
case curlyOpen:
|
|
204
|
-
stack.push('{');
|
|
205
|
-
break;
|
|
206
|
-
case curlyClose:
|
|
207
|
-
popIfMatch('{');
|
|
208
|
-
break;
|
|
209
|
-
}
|
|
210
|
-
input.advance();
|
|
211
|
-
}
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
const glimmerHighlighting = styleTags({
|
|
215
|
-
'Text RawText': tags.content,
|
|
216
|
-
'StartTag StartCloseTag SelfClosingEndTag EndTag': tags.angleBracket,
|
|
217
|
-
TagName: tags.tagName,
|
|
218
|
-
'MismatchedCloseTag/TagName': [tags.tagName, tags.invalid],
|
|
219
|
-
AttributeName: tags.attributeName,
|
|
220
|
-
// Glimmer
|
|
221
|
-
TemplateTag: tags.definition(tags.annotation),
|
|
222
|
-
'{{ }}': tags.bracket,
|
|
223
|
-
'( )': tags.paren,
|
|
224
|
-
Function: tags.function(tags.name),
|
|
225
|
-
Splattributes: tags.derefOperator,
|
|
226
|
-
Comment: tags.blockComment,
|
|
227
|
-
ShortComment: tags.blockComment,
|
|
228
|
-
LongComment: tags.blockComment,
|
|
229
|
-
HtmlComment: tags.blockComment,
|
|
230
|
-
ArgName: tags.attributeName,
|
|
231
|
-
Argument: tags.propertyName,
|
|
232
|
-
NamedBlock: tags.tagName,
|
|
233
|
-
Is: tags.definitionOperator,
|
|
234
|
-
Pipe: tags.definitionOperator,
|
|
235
|
-
as: tags.definitionOperator,
|
|
236
|
-
let: tags.function(tags.definitionOperator),
|
|
237
|
-
this: tags.self,
|
|
238
|
-
yield: tags.operatorKeyword,
|
|
239
|
-
outlet: tags.operatorKeyword,
|
|
240
|
-
component: tags.function(tags.definitionKeyword),
|
|
241
|
-
modifier: tags.function(tags.definitionKeyword),
|
|
242
|
-
helper: tags.function(tags.definitionKeyword),
|
|
243
|
-
hash: tags.function(tags.definitionKeyword),
|
|
244
|
-
array: tags.function(tags.definitionKeyword),
|
|
245
|
-
on: tags.function(tags.definitionKeyword),
|
|
246
|
-
concat: tags.function(tags.operatorKeyword),
|
|
247
|
-
'if then catch unless else each each-in': tags.controlKeyword,
|
|
248
|
-
// TODO:
|
|
249
|
-
UnquotedAttributeValue: tags.attributeValue,
|
|
250
|
-
'DoubleQuote SingleQuote AttributeValueContent': tags.attributeValue,
|
|
251
|
-
'EntityReference CharacterReference': tags.character,
|
|
252
|
-
'[ ]': tags.squareBracket,
|
|
253
|
-
ComponentName: tags.className,
|
|
254
|
-
StyleAttributeName: tags.propertyName,
|
|
255
|
-
BlockType: tags.controlKeyword,
|
|
256
|
-
BlockPrefix: tags.typeOperator,
|
|
257
|
-
'UnknownBlock/BlockType': tags.invalid,
|
|
258
|
-
UnknownBlockContent: tags.invalid,
|
|
259
|
-
Variable: tags.variableName,
|
|
260
|
-
Modifier: tags.modifier,
|
|
261
|
-
ModifierValue: tags.function(tags.modifier),
|
|
262
|
-
});
|
|
263
|
-
|
|
264
|
-
// This file was generated by lezer-generator. You probably shouldn't edit it.
|
|
265
|
-
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};
|
|
266
|
-
const parser = LRParser.deserialize({
|
|
267
|
-
version: 14,
|
|
268
|
-
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=`",
|
|
269
|
-
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!_~",
|
|
270
|
-
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]",
|
|
271
|
-
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",
|
|
272
|
-
maxTerm: 75,
|
|
273
|
-
nodeProps: [
|
|
274
|
-
["closedBy", 3,"templateTagEnd",10,"}}",13,"("],
|
|
275
|
-
["openedBy", 4,"templateTagStart",15,")",46,"{{"]
|
|
276
|
-
],
|
|
277
|
-
propSources: [glimmerHighlighting],
|
|
278
|
-
skippedNodes: [0],
|
|
279
|
-
repeatNodeCount: 6,
|
|
280
|
-
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",
|
|
281
|
-
tokenizers: [shortCommentContent, longCommentContent, htmlCommentContent, templateTagContent, 0, 1],
|
|
282
|
-
topRules: {"Template":[0,1]},
|
|
283
|
-
specialized: [{term: 68, get: value => spec_identifier[value] || -1}],
|
|
284
|
-
tokenPrec: 398
|
|
201
|
+
return { range };
|
|
202
|
+
});
|
|
203
|
+
if (changes.changes.empty)
|
|
204
|
+
return false;
|
|
205
|
+
view.dispatch(changes, { userEvent: 'input.type', scrollIntoView: true });
|
|
206
|
+
return true;
|
|
285
207
|
});
|
|
286
208
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
case 'Comment':
|
|
297
|
-
case 'MoustacheExpression':
|
|
298
|
-
case 'NamedBlock':
|
|
299
|
-
case 'Splattributes':
|
|
300
|
-
case 'Argument':
|
|
301
|
-
return { parser };
|
|
302
|
-
}
|
|
303
|
-
return { parser: parser$1 };
|
|
304
|
-
}),
|
|
305
|
-
props: [
|
|
306
|
-
// indentNodeProp.add({
|
|
307
|
-
// Element: (context) => {
|
|
308
|
-
// let after = /^(\s*)(<\/)?/.exec(context.textAfter);
|
|
309
|
-
// if (context.node.to <= context.pos + (after?.[0].length || 0)) return context.continue();
|
|
310
|
-
// return context.lineIndent(context.node.from) + (after?.[2] ? 0 : context.unit);
|
|
311
|
-
// },
|
|
312
|
-
// Block: (context) => {
|
|
313
|
-
// const node = context.node;
|
|
314
|
-
// const text = context.textAfter.trim();
|
|
315
|
-
// if (text.startsWith('{/')) {
|
|
316
|
-
// const name = node.name;
|
|
317
|
-
// if (
|
|
318
|
-
// (name === 'IfBlock' && text.startsWith('{/if')) ||
|
|
319
|
-
// (name === 'EachBlock' && text.startsWith('{/each')) ||
|
|
320
|
-
// (name === 'KeyBlock' && text.startsWith('{/key'))
|
|
321
|
-
// ) {
|
|
322
|
-
// return context.lineIndent(context.node.from);
|
|
323
|
-
// }
|
|
324
|
-
// return null;
|
|
325
|
-
// }
|
|
326
|
-
// if (node.name === 'IfBlock' || node.name === 'EachBlock') {
|
|
327
|
-
// if (text.startsWith('{{:else')) return context.lineIndent(node.from);
|
|
328
|
-
// if (text.startsWith('{{else')) return context.lineIndent(node.from);
|
|
329
|
-
// }
|
|
330
|
-
// // not sure if this needed to be duplicated
|
|
331
|
-
// let after = /^(\s*)(<\/)?/.exec(context.textAfter);
|
|
332
|
-
// if (context.node.to <= context.pos + (after?.[0].length || 0)) return context.continue();
|
|
333
|
-
// return context.lineIndent(context.node.from) + (after?.[2] ? 0 : context.unit);
|
|
334
|
-
// },
|
|
335
|
-
// 'BlockOpen BlockClose BlockInline': (context) => {
|
|
336
|
-
// return context.column(context.node.from) + context.unit;
|
|
337
|
-
// },
|
|
338
|
-
// 'OpenTag CloseTag SelfClosingTag': (context) => {
|
|
339
|
-
// return context.column(context.node.from) + context.unit;
|
|
340
|
-
// },
|
|
341
|
-
// Document: (context) => {
|
|
342
|
-
// if (context.pos + (/\s*/.exec(context.textAfter)?.[0].length || 0) < context.node.to) {
|
|
343
|
-
// return context.continue();
|
|
344
|
-
// }
|
|
345
|
-
// let endElt: SyntaxNode | null = null;
|
|
346
|
-
// let close: SyntaxNode;
|
|
347
|
-
// for (let cur = context.node; ; ) {
|
|
348
|
-
// let last = cur.lastChild;
|
|
349
|
-
// if (!last || last.name != 'Element' || last.to != cur.to) break;
|
|
350
|
-
// endElt = cur = last;
|
|
351
|
-
// }
|
|
352
|
-
// if (
|
|
353
|
-
// endElt?.lastChild &&
|
|
354
|
-
// !(
|
|
355
|
-
// (close = endElt.lastChild) &&
|
|
356
|
-
// (close.name === 'CloseTag' || close.name === 'SelfClosingTag')
|
|
357
|
-
// )
|
|
358
|
-
// ) {
|
|
359
|
-
// return context.lineIndent(endElt.from) + context.unit;
|
|
360
|
-
// }
|
|
361
|
-
// return null;
|
|
362
|
-
// },
|
|
363
|
-
// }),
|
|
364
|
-
// foldNodeProp.add({
|
|
365
|
-
// Block: (node) => {
|
|
366
|
-
// const open = `${node.name}Open`;
|
|
367
|
-
// const close = `${node.name}Close`;
|
|
368
|
-
// const first = node.firstChild;
|
|
369
|
-
// const last = node.lastChild;
|
|
370
|
-
// if (!first || first.name !== open) return null;
|
|
371
|
-
// return {
|
|
372
|
-
// from: first.to,
|
|
373
|
-
// to: last?.name === close ? last.from : node.to,
|
|
374
|
-
// };
|
|
375
|
-
// },
|
|
376
|
-
// Element: (node) => {
|
|
377
|
-
// let first = node.firstChild;
|
|
378
|
-
// let last = node.lastChild;
|
|
379
|
-
// if (!first || first.name != 'OpenTag') return null;
|
|
380
|
-
// return {
|
|
381
|
-
// from: first.to,
|
|
382
|
-
// to: last?.name === 'CloseTag' ? last.from : node.to,
|
|
383
|
-
// };
|
|
384
|
-
// },
|
|
385
|
-
// }),
|
|
386
|
-
],
|
|
209
|
+
/**
|
|
210
|
+
A collection of JavaScript-related
|
|
211
|
+
[snippets](https://codemirror.net/6/docs/ref/#autocomplete.snippet).
|
|
212
|
+
*/
|
|
213
|
+
const snippets = [
|
|
214
|
+
/*@__PURE__*/snippetCompletion('#each ${list} as |${item}|}}\n\t${}\n{{/each', {
|
|
215
|
+
label: '#each',
|
|
216
|
+
detail: 'loop',
|
|
217
|
+
type: 'keyword',
|
|
387
218
|
}),
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
}
|
|
219
|
+
/*@__PURE__*/snippetCompletion('#each-in ${object} as |${key} ${value}|}}\n\t${}\n{{/each-in', {
|
|
220
|
+
label: '#each-in',
|
|
221
|
+
detail: 'loop',
|
|
222
|
+
type: 'keyword',
|
|
223
|
+
}),
|
|
224
|
+
/*@__PURE__*/snippetCompletion('#let ${subExpression} as |${result}|}}\n\t${}\n{{/let', {
|
|
225
|
+
label: '#let',
|
|
226
|
+
detail: 'block',
|
|
227
|
+
type: 'keyword',
|
|
228
|
+
}),
|
|
229
|
+
/*@__PURE__*/snippetCompletion('#if ${condition}}}\n\t${}\n{{/if', {
|
|
230
|
+
label: '#if',
|
|
231
|
+
detail: 'block',
|
|
232
|
+
type: 'keyword',
|
|
233
|
+
}),
|
|
234
|
+
/*@__PURE__*/snippetCompletion('#in-element ${element}}}\n\t${}\n{{/in-element', {
|
|
235
|
+
label: '#in-element',
|
|
236
|
+
detail: 'block',
|
|
237
|
+
type: 'keyword',
|
|
238
|
+
}),
|
|
239
|
+
/*@__PURE__*/snippetCompletion('#unless ${condition}}}\n\t${}\n{{/unless', {
|
|
240
|
+
label: '#unless',
|
|
241
|
+
detail: 'block',
|
|
242
|
+
type: 'keyword',
|
|
243
|
+
}),
|
|
244
|
+
/*@__PURE__*/snippetCompletion('#if ${condition}}}\n\t${}\n{{else}}\n\t${}\n{{/if', {
|
|
245
|
+
label: '#if',
|
|
246
|
+
detail: '/ else block',
|
|
247
|
+
type: 'keyword',
|
|
248
|
+
}),
|
|
249
|
+
/*@__PURE__*/snippetCompletion('#unless ${condition}}}\n\t${}\n{{else}}\n\t${}\n{{/unless', {
|
|
250
|
+
label: '#unless',
|
|
251
|
+
detail: '/ else block',
|
|
252
|
+
type: 'keyword',
|
|
253
|
+
}),
|
|
254
|
+
];
|
|
255
|
+
|
|
399
256
|
function glimmer() {
|
|
400
|
-
return new LanguageSupport(glimmerLanguage, [
|
|
257
|
+
return new LanguageSupport(glimmerLanguage, [
|
|
258
|
+
javascript().support,
|
|
259
|
+
css().support,
|
|
260
|
+
new LanguageSupport(LRLanguage.define({
|
|
261
|
+
name: 'glimmer-expression',
|
|
262
|
+
parser: parser.configure({}),
|
|
263
|
+
}), []),
|
|
264
|
+
glimmerLanguage.data.of({ autocomplete: snippets }),
|
|
265
|
+
// We may want to swap this with Glimmer-specific tag completion
|
|
266
|
+
glimmerLanguage.data.of({ autocomplete: htmlTagCompletion }),
|
|
267
|
+
autoCloseTags,
|
|
268
|
+
]);
|
|
269
|
+
}
|
|
270
|
+
function htmlTagCompletion(context) {
|
|
271
|
+
let { state, pos } = context, m = /<[:\-.\w\u00b7-\uffff]*$/.exec(state.sliceDoc(pos - 25, pos));
|
|
272
|
+
if (!m)
|
|
273
|
+
return null;
|
|
274
|
+
let tree = syntaxTree(state).resolveInner(pos, -1);
|
|
275
|
+
while (tree && !tree.type.isTop) {
|
|
276
|
+
if (tree.name == 'CodeBlock' ||
|
|
277
|
+
tree.name == 'FencedCode' ||
|
|
278
|
+
tree.name == 'ProcessingInstructionBlock' ||
|
|
279
|
+
tree.name == 'CommentBlock' ||
|
|
280
|
+
tree.name == 'Link' ||
|
|
281
|
+
tree.name == 'Image') {
|
|
282
|
+
return null;
|
|
283
|
+
}
|
|
284
|
+
tree = tree.parent;
|
|
285
|
+
}
|
|
286
|
+
return {
|
|
287
|
+
from: pos - m[0].length,
|
|
288
|
+
to: pos,
|
|
289
|
+
options: htmlTagCompletions(),
|
|
290
|
+
validFor: /^<[:\-.\w\u00b7-\uffff]*$/,
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
let _tagCompletions = null;
|
|
294
|
+
const htmlNoMatch = /*@__PURE__*/html({ matchClosingTags: false });
|
|
295
|
+
function htmlTagCompletions() {
|
|
296
|
+
if (_tagCompletions)
|
|
297
|
+
return _tagCompletions;
|
|
298
|
+
let result = htmlCompletionSource(new CompletionContext(EditorState.create({ extensions: htmlNoMatch }), 0, true));
|
|
299
|
+
return (_tagCompletions = result ? result.options : []);
|
|
401
300
|
}
|
|
402
301
|
|
|
403
|
-
export { glimmer, glimmerLanguage,
|
|
302
|
+
export { defaultNesting, glimmer, glimmerLanguage, glimmerPlain, snippets };
|