@spyglassmc/core 0.1.2 → 0.4.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/Dev.d.ts +11 -0
- package/lib/common/Dev.js +90 -0
- package/lib/{service → common}/Logger.d.ts +0 -0
- package/lib/{service → common}/Logger.js +2 -5
- package/lib/common/Operations.d.ts +12 -0
- package/lib/common/Operations.js +33 -0
- package/lib/common/ReadonlyProxy.d.ts +9 -0
- package/lib/common/ReadonlyProxy.js +23 -0
- package/lib/common/StateProxy.d.ts +35 -0
- package/lib/common/StateProxy.js +69 -0
- package/lib/common/TwoWayMap.js +4 -10
- 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 +152 -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 +8 -1
- package/lib/common/index.js +8 -17
- package/lib/common/util.d.ts +48 -20
- package/lib/common/util.js +71 -86
- package/lib/index.d.ts +7 -7
- package/lib/index.js +7 -23
- package/lib/node/AstNode.d.ts +12 -11
- 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 +6 -5
- package/lib/node/CommentNode.js +4 -9
- package/lib/node/ErrorNode.d.ts +1 -1
- package/lib/node/ErrorNode.js +2 -5
- package/lib/node/FileNode.d.ts +8 -4
- package/lib/node/FileNode.js +3 -6
- package/lib/node/FloatNode.d.ts +3 -3
- package/lib/node/FloatNode.js +4 -7
- package/lib/node/IntegerNode.d.ts +3 -3
- 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 +4 -7
- package/lib/node/LongNode.d.ts +3 -3
- 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 +7 -7
- package/lib/node/ResourceLocationNode.js +9 -12
- package/lib/node/Sequence.d.ts +2 -2
- package/lib/node/Sequence.js +4 -7
- 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 +4 -7
- package/lib/node/index.d.ts +15 -15
- package/lib/node/index.js +15 -31
- 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 -38
- 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 +12 -24
- package/lib/parser/string.d.ts +7 -7
- package/lib/parser/string.js +36 -42
- package/lib/parser/symbol.d.ts +3 -3
- package/lib/parser/symbol.js +4 -14
- package/lib/parser/util.d.ts +6 -5
- package/lib/parser/util.js +40 -60
- package/lib/processor/ColorInfoProvider.d.ts +1 -1
- package/lib/processor/ColorInfoProvider.js +6 -9
- package/lib/processor/InlayHintProvider.d.ts +4 -3
- package/lib/processor/InlayHintProvider.js +1 -2
- package/lib/processor/SignatureHelpProvider.d.ts +4 -3
- package/lib/processor/SignatureHelpProvider.js +1 -2
- package/lib/processor/binder/Binder.d.ts +26 -0
- package/lib/processor/binder/Binder.js +18 -0
- package/lib/processor/binder/builtin.d.ts +27 -0
- package/lib/processor/binder/builtin.js +116 -0
- package/lib/processor/binder/index.d.ts +3 -0
- package/lib/processor/binder/index.js +3 -0
- package/lib/processor/checker/Checker.d.ts +2 -2
- package/lib/processor/checker/Checker.js +1 -5
- package/lib/processor/checker/builtin.d.ts +4 -4
- package/lib/processor/checker/builtin.js +22 -33
- package/lib/processor/checker/index.d.ts +2 -2
- package/lib/processor/checker/index.js +2 -31
- package/lib/processor/colorizer/Colorizer.d.ts +6 -5
- package/lib/processor/colorizer/Colorizer.js +8 -11
- package/lib/processor/colorizer/builtin.d.ts +3 -3
- package/lib/processor/colorizer/builtin.js +34 -46
- package/lib/processor/colorizer/index.d.ts +2 -2
- package/lib/processor/colorizer/index.js +2 -31
- package/lib/processor/completer/Completer.d.ts +6 -5
- package/lib/processor/completer/Completer.js +14 -33
- package/lib/processor/completer/builtin.d.ts +10 -9
- package/lib/processor/completer/builtin.js +47 -63
- package/lib/processor/completer/index.d.ts +2 -2
- package/lib/processor/completer/index.js +2 -31
- package/lib/processor/formatter/Formatter.d.ts +4 -3
- 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 -31
- package/lib/processor/index.d.ts +10 -9
- package/lib/processor/index.js +10 -25
- package/lib/processor/linter/Linter.d.ts +4 -3
- 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 +20 -24
- package/lib/processor/linter/builtin.d.ts +4 -3
- package/lib/processor/linter/builtin.js +19 -26
- package/lib/processor/linter/index.d.ts +2 -2
- package/lib/processor/linter/index.js +2 -31
- package/lib/processor/util.d.ts +4 -14
- package/lib/processor/util.js +1 -16
- package/lib/service/CacheService.d.ts +13 -8
- package/lib/service/CacheService.js +45 -57
- package/lib/service/Config.d.ts +11 -12
- package/lib/service/Config.js +50 -45
- package/lib/service/Context.d.ts +23 -20
- package/lib/service/Context.js +39 -36
- package/lib/service/Dependency.js +2 -5
- package/lib/service/Downloader.d.ts +9 -40
- package/lib/service/Downloader.js +37 -110
- package/lib/service/ErrorReporter.d.ts +2 -2
- package/lib/service/ErrorReporter.js +10 -14
- package/lib/service/FileService.d.ts +15 -14
- package/lib/service/FileService.js +55 -92
- package/lib/service/Hover.d.ts +2 -2
- package/lib/service/Hover.js +4 -7
- package/lib/service/MetaRegistry.d.ts +22 -12
- package/lib/service/MetaRegistry.js +81 -73
- package/lib/service/Profiler.d.ts +3 -2
- package/lib/service/Profiler.js +81 -45
- package/lib/service/Project.d.ts +105 -76
- package/lib/service/Project.js +449 -370
- package/lib/service/Service.d.ts +17 -27
- package/lib/service/Service.js +37 -43
- 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/UriProcessor.d.ts +5 -0
- package/lib/service/UriProcessor.js +2 -0
- package/lib/service/fileUtil.d.ts +15 -45
- package/lib/service/fileUtil.js +38 -143
- package/lib/service/index.d.ts +16 -17
- package/lib/service/index.js +16 -35
- package/lib/source/IndexMap.d.ts +1 -1
- package/lib/source/IndexMap.js +7 -10
- package/lib/source/LanguageError.d.ts +20 -6
- package/lib/source/LanguageError.js +16 -9
- 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 +3 -3
- package/lib/source/PositionRange.js +17 -20
- package/lib/source/Range.d.ts +1 -1
- package/lib/source/Range.js +7 -10
- package/lib/source/Source.d.ts +5 -3
- package/lib/source/Source.js +34 -29
- package/lib/source/index.d.ts +8 -8
- package/lib/source/index.js +8 -24
- package/lib/symbol/Symbol.d.ts +5 -4
- package/lib/symbol/Symbol.js +49 -65
- package/lib/symbol/SymbolUtil.d.ts +29 -31
- package/lib/symbol/SymbolUtil.js +178 -157
- package/lib/symbol/index.d.ts +2 -3
- package/lib/symbol/index.js +2 -19
- package/package.json +7 -4
- package/lib/service/Operations.d.ts +0 -8
- package/lib/service/Operations.js +0 -26
- package/lib/symbol/UriBinder.d.ts +0 -3
- package/lib/symbol/UriBinder.js +0 -3
|
@@ -1,20 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
4
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
5
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
6
|
-
};
|
|
7
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
8
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
9
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
10
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
11
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
12
|
-
};
|
|
13
|
-
var _InsertTextBuilder_ans, _InsertTextBuilder_nextPlaceholder;
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.InsertTextBuilder = exports.CompletionItem = void 0;
|
|
16
|
-
const source_1 = require("../../source");
|
|
17
|
-
var CompletionItem;
|
|
1
|
+
import { Range } from '../../source/index.js';
|
|
2
|
+
export var CompletionItem;
|
|
18
3
|
(function (CompletionItem) {
|
|
19
4
|
/* istanbul ignore next */
|
|
20
5
|
/**
|
|
@@ -31,7 +16,7 @@ var CompletionItem;
|
|
|
31
16
|
return {
|
|
32
17
|
...other,
|
|
33
18
|
label,
|
|
34
|
-
range:
|
|
19
|
+
range: Range.get(range),
|
|
35
20
|
...shouldEscape ? { insertText: escape(label) } : {},
|
|
36
21
|
};
|
|
37
22
|
}
|
|
@@ -50,35 +35,33 @@ var CompletionItem;
|
|
|
50
35
|
return textToInsert.replace(/([\\$}])/g, '\\$1');
|
|
51
36
|
}
|
|
52
37
|
CompletionItem.escape = escape;
|
|
53
|
-
})(CompletionItem
|
|
54
|
-
class InsertTextBuilder {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
_InsertTextBuilder_nextPlaceholder.set(this, 1);
|
|
58
|
-
}
|
|
38
|
+
})(CompletionItem || (CompletionItem = {}));
|
|
39
|
+
export class InsertTextBuilder {
|
|
40
|
+
#ans = '';
|
|
41
|
+
#nextPlaceholder = 1;
|
|
59
42
|
literal(str) {
|
|
60
|
-
|
|
43
|
+
this.#ans += CompletionItem.escape(str);
|
|
61
44
|
return this;
|
|
62
45
|
}
|
|
63
46
|
placeholder(...defaultValues) {
|
|
64
47
|
if (defaultValues.length === 0) {
|
|
65
|
-
|
|
48
|
+
this.#ans += `$\{${this.#nextPlaceholder}}`;
|
|
66
49
|
}
|
|
67
50
|
else if (defaultValues.length === 1) {
|
|
68
|
-
|
|
51
|
+
this.#ans += `$\{${this.#nextPlaceholder}:${CompletionItem.escape(defaultValues[0])}}`;
|
|
69
52
|
}
|
|
70
53
|
else {
|
|
71
|
-
|
|
54
|
+
this.#ans += `$\{${this.#nextPlaceholder}|${defaultValues.map(v => v.replace(/([\\$},|])/g, '\\$1')).join(',')}|}`;
|
|
72
55
|
}
|
|
73
|
-
|
|
56
|
+
this.#nextPlaceholder += 1;
|
|
74
57
|
return this;
|
|
75
58
|
}
|
|
76
59
|
exitPlace() {
|
|
77
|
-
|
|
60
|
+
this.#ans += '$0';
|
|
78
61
|
return this;
|
|
79
62
|
}
|
|
80
63
|
build() {
|
|
81
|
-
return
|
|
64
|
+
return this.#ans;
|
|
82
65
|
}
|
|
83
66
|
if(condition, callback) {
|
|
84
67
|
if (condition) {
|
|
@@ -87,6 +70,4 @@ class InsertTextBuilder {
|
|
|
87
70
|
return this;
|
|
88
71
|
}
|
|
89
72
|
}
|
|
90
|
-
exports.InsertTextBuilder = InsertTextBuilder;
|
|
91
|
-
_InsertTextBuilder_ans = new WeakMap(), _InsertTextBuilder_nextPlaceholder = new WeakMap();
|
|
92
73
|
//# sourceMappingURL=Completer.js.map
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import {
|
|
3
|
-
import type {
|
|
4
|
-
import
|
|
5
|
-
import type {
|
|
6
|
-
import type {
|
|
7
|
-
import {
|
|
1
|
+
import type { DeepReadonly } from '../../common/index.js';
|
|
2
|
+
import type { BooleanBaseNode } from '../../node/BooleanNode.js';
|
|
3
|
+
import type { FileNode, LiteralBaseNode, PairNode, RecordBaseNode, ResourceLocationNode, StringBaseNode, SymbolBaseNode } from '../../node/index.js';
|
|
4
|
+
import { AstNode } from '../../node/index.js';
|
|
5
|
+
import type { CompleterContext, MetaRegistry } from '../../service/index.js';
|
|
6
|
+
import type { RangeLike } from '../../source/index.js';
|
|
7
|
+
import type { Completer } from './Completer.js';
|
|
8
|
+
import { CompletionItem } from './Completer.js';
|
|
8
9
|
/**
|
|
9
10
|
* Uses the shallowest selected node that has its own completer to provide the completion items.
|
|
10
11
|
*/
|
|
@@ -18,8 +19,8 @@ export declare const file: Completer<FileNode<AstNode>>;
|
|
|
18
19
|
export declare const literal: Completer<LiteralBaseNode>;
|
|
19
20
|
export declare const noop: Completer<any>;
|
|
20
21
|
interface RecordOptions<K extends AstNode, V extends AstNode, N extends RecordBaseNode<K, V>> {
|
|
21
|
-
key: (record: N
|
|
22
|
-
value: (record: N
|
|
22
|
+
key: (record: DeepReadonly<N>, pair: DeepReadonly<PairNode<K, V>> | undefined, ctx: CompleterContext, range: RangeLike, insertValue: boolean, insertPairEnd: boolean, existingKeys: DeepReadonly<K>[]) => CompletionItem[];
|
|
23
|
+
value: (record: DeepReadonly<N>, pair: DeepReadonly<PairNode<K, V>>, ctx: CompleterContext) => CompletionItem[];
|
|
23
24
|
}
|
|
24
25
|
export declare function record<K extends AstNode, V extends AstNode, N extends RecordBaseNode<K, V>>(o: RecordOptions<K, V, N>): Completer<N>;
|
|
25
26
|
export declare const resourceLocation: Completer<ResourceLocationNode>;
|
|
@@ -1,21 +1,15 @@
|
|
|
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 =
|
|
18
|
-
node,
|
|
10
|
+
export const dispatch = (node, ctx) => {
|
|
11
|
+
const child = AstNode.findShallowestChild({
|
|
12
|
+
node: node,
|
|
19
13
|
needle: ctx.offset,
|
|
20
14
|
endInclusive: true,
|
|
21
15
|
predicate: n => ctx.meta.hasCompleter(n.type),
|
|
@@ -24,24 +18,21 @@ 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
37
|
['enum', 13 /* CompletionKind.Enum */],
|
|
47
38
|
['enumMember', 20 /* CompletionKind.EnumMember */],
|
|
@@ -54,14 +45,12 @@ const literal = node => {
|
|
|
54
45
|
['resourceLocation', 17 /* CompletionKind.File */],
|
|
55
46
|
['variable', 6 /* CompletionKind.Variable */],
|
|
56
47
|
]).get(node.options.colorTokenType ?? 'keyword') ?? 14 /* CompletionKind.Keyword */;
|
|
57
|
-
return node.options.pool.map(v =>
|
|
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
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,32 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
26
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.completer = void 0;
|
|
30
|
-
exports.completer = __importStar(require("./builtin"));
|
|
31
|
-
__exportStar(require("./Completer"), exports);
|
|
1
|
+
export * as completer from './builtin.js';
|
|
2
|
+
export * from './Completer.js';
|
|
32
3
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
|
|
1
|
+
import type { DeepReadonly } from '../../common/index.js';
|
|
2
|
+
import type { AstNode } from '../../node/index.js';
|
|
3
|
+
import type { FormatterContext } from '../../service/index.js';
|
|
4
|
+
export declare type Formatter<N extends AstNode = AstNode> = (node: DeepReadonly<N>, ctx: FormatterContext) => string;
|
|
4
5
|
export declare function formatterContextIndentation(ctx: FormatterContext, additionalLevels?: number): string;
|
|
5
6
|
export declare function indentFormatter(ctx: FormatterContext, additionalLevels?: number): FormatterContext;
|
|
6
7
|
//# sourceMappingURL=Formatter.d.ts.map
|
|
@@ -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,32 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
26
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.formatter = void 0;
|
|
30
|
-
exports.formatter = __importStar(require("./builtin"));
|
|
31
|
-
__exportStar(require("./Formatter"), exports);
|
|
1
|
+
export * as formatter from './builtin.js';
|
|
2
|
+
export * from './Formatter.js';
|
|
32
3
|
//# sourceMappingURL=index.js.map
|
package/lib/processor/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './
|
|
6
|
-
export * from './
|
|
7
|
-
export * from './
|
|
8
|
-
export * from './
|
|
9
|
-
export * from './
|
|
1
|
+
export * from './binder/index.js';
|
|
2
|
+
export * from './checker/index.js';
|
|
3
|
+
export * from './ColorInfoProvider.js';
|
|
4
|
+
export * from './colorizer/index.js';
|
|
5
|
+
export * from './completer/index.js';
|
|
6
|
+
export * from './formatter/index.js';
|
|
7
|
+
export * from './InlayHintProvider.js';
|
|
8
|
+
export * from './linter/index.js';
|
|
9
|
+
export * from './SignatureHelpProvider.js';
|
|
10
|
+
export * from './util.js';
|
|
10
11
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/processor/index.js
CHANGED
|
@@ -1,26 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./checker"), exports);
|
|
18
|
-
__exportStar(require("./ColorInfoProvider"), exports);
|
|
19
|
-
__exportStar(require("./colorizer"), exports);
|
|
20
|
-
__exportStar(require("./completer"), exports);
|
|
21
|
-
__exportStar(require("./formatter"), exports);
|
|
22
|
-
__exportStar(require("./InlayHintProvider"), exports);
|
|
23
|
-
__exportStar(require("./linter"), exports);
|
|
24
|
-
__exportStar(require("./SignatureHelpProvider"), exports);
|
|
25
|
-
__exportStar(require("./util"), exports);
|
|
1
|
+
export * from './binder/index.js';
|
|
2
|
+
export * from './checker/index.js';
|
|
3
|
+
export * from './ColorInfoProvider.js';
|
|
4
|
+
export * from './colorizer/index.js';
|
|
5
|
+
export * from './completer/index.js';
|
|
6
|
+
export * from './formatter/index.js';
|
|
7
|
+
export * from './InlayHintProvider.js';
|
|
8
|
+
export * from './linter/index.js';
|
|
9
|
+
export * from './SignatureHelpProvider.js';
|
|
10
|
+
export * from './util.js';
|
|
26
11
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
|
|
1
|
+
import type { StateProxy } from '../../index.js';
|
|
2
|
+
import type { AstNode } from '../../node/index.js';
|
|
3
|
+
import type { LinterContext } from '../../service/index.js';
|
|
4
|
+
export declare type Linter<N extends AstNode> = (node: StateProxy<N>, ctx: LinterContext) => void;
|
|
4
5
|
//# 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
|