@spyglassmc/core 0.1.2 → 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.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 +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 -17
- package/lib/common/util.d.ts +15 -15
- package/lib/common/util.js +30 -77
- package/lib/index.d.ts +7 -7
- package/lib/index.js +7 -23
- 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 +3 -3
- package/lib/node/LiteralNode.js +4 -7
- 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 +5 -5
- 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 +4 -4
- package/lib/node/StringNode.js +9 -12
- package/lib/node/SymbolNode.d.ts +3 -3
- 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 +14 -18
- package/lib/parser/string.d.ts +5 -5
- package/lib/parser/string.js +36 -42
- package/lib/parser/symbol.d.ts +3 -3
- package/lib/parser/symbol.js +3 -7
- package/lib/parser/util.d.ts +5 -5
- package/lib/parser/util.js +38 -56
- 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 +4 -4
- package/lib/processor/checker/builtin.js +19 -30
- package/lib/processor/checker/index.d.ts +2 -2
- package/lib/processor/checker/index.js +2 -31
- 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 -31
- 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 +46 -62
- package/lib/processor/completer/index.d.ts +2 -2
- package/lib/processor/completer/index.js +2 -31
- 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 -31
- package/lib/processor/index.d.ts +9 -9
- package/lib/processor/index.js +9 -25
- 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 +20 -24
- package/lib/processor/linter/builtin.d.ts +3 -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 +2 -2
- package/lib/processor/util.js +4 -9
- package/lib/service/CacheService.d.ts +6 -6
- package/lib/service/CacheService.js +32 -56
- package/lib/service/Config.d.ts +11 -12
- package/lib/service/Config.js +50 -45
- package/lib/service/Context.d.ts +13 -13
- package/lib/service/Context.js +29 -32
- package/lib/service/Dependency.js +2 -5
- package/lib/service/Downloader.d.ts +10 -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 +16 -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/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 +47 -51
- package/lib/service/Project.js +199 -239
- 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/fileUtil.d.ts +15 -45
- package/lib/service/fileUtil.js +38 -143
- package/lib/service/index.d.ts +17 -17
- package/lib/service/index.js +17 -35
- 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 +2 -5
- 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 +3 -3
- package/lib/source/Source.js +28 -29
- package/lib/source/index.d.ts +8 -8
- package/lib/source/index.js +8 -24
- package/lib/symbol/Symbol.d.ts +2 -2
- package/lib/symbol/Symbol.js +49 -65
- package/lib/symbol/SymbolUtil.d.ts +22 -25
- package/lib/symbol/SymbolUtil.js +150 -151
- 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 -19
- package/package.json +7 -4
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const service_1 = require("../../service");
|
|
7
|
-
const util_1 = require("../util");
|
|
8
|
-
function attempt(checker, node, ctx) {
|
|
1
|
+
import { localize } from '@spyglassmc/locales';
|
|
2
|
+
import { ResourceLocationNode } from '../../node/index.js';
|
|
3
|
+
import { ErrorReporter, Operations } from '../../service/index.js';
|
|
4
|
+
import { traversePreOrder } from '../util.js';
|
|
5
|
+
export function attempt(checker, node, ctx) {
|
|
9
6
|
const tempCtx = {
|
|
10
7
|
...ctx,
|
|
11
|
-
err: new
|
|
12
|
-
ops: new
|
|
8
|
+
err: new ErrorReporter(),
|
|
9
|
+
ops: new Operations(),
|
|
13
10
|
symbols: ctx.symbols.clone(),
|
|
14
11
|
};
|
|
15
12
|
// FIXME: await
|
|
@@ -28,8 +25,7 @@ function attempt(checker, node, ctx) {
|
|
|
28
25
|
},
|
|
29
26
|
};
|
|
30
27
|
}
|
|
31
|
-
|
|
32
|
-
function any(checkers) {
|
|
28
|
+
export function any(checkers) {
|
|
33
29
|
if (checkers.length === 0) {
|
|
34
30
|
throw new Error('Expected at least one checker');
|
|
35
31
|
}
|
|
@@ -40,18 +36,16 @@ function any(checkers) {
|
|
|
40
36
|
attempts[0].updateNodeAndCtx();
|
|
41
37
|
};
|
|
42
38
|
}
|
|
43
|
-
exports.any = any;
|
|
44
39
|
/**
|
|
45
40
|
* No operation.
|
|
46
41
|
*/
|
|
47
|
-
const noop = () => { };
|
|
48
|
-
exports.noop = noop;
|
|
42
|
+
export const noop = () => { };
|
|
49
43
|
/**
|
|
50
44
|
* Use the shallowest children that have their own checker to validate.
|
|
51
45
|
*/
|
|
52
|
-
const fallback = async (node, ctx) => {
|
|
46
|
+
export const fallback = async (node, ctx) => {
|
|
53
47
|
const promises = [];
|
|
54
|
-
|
|
48
|
+
traversePreOrder(node, node => !ctx.meta.hasChecker(node.type), node => ctx.meta.hasChecker(node.type), node => {
|
|
55
49
|
const checker = ctx.meta.getChecker(node.type);
|
|
56
50
|
const result = checker(node, ctx);
|
|
57
51
|
if (result instanceof Promise) {
|
|
@@ -60,8 +54,7 @@ const fallback = async (node, ctx) => {
|
|
|
60
54
|
});
|
|
61
55
|
await Promise.allSettled(promises);
|
|
62
56
|
};
|
|
63
|
-
|
|
64
|
-
const dispatchSync = (node, ctx) => {
|
|
57
|
+
export const dispatchSync = (node, ctx) => {
|
|
65
58
|
for (const child of node.children ?? []) {
|
|
66
59
|
if (ctx.meta.hasChecker(child.type)) {
|
|
67
60
|
const checker = ctx.meta.getChecker(child.type);
|
|
@@ -69,24 +62,20 @@ const dispatchSync = (node, ctx) => {
|
|
|
69
62
|
}
|
|
70
63
|
}
|
|
71
64
|
};
|
|
72
|
-
|
|
73
|
-
const
|
|
74
|
-
const full = node_1.ResourceLocationNode.toString(node, 'full');
|
|
65
|
+
export const resourceLocation = (node, ctx) => {
|
|
66
|
+
const full = ResourceLocationNode.toString(node, 'full');
|
|
75
67
|
if (node.options.pool) {
|
|
76
68
|
if (!node.options.pool.includes(full)) {
|
|
77
|
-
ctx.err.report(
|
|
69
|
+
ctx.err.report(localize('expected', node.options.pool), node, 3 /* ErrorSeverity.Error */);
|
|
78
70
|
}
|
|
79
71
|
return;
|
|
80
72
|
}
|
|
81
73
|
};
|
|
82
|
-
|
|
83
|
-
const symbol = (_node, _ctx) => {
|
|
74
|
+
export const symbol = (_node, _ctx) => {
|
|
84
75
|
// TODO
|
|
85
76
|
};
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
meta.registerChecker('
|
|
89
|
-
meta.registerChecker('symbol', exports.symbol);
|
|
77
|
+
export function registerCheckers(meta) {
|
|
78
|
+
meta.registerChecker('resource_location', resourceLocation);
|
|
79
|
+
meta.registerChecker('symbol', symbol);
|
|
90
80
|
}
|
|
91
|
-
exports.registerCheckers = registerCheckers;
|
|
92
81
|
//# sourceMappingURL=builtin.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * as checker from './builtin';
|
|
2
|
-
export * from './Checker';
|
|
1
|
+
export * as checker from './builtin.js';
|
|
2
|
+
export * from './Checker.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.checker = void 0;
|
|
30
|
-
exports.checker = __importStar(require("./builtin"));
|
|
31
|
-
__exportStar(require("./Checker"), exports);
|
|
1
|
+
export * as checker from './builtin.js';
|
|
2
|
+
export * from './Checker.js';
|
|
32
3
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { AstNode } from '../../node';
|
|
2
|
-
import type { ColorizerContext } from '../../service';
|
|
3
|
-
import type { RangeLike } from '../../source';
|
|
4
|
-
import { Range } from '../../source';
|
|
1
|
+
import type { AstNode } from '../../node/index.js';
|
|
2
|
+
import type { ColorizerContext } from '../../service/index.js';
|
|
3
|
+
import type { RangeLike } from '../../source/index.js';
|
|
4
|
+
import { Range } from '../../source/index.js';
|
|
5
5
|
export declare type Colorizer<N = AstNode> = (node: N, ctx: ColorizerContext) => readonly ColorToken[];
|
|
6
6
|
export interface ColorToken {
|
|
7
7
|
range: Range;
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.ColorTokenModifiers = exports.ColorTokenTypes = exports.ColorToken = void 0;
|
|
4
|
-
const source_1 = require("../../source");
|
|
5
|
-
var ColorToken;
|
|
1
|
+
import { Range } from '../../source/index.js';
|
|
2
|
+
export var ColorToken;
|
|
6
3
|
(function (ColorToken) {
|
|
7
4
|
/* istanbul ignore next */
|
|
8
5
|
function create(range, type, modifiers) {
|
|
9
6
|
return {
|
|
10
|
-
range:
|
|
7
|
+
range: Range.get(range),
|
|
11
8
|
type,
|
|
12
9
|
modifiers,
|
|
13
10
|
};
|
|
@@ -22,20 +19,20 @@ var ColorToken;
|
|
|
22
19
|
let nextStart = Math.min(targetRange.start, tokens[0]?.range.start ?? Infinity);
|
|
23
20
|
for (const t of tokens) {
|
|
24
21
|
if (t.range.start > nextStart) {
|
|
25
|
-
ans.push(ColorToken.create(
|
|
22
|
+
ans.push(ColorToken.create(Range.create(nextStart, t.range.start), type, modifiers));
|
|
26
23
|
}
|
|
27
24
|
ans.push(t);
|
|
28
25
|
nextStart = t.range.end;
|
|
29
26
|
}
|
|
30
27
|
if (nextStart < targetRange.end) {
|
|
31
|
-
ans.push(ColorToken.create(
|
|
28
|
+
ans.push(ColorToken.create(Range.create(nextStart, targetRange.end), type, modifiers));
|
|
32
29
|
}
|
|
33
30
|
return ans;
|
|
34
31
|
}
|
|
35
32
|
ColorToken.fillGap = fillGap;
|
|
36
|
-
})(ColorToken
|
|
33
|
+
})(ColorToken || (ColorToken = {}));
|
|
37
34
|
// Built-in LSP semantic tokens: https://microsoft.github.io/language-server-protocol/specifications/specification-3-17/#textDocument_semanticTokens
|
|
38
|
-
|
|
35
|
+
export const ColorTokenTypes = Object.freeze([
|
|
39
36
|
'comment',
|
|
40
37
|
'enum',
|
|
41
38
|
'enumMember',
|
|
@@ -57,7 +54,7 @@ exports.ColorTokenTypes = Object.freeze([
|
|
|
57
54
|
'resourceLocation',
|
|
58
55
|
'vector',
|
|
59
56
|
]);
|
|
60
|
-
|
|
57
|
+
export const ColorTokenModifiers = Object.freeze([
|
|
61
58
|
'declaration',
|
|
62
59
|
'defaultLibrary',
|
|
63
60
|
'definition',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { LiteralBaseNode, ResourceLocationBaseNode, StringBaseNode, SymbolBaseNode } from '../../node';
|
|
2
|
-
import type { MetaRegistry } from '../../service';
|
|
3
|
-
import type { Colorizer } from './Colorizer';
|
|
1
|
+
import type { LiteralBaseNode, ResourceLocationBaseNode, StringBaseNode, SymbolBaseNode } from '../../node/index.js';
|
|
2
|
+
import type { MetaRegistry } from '../../service/index.js';
|
|
3
|
+
import type { Colorizer } from './Colorizer.js';
|
|
4
4
|
/**
|
|
5
5
|
* Use the shallowest children that have their own colorizers to provide the color tokens.
|
|
6
6
|
*/
|
|
@@ -1,43 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const source_1 = require("../../source");
|
|
5
|
-
const util_1 = require("../util");
|
|
6
|
-
const Colorizer_1 = require("./Colorizer");
|
|
1
|
+
import { Range } from '../../source/index.js';
|
|
2
|
+
import { traversePreOrder } from '../util.js';
|
|
3
|
+
import { ColorToken } from './Colorizer.js';
|
|
7
4
|
/**
|
|
8
5
|
* Use the shallowest children that have their own colorizers to provide the color tokens.
|
|
9
6
|
*/
|
|
10
|
-
const fallback = (node, ctx) => {
|
|
7
|
+
export const fallback = (node, ctx) => {
|
|
11
8
|
const ans = [];
|
|
12
|
-
|
|
9
|
+
traversePreOrder(node, node => !ctx.meta.hasColorizer(node.type) && (!ctx.range || Range.intersects(node.range, ctx.range)), node => ctx.meta.hasColorizer(node.type), node => {
|
|
13
10
|
const colorizer = ctx.meta.getColorizer(node.type);
|
|
14
11
|
const result = colorizer(node, ctx);
|
|
15
12
|
ans.push(...result);
|
|
16
13
|
});
|
|
17
14
|
return Object.freeze(ans);
|
|
18
15
|
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return [Colorizer_1.ColorToken.create(node, 'literal')];
|
|
16
|
+
export const boolean = node => {
|
|
17
|
+
return [ColorToken.create(node, 'literal')];
|
|
22
18
|
};
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return [Colorizer_1.ColorToken.create(node, 'comment')];
|
|
19
|
+
export const comment = node => {
|
|
20
|
+
return [ColorToken.create(node, 'comment')];
|
|
26
21
|
};
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return [Colorizer_1.ColorToken.create(node, 'error')];
|
|
22
|
+
export const error = node => {
|
|
23
|
+
return [ColorToken.create(node, 'error')];
|
|
30
24
|
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
return [Colorizer_1.ColorToken.create(node, node.options.colorTokenType ?? 'literal')];
|
|
25
|
+
export const literal = node => {
|
|
26
|
+
return [ColorToken.create(node, node.options.colorTokenType ?? 'literal')];
|
|
34
27
|
};
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return [Colorizer_1.ColorToken.create(node, 'number')];
|
|
28
|
+
export const number = node => {
|
|
29
|
+
return [ColorToken.create(node, 'number')];
|
|
38
30
|
};
|
|
39
|
-
|
|
40
|
-
const resourceLocation = (node, _ctx) => {
|
|
31
|
+
export const resourceLocation = (node, _ctx) => {
|
|
41
32
|
let type;
|
|
42
33
|
switch (node.options.category) {
|
|
43
34
|
case 'function':
|
|
@@ -48,37 +39,33 @@ const resourceLocation = (node, _ctx) => {
|
|
|
48
39
|
type = 'resourceLocation';
|
|
49
40
|
break;
|
|
50
41
|
}
|
|
51
|
-
return [
|
|
42
|
+
return [ColorToken.create(node, type)];
|
|
52
43
|
};
|
|
53
|
-
|
|
54
|
-
const string = (node, ctx) => {
|
|
44
|
+
export const string = (node, ctx) => {
|
|
55
45
|
if (node.children) {
|
|
56
46
|
const colorizer = ctx.meta.getColorizer(node.children[0].type);
|
|
57
47
|
const result = colorizer(node.children[0], ctx);
|
|
58
48
|
// TODO: Fill the gap between the last token and the ending quote with errors.
|
|
59
|
-
return
|
|
49
|
+
return ColorToken.fillGap(result, node.range, node.options.colorTokenType ?? 'string');
|
|
60
50
|
}
|
|
61
51
|
else {
|
|
62
|
-
return [
|
|
52
|
+
return [ColorToken.create(node, node.options.colorTokenType ?? 'string')];
|
|
63
53
|
}
|
|
64
54
|
};
|
|
65
|
-
|
|
66
|
-
const symbol = node => {
|
|
55
|
+
export const symbol = node => {
|
|
67
56
|
// TODO: Set the modifiers according to `node.symbol`.
|
|
68
|
-
return [
|
|
57
|
+
return [ColorToken.create(node, 'variable')];
|
|
69
58
|
};
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
meta.registerColorizer('
|
|
73
|
-
meta.registerColorizer('
|
|
74
|
-
meta.registerColorizer('
|
|
75
|
-
meta.registerColorizer('
|
|
76
|
-
meta.registerColorizer('
|
|
77
|
-
meta.registerColorizer('
|
|
78
|
-
meta.registerColorizer('
|
|
79
|
-
meta.registerColorizer('
|
|
80
|
-
meta.registerColorizer('
|
|
81
|
-
meta.registerColorizer('symbol', exports.symbol);
|
|
59
|
+
export function registerColorizers(meta) {
|
|
60
|
+
meta.registerColorizer('boolean', boolean);
|
|
61
|
+
meta.registerColorizer('comment', comment);
|
|
62
|
+
meta.registerColorizer('error', error);
|
|
63
|
+
meta.registerColorizer('float', number);
|
|
64
|
+
meta.registerColorizer('integer', number);
|
|
65
|
+
meta.registerColorizer('long', number);
|
|
66
|
+
meta.registerColorizer('literal', literal);
|
|
67
|
+
meta.registerColorizer('resource_location', resourceLocation);
|
|
68
|
+
meta.registerColorizer('string', string);
|
|
69
|
+
meta.registerColorizer('symbol', symbol);
|
|
82
70
|
}
|
|
83
|
-
exports.registerColorizers = registerColorizers;
|
|
84
71
|
//# sourceMappingURL=builtin.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * as colorizer from './builtin';
|
|
2
|
-
export * from './Colorizer';
|
|
1
|
+
export * as colorizer from './builtin.js';
|
|
2
|
+
export * from './Colorizer.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.colorizer = void 0;
|
|
30
|
-
exports.colorizer = __importStar(require("./builtin"));
|
|
31
|
-
__exportStar(require("./Colorizer"), exports);
|
|
1
|
+
export * as colorizer from './builtin.js';
|
|
2
|
+
export * from './Colorizer.js';
|
|
32
3
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { AstNode } from '../../node';
|
|
2
|
-
import type { CompleterContext } from '../../service';
|
|
3
|
-
import type { RangeLike } from '../../source';
|
|
4
|
-
import { Range } from '../../source';
|
|
1
|
+
import type { AstNode } from '../../node/index.js';
|
|
2
|
+
import type { CompleterContext } from '../../service/index.js';
|
|
3
|
+
import type { RangeLike } from '../../source/index.js';
|
|
4
|
+
import { Range } from '../../source/index.js';
|
|
5
5
|
export declare type Completer<N = AstNode> = (node: N, ctx: CompleterContext) => CompletionItem[];
|
|
6
6
|
export declare const enum CompletionKind {
|
|
7
7
|
Text = 1,
|
|
@@ -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,10 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import type { CompleterContext, MetaRegistry } from '../../service';
|
|
5
|
-
import type { RangeLike } from '../../source';
|
|
6
|
-
import type { Completer } from './Completer';
|
|
7
|
-
import { CompletionItem } from './Completer';
|
|
1
|
+
import type { BooleanBaseNode } from '../../node/BooleanNode.js';
|
|
2
|
+
import type { FileNode, LiteralBaseNode, PairNode, RecordBaseNode, ResourceLocationNode, StringBaseNode, SymbolBaseNode } from '../../node/index.js';
|
|
3
|
+
import { AstNode } from '../../node/index.js';
|
|
4
|
+
import type { CompleterContext, MetaRegistry } from '../../service/index.js';
|
|
5
|
+
import type { RangeLike } from '../../source/index.js';
|
|
6
|
+
import type { Completer } from './Completer.js';
|
|
7
|
+
import { CompletionItem } from './Completer.js';
|
|
8
8
|
/**
|
|
9
9
|
* Uses the shallowest selected node that has its own completer to provide the completion items.
|
|
10
10
|
*/
|