@spyglassmc/core 0.1.0 → 0.2.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 +7 -0
- package/lib/browser.d.ts +2 -0
- package/lib/browser.js +2 -0
- package/lib/common/TwoWayMap.d.ts +21 -0
- package/lib/common/TwoWayMap.js +69 -0
- package/lib/common/externals/BrowserExternals.d.ts +3 -0
- package/lib/common/externals/BrowserExternals.js +191 -0
- package/lib/common/externals/NodeJsExternals.d.ts +3 -0
- package/lib/common/externals/NodeJsExternals.js +151 -0
- package/lib/common/externals/downloader.d.ts +31 -0
- package/lib/common/externals/downloader.js +32 -0
- package/lib/common/externals/index.d.ts +96 -0
- package/lib/common/externals/index.js +2 -0
- package/lib/common/index.d.ts +2 -1
- package/lib/common/index.js +2 -13
- package/lib/common/util.d.ts +17 -34
- package/lib/common/util.js +32 -113
- package/lib/index.d.ts +7 -7
- package/lib/index.js +7 -19
- package/lib/node/AstNode.d.ts +3 -3
- package/lib/node/AstNode.js +10 -16
- package/lib/node/BooleanNode.d.ts +2 -2
- package/lib/node/BooleanNode.js +4 -7
- package/lib/node/CommentNode.d.ts +1 -1
- package/lib/node/CommentNode.js +2 -5
- package/lib/node/ErrorNode.d.ts +1 -1
- package/lib/node/ErrorNode.js +2 -5
- package/lib/node/FileNode.d.ts +3 -3
- package/lib/node/FileNode.js +2 -5
- package/lib/node/FloatNode.d.ts +2 -2
- package/lib/node/FloatNode.js +4 -7
- package/lib/node/IntegerNode.d.ts +2 -2
- package/lib/node/IntegerNode.js +4 -7
- package/lib/node/ListNode.d.ts +2 -2
- package/lib/node/ListNode.js +2 -5
- package/lib/node/LiteralNode.d.ts +4 -4
- package/lib/node/LiteralNode.js +5 -8
- package/lib/node/LongNode.d.ts +2 -2
- package/lib/node/LongNode.js +4 -7
- package/lib/node/RecordNode.d.ts +2 -2
- package/lib/node/RecordNode.js +2 -5
- package/lib/node/ResourceLocationNode.d.ts +6 -8
- package/lib/node/ResourceLocationNode.js +9 -12
- package/lib/node/Sequence.d.ts +4 -3
- package/lib/node/Sequence.js +4 -6
- package/lib/node/StringNode.d.ts +5 -5
- package/lib/node/StringNode.js +9 -12
- package/lib/node/SymbolNode.d.ts +4 -4
- package/lib/node/SymbolNode.js +5 -8
- package/lib/node/index.d.ts +15 -15
- package/lib/node/index.js +15 -27
- package/lib/nodejs.d.ts +2 -0
- package/lib/nodejs.js +2 -0
- package/lib/parser/Parser.d.ts +3 -3
- package/lib/parser/Parser.js +1 -4
- package/lib/parser/boolean.d.ts +2 -2
- package/lib/parser/boolean.js +3 -6
- package/lib/parser/comment.d.ts +2 -2
- package/lib/parser/comment.js +5 -9
- package/lib/parser/empty.d.ts +1 -1
- package/lib/parser/empty.js +1 -5
- package/lib/parser/error.d.ts +2 -2
- package/lib/parser/error.js +5 -9
- package/lib/parser/file.d.ts +3 -3
- package/lib/parser/file.js +9 -13
- package/lib/parser/float.d.ts +4 -4
- package/lib/parser/float.js +12 -16
- package/lib/parser/index.d.ts +16 -16
- package/lib/parser/index.js +16 -34
- package/lib/parser/integer.d.ts +4 -4
- package/lib/parser/integer.js +10 -14
- package/lib/parser/list.d.ts +2 -2
- package/lib/parser/list.js +15 -19
- package/lib/parser/literal.d.ts +2 -2
- package/lib/parser/literal.js +5 -9
- package/lib/parser/long.d.ts +4 -4
- package/lib/parser/long.js +10 -14
- package/lib/parser/record.d.ts +3 -3
- package/lib/parser/record.js +20 -24
- package/lib/parser/resourceLocation.d.ts +2 -2
- package/lib/parser/resourceLocation.js +14 -18
- package/lib/parser/string.d.ts +7 -7
- package/lib/parser/string.js +40 -44
- package/lib/parser/symbol.d.ts +3 -3
- package/lib/parser/symbol.js +3 -7
- package/lib/parser/util.d.ts +30 -12
- package/lib/parser/util.js +78 -63
- package/lib/processor/ColorInfoProvider.d.ts +1 -1
- package/lib/processor/ColorInfoProvider.js +6 -9
- package/lib/processor/InlayHintProvider.d.ts +2 -2
- package/lib/processor/InlayHintProvider.js +1 -2
- package/lib/processor/SignatureHelpProvider.d.ts +2 -2
- package/lib/processor/SignatureHelpProvider.js +1 -2
- package/lib/processor/checker/Checker.d.ts +2 -2
- package/lib/processor/checker/Checker.js +1 -5
- package/lib/processor/checker/builtin.d.ts +5 -4
- package/lib/processor/checker/builtin.js +26 -28
- package/lib/processor/checker/index.d.ts +2 -2
- package/lib/processor/checker/index.js +2 -27
- package/lib/processor/colorizer/Colorizer.d.ts +4 -4
- package/lib/processor/colorizer/Colorizer.js +8 -11
- package/lib/processor/colorizer/builtin.d.ts +3 -3
- package/lib/processor/colorizer/builtin.js +33 -46
- package/lib/processor/colorizer/index.d.ts +2 -2
- package/lib/processor/colorizer/index.js +2 -27
- package/lib/processor/completer/Completer.d.ts +4 -4
- package/lib/processor/completer/Completer.js +14 -33
- package/lib/processor/completer/builtin.d.ts +7 -7
- package/lib/processor/completer/builtin.js +58 -74
- package/lib/processor/completer/index.d.ts +2 -2
- package/lib/processor/completer/index.js +2 -27
- package/lib/processor/formatter/Formatter.d.ts +2 -2
- package/lib/processor/formatter/Formatter.js +2 -7
- package/lib/processor/formatter/builtin.d.ts +3 -3
- package/lib/processor/formatter/builtin.js +22 -36
- package/lib/processor/formatter/index.d.ts +2 -2
- package/lib/processor/formatter/index.js +2 -27
- package/lib/processor/index.d.ts +9 -9
- package/lib/processor/index.js +9 -21
- package/lib/processor/linter/Linter.d.ts +2 -2
- package/lib/processor/linter/Linter.js +1 -2
- package/lib/processor/linter/builtin/undeclaredSymbol.d.ts +2 -2
- package/lib/processor/linter/builtin/undeclaredSymbol.js +23 -27
- package/lib/processor/linter/builtin.d.ts +3 -3
- package/lib/processor/linter/builtin.js +19 -31
- package/lib/processor/linter/index.d.ts +2 -2
- package/lib/processor/linter/index.js +2 -27
- package/lib/processor/util.d.ts +2 -2
- package/lib/processor/util.js +4 -9
- package/lib/service/CacheService.d.ts +6 -6
- package/lib/service/CacheService.js +38 -48
- package/lib/service/Config.d.ts +17 -16
- package/lib/service/Config.js +56 -51
- package/lib/service/Context.d.ts +14 -14
- package/lib/service/Context.js +30 -32
- package/lib/service/Dependency.js +2 -5
- package/lib/service/Downloader.d.ts +10 -39
- package/lib/service/Downloader.js +37 -106
- package/lib/service/ErrorReporter.d.ts +2 -2
- package/lib/service/ErrorReporter.js +11 -15
- package/lib/service/FileService.d.ts +41 -14
- package/lib/service/FileService.js +107 -81
- package/lib/service/Hover.d.ts +2 -2
- package/lib/service/Hover.js +4 -7
- package/lib/service/Logger.js +2 -5
- package/lib/service/MetaRegistry.d.ts +12 -12
- package/lib/service/MetaRegistry.js +62 -73
- package/lib/service/Operations.js +3 -9
- package/lib/service/Profiler.d.ts +1 -1
- package/lib/service/Profiler.js +25 -41
- package/lib/service/Project.d.ts +50 -51
- package/lib/service/Project.js +240 -238
- package/lib/service/Service.d.ts +19 -29
- package/lib/service/Service.js +57 -53
- package/lib/service/SymbolLocations.d.ts +3 -3
- package/lib/service/SymbolLocations.js +4 -7
- package/lib/service/SymbolRegistrar.d.ts +1 -1
- package/lib/service/SymbolRegistrar.js +1 -2
- package/lib/service/fileUtil.d.ts +21 -41
- package/lib/service/fileUtil.js +59 -129
- package/lib/service/index.d.ts +17 -17
- package/lib/service/index.js +17 -31
- package/lib/source/IndexMap.d.ts +1 -1
- package/lib/source/IndexMap.js +7 -10
- package/lib/source/LanguageError.d.ts +2 -2
- package/lib/source/LanguageError.js +3 -6
- package/lib/source/Location.d.ts +3 -3
- package/lib/source/Location.js +6 -9
- package/lib/source/Offset.d.ts +1 -1
- package/lib/source/Offset.js +4 -7
- package/lib/source/Position.js +2 -5
- package/lib/source/PositionRange.d.ts +2 -2
- package/lib/source/PositionRange.js +14 -17
- package/lib/source/Range.d.ts +1 -1
- package/lib/source/Range.js +7 -10
- package/lib/source/Source.d.ts +12 -4
- package/lib/source/Source.js +84 -29
- package/lib/source/index.d.ts +8 -8
- package/lib/source/index.js +8 -20
- package/lib/symbol/Symbol.d.ts +15 -15
- package/lib/symbol/Symbol.js +53 -68
- package/lib/symbol/SymbolUtil.d.ts +23 -33
- package/lib/symbol/SymbolUtil.js +162 -163
- package/lib/symbol/UriBinder.d.ts +1 -1
- package/lib/symbol/UriBinder.js +1 -2
- package/lib/symbol/index.d.ts +3 -3
- package/lib/symbol/index.js +3 -15
- package/package.json +7 -4
- package/lib/common/Heap.d.ts +0 -1
- package/lib/common/Heap.js +0 -2
- package/lib/node/TableNode.d.ts +0 -17
- package/lib/node/TableNode.js +0 -11
- package/lib/parser/table.d.ts +0 -22
- package/lib/parser/table.js +0 -97
- package/lib/service/CommandExecutor.d.ts +0 -3
- package/lib/service/CommandExecutor.js +0 -7
|
@@ -1,20 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const binary_search_1 = __importDefault(require("binary-search"));
|
|
8
|
-
const common_1 = require("../../common");
|
|
9
|
-
const node_1 = require("../../node");
|
|
10
|
-
const service_1 = require("../../service");
|
|
11
|
-
const source_1 = require("../../source");
|
|
12
|
-
const Completer_1 = require("./Completer");
|
|
1
|
+
import binarySearch from 'binary-search';
|
|
2
|
+
import { ResourceLocation } from '../../common/index.js';
|
|
3
|
+
import { AstNode } from '../../node/index.js';
|
|
4
|
+
import { LinterConfigValue } from '../../service/index.js';
|
|
5
|
+
import { Range } from '../../source/index.js';
|
|
6
|
+
import { CompletionItem } from './Completer.js';
|
|
13
7
|
/**
|
|
14
8
|
* Uses the shallowest selected node that has its own completer to provide the completion items.
|
|
15
9
|
*/
|
|
16
|
-
const dispatch = (node, ctx) => {
|
|
17
|
-
const child =
|
|
10
|
+
export const dispatch = (node, ctx) => {
|
|
11
|
+
const child = AstNode.findShallowestChild({
|
|
18
12
|
node,
|
|
19
13
|
needle: ctx.offset,
|
|
20
14
|
endInclusive: true,
|
|
@@ -24,44 +18,39 @@ const dispatch = (node, ctx) => {
|
|
|
24
18
|
? ctx.meta.getCompleter(child.type)(child, ctx)
|
|
25
19
|
: [];
|
|
26
20
|
};
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const boolean = (node, ctx) => {
|
|
21
|
+
export const fallback = dispatch;
|
|
22
|
+
export const boolean = (node, ctx) => {
|
|
30
23
|
return [
|
|
31
|
-
|
|
32
|
-
|
|
24
|
+
CompletionItem.create('false', node, { kind: 21 /* CompletionKind.Constant */ }),
|
|
25
|
+
CompletionItem.create('true', node, { kind: 21 /* CompletionKind.Constant */ }),
|
|
33
26
|
];
|
|
34
27
|
};
|
|
35
|
-
exports.boolean = boolean;
|
|
36
28
|
/**
|
|
37
29
|
* Dispatches to the corresponding file for the language.
|
|
38
30
|
*/
|
|
39
|
-
const file = (node, ctx) => {
|
|
31
|
+
export const file = (node, ctx) => {
|
|
40
32
|
const completer = ctx.meta.getCompleterForLanguageID(ctx.doc.languageId);
|
|
41
33
|
return completer(node.children[0], ctx);
|
|
42
34
|
};
|
|
43
|
-
|
|
44
|
-
const literal = node => {
|
|
35
|
+
export const literal = node => {
|
|
45
36
|
const kind = new Map([
|
|
46
|
-
['enum', 13 /* Enum */],
|
|
47
|
-
['enumMember', 20 /* EnumMember */],
|
|
48
|
-
['function', 3 /* Function */],
|
|
49
|
-
['keyword', 14 /* Keyword */],
|
|
50
|
-
['literal', 14 /* Keyword */],
|
|
51
|
-
['number', 21 /* Constant */],
|
|
52
|
-
['operator', 24 /* Operator */],
|
|
53
|
-
['property', 10 /* Property */],
|
|
54
|
-
['resourceLocation', 17 /* File */],
|
|
55
|
-
['variable', 6 /* Variable */],
|
|
56
|
-
]).get(node.options.colorTokenType ?? 'keyword') ?? 14 /* Keyword */;
|
|
57
|
-
return node.options.pool.map(v =>
|
|
37
|
+
['enum', 13 /* CompletionKind.Enum */],
|
|
38
|
+
['enumMember', 20 /* CompletionKind.EnumMember */],
|
|
39
|
+
['function', 3 /* CompletionKind.Function */],
|
|
40
|
+
['keyword', 14 /* CompletionKind.Keyword */],
|
|
41
|
+
['literal', 14 /* CompletionKind.Keyword */],
|
|
42
|
+
['number', 21 /* CompletionKind.Constant */],
|
|
43
|
+
['operator', 24 /* CompletionKind.Operator */],
|
|
44
|
+
['property', 10 /* CompletionKind.Property */],
|
|
45
|
+
['resourceLocation', 17 /* CompletionKind.File */],
|
|
46
|
+
['variable', 6 /* CompletionKind.Variable */],
|
|
47
|
+
]).get(node.options.colorTokenType ?? 'keyword') ?? 14 /* CompletionKind.Keyword */;
|
|
48
|
+
return node.options.pool.map(v => CompletionItem.create(v, node, { kind })) ?? [];
|
|
58
49
|
};
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
exports.noop = noop;
|
|
62
|
-
function record(o) {
|
|
50
|
+
export const noop = () => [];
|
|
51
|
+
export function record(o) {
|
|
63
52
|
return (node, ctx) => {
|
|
64
|
-
if (!
|
|
53
|
+
if (!Range.contains(Range.translate(node, 1, -1), ctx.offset, true)) {
|
|
65
54
|
return [];
|
|
66
55
|
}
|
|
67
56
|
const completeKeys = (pair) => o.key(node, pair, ctx, pair?.key ?? ctx.offset, false, false, existingKeys);
|
|
@@ -69,9 +58,9 @@ function record(o) {
|
|
|
69
58
|
const existingKeys = node.children
|
|
70
59
|
.filter((n) => !!n.key)
|
|
71
60
|
.map(n => n.key);
|
|
72
|
-
const index = (
|
|
73
|
-
?
|
|
74
|
-
:
|
|
61
|
+
const index = binarySearch(node.children, ctx.offset, (n, o) => n.end
|
|
62
|
+
? Range.compareOffset(Range.translate(n, 0, -1), o, true)
|
|
63
|
+
: Range.compareOffset(n.range, o, true));
|
|
75
64
|
const pair = index >= 0 ? node.children[index] : undefined;
|
|
76
65
|
const hasNextPair = !!node.children.find(n => n.range.start > ctx.offset);
|
|
77
66
|
if (!pair) {
|
|
@@ -81,29 +70,28 @@ function record(o) {
|
|
|
81
70
|
if (!key && !sep && !value) {
|
|
82
71
|
return completePairs(undefined);
|
|
83
72
|
}
|
|
84
|
-
if ((key &&
|
|
73
|
+
if ((key && Range.contains(key, ctx.offset, true)) || (sep && ctx.offset <= sep.start) || (value && ctx.offset < value.range.start)) {
|
|
85
74
|
// Selected key.
|
|
86
|
-
if (!value ||
|
|
75
|
+
if (!value || Range.isEmpty(value.range)) {
|
|
87
76
|
return completePairs(pair);
|
|
88
77
|
}
|
|
89
78
|
return completeKeys(pair);
|
|
90
79
|
}
|
|
91
|
-
if ((value &&
|
|
80
|
+
if ((value && Range.contains(value, ctx.offset, true)) || (sep && ctx.offset >= sep.end) || (key && ctx.offset > key.range.end)) {
|
|
92
81
|
// Selected value.
|
|
93
82
|
return o.value(node, pair, ctx);
|
|
94
83
|
}
|
|
95
84
|
return [];
|
|
96
85
|
};
|
|
97
86
|
}
|
|
98
|
-
|
|
99
|
-
const
|
|
100
|
-
const config = service_1.LinterConfigValue.destruct(ctx.config.lint.idOmitDefaultNamespace);
|
|
87
|
+
export const resourceLocation = (node, ctx) => {
|
|
88
|
+
const config = LinterConfigValue.destruct(ctx.config.lint.idOmitDefaultNamespace);
|
|
101
89
|
const includeEmptyNamespace = !node.options.isPredicate && node.namespace === '';
|
|
102
90
|
const includeDefaultNamespace = node.options.isPredicate || config?.ruleValue !== true;
|
|
103
91
|
const excludeDefaultNamespace = !node.options.isPredicate && config?.ruleValue !== false;
|
|
104
92
|
const getPool = (category) => optimizePool(Object.keys(ctx.symbols.getVisibleSymbols(category, ctx.doc.uri)));
|
|
105
93
|
const optimizePool = (pool) => {
|
|
106
|
-
const defaultNsPrefix = `${
|
|
94
|
+
const defaultNsPrefix = `${ResourceLocation.DefaultNamespace}${ResourceLocation.NamespacePathSep}`;
|
|
107
95
|
const defaultNsIds = [];
|
|
108
96
|
const otherIds = [];
|
|
109
97
|
for (const id of pool) {
|
|
@@ -118,10 +106,10 @@ const resourceLocation = (node, ctx) => {
|
|
|
118
106
|
...otherIds,
|
|
119
107
|
...includeDefaultNamespace ? defaultNsIds : [],
|
|
120
108
|
...excludeDefaultNamespace ? defaultNsIds.map(id => id.slice(defaultNsPrefix.length)) : [],
|
|
121
|
-
...includeEmptyNamespace ? defaultNsIds.map(id => id.slice(
|
|
109
|
+
...includeEmptyNamespace ? defaultNsIds.map(id => id.slice(ResourceLocation.DefaultNamespace.length)) : [],
|
|
122
110
|
];
|
|
123
111
|
if (node.options.namespacePathSep === '.') {
|
|
124
|
-
return ans.map(v => v.replace(
|
|
112
|
+
return ans.map(v => v.replace(ResourceLocation.NamespacePathSep, '.'));
|
|
125
113
|
}
|
|
126
114
|
return ans;
|
|
127
115
|
};
|
|
@@ -131,42 +119,38 @@ const resourceLocation = (node, ctx) => {
|
|
|
131
119
|
...getPool(node.options.category),
|
|
132
120
|
...node.options.allowTag
|
|
133
121
|
? getPool(`tag/${node.options.category}`)
|
|
134
|
-
.map(v => `${
|
|
122
|
+
.map(v => `${ResourceLocation.TagPrefix}${v}`)
|
|
135
123
|
: [],
|
|
136
124
|
];
|
|
137
|
-
return pool.map(v =>
|
|
125
|
+
return pool.map(v => CompletionItem.create(v, node, { kind: 3 /* CompletionKind.Function */ }));
|
|
138
126
|
};
|
|
139
|
-
|
|
140
|
-
const string = (node, ctx) => {
|
|
127
|
+
export const string = (node, ctx) => {
|
|
141
128
|
if (node.children?.length) {
|
|
142
129
|
// FIXME: Escape quotes/slashes in the result. Note that `\`, `$`, and `}` have to be escaped due to TextMate syntax.
|
|
143
|
-
return
|
|
130
|
+
return dispatch(node.children[0], ctx);
|
|
144
131
|
}
|
|
145
132
|
if (node.options.quotes && node.value === '') {
|
|
146
|
-
return node.options.quotes.map(q =>
|
|
133
|
+
return node.options.quotes.map(q => CompletionItem.create(`${q}${q}`, node, {
|
|
147
134
|
insertText: `${q}$1${q}`,
|
|
148
|
-
kind: 12 /* Value */,
|
|
135
|
+
kind: 12 /* CompletionKind.Value */,
|
|
149
136
|
}));
|
|
150
137
|
}
|
|
151
138
|
return [];
|
|
152
139
|
};
|
|
153
|
-
|
|
154
|
-
const symbol = (node, ctx) => {
|
|
140
|
+
export const symbol = (node, ctx) => {
|
|
155
141
|
return Object
|
|
156
142
|
.keys(ctx.symbols.query(ctx.doc, node.options.category, ...node.options.parentPath ?? []).visibleMembers)
|
|
157
|
-
.map(v =>
|
|
143
|
+
.map(v => CompletionItem.create(v, node, { kind: 6 /* CompletionKind.Variable */ }));
|
|
158
144
|
};
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
meta.registerCompleter('
|
|
162
|
-
meta.registerCompleter('
|
|
163
|
-
meta.registerCompleter('
|
|
164
|
-
meta.registerCompleter('
|
|
165
|
-
meta.registerCompleter('
|
|
166
|
-
meta.registerCompleter('
|
|
167
|
-
meta.registerCompleter('
|
|
168
|
-
meta.registerCompleter('
|
|
169
|
-
meta.registerCompleter('symbol', exports.symbol);
|
|
145
|
+
export function registerCompleters(meta) {
|
|
146
|
+
meta.registerCompleter('boolean', boolean);
|
|
147
|
+
meta.registerCompleter('comment', noop);
|
|
148
|
+
meta.registerCompleter('float', noop);
|
|
149
|
+
meta.registerCompleter('integer', noop);
|
|
150
|
+
meta.registerCompleter('long', noop);
|
|
151
|
+
meta.registerCompleter('literal', literal);
|
|
152
|
+
meta.registerCompleter('resource_location', resourceLocation);
|
|
153
|
+
meta.registerCompleter('string', string);
|
|
154
|
+
meta.registerCompleter('symbol', symbol);
|
|
170
155
|
}
|
|
171
|
-
exports.registerCompleters = registerCompleters;
|
|
172
156
|
//# sourceMappingURL=builtin.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * as completer from './builtin';
|
|
2
|
-
export * from './Completer';
|
|
1
|
+
export * as completer from './builtin.js';
|
|
2
|
+
export * from './Completer.js';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,28 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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.completer = void 0;
|
|
26
|
-
exports.completer = __importStar(require("./builtin"));
|
|
27
|
-
__exportStar(require("./Completer"), exports);
|
|
1
|
+
export * as completer from './builtin.js';
|
|
2
|
+
export * from './Completer.js';
|
|
28
3
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { AstNode } from '../../node';
|
|
2
|
-
import type { FormatterContext } from '../../service';
|
|
1
|
+
import type { AstNode } from '../../node/index.js';
|
|
2
|
+
import type { FormatterContext } from '../../service/index.js';
|
|
3
3
|
export declare type Formatter<N = AstNode> = (node: N, ctx: FormatterContext) => string;
|
|
4
4
|
export declare function formatterContextIndentation(ctx: FormatterContext, additionalLevels?: number): string;
|
|
5
5
|
export declare function indentFormatter(ctx: FormatterContext, additionalLevels?: number): FormatterContext;
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.indentFormatter = exports.formatterContextIndentation = void 0;
|
|
4
|
-
function formatterContextIndentation(ctx, additionalLevels = 0) {
|
|
1
|
+
export function formatterContextIndentation(ctx, additionalLevels = 0) {
|
|
5
2
|
const total = ctx.indentLevel + additionalLevels;
|
|
6
3
|
return ctx.insertSpaces ? ' '.repeat(total * ctx.tabSize) : '\t'.repeat(total);
|
|
7
4
|
}
|
|
8
|
-
|
|
9
|
-
function indentFormatter(ctx, additionalLevels = 1) {
|
|
5
|
+
export function indentFormatter(ctx, additionalLevels = 1) {
|
|
10
6
|
return {
|
|
11
7
|
...ctx,
|
|
12
8
|
indentLevel: ctx.indentLevel + additionalLevels,
|
|
@@ -15,5 +11,4 @@ function indentFormatter(ctx, additionalLevels = 1) {
|
|
|
15
11
|
},
|
|
16
12
|
};
|
|
17
13
|
}
|
|
18
|
-
exports.indentFormatter = indentFormatter;
|
|
19
14
|
//# sourceMappingURL=Formatter.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { AstNode, BooleanBaseNode, CommentNode, FileNode, FloatBaseNode, IntegerNode, LiteralBaseNode, LongNode, ResourceLocationBaseNode, StringBaseNode } from '../../node';
|
|
2
|
-
import type { MetaRegistry } from '../../service';
|
|
3
|
-
import type { Formatter } from './Formatter';
|
|
1
|
+
import type { AstNode, BooleanBaseNode, CommentNode, FileNode, FloatBaseNode, IntegerNode, LiteralBaseNode, LongNode, ResourceLocationBaseNode, StringBaseNode } from '../../node/index.js';
|
|
2
|
+
import type { MetaRegistry } from '../../service/index.js';
|
|
3
|
+
import type { Formatter } from './Formatter.js';
|
|
4
4
|
export declare const fallback: Formatter;
|
|
5
5
|
export declare const file: Formatter<FileNode<AstNode>>;
|
|
6
6
|
export declare const boolean: Formatter<BooleanBaseNode>;
|
|
@@ -1,60 +1,46 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.registerFormatters = exports.string = exports.resourceLocation = exports.long = exports.literal = exports.integer = exports.float = exports.comment = exports.boolean = exports.file = exports.fallback = void 0;
|
|
4
|
-
const node_1 = require("../../node");
|
|
5
|
-
const fallback = node => {
|
|
1
|
+
import { ResourceLocationNode } from '../../node/index.js';
|
|
2
|
+
export const fallback = node => {
|
|
6
3
|
throw new Error(`No formatter registered for type ${node.type}`);
|
|
7
4
|
};
|
|
8
|
-
|
|
9
|
-
const file = (node, ctx) => {
|
|
5
|
+
export const file = (node, ctx) => {
|
|
10
6
|
return node.children.map(child => {
|
|
11
7
|
return ctx.meta.getFormatter(child.type)(child, ctx);
|
|
12
8
|
}).join('');
|
|
13
9
|
};
|
|
14
|
-
|
|
15
|
-
const boolean = node => {
|
|
10
|
+
export const boolean = node => {
|
|
16
11
|
return node.value ? 'true' : 'false';
|
|
17
12
|
};
|
|
18
|
-
|
|
19
|
-
const comment = node => {
|
|
13
|
+
export const comment = node => {
|
|
20
14
|
return '#' + node.comment;
|
|
21
15
|
};
|
|
22
|
-
|
|
23
|
-
const float = node => {
|
|
16
|
+
export const float = node => {
|
|
24
17
|
return node.value.toString();
|
|
25
18
|
};
|
|
26
|
-
|
|
27
|
-
const integer = node => {
|
|
19
|
+
export const integer = node => {
|
|
28
20
|
return node.value.toFixed();
|
|
29
21
|
};
|
|
30
|
-
|
|
31
|
-
const literal = node => {
|
|
22
|
+
export const literal = node => {
|
|
32
23
|
return node.value;
|
|
33
24
|
};
|
|
34
|
-
|
|
35
|
-
const long = node => {
|
|
25
|
+
export const long = node => {
|
|
36
26
|
return node.value.toString();
|
|
37
27
|
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
return node_1.ResourceLocationNode.toString(node, 'origin');
|
|
28
|
+
export const resourceLocation = node => {
|
|
29
|
+
return ResourceLocationNode.toString(node, 'origin');
|
|
41
30
|
};
|
|
42
|
-
|
|
43
|
-
const string = node => {
|
|
31
|
+
export const string = node => {
|
|
44
32
|
// FIXME: escape this value according to the node's IndexMap and context
|
|
45
33
|
return `"${node.value}"`;
|
|
46
34
|
};
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
meta.registerFormatter('
|
|
50
|
-
meta.registerFormatter('
|
|
51
|
-
meta.registerFormatter('
|
|
52
|
-
meta.registerFormatter('
|
|
53
|
-
meta.registerFormatter('
|
|
54
|
-
meta.registerFormatter('
|
|
55
|
-
meta.registerFormatter('
|
|
56
|
-
meta.registerFormatter('
|
|
57
|
-
meta.registerFormatter('string', exports.string);
|
|
35
|
+
export function registerFormatters(meta) {
|
|
36
|
+
meta.registerFormatter('file', file);
|
|
37
|
+
meta.registerFormatter('boolean', boolean);
|
|
38
|
+
meta.registerFormatter('comment', comment);
|
|
39
|
+
meta.registerFormatter('float', float);
|
|
40
|
+
meta.registerFormatter('integer', integer);
|
|
41
|
+
meta.registerFormatter('long', long);
|
|
42
|
+
meta.registerFormatter('literal', literal);
|
|
43
|
+
meta.registerFormatter('resource_location', resourceLocation);
|
|
44
|
+
meta.registerFormatter('string', string);
|
|
58
45
|
}
|
|
59
|
-
exports.registerFormatters = registerFormatters;
|
|
60
46
|
//# sourceMappingURL=builtin.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * as formatter from './builtin';
|
|
2
|
-
export * from './Formatter';
|
|
1
|
+
export * as formatter from './builtin.js';
|
|
2
|
+
export * from './Formatter.js';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,28 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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.formatter = void 0;
|
|
26
|
-
exports.formatter = __importStar(require("./builtin"));
|
|
27
|
-
__exportStar(require("./Formatter"), exports);
|
|
1
|
+
export * as formatter from './builtin.js';
|
|
2
|
+
export * from './Formatter.js';
|
|
28
3
|
//# sourceMappingURL=index.js.map
|
package/lib/processor/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export * from './checker';
|
|
2
|
-
export * from './ColorInfoProvider';
|
|
3
|
-
export * from './colorizer';
|
|
4
|
-
export * from './completer';
|
|
5
|
-
export * from './formatter';
|
|
6
|
-
export * from './InlayHintProvider';
|
|
7
|
-
export * from './linter';
|
|
8
|
-
export * from './SignatureHelpProvider';
|
|
9
|
-
export * from './util';
|
|
1
|
+
export * from './checker/index.js';
|
|
2
|
+
export * from './ColorInfoProvider.js';
|
|
3
|
+
export * from './colorizer/index.js';
|
|
4
|
+
export * from './completer/index.js';
|
|
5
|
+
export * from './formatter/index.js';
|
|
6
|
+
export * from './InlayHintProvider.js';
|
|
7
|
+
export * from './linter/index.js';
|
|
8
|
+
export * from './SignatureHelpProvider.js';
|
|
9
|
+
export * from './util.js';
|
|
10
10
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/processor/index.js
CHANGED
|
@@ -1,22 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
-
};
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
__exportStar(require("./checker"), exports);
|
|
14
|
-
__exportStar(require("./ColorInfoProvider"), exports);
|
|
15
|
-
__exportStar(require("./colorizer"), exports);
|
|
16
|
-
__exportStar(require("./completer"), exports);
|
|
17
|
-
__exportStar(require("./formatter"), exports);
|
|
18
|
-
__exportStar(require("./InlayHintProvider"), exports);
|
|
19
|
-
__exportStar(require("./linter"), exports);
|
|
20
|
-
__exportStar(require("./SignatureHelpProvider"), exports);
|
|
21
|
-
__exportStar(require("./util"), exports);
|
|
1
|
+
export * from './checker/index.js';
|
|
2
|
+
export * from './ColorInfoProvider.js';
|
|
3
|
+
export * from './colorizer/index.js';
|
|
4
|
+
export * from './completer/index.js';
|
|
5
|
+
export * from './formatter/index.js';
|
|
6
|
+
export * from './InlayHintProvider.js';
|
|
7
|
+
export * from './linter/index.js';
|
|
8
|
+
export * from './SignatureHelpProvider.js';
|
|
9
|
+
export * from './util.js';
|
|
22
10
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AstNode } from '../../node';
|
|
2
|
-
import type { LinterContext } from '../../service';
|
|
1
|
+
import type { AstNode } from '../../node/index.js';
|
|
2
|
+
import type { LinterContext } from '../../service/index.js';
|
|
3
3
|
export declare type Linter<N extends AstNode> = (node: N, ctx: LinterContext) => void;
|
|
4
4
|
//# sourceMappingURL=Linter.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AstNode } from '../../../node';
|
|
2
|
-
import type { Linter } from '../Linter';
|
|
1
|
+
import type { AstNode } from '../../../node/index.js';
|
|
2
|
+
import type { Linter } from '../Linter.js';
|
|
3
3
|
export declare const undeclaredSymbol: Linter<AstNode>;
|
|
4
4
|
//# sourceMappingURL=undeclaredSymbol.d.ts.map
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
const symbol_1 = require("../../../symbol");
|
|
8
|
-
const undeclaredSymbol = (node, ctx) => {
|
|
9
|
-
if (!node.symbol || symbol_1.SymbolUtil.isDeclared(node.symbol)) {
|
|
1
|
+
import { localeQuote, localize } from '@spyglassmc/locales';
|
|
2
|
+
import { Arrayable, ResourceLocation } from '../../../common/index.js';
|
|
3
|
+
import { LinterSeverity, SymbolLinterConfig as Config } from '../../../service/index.js';
|
|
4
|
+
import { SymbolUtil } from '../../../symbol/index.js';
|
|
5
|
+
export const undeclaredSymbol = (node, ctx) => {
|
|
6
|
+
if (!node.symbol || SymbolUtil.isDeclared(node.symbol)) {
|
|
10
7
|
return;
|
|
11
8
|
}
|
|
12
9
|
const action = getAction(ctx.ruleValue, node.symbol, ctx);
|
|
13
|
-
if (
|
|
10
|
+
if (Config.Action.isDeclare(action)) {
|
|
14
11
|
ctx.symbols
|
|
15
12
|
.query({ doc: ctx.doc, node }, node.symbol.category, ...node.symbol.path)
|
|
16
13
|
.amend({
|
|
@@ -18,28 +15,27 @@ const undeclaredSymbol = (node, ctx) => {
|
|
|
18
15
|
usage: { type: 'declaration', node },
|
|
19
16
|
});
|
|
20
17
|
}
|
|
21
|
-
if (
|
|
22
|
-
const severityOverride = action.report === 'inherit' ? undefined :
|
|
23
|
-
ctx.err.lint(
|
|
18
|
+
if (Config.Action.isReport(action)) {
|
|
19
|
+
const severityOverride = action.report === 'inherit' ? undefined : LinterSeverity.toErrorSeverity(action.report);
|
|
20
|
+
ctx.err.lint(localize('linter.undeclared-symbol.message', node.symbol.category, localeQuote(node.symbol.identifier)), node, undefined, severityOverride);
|
|
24
21
|
}
|
|
25
22
|
};
|
|
26
|
-
exports.undeclaredSymbol = undeclaredSymbol;
|
|
27
23
|
function getAction(config, symbol, ctx) {
|
|
28
|
-
if (
|
|
24
|
+
if (Config.Action.is(config)) {
|
|
29
25
|
return config;
|
|
30
26
|
}
|
|
31
27
|
function test(conditions) {
|
|
32
28
|
function testSingleCondition(condition) {
|
|
33
|
-
const resourceLocation =
|
|
34
|
-
const namespace = resourceLocation.slice(0, resourceLocation.indexOf(
|
|
35
|
-
return ((condition.category ?
|
|
36
|
-
(condition.namespace ?
|
|
37
|
-
(condition.excludeNamespace ? !
|
|
38
|
-
(condition.pattern ?
|
|
39
|
-
(condition.excludePattern ? !
|
|
29
|
+
const resourceLocation = ResourceLocation.lengthen(symbol.identifier);
|
|
30
|
+
const namespace = resourceLocation.slice(0, resourceLocation.indexOf(ResourceLocation.NamespacePathSep));
|
|
31
|
+
return ((condition.category ? Arrayable.toArray(condition.category).includes(symbol.category) : true) &&
|
|
32
|
+
(condition.namespace ? Arrayable.toArray(condition.namespace).includes(namespace) : true) &&
|
|
33
|
+
(condition.excludeNamespace ? !Arrayable.toArray(condition.excludeNamespace).includes(namespace) : true) &&
|
|
34
|
+
(condition.pattern ? Arrayable.toArray(condition.pattern).some(p => new RegExp(p).test(symbol.identifier)) : true) &&
|
|
35
|
+
(condition.excludePattern ? !Arrayable.toArray(condition.excludePattern).some(p => new RegExp(p).test(symbol.identifier)) : true));
|
|
40
36
|
}
|
|
41
37
|
try {
|
|
42
|
-
return
|
|
38
|
+
return Arrayable.toArray(conditions).some(testSingleCondition);
|
|
43
39
|
}
|
|
44
40
|
catch (e) {
|
|
45
41
|
// Illegal RegExp.
|
|
@@ -48,7 +44,7 @@ function getAction(config, symbol, ctx) {
|
|
|
48
44
|
}
|
|
49
45
|
}
|
|
50
46
|
function evaluateComplexes(complexes) {
|
|
51
|
-
for (const complex of
|
|
47
|
+
for (const complex of Arrayable.toArray(complexes)) {
|
|
52
48
|
if (complex.if && !test(complex.if)) {
|
|
53
49
|
continue;
|
|
54
50
|
}
|
|
@@ -63,11 +59,11 @@ function getAction(config, symbol, ctx) {
|
|
|
63
59
|
function getVisibility(input) {
|
|
64
60
|
switch (input) {
|
|
65
61
|
case 'block':
|
|
66
|
-
return 0 /* Block */;
|
|
62
|
+
return 0 /* SymbolVisibility.Block */;
|
|
67
63
|
case 'file':
|
|
68
|
-
return 1 /* File */;
|
|
64
|
+
return 1 /* SymbolVisibility.File */;
|
|
69
65
|
case 'public':
|
|
70
|
-
return 2 /* Public */;
|
|
66
|
+
return 2 /* SymbolVisibility.Public */;
|
|
71
67
|
}
|
|
72
68
|
}
|
|
73
69
|
//# sourceMappingURL=undeclaredSymbol.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { AstNode, StringBaseNode } from '../../node';
|
|
2
|
-
import type { Logger, MetaRegistry } from '../../service';
|
|
3
|
-
import type { Linter } from './Linter';
|
|
1
|
+
import type { AstNode, StringBaseNode } from '../../node/index.js';
|
|
2
|
+
import type { Logger, MetaRegistry } from '../../service/index.js';
|
|
3
|
+
import type { Linter } from './Linter.js';
|
|
4
4
|
export declare const noop: Linter<AstNode>;
|
|
5
5
|
/**
|
|
6
6
|
* @param key The name of the key on the {@link AstNode} that contains the value to be validated.
|