@spyglassmc/core 0.1.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/README.md +10 -0
- package/lib/common/Heap.d.ts +1 -0
- package/lib/common/Heap.js +2 -0
- package/lib/common/index.d.ts +2 -0
- package/lib/common/index.js +14 -0
- package/lib/common/util.d.ts +120 -0
- package/lib/common/util.js +292 -0
- package/lib/index.d.ts +8 -0
- package/lib/index.js +20 -0
- package/lib/node/AstNode.d.ts +64 -0
- package/lib/node/AstNode.js +108 -0
- package/lib/node/BooleanNode.d.ts +13 -0
- package/lib/node/BooleanNode.js +20 -0
- package/lib/node/CommentNode.d.ts +12 -0
- package/lib/node/CommentNode.js +11 -0
- package/lib/node/ErrorNode.d.ts +8 -0
- package/lib/node/ErrorNode.js +12 -0
- package/lib/node/FileNode.d.ts +21 -0
- package/lib/node/FileNode.js +11 -0
- package/lib/node/FloatNode.d.ts +13 -0
- package/lib/node/FloatNode.js +21 -0
- package/lib/node/IntegerNode.d.ts +13 -0
- package/lib/node/IntegerNode.js +20 -0
- package/lib/node/ListNode.d.ts +15 -0
- package/lib/node/ListNode.js +11 -0
- package/lib/node/LiteralNode.d.ts +19 -0
- package/lib/node/LiteralNode.js +22 -0
- package/lib/node/LongNode.d.ts +13 -0
- package/lib/node/LongNode.js +20 -0
- package/lib/node/RecordNode.d.ts +20 -0
- package/lib/node/RecordNode.js +11 -0
- package/lib/node/ResourceLocationNode.d.ts +41 -0
- package/lib/node/ResourceLocationNode.js +65 -0
- package/lib/node/Sequence.d.ts +22 -0
- package/lib/node/Sequence.js +11 -0
- package/lib/node/StringNode.d.ts +63 -0
- package/lib/node/StringNode.js +43 -0
- package/lib/node/SymbolNode.d.ts +21 -0
- package/lib/node/SymbolNode.js +22 -0
- package/lib/node/TableNode.d.ts +17 -0
- package/lib/node/TableNode.js +11 -0
- package/lib/node/index.d.ts +16 -0
- package/lib/node/index.js +28 -0
- package/lib/parser/Parser.d.ts +16 -0
- package/lib/parser/Parser.js +5 -0
- package/lib/parser/boolean.d.ts +4 -0
- package/lib/parser/boolean.js +11 -0
- package/lib/parser/comment.d.ts +12 -0
- package/lib/parser/comment.js +34 -0
- package/lib/parser/empty.d.ts +3 -0
- package/lib/parser/empty.js +7 -0
- package/lib/parser/error.d.ts +8 -0
- package/lib/parser/error.js +22 -0
- package/lib/parser/file.d.ts +9 -0
- package/lib/parser/file.js +37 -0
- package/lib/parser/float.d.ts +33 -0
- package/lib/parser/float.js +57 -0
- package/lib/parser/index.d.ts +17 -0
- package/lib/parser/index.js +36 -0
- package/lib/parser/integer.d.ts +33 -0
- package/lib/parser/integer.js +46 -0
- package/lib/parser/list.d.ts +12 -0
- package/lib/parser/list.js +70 -0
- package/lib/parser/literal.d.ts +5 -0
- package/lib/parser/literal.js +41 -0
- package/lib/parser/long.d.ts +33 -0
- package/lib/parser/long.js +50 -0
- package/lib/parser/record.d.ts +22 -0
- package/lib/parser/record.js +97 -0
- package/lib/parser/resourceLocation.d.ts +4 -0
- package/lib/parser/resourceLocation.js +67 -0
- package/lib/parser/string.d.ts +18 -0
- package/lib/parser/string.js +129 -0
- package/lib/parser/symbol.d.ts +12 -0
- package/lib/parser/symbol.js +33 -0
- package/lib/parser/table.d.ts +22 -0
- package/lib/parser/table.js +97 -0
- package/lib/parser/util.d.ts +134 -0
- package/lib/parser/util.js +224 -0
- package/lib/processor/ColorInfoProvider.d.ts +87 -0
- package/lib/processor/ColorInfoProvider.js +141 -0
- package/lib/processor/InlayHintProvider.d.ts +8 -0
- package/lib/processor/InlayHintProvider.js +3 -0
- package/lib/processor/SignatureHelpProvider.d.ts +18 -0
- package/lib/processor/SignatureHelpProvider.js +3 -0
- package/lib/processor/checker/Checker.d.ts +7 -0
- package/lib/processor/checker/Checker.js +7 -0
- package/lib/processor/checker/builtin.d.ts +23 -0
- package/lib/processor/checker/builtin.js +83 -0
- package/lib/processor/checker/index.d.ts +3 -0
- package/lib/processor/checker/index.js +28 -0
- package/lib/processor/colorizer/Colorizer.d.ts +23 -0
- package/lib/processor/colorizer/Colorizer.js +70 -0
- package/lib/processor/colorizer/builtin.d.ts +17 -0
- package/lib/processor/colorizer/builtin.js +84 -0
- package/lib/processor/colorizer/index.d.ts +3 -0
- package/lib/processor/colorizer/index.js +28 -0
- package/lib/processor/completer/Completer.d.ts +75 -0
- package/lib/processor/completer/Completer.js +92 -0
- package/lib/processor/completer/builtin.d.ts +30 -0
- package/lib/processor/completer/builtin.js +172 -0
- package/lib/processor/completer/index.d.ts +3 -0
- package/lib/processor/completer/index.js +28 -0
- package/lib/processor/formatter/Formatter.d.ts +6 -0
- package/lib/processor/formatter/Formatter.js +19 -0
- package/lib/processor/formatter/builtin.d.ts +15 -0
- package/lib/processor/formatter/builtin.js +60 -0
- package/lib/processor/formatter/index.d.ts +3 -0
- package/lib/processor/formatter/index.js +28 -0
- package/lib/processor/index.d.ts +10 -0
- package/lib/processor/index.js +22 -0
- package/lib/processor/linter/Linter.d.ts +4 -0
- package/lib/processor/linter/Linter.js +3 -0
- package/lib/processor/linter/builtin/undeclaredSymbol.d.ts +4 -0
- package/lib/processor/linter/builtin/undeclaredSymbol.js +73 -0
- package/lib/processor/linter/builtin.d.ts +15 -0
- package/lib/processor/linter/builtin.js +120 -0
- package/lib/processor/linter/index.d.ts +3 -0
- package/lib/processor/linter/index.js +28 -0
- package/lib/processor/util.d.ts +17 -0
- package/lib/processor/util.js +32 -0
- package/lib/service/CacheService.d.ts +54 -0
- package/lib/service/CacheService.js +195 -0
- package/lib/service/CommandExecutor.d.ts +3 -0
- package/lib/service/CommandExecutor.js +7 -0
- package/lib/service/Config.d.ts +218 -0
- package/lib/service/Config.js +264 -0
- package/lib/service/Context.d.ts +143 -0
- package/lib/service/Context.js +143 -0
- package/lib/service/Dependency.d.ts +10 -0
- package/lib/service/Dependency.js +11 -0
- package/lib/service/Downloader.d.ts +67 -0
- package/lib/service/Downloader.js +185 -0
- package/lib/service/ErrorReporter.d.ts +27 -0
- package/lib/service/ErrorReporter.js +49 -0
- package/lib/service/FileService.d.ts +96 -0
- package/lib/service/FileService.js +224 -0
- package/lib/service/Hover.d.ts +10 -0
- package/lib/service/Hover.js +16 -0
- package/lib/service/Logger.d.ts +31 -0
- package/lib/service/Logger.js +30 -0
- package/lib/service/MetaRegistry.d.ts +106 -0
- package/lib/service/MetaRegistry.js +192 -0
- package/lib/service/Operations.d.ts +8 -0
- package/lib/service/Operations.js +26 -0
- package/lib/service/Profiler.d.ts +33 -0
- package/lib/service/Profiler.js +76 -0
- package/lib/service/Project.d.ts +173 -0
- package/lib/service/Project.js +593 -0
- package/lib/service/Service.d.ts +55 -0
- package/lib/service/Service.js +207 -0
- package/lib/service/SymbolLocations.d.ts +17 -0
- package/lib/service/SymbolLocations.js +16 -0
- package/lib/service/SymbolRegistrar.d.ts +5 -0
- package/lib/service/SymbolRegistrar.js +3 -0
- package/lib/service/fileUtil.d.ts +121 -0
- package/lib/service/fileUtil.js +268 -0
- package/lib/service/index.d.ts +18 -0
- package/lib/service/index.js +33 -0
- package/lib/source/IndexMap.d.ts +16 -0
- package/lib/source/IndexMap.js +46 -0
- package/lib/source/LanguageError.d.ts +27 -0
- package/lib/source/LanguageError.js +15 -0
- package/lib/source/Location.d.ts +19 -0
- package/lib/source/Location.js +25 -0
- package/lib/source/Offset.d.ts +13 -0
- package/lib/source/Offset.js +25 -0
- package/lib/source/Position.d.ts +23 -0
- package/lib/source/Position.js +43 -0
- package/lib/source/PositionRange.d.ts +38 -0
- package/lib/source/PositionRange.js +83 -0
- package/lib/source/Range.d.ts +68 -0
- package/lib/source/Range.js +155 -0
- package/lib/source/Source.d.ts +110 -0
- package/lib/source/Source.js +222 -0
- package/lib/source/index.d.ts +9 -0
- package/lib/source/index.js +21 -0
- package/lib/symbol/Symbol.d.ts +219 -0
- package/lib/symbol/Symbol.js +324 -0
- package/lib/symbol/SymbolUtil.d.ts +407 -0
- package/lib/symbol/SymbolUtil.js +880 -0
- package/lib/symbol/UriBinder.d.ts +3 -0
- package/lib/symbol/UriBinder.js +3 -0
- package/lib/symbol/index.d.ts +4 -0
- package/lib/symbol/index.js +16 -0
- package/package.json +41 -0
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.acceptOnly = exports.stopBefore = exports.validate = exports.setType = exports.map = exports.select = exports.recover = exports.optional = exports.failOnEmpty = exports.any = exports.repeat = exports.sequence = exports.attempt = void 0;
|
|
4
|
+
const node_1 = require("../node");
|
|
5
|
+
const service_1 = require("../service");
|
|
6
|
+
const source_1 = require("../source");
|
|
7
|
+
const Parser_1 = require("./Parser");
|
|
8
|
+
function attempt(parser, src, ctx) {
|
|
9
|
+
const tmpSrc = src.clone();
|
|
10
|
+
const tmpCtx = {
|
|
11
|
+
...ctx,
|
|
12
|
+
err: new service_1.ErrorReporter(),
|
|
13
|
+
symbols: ctx.symbols.clone(),
|
|
14
|
+
};
|
|
15
|
+
const result = parser(tmpSrc, tmpCtx);
|
|
16
|
+
return {
|
|
17
|
+
result,
|
|
18
|
+
endCursor: tmpSrc.cursor,
|
|
19
|
+
errorAmount: tmpCtx.err.errors.length,
|
|
20
|
+
updateSrcAndCtx: () => {
|
|
21
|
+
src.innerCursor = tmpSrc.innerCursor;
|
|
22
|
+
ctx.err.absorb(tmpCtx.err);
|
|
23
|
+
tmpCtx.symbols.applyDelayedEdits();
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
exports.attempt = attempt;
|
|
28
|
+
function sequence(parsers, parseGap) {
|
|
29
|
+
return (src, ctx) => {
|
|
30
|
+
const ans = {
|
|
31
|
+
isSequenceUtil: true,
|
|
32
|
+
children: [],
|
|
33
|
+
range: source_1.Range.create(src),
|
|
34
|
+
};
|
|
35
|
+
for (const [i, p] of parsers.entries()) {
|
|
36
|
+
const parser = typeof p === 'function' ? p : p.get(ans);
|
|
37
|
+
if (parser === undefined) {
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
if (i > 0 && parseGap) {
|
|
41
|
+
ans.children.push(...parseGap(src, ctx));
|
|
42
|
+
}
|
|
43
|
+
const result = parser(src, ctx);
|
|
44
|
+
if (result === Parser_1.Failure) {
|
|
45
|
+
return Parser_1.Failure;
|
|
46
|
+
}
|
|
47
|
+
else if (result === undefined) {
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
else if (node_1.SequenceUtil.is(result)) {
|
|
51
|
+
ans.children.push(...result.children);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
ans.children.push(result);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
ans.range.end = src.cursor;
|
|
58
|
+
return ans;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
exports.sequence = sequence;
|
|
62
|
+
function repeat(parser, parseGap) {
|
|
63
|
+
return (src, ctx) => {
|
|
64
|
+
const ans = {
|
|
65
|
+
isSequenceUtil: true,
|
|
66
|
+
children: [],
|
|
67
|
+
range: source_1.Range.create(src),
|
|
68
|
+
};
|
|
69
|
+
while (src.canRead()) {
|
|
70
|
+
if (parseGap) {
|
|
71
|
+
ans.children.push(...parseGap(src, ctx));
|
|
72
|
+
}
|
|
73
|
+
const { result, updateSrcAndCtx } = attempt(parser, src, ctx);
|
|
74
|
+
if (result === Parser_1.Failure) {
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
updateSrcAndCtx();
|
|
78
|
+
if (node_1.SequenceUtil.is(result)) {
|
|
79
|
+
ans.children.push(...result.children);
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
ans.children.push(result);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
ans.range.end = src.cursor;
|
|
86
|
+
return ans;
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
exports.repeat = repeat;
|
|
90
|
+
function any(parsers, out) {
|
|
91
|
+
return (src, ctx) => {
|
|
92
|
+
const results = parsers
|
|
93
|
+
.map((parser, i) => ({ attempt: attempt(parser, src, ctx), index: i }))
|
|
94
|
+
.filter(({ attempt }) => attempt.result !== Parser_1.Failure)
|
|
95
|
+
.sort((a, b) => (b.attempt.endCursor - a.attempt.endCursor) || (a.attempt.errorAmount - b.attempt.errorAmount));
|
|
96
|
+
if (results.length === 0) {
|
|
97
|
+
if (out) {
|
|
98
|
+
out.index = -1;
|
|
99
|
+
}
|
|
100
|
+
return Parser_1.Failure;
|
|
101
|
+
}
|
|
102
|
+
results[0].attempt.updateSrcAndCtx();
|
|
103
|
+
if (out) {
|
|
104
|
+
out.index = results[0].index;
|
|
105
|
+
}
|
|
106
|
+
return results[0].attempt.result;
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
exports.any = any;
|
|
110
|
+
/**
|
|
111
|
+
* @returns A parser that fails when the passed-in parser didn't move the cursor at all.
|
|
112
|
+
*/
|
|
113
|
+
function failOnEmpty(parser) {
|
|
114
|
+
return (src, ctx) => {
|
|
115
|
+
const start = src.cursor;
|
|
116
|
+
const { endCursor, updateSrcAndCtx, result } = attempt(parser, src, ctx);
|
|
117
|
+
if (endCursor - start > 0) {
|
|
118
|
+
updateSrcAndCtx();
|
|
119
|
+
return result;
|
|
120
|
+
}
|
|
121
|
+
return Parser_1.Failure;
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
exports.failOnEmpty = failOnEmpty;
|
|
125
|
+
function optional(parser) {
|
|
126
|
+
// return any<N | undefined>([
|
|
127
|
+
// parser,
|
|
128
|
+
// empty,
|
|
129
|
+
// ])
|
|
130
|
+
return (src, ctx) => {
|
|
131
|
+
const { result, updateSrcAndCtx } = attempt(parser, src, ctx);
|
|
132
|
+
if (result === Parser_1.Failure) {
|
|
133
|
+
return undefined;
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
updateSrcAndCtx();
|
|
137
|
+
return result;
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
exports.optional = optional;
|
|
142
|
+
function recover(parser, defaultValue) {
|
|
143
|
+
return (src, ctx) => {
|
|
144
|
+
const result = parser(src, ctx);
|
|
145
|
+
if (result === Parser_1.Failure) {
|
|
146
|
+
const ans = defaultValue(src, ctx);
|
|
147
|
+
return ans;
|
|
148
|
+
}
|
|
149
|
+
return result;
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
exports.recover = recover;
|
|
153
|
+
function select(cases) {
|
|
154
|
+
return (src, ctx) => {
|
|
155
|
+
for (const { predicate, parser } of cases) {
|
|
156
|
+
if (predicate?.(src) ?? true) {
|
|
157
|
+
return parser(src, ctx);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return Parser_1.Failure;
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
exports.select = select;
|
|
164
|
+
function map(parser, fn) {
|
|
165
|
+
return (src, ctx) => {
|
|
166
|
+
const result = parser(src, ctx);
|
|
167
|
+
if (result === Parser_1.Failure) {
|
|
168
|
+
return Parser_1.Failure;
|
|
169
|
+
}
|
|
170
|
+
const ans = fn(result, src, ctx);
|
|
171
|
+
return ans;
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
exports.map = map;
|
|
175
|
+
function setType(type, parser) {
|
|
176
|
+
return map(parser, res => ({
|
|
177
|
+
...res,
|
|
178
|
+
type,
|
|
179
|
+
}));
|
|
180
|
+
}
|
|
181
|
+
exports.setType = setType;
|
|
182
|
+
function validate(parser, validator, message, severity) {
|
|
183
|
+
return map(parser, (res, src, ctx) => {
|
|
184
|
+
const isLegal = validator(res, src, ctx);
|
|
185
|
+
if (!isLegal) {
|
|
186
|
+
ctx.err.report(message, res.range, severity);
|
|
187
|
+
}
|
|
188
|
+
return res;
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
exports.validate = validate;
|
|
192
|
+
function stopBefore(parser, ...teminators) {
|
|
193
|
+
const flatTerminators = teminators.flat();
|
|
194
|
+
return (src, ctx) => {
|
|
195
|
+
const tmpSrc = src.clone();
|
|
196
|
+
// Cut tmpSrc.string before the nearest terminator.
|
|
197
|
+
tmpSrc.string = tmpSrc.string.slice(0, flatTerminators.reduce((p, c) => {
|
|
198
|
+
const index = tmpSrc.string.indexOf(c, tmpSrc.innerCursor);
|
|
199
|
+
return Math.min(p, index === -1 ? Infinity : index);
|
|
200
|
+
}, Infinity));
|
|
201
|
+
const ans = parser(tmpSrc, ctx);
|
|
202
|
+
src.cursor = tmpSrc.cursor;
|
|
203
|
+
return ans;
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
exports.stopBefore = stopBefore;
|
|
207
|
+
function acceptOnly(parser, ...characters) {
|
|
208
|
+
const set = new Set(characters.flat());
|
|
209
|
+
return (src, ctx) => {
|
|
210
|
+
const tmpSrc = src.clone();
|
|
211
|
+
// Cut tmpSrc.string before the nearest unacceptable character.
|
|
212
|
+
for (let i = tmpSrc.innerCursor; i < tmpSrc.string.length; i++) {
|
|
213
|
+
if (!set.has(tmpSrc.string.charAt(i))) {
|
|
214
|
+
tmpSrc.string = tmpSrc.string.slice(0, i);
|
|
215
|
+
break;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
const ans = parser(tmpSrc, ctx);
|
|
219
|
+
src.cursor = tmpSrc.cursor;
|
|
220
|
+
return ans;
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
exports.acceptOnly = acceptOnly;
|
|
224
|
+
//# sourceMappingURL=util.js.map
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { Range } from '../source';
|
|
2
|
+
export interface ColorInfo {
|
|
3
|
+
range: Range;
|
|
4
|
+
color: Color;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* An array of four decimal numbers within the interval [0, 1] that represent R, G, B, and A respectively.
|
|
8
|
+
*/
|
|
9
|
+
export declare type Color = [number, number, number, number];
|
|
10
|
+
export declare namespace Color {
|
|
11
|
+
const NamedColors: Map<string, number>;
|
|
12
|
+
const ColorNames: string[];
|
|
13
|
+
/**
|
|
14
|
+
* @param r A decimal within [0.0, 1.0].
|
|
15
|
+
* @param g A decimal within [0.0, 1.0].
|
|
16
|
+
* @param b A decimal within [0.0, 1.0].
|
|
17
|
+
* @param a A decimal within [0.0, 1.0].
|
|
18
|
+
*/
|
|
19
|
+
function fromDecRGBA(r: number, g: number, b: number, a: number): Color;
|
|
20
|
+
/**
|
|
21
|
+
* @param r A decimal within [0.0, 1.0].
|
|
22
|
+
* @param g A decimal within [0.0, 1.0].
|
|
23
|
+
* @param b A decimal within [0.0, 1.0].
|
|
24
|
+
*/
|
|
25
|
+
function fromDecRGB(r: number, g: number, b: number): Color;
|
|
26
|
+
/**
|
|
27
|
+
* @param r An integer within [0, 255].
|
|
28
|
+
* @param g An integer within [0, 255].
|
|
29
|
+
* @param b An integer within [0, 255].
|
|
30
|
+
* @param a An integer within [0, 255].
|
|
31
|
+
*/
|
|
32
|
+
function fromIntRGBA(r: number, g: number, b: number, a: number): Color;
|
|
33
|
+
/**
|
|
34
|
+
* @param r An integer within [0, 255].
|
|
35
|
+
* @param g An integer within [0, 255].
|
|
36
|
+
* @param b An integer within [0, 255].
|
|
37
|
+
*/
|
|
38
|
+
function fromIntRGB(r: number, g: number, b: number): Color;
|
|
39
|
+
/**
|
|
40
|
+
* @param value `R << 16 + G << 8 + B`. Negative values result in white.
|
|
41
|
+
*/
|
|
42
|
+
function fromCompositeInt(value: number): Color;
|
|
43
|
+
}
|
|
44
|
+
export declare enum ColorFormat {
|
|
45
|
+
/**
|
|
46
|
+
* `1 0.6 0.2 1.0`
|
|
47
|
+
*/
|
|
48
|
+
DecRGBA = 0,
|
|
49
|
+
/**
|
|
50
|
+
* `1 0.6 0.2`
|
|
51
|
+
*/
|
|
52
|
+
DecRGB = 1,
|
|
53
|
+
/**
|
|
54
|
+
* `255 153 51 25`
|
|
55
|
+
*/
|
|
56
|
+
IntRGBA = 2,
|
|
57
|
+
/**
|
|
58
|
+
* `255 153 51`
|
|
59
|
+
*/
|
|
60
|
+
IntRGB = 3,
|
|
61
|
+
/**
|
|
62
|
+
* `#ff9933ff`
|
|
63
|
+
*/
|
|
64
|
+
HexRGBA = 4,
|
|
65
|
+
/**
|
|
66
|
+
* `#ff9933`
|
|
67
|
+
*/
|
|
68
|
+
HexRGB = 5,
|
|
69
|
+
/**
|
|
70
|
+
* `16620441`
|
|
71
|
+
*/
|
|
72
|
+
CompositeInt = 6
|
|
73
|
+
}
|
|
74
|
+
export declare type FormattableColor = {
|
|
75
|
+
value: Color;
|
|
76
|
+
format: ColorFormat[];
|
|
77
|
+
range?: Range;
|
|
78
|
+
};
|
|
79
|
+
export declare type ColorPresentation = {
|
|
80
|
+
label: string;
|
|
81
|
+
text: string;
|
|
82
|
+
range: Range;
|
|
83
|
+
};
|
|
84
|
+
export declare namespace ColorPresentation {
|
|
85
|
+
function fromColorFormat(format: ColorFormat, color: Color, range: Range): ColorPresentation;
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=ColorInfoProvider.d.ts.map
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ColorPresentation = exports.ColorFormat = exports.Color = void 0;
|
|
4
|
+
var Color;
|
|
5
|
+
(function (Color) {
|
|
6
|
+
Color.NamedColors = new Map([
|
|
7
|
+
['aqua', 0x55ffff],
|
|
8
|
+
['black', 0x000000],
|
|
9
|
+
['blue', 0x5555ff],
|
|
10
|
+
['dark_aqua', 0x00aaaa],
|
|
11
|
+
['dark_blue', 0x0000aa],
|
|
12
|
+
['dark_gray', 0x555555],
|
|
13
|
+
['dark_green', 0x00aa00],
|
|
14
|
+
['dark_purple', 0xaa00aa],
|
|
15
|
+
['dark_red', 0xaa0000],
|
|
16
|
+
['gold', 0xffaa00],
|
|
17
|
+
['gray', 0xaaaaaa],
|
|
18
|
+
['green', 0x55ff55],
|
|
19
|
+
['light_purple', 0xff55ff],
|
|
20
|
+
['red', 0xff5555],
|
|
21
|
+
['white', 0xffffff],
|
|
22
|
+
['yellow', 0xffff55],
|
|
23
|
+
]);
|
|
24
|
+
Color.ColorNames = [...Color.NamedColors.keys()];
|
|
25
|
+
/**
|
|
26
|
+
* @param r A decimal within [0.0, 1.0].
|
|
27
|
+
* @param g A decimal within [0.0, 1.0].
|
|
28
|
+
* @param b A decimal within [0.0, 1.0].
|
|
29
|
+
* @param a A decimal within [0.0, 1.0].
|
|
30
|
+
*/
|
|
31
|
+
function fromDecRGBA(r, g, b, a) {
|
|
32
|
+
return [r, g, b, a];
|
|
33
|
+
}
|
|
34
|
+
Color.fromDecRGBA = fromDecRGBA;
|
|
35
|
+
/**
|
|
36
|
+
* @param r A decimal within [0.0, 1.0].
|
|
37
|
+
* @param g A decimal within [0.0, 1.0].
|
|
38
|
+
* @param b A decimal within [0.0, 1.0].
|
|
39
|
+
*/
|
|
40
|
+
function fromDecRGB(r, g, b) {
|
|
41
|
+
return fromDecRGBA(r, g, b, 1.0);
|
|
42
|
+
}
|
|
43
|
+
Color.fromDecRGB = fromDecRGB;
|
|
44
|
+
/**
|
|
45
|
+
* @param r An integer within [0, 255].
|
|
46
|
+
* @param g An integer within [0, 255].
|
|
47
|
+
* @param b An integer within [0, 255].
|
|
48
|
+
* @param a An integer within [0, 255].
|
|
49
|
+
*/
|
|
50
|
+
function fromIntRGBA(r, g, b, a) {
|
|
51
|
+
return fromDecRGBA(r / 255, g / 255, b / 255, a / 255);
|
|
52
|
+
}
|
|
53
|
+
Color.fromIntRGBA = fromIntRGBA;
|
|
54
|
+
/**
|
|
55
|
+
* @param r An integer within [0, 255].
|
|
56
|
+
* @param g An integer within [0, 255].
|
|
57
|
+
* @param b An integer within [0, 255].
|
|
58
|
+
*/
|
|
59
|
+
function fromIntRGB(r, g, b) {
|
|
60
|
+
return fromIntRGBA(r, g, b, 255);
|
|
61
|
+
}
|
|
62
|
+
Color.fromIntRGB = fromIntRGB;
|
|
63
|
+
/**
|
|
64
|
+
* @param value `R << 16 + G << 8 + B`. Negative values result in white.
|
|
65
|
+
*/
|
|
66
|
+
function fromCompositeInt(value) {
|
|
67
|
+
if (value < 0) {
|
|
68
|
+
return fromDecRGB(1.0, 1.0, 1.0);
|
|
69
|
+
}
|
|
70
|
+
const b = value % 256;
|
|
71
|
+
value >>= 8;
|
|
72
|
+
const g = value % 256;
|
|
73
|
+
value >>= 8;
|
|
74
|
+
const r = value % 256;
|
|
75
|
+
return fromIntRGB(r, g, b);
|
|
76
|
+
}
|
|
77
|
+
Color.fromCompositeInt = fromCompositeInt;
|
|
78
|
+
})(Color = exports.Color || (exports.Color = {}));
|
|
79
|
+
var ColorFormat;
|
|
80
|
+
(function (ColorFormat) {
|
|
81
|
+
/**
|
|
82
|
+
* `1 0.6 0.2 1.0`
|
|
83
|
+
*/
|
|
84
|
+
ColorFormat[ColorFormat["DecRGBA"] = 0] = "DecRGBA";
|
|
85
|
+
/**
|
|
86
|
+
* `1 0.6 0.2`
|
|
87
|
+
*/
|
|
88
|
+
ColorFormat[ColorFormat["DecRGB"] = 1] = "DecRGB";
|
|
89
|
+
/**
|
|
90
|
+
* `255 153 51 25`
|
|
91
|
+
*/
|
|
92
|
+
ColorFormat[ColorFormat["IntRGBA"] = 2] = "IntRGBA";
|
|
93
|
+
/**
|
|
94
|
+
* `255 153 51`
|
|
95
|
+
*/
|
|
96
|
+
ColorFormat[ColorFormat["IntRGB"] = 3] = "IntRGB";
|
|
97
|
+
/**
|
|
98
|
+
* `#ff9933ff`
|
|
99
|
+
*/
|
|
100
|
+
ColorFormat[ColorFormat["HexRGBA"] = 4] = "HexRGBA";
|
|
101
|
+
/**
|
|
102
|
+
* `#ff9933`
|
|
103
|
+
*/
|
|
104
|
+
ColorFormat[ColorFormat["HexRGB"] = 5] = "HexRGB";
|
|
105
|
+
/**
|
|
106
|
+
* `16620441`
|
|
107
|
+
*/
|
|
108
|
+
ColorFormat[ColorFormat["CompositeInt"] = 6] = "CompositeInt";
|
|
109
|
+
})(ColorFormat = exports.ColorFormat || (exports.ColorFormat = {}));
|
|
110
|
+
var ColorPresentation;
|
|
111
|
+
(function (ColorPresentation) {
|
|
112
|
+
function fromColorFormat(format, color, range) {
|
|
113
|
+
const presentation = colorPresentation(format, color);
|
|
114
|
+
return {
|
|
115
|
+
label: presentation,
|
|
116
|
+
text: presentation,
|
|
117
|
+
range,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
ColorPresentation.fromColorFormat = fromColorFormat;
|
|
121
|
+
function colorPresentation(format, color) {
|
|
122
|
+
const round = (num) => parseFloat(num.toFixed(3));
|
|
123
|
+
switch (format) {
|
|
124
|
+
case ColorFormat.DecRGBA:
|
|
125
|
+
return color.map(c => round(c)).join(' ');
|
|
126
|
+
case ColorFormat.DecRGB:
|
|
127
|
+
return color.slice(0, 3).map(c => round(c)).join(' ');
|
|
128
|
+
case ColorFormat.IntRGBA:
|
|
129
|
+
return color.map(c => Math.round(c * 255)).join(' ');
|
|
130
|
+
case ColorFormat.IntRGB:
|
|
131
|
+
return color.slice(0, 3).map(c => Math.round(c * 255)).join(' ');
|
|
132
|
+
case ColorFormat.HexRGBA:
|
|
133
|
+
return `#${Math.round((color[0] * 255 << 24) + (color[1] * 255 << 16) + (color[2] * 255) << 8 + color[3] * 255).toString(16).padStart(8, '0')}`;
|
|
134
|
+
case ColorFormat.HexRGB:
|
|
135
|
+
return `#${Math.round((color[0] * 255 << 16) + (color[1] * 255 << 8) + color[2] * 255).toString(16).padStart(6, '0')}`;
|
|
136
|
+
case ColorFormat.CompositeInt:
|
|
137
|
+
return `${Math.round((color[0] * 255 << 16) + (color[1] * 255 << 8) + color[2] * 255)}`;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
})(ColorPresentation = exports.ColorPresentation || (exports.ColorPresentation = {}));
|
|
141
|
+
//# sourceMappingURL=ColorInfoProvider.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AstNode } from '../node';
|
|
2
|
+
import type { ProcessorContext } from '../service';
|
|
3
|
+
export interface InlayHint {
|
|
4
|
+
offset: number;
|
|
5
|
+
text: string;
|
|
6
|
+
}
|
|
7
|
+
export declare type InlayHintProvider<N = AstNode> = (node: N, ctx: ProcessorContext) => readonly InlayHint[];
|
|
8
|
+
//# sourceMappingURL=InlayHintProvider.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { AstNode } from '../node';
|
|
2
|
+
import type { SignatureHelpProviderContext } from '../service';
|
|
3
|
+
export interface SignatureHelp {
|
|
4
|
+
signatures: SignatureInfo[];
|
|
5
|
+
activeSignature: number;
|
|
6
|
+
}
|
|
7
|
+
export interface SignatureInfo {
|
|
8
|
+
label: string;
|
|
9
|
+
documentation?: string;
|
|
10
|
+
parameters: ParameterInfo[];
|
|
11
|
+
activeParameter: number;
|
|
12
|
+
}
|
|
13
|
+
export interface ParameterInfo {
|
|
14
|
+
label: [number, number];
|
|
15
|
+
documentation?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare type SignatureHelpProvider<N = AstNode> = (node: N, ctx: SignatureHelpProviderContext) => SignatureHelp | undefined;
|
|
18
|
+
//# sourceMappingURL=SignatureHelpProvider.d.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AstNode } from '../../node';
|
|
2
|
+
import type { CheckerContext } from '../../service';
|
|
3
|
+
export declare type Checker<N extends AstNode> = (node: N, ctx: CheckerContext) => PromiseLike<void> | void;
|
|
4
|
+
export declare type SyncChecker<N extends AstNode> = (node: N, ctx: CheckerContext) => void;
|
|
5
|
+
export declare type AsyncChecker<N extends AstNode> = (node: N, ctx: CheckerContext) => PromiseLike<void>;
|
|
6
|
+
export declare const FallbackChecker: Checker<any>;
|
|
7
|
+
//# sourceMappingURL=Checker.d.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FallbackChecker = void 0;
|
|
4
|
+
/* istanbul ignore next */
|
|
5
|
+
const FallbackChecker = () => Promise.resolve();
|
|
6
|
+
exports.FallbackChecker = FallbackChecker;
|
|
7
|
+
//# sourceMappingURL=Checker.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { AstNode, SymbolBaseNode } from '../../node';
|
|
2
|
+
import { ResourceLocationNode } from '../../node';
|
|
3
|
+
import type { CheckerContext, MetaRegistry } from '../../service';
|
|
4
|
+
import type { Checker, SyncChecker } from './Checker';
|
|
5
|
+
export declare type AttemptResult = {
|
|
6
|
+
errorAmount: number;
|
|
7
|
+
totalErrorSpan: number;
|
|
8
|
+
updateNodeAndCtx: () => void;
|
|
9
|
+
};
|
|
10
|
+
export declare function attempt<N extends AstNode>(checker: Checker<N>, node: N, ctx: CheckerContext): AttemptResult;
|
|
11
|
+
export declare function any<N extends AstNode>(checkers: Checker<N>[]): Checker<N>;
|
|
12
|
+
/**
|
|
13
|
+
* No operation.
|
|
14
|
+
*/
|
|
15
|
+
export declare const noop: SyncChecker<AstNode>;
|
|
16
|
+
/**
|
|
17
|
+
* Use the shallowest children that have their own checker to validate.
|
|
18
|
+
*/
|
|
19
|
+
export declare const fallback: Checker<AstNode>;
|
|
20
|
+
export declare const resourceLocation: Checker<ResourceLocationNode>;
|
|
21
|
+
export declare const symbol: Checker<SymbolBaseNode>;
|
|
22
|
+
export declare function registerCheckers(meta: MetaRegistry): void;
|
|
23
|
+
//# sourceMappingURL=builtin.d.ts.map
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerCheckers = exports.symbol = exports.resourceLocation = exports.fallback = exports.noop = exports.any = exports.attempt = void 0;
|
|
4
|
+
const lib_1 = require("../../../../locales/lib");
|
|
5
|
+
const node_1 = require("../../node");
|
|
6
|
+
const service_1 = require("../../service");
|
|
7
|
+
const util_1 = require("../util");
|
|
8
|
+
function attempt(checker, node, ctx) {
|
|
9
|
+
const tempCtx = {
|
|
10
|
+
...ctx,
|
|
11
|
+
err: new service_1.ErrorReporter(),
|
|
12
|
+
ops: new service_1.Operations(),
|
|
13
|
+
symbols: ctx.symbols.clone(),
|
|
14
|
+
};
|
|
15
|
+
// FIXME: await
|
|
16
|
+
checker(node, tempCtx);
|
|
17
|
+
tempCtx.ops.undo();
|
|
18
|
+
const totalErrorSpan = tempCtx.err.errors
|
|
19
|
+
.map(e => e.range.end - e.range.start)
|
|
20
|
+
.reduce((a, b) => a + b, 0);
|
|
21
|
+
return {
|
|
22
|
+
errorAmount: tempCtx.err.errors.length,
|
|
23
|
+
totalErrorSpan,
|
|
24
|
+
updateNodeAndCtx: () => {
|
|
25
|
+
ctx.err.absorb(tempCtx.err);
|
|
26
|
+
tempCtx.ops.redo();
|
|
27
|
+
tempCtx.symbols.applyDelayedEdits();
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
exports.attempt = attempt;
|
|
32
|
+
function any(checkers) {
|
|
33
|
+
if (checkers.length === 0) {
|
|
34
|
+
throw new Error('Expected at least one checker');
|
|
35
|
+
}
|
|
36
|
+
return (node, ctx) => {
|
|
37
|
+
const attempts = checkers
|
|
38
|
+
.map(checker => attempt(checker, node, ctx))
|
|
39
|
+
.sort((a, b) => a.errorAmount - b.errorAmount || a.totalErrorSpan - b.totalErrorSpan);
|
|
40
|
+
attempts[0].updateNodeAndCtx();
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
exports.any = any;
|
|
44
|
+
/**
|
|
45
|
+
* No operation.
|
|
46
|
+
*/
|
|
47
|
+
const noop = () => { };
|
|
48
|
+
exports.noop = noop;
|
|
49
|
+
/**
|
|
50
|
+
* Use the shallowest children that have their own checker to validate.
|
|
51
|
+
*/
|
|
52
|
+
const fallback = async (node, ctx) => {
|
|
53
|
+
const promises = [];
|
|
54
|
+
(0, util_1.traversePreOrder)(node, node => !ctx.meta.hasChecker(node.type), node => ctx.meta.hasChecker(node.type), node => {
|
|
55
|
+
const checker = ctx.meta.getChecker(node.type);
|
|
56
|
+
const result = checker(node, ctx);
|
|
57
|
+
if (result instanceof Promise) {
|
|
58
|
+
promises.push(result);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
await Promise.allSettled(promises);
|
|
62
|
+
};
|
|
63
|
+
exports.fallback = fallback;
|
|
64
|
+
const resourceLocation = (node, ctx) => {
|
|
65
|
+
const full = node_1.ResourceLocationNode.toString(node, 'full');
|
|
66
|
+
if (node.options.pool) {
|
|
67
|
+
if (!node.options.pool.includes(full)) {
|
|
68
|
+
ctx.err.report((0, lib_1.localize)('expected', node.options.pool), node, 3 /* Error */);
|
|
69
|
+
}
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
exports.resourceLocation = resourceLocation;
|
|
74
|
+
const symbol = (_node, _ctx) => {
|
|
75
|
+
// TODO
|
|
76
|
+
};
|
|
77
|
+
exports.symbol = symbol;
|
|
78
|
+
function registerCheckers(meta) {
|
|
79
|
+
meta.registerChecker('resource_location', exports.resourceLocation);
|
|
80
|
+
meta.registerChecker('symbol', exports.symbol);
|
|
81
|
+
}
|
|
82
|
+
exports.registerCheckers = registerCheckers;
|
|
83
|
+
//# sourceMappingURL=builtin.js.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
22
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.checker = void 0;
|
|
26
|
+
exports.checker = __importStar(require("./builtin"));
|
|
27
|
+
__exportStar(require("./Checker"), exports);
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { AstNode } from '../../node';
|
|
2
|
+
import type { ColorizerContext } from '../../service';
|
|
3
|
+
import type { RangeLike } from '../../source';
|
|
4
|
+
import { Range } from '../../source';
|
|
5
|
+
export declare type Colorizer<N = AstNode> = (node: N, ctx: ColorizerContext) => readonly ColorToken[];
|
|
6
|
+
export interface ColorToken {
|
|
7
|
+
range: Range;
|
|
8
|
+
type: ColorTokenType;
|
|
9
|
+
modifiers?: ColorTokenModifier[];
|
|
10
|
+
}
|
|
11
|
+
export declare namespace ColorToken {
|
|
12
|
+
function create(range: RangeLike, type: ColorTokenType, modifiers?: ColorTokenModifier[]): ColorToken;
|
|
13
|
+
/**
|
|
14
|
+
* @returns An array of color tokens that cover the whole range of `targetRange`, with gaps in `tokens` filled
|
|
15
|
+
* with tokens created from the specified `type` and `modifiers`.
|
|
16
|
+
*/
|
|
17
|
+
function fillGap(tokens: readonly ColorToken[], targetRange: Range, type: ColorTokenType, modifiers?: ColorTokenModifier[]): ColorToken[];
|
|
18
|
+
}
|
|
19
|
+
export declare const ColorTokenTypes: readonly ["comment", "enum", "enumMember", "function", "keyword", "modifier", "number", "operator", "property", "string", "struct", "type", "type", "variable", "error", "literal", "operator", "resourceLocation", "vector"];
|
|
20
|
+
export declare type ColorTokenType = typeof ColorTokenTypes[number];
|
|
21
|
+
export declare const ColorTokenModifiers: readonly ["declaration", "defaultLibrary", "definition", "deprecated", "documentation", "modification", "readonly"];
|
|
22
|
+
export declare type ColorTokenModifier = typeof ColorTokenModifiers[number];
|
|
23
|
+
//# sourceMappingURL=Colorizer.d.ts.map
|