@spyglassmc/core 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -0
- package/lib/common/Heap.d.ts +1 -0
- package/lib/common/Heap.js +2 -0
- package/lib/common/index.d.ts +2 -0
- package/lib/common/index.js +14 -0
- package/lib/common/util.d.ts +120 -0
- package/lib/common/util.js +292 -0
- package/lib/index.d.ts +8 -0
- package/lib/index.js +20 -0
- package/lib/node/AstNode.d.ts +64 -0
- package/lib/node/AstNode.js +108 -0
- package/lib/node/BooleanNode.d.ts +13 -0
- package/lib/node/BooleanNode.js +20 -0
- package/lib/node/CommentNode.d.ts +12 -0
- package/lib/node/CommentNode.js +11 -0
- package/lib/node/ErrorNode.d.ts +8 -0
- package/lib/node/ErrorNode.js +12 -0
- package/lib/node/FileNode.d.ts +21 -0
- package/lib/node/FileNode.js +11 -0
- package/lib/node/FloatNode.d.ts +13 -0
- package/lib/node/FloatNode.js +21 -0
- package/lib/node/IntegerNode.d.ts +13 -0
- package/lib/node/IntegerNode.js +20 -0
- package/lib/node/ListNode.d.ts +15 -0
- package/lib/node/ListNode.js +11 -0
- package/lib/node/LiteralNode.d.ts +19 -0
- package/lib/node/LiteralNode.js +22 -0
- package/lib/node/LongNode.d.ts +13 -0
- package/lib/node/LongNode.js +20 -0
- package/lib/node/RecordNode.d.ts +20 -0
- package/lib/node/RecordNode.js +11 -0
- package/lib/node/ResourceLocationNode.d.ts +41 -0
- package/lib/node/ResourceLocationNode.js +65 -0
- package/lib/node/Sequence.d.ts +22 -0
- package/lib/node/Sequence.js +11 -0
- package/lib/node/StringNode.d.ts +63 -0
- package/lib/node/StringNode.js +43 -0
- package/lib/node/SymbolNode.d.ts +21 -0
- package/lib/node/SymbolNode.js +22 -0
- package/lib/node/TableNode.d.ts +17 -0
- package/lib/node/TableNode.js +11 -0
- package/lib/node/index.d.ts +16 -0
- package/lib/node/index.js +28 -0
- package/lib/parser/Parser.d.ts +16 -0
- package/lib/parser/Parser.js +5 -0
- package/lib/parser/boolean.d.ts +4 -0
- package/lib/parser/boolean.js +11 -0
- package/lib/parser/comment.d.ts +12 -0
- package/lib/parser/comment.js +34 -0
- package/lib/parser/empty.d.ts +3 -0
- package/lib/parser/empty.js +7 -0
- package/lib/parser/error.d.ts +8 -0
- package/lib/parser/error.js +22 -0
- package/lib/parser/file.d.ts +9 -0
- package/lib/parser/file.js +37 -0
- package/lib/parser/float.d.ts +33 -0
- package/lib/parser/float.js +57 -0
- package/lib/parser/index.d.ts +17 -0
- package/lib/parser/index.js +36 -0
- package/lib/parser/integer.d.ts +33 -0
- package/lib/parser/integer.js +46 -0
- package/lib/parser/list.d.ts +12 -0
- package/lib/parser/list.js +70 -0
- package/lib/parser/literal.d.ts +5 -0
- package/lib/parser/literal.js +41 -0
- package/lib/parser/long.d.ts +33 -0
- package/lib/parser/long.js +50 -0
- package/lib/parser/record.d.ts +22 -0
- package/lib/parser/record.js +97 -0
- package/lib/parser/resourceLocation.d.ts +4 -0
- package/lib/parser/resourceLocation.js +67 -0
- package/lib/parser/string.d.ts +18 -0
- package/lib/parser/string.js +129 -0
- package/lib/parser/symbol.d.ts +12 -0
- package/lib/parser/symbol.js +33 -0
- package/lib/parser/table.d.ts +22 -0
- package/lib/parser/table.js +97 -0
- package/lib/parser/util.d.ts +134 -0
- package/lib/parser/util.js +224 -0
- package/lib/processor/ColorInfoProvider.d.ts +87 -0
- package/lib/processor/ColorInfoProvider.js +141 -0
- package/lib/processor/InlayHintProvider.d.ts +8 -0
- package/lib/processor/InlayHintProvider.js +3 -0
- package/lib/processor/SignatureHelpProvider.d.ts +18 -0
- package/lib/processor/SignatureHelpProvider.js +3 -0
- package/lib/processor/checker/Checker.d.ts +7 -0
- package/lib/processor/checker/Checker.js +7 -0
- package/lib/processor/checker/builtin.d.ts +23 -0
- package/lib/processor/checker/builtin.js +83 -0
- package/lib/processor/checker/index.d.ts +3 -0
- package/lib/processor/checker/index.js +28 -0
- package/lib/processor/colorizer/Colorizer.d.ts +23 -0
- package/lib/processor/colorizer/Colorizer.js +70 -0
- package/lib/processor/colorizer/builtin.d.ts +17 -0
- package/lib/processor/colorizer/builtin.js +84 -0
- package/lib/processor/colorizer/index.d.ts +3 -0
- package/lib/processor/colorizer/index.js +28 -0
- package/lib/processor/completer/Completer.d.ts +75 -0
- package/lib/processor/completer/Completer.js +92 -0
- package/lib/processor/completer/builtin.d.ts +30 -0
- package/lib/processor/completer/builtin.js +172 -0
- package/lib/processor/completer/index.d.ts +3 -0
- package/lib/processor/completer/index.js +28 -0
- package/lib/processor/formatter/Formatter.d.ts +6 -0
- package/lib/processor/formatter/Formatter.js +19 -0
- package/lib/processor/formatter/builtin.d.ts +15 -0
- package/lib/processor/formatter/builtin.js +60 -0
- package/lib/processor/formatter/index.d.ts +3 -0
- package/lib/processor/formatter/index.js +28 -0
- package/lib/processor/index.d.ts +10 -0
- package/lib/processor/index.js +22 -0
- package/lib/processor/linter/Linter.d.ts +4 -0
- package/lib/processor/linter/Linter.js +3 -0
- package/lib/processor/linter/builtin/undeclaredSymbol.d.ts +4 -0
- package/lib/processor/linter/builtin/undeclaredSymbol.js +73 -0
- package/lib/processor/linter/builtin.d.ts +15 -0
- package/lib/processor/linter/builtin.js +120 -0
- package/lib/processor/linter/index.d.ts +3 -0
- package/lib/processor/linter/index.js +28 -0
- package/lib/processor/util.d.ts +17 -0
- package/lib/processor/util.js +32 -0
- package/lib/service/CacheService.d.ts +54 -0
- package/lib/service/CacheService.js +195 -0
- package/lib/service/CommandExecutor.d.ts +3 -0
- package/lib/service/CommandExecutor.js +7 -0
- package/lib/service/Config.d.ts +218 -0
- package/lib/service/Config.js +264 -0
- package/lib/service/Context.d.ts +143 -0
- package/lib/service/Context.js +143 -0
- package/lib/service/Dependency.d.ts +10 -0
- package/lib/service/Dependency.js +11 -0
- package/lib/service/Downloader.d.ts +67 -0
- package/lib/service/Downloader.js +185 -0
- package/lib/service/ErrorReporter.d.ts +27 -0
- package/lib/service/ErrorReporter.js +49 -0
- package/lib/service/FileService.d.ts +96 -0
- package/lib/service/FileService.js +224 -0
- package/lib/service/Hover.d.ts +10 -0
- package/lib/service/Hover.js +16 -0
- package/lib/service/Logger.d.ts +31 -0
- package/lib/service/Logger.js +30 -0
- package/lib/service/MetaRegistry.d.ts +106 -0
- package/lib/service/MetaRegistry.js +192 -0
- package/lib/service/Operations.d.ts +8 -0
- package/lib/service/Operations.js +26 -0
- package/lib/service/Profiler.d.ts +33 -0
- package/lib/service/Profiler.js +76 -0
- package/lib/service/Project.d.ts +173 -0
- package/lib/service/Project.js +593 -0
- package/lib/service/Service.d.ts +55 -0
- package/lib/service/Service.js +207 -0
- package/lib/service/SymbolLocations.d.ts +17 -0
- package/lib/service/SymbolLocations.js +16 -0
- package/lib/service/SymbolRegistrar.d.ts +5 -0
- package/lib/service/SymbolRegistrar.js +3 -0
- package/lib/service/fileUtil.d.ts +121 -0
- package/lib/service/fileUtil.js +268 -0
- package/lib/service/index.d.ts +18 -0
- package/lib/service/index.js +33 -0
- package/lib/source/IndexMap.d.ts +16 -0
- package/lib/source/IndexMap.js +46 -0
- package/lib/source/LanguageError.d.ts +27 -0
- package/lib/source/LanguageError.js +15 -0
- package/lib/source/Location.d.ts +19 -0
- package/lib/source/Location.js +25 -0
- package/lib/source/Offset.d.ts +13 -0
- package/lib/source/Offset.js +25 -0
- package/lib/source/Position.d.ts +23 -0
- package/lib/source/Position.js +43 -0
- package/lib/source/PositionRange.d.ts +38 -0
- package/lib/source/PositionRange.js +83 -0
- package/lib/source/Range.d.ts +68 -0
- package/lib/source/Range.js +155 -0
- package/lib/source/Source.d.ts +110 -0
- package/lib/source/Source.js +222 -0
- package/lib/source/index.d.ts +9 -0
- package/lib/source/index.js +21 -0
- package/lib/symbol/Symbol.d.ts +219 -0
- package/lib/symbol/Symbol.js +324 -0
- package/lib/symbol/SymbolUtil.d.ts +407 -0
- package/lib/symbol/SymbolUtil.js +880 -0
- package/lib/symbol/UriBinder.d.ts +3 -0
- package/lib/symbol/UriBinder.js +3 -0
- package/lib/symbol/index.d.ts +4 -0
- package/lib/symbol/index.js +16 -0
- package/package.json +41 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BooleanNode = void 0;
|
|
4
|
+
const source_1 = require("../source");
|
|
5
|
+
var BooleanNode;
|
|
6
|
+
(function (BooleanNode) {
|
|
7
|
+
/* istanbul ignore next */
|
|
8
|
+
function is(obj) {
|
|
9
|
+
return obj.type === 'boolean';
|
|
10
|
+
}
|
|
11
|
+
BooleanNode.is = is;
|
|
12
|
+
function mock(range) {
|
|
13
|
+
return {
|
|
14
|
+
type: 'boolean',
|
|
15
|
+
range: source_1.Range.get(range),
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
BooleanNode.mock = mock;
|
|
19
|
+
})(BooleanNode = exports.BooleanNode || (exports.BooleanNode = {}));
|
|
20
|
+
//# sourceMappingURL=BooleanNode.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AstNode } from './AstNode';
|
|
2
|
+
export interface CommentNode extends AstNode {
|
|
3
|
+
readonly type: 'comment';
|
|
4
|
+
/**
|
|
5
|
+
* The actual comment with prefixes and suffixes removed.
|
|
6
|
+
*/
|
|
7
|
+
readonly comment: string;
|
|
8
|
+
}
|
|
9
|
+
export declare namespace CommentNode {
|
|
10
|
+
function is(obj: AstNode | undefined): obj is CommentNode;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=CommentNode.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CommentNode = void 0;
|
|
4
|
+
var CommentNode;
|
|
5
|
+
(function (CommentNode) {
|
|
6
|
+
function is(obj) {
|
|
7
|
+
return obj?.type === 'comment';
|
|
8
|
+
}
|
|
9
|
+
CommentNode.is = is;
|
|
10
|
+
})(CommentNode = exports.CommentNode || (exports.CommentNode = {}));
|
|
11
|
+
//# sourceMappingURL=CommentNode.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ErrorNode = void 0;
|
|
4
|
+
var ErrorNode;
|
|
5
|
+
(function (ErrorNode) {
|
|
6
|
+
/* istanbul ignore next */
|
|
7
|
+
function is(obj) {
|
|
8
|
+
return obj.type === 'error';
|
|
9
|
+
}
|
|
10
|
+
ErrorNode.is = is;
|
|
11
|
+
})(ErrorNode = exports.ErrorNode || (exports.ErrorNode = {}));
|
|
12
|
+
//# sourceMappingURL=ErrorNode.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { AstNode } from '../node';
|
|
2
|
+
import type { LanguageError } from '../source';
|
|
3
|
+
import type { SymbolTable } from '../symbol';
|
|
4
|
+
export interface FileNode<CN extends AstNode> extends AstNode {
|
|
5
|
+
readonly type: 'file';
|
|
6
|
+
readonly children: CN[];
|
|
7
|
+
locals: SymbolTable;
|
|
8
|
+
readonly parserErrors: readonly LanguageError[];
|
|
9
|
+
/**
|
|
10
|
+
* Only exists when the file has been checked.
|
|
11
|
+
*/
|
|
12
|
+
checkerErrors?: readonly LanguageError[];
|
|
13
|
+
/**
|
|
14
|
+
* Only exists when the file has been checked.
|
|
15
|
+
*/
|
|
16
|
+
linterErrors?: readonly LanguageError[];
|
|
17
|
+
}
|
|
18
|
+
export declare namespace FileNode {
|
|
19
|
+
function getErrors(node: FileNode<any>): LanguageError[];
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=FileNode.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FileNode = void 0;
|
|
4
|
+
var FileNode;
|
|
5
|
+
(function (FileNode) {
|
|
6
|
+
function getErrors(node) {
|
|
7
|
+
return [...node.parserErrors, ...node.checkerErrors ?? [], ...node.linterErrors ?? []];
|
|
8
|
+
}
|
|
9
|
+
FileNode.getErrors = getErrors;
|
|
10
|
+
})(FileNode = exports.FileNode || (exports.FileNode = {}));
|
|
11
|
+
//# sourceMappingURL=FileNode.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { RangeLike } from '../source';
|
|
2
|
+
import type { AstNode } from './AstNode';
|
|
3
|
+
export interface FloatBaseNode extends AstNode {
|
|
4
|
+
readonly value: number;
|
|
5
|
+
}
|
|
6
|
+
export interface FloatNode extends FloatBaseNode {
|
|
7
|
+
readonly type: 'float';
|
|
8
|
+
}
|
|
9
|
+
export declare namespace FloatNode {
|
|
10
|
+
function is(obj: object): obj is FloatNode;
|
|
11
|
+
function mock(range: RangeLike): FloatNode;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=FloatNode.d.ts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FloatNode = void 0;
|
|
4
|
+
const source_1 = require("../source");
|
|
5
|
+
var FloatNode;
|
|
6
|
+
(function (FloatNode) {
|
|
7
|
+
/* istanbul ignore next */
|
|
8
|
+
function is(obj) {
|
|
9
|
+
return obj.type === 'float';
|
|
10
|
+
}
|
|
11
|
+
FloatNode.is = is;
|
|
12
|
+
function mock(range) {
|
|
13
|
+
return {
|
|
14
|
+
type: 'float',
|
|
15
|
+
range: source_1.Range.get(range),
|
|
16
|
+
value: 0,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
FloatNode.mock = mock;
|
|
20
|
+
})(FloatNode = exports.FloatNode || (exports.FloatNode = {}));
|
|
21
|
+
//# sourceMappingURL=FloatNode.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { RangeLike } from '../source';
|
|
2
|
+
import type { AstNode } from './AstNode';
|
|
3
|
+
export interface IntegerBaseNode extends AstNode {
|
|
4
|
+
readonly value: number;
|
|
5
|
+
}
|
|
6
|
+
export interface IntegerNode extends IntegerBaseNode {
|
|
7
|
+
readonly type: 'integer';
|
|
8
|
+
}
|
|
9
|
+
export declare namespace IntegerNode {
|
|
10
|
+
function is(obj: object): obj is IntegerNode;
|
|
11
|
+
function mock(range: RangeLike): IntegerNode;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=IntegerNode.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IntegerNode = void 0;
|
|
4
|
+
const source_1 = require("../source");
|
|
5
|
+
var IntegerNode;
|
|
6
|
+
(function (IntegerNode) {
|
|
7
|
+
function is(obj) {
|
|
8
|
+
return obj.type === 'integer';
|
|
9
|
+
}
|
|
10
|
+
IntegerNode.is = is;
|
|
11
|
+
function mock(range) {
|
|
12
|
+
return {
|
|
13
|
+
type: 'integer',
|
|
14
|
+
range: source_1.Range.get(range),
|
|
15
|
+
value: 0,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
IntegerNode.mock = mock;
|
|
19
|
+
})(IntegerNode = exports.IntegerNode || (exports.IntegerNode = {}));
|
|
20
|
+
//# sourceMappingURL=IntegerNode.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Range } from '../source';
|
|
2
|
+
import type { AstNode } from './AstNode';
|
|
3
|
+
export interface ListNode<V extends AstNode> extends AstNode {
|
|
4
|
+
readonly children: ItemNode<V>[];
|
|
5
|
+
}
|
|
6
|
+
export interface ItemNode<V extends AstNode> extends AstNode {
|
|
7
|
+
readonly type: 'item';
|
|
8
|
+
readonly children?: [V];
|
|
9
|
+
readonly value?: V;
|
|
10
|
+
readonly sep?: Range;
|
|
11
|
+
}
|
|
12
|
+
export declare namespace ItemNode {
|
|
13
|
+
function is<V extends AstNode>(node: AstNode | undefined): node is ItemNode<V>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=ListNode.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ItemNode = void 0;
|
|
4
|
+
var ItemNode;
|
|
5
|
+
(function (ItemNode) {
|
|
6
|
+
function is(node) {
|
|
7
|
+
return node?.type === 'item';
|
|
8
|
+
}
|
|
9
|
+
ItemNode.is = is;
|
|
10
|
+
})(ItemNode = exports.ItemNode || (exports.ItemNode = {}));
|
|
11
|
+
//# sourceMappingURL=ListNode.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ColorTokenType } from '../processor';
|
|
2
|
+
import type { RangeLike } from '../source';
|
|
3
|
+
import type { AstNode } from './AstNode';
|
|
4
|
+
export interface LiteralOptions {
|
|
5
|
+
pool: string[];
|
|
6
|
+
colorTokenType?: ColorTokenType;
|
|
7
|
+
}
|
|
8
|
+
export interface LiteralBaseNode extends AstNode {
|
|
9
|
+
readonly options: LiteralOptions;
|
|
10
|
+
readonly value: string;
|
|
11
|
+
}
|
|
12
|
+
export interface LiteralNode extends LiteralBaseNode {
|
|
13
|
+
readonly type: 'literal';
|
|
14
|
+
}
|
|
15
|
+
export declare namespace LiteralNode {
|
|
16
|
+
function is(obj: object): obj is LiteralNode;
|
|
17
|
+
function mock(range: RangeLike, options: LiteralOptions): LiteralNode;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=LiteralNode.d.ts.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LiteralNode = void 0;
|
|
4
|
+
const source_1 = require("../source");
|
|
5
|
+
var LiteralNode;
|
|
6
|
+
(function (LiteralNode) {
|
|
7
|
+
/* istanbul ignore next */
|
|
8
|
+
function is(obj) {
|
|
9
|
+
return obj.type === 'literal';
|
|
10
|
+
}
|
|
11
|
+
LiteralNode.is = is;
|
|
12
|
+
function mock(range, options) {
|
|
13
|
+
return {
|
|
14
|
+
type: 'literal',
|
|
15
|
+
range: source_1.Range.get(range),
|
|
16
|
+
options,
|
|
17
|
+
value: '',
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
LiteralNode.mock = mock;
|
|
21
|
+
})(LiteralNode = exports.LiteralNode || (exports.LiteralNode = {}));
|
|
22
|
+
//# sourceMappingURL=LiteralNode.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { RangeLike } from '../source';
|
|
2
|
+
import type { AstNode } from './AstNode';
|
|
3
|
+
export interface LongBaseNode extends AstNode {
|
|
4
|
+
readonly value: bigint;
|
|
5
|
+
}
|
|
6
|
+
export interface LongNode extends LongBaseNode {
|
|
7
|
+
readonly type: 'long';
|
|
8
|
+
}
|
|
9
|
+
export declare namespace LongNode {
|
|
10
|
+
function is(obj: object): obj is LongNode;
|
|
11
|
+
function mock(range: RangeLike): LongNode;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=LongNode.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LongNode = void 0;
|
|
4
|
+
const source_1 = require("../source");
|
|
5
|
+
var LongNode;
|
|
6
|
+
(function (LongNode) {
|
|
7
|
+
function is(obj) {
|
|
8
|
+
return obj.type === 'long';
|
|
9
|
+
}
|
|
10
|
+
LongNode.is = is;
|
|
11
|
+
function mock(range) {
|
|
12
|
+
return {
|
|
13
|
+
type: 'long',
|
|
14
|
+
range: source_1.Range.get(range),
|
|
15
|
+
value: 0n,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
LongNode.mock = mock;
|
|
19
|
+
})(LongNode = exports.LongNode || (exports.LongNode = {}));
|
|
20
|
+
//# sourceMappingURL=LongNode.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Range } from '../source';
|
|
2
|
+
import type { AstNode } from './AstNode';
|
|
3
|
+
export interface RecordBaseNode<K extends AstNode, V extends AstNode> extends AstNode {
|
|
4
|
+
readonly children: PairNode<K, V>[];
|
|
5
|
+
}
|
|
6
|
+
export interface RecordNode<K extends AstNode, V extends AstNode> extends RecordBaseNode<K, V> {
|
|
7
|
+
type: 'record';
|
|
8
|
+
}
|
|
9
|
+
export interface PairNode<K extends AstNode, V extends AstNode> extends AstNode {
|
|
10
|
+
readonly type: 'pair';
|
|
11
|
+
readonly children?: [K, V] | [K] | [V];
|
|
12
|
+
readonly key?: K;
|
|
13
|
+
readonly sep?: Range;
|
|
14
|
+
readonly value?: V;
|
|
15
|
+
readonly end?: Range;
|
|
16
|
+
}
|
|
17
|
+
export declare namespace PairNode {
|
|
18
|
+
function is<K extends AstNode, V extends AstNode>(node: AstNode | undefined): node is PairNode<K, V>;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=RecordNode.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PairNode = void 0;
|
|
4
|
+
var PairNode;
|
|
5
|
+
(function (PairNode) {
|
|
6
|
+
function is(node) {
|
|
7
|
+
return node?.type === 'pair';
|
|
8
|
+
}
|
|
9
|
+
PairNode.is = is;
|
|
10
|
+
})(PairNode = exports.PairNode || (exports.PairNode = {}));
|
|
11
|
+
//# sourceMappingURL=RecordNode.js.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { FullResourceLocation } from '../common';
|
|
2
|
+
import type { RangeLike } from '../source';
|
|
3
|
+
import type { ResourceLocationCategory, SymbolAccessType, SymbolUsageType, TaggableResourceLocationCategory } from '../symbol';
|
|
4
|
+
import type { AstNode } from './AstNode';
|
|
5
|
+
export declare type ResourceLocationOptions = {
|
|
6
|
+
accessType?: SymbolAccessType;
|
|
7
|
+
isPredicate?: boolean;
|
|
8
|
+
usageType?: SymbolUsageType;
|
|
9
|
+
namespacePathSep?: ':' | '.';
|
|
10
|
+
} & ({
|
|
11
|
+
category: ResourceLocationCategory;
|
|
12
|
+
pool?: undefined;
|
|
13
|
+
allowTag?: false;
|
|
14
|
+
allowUnknown?: false;
|
|
15
|
+
} | {
|
|
16
|
+
category: TaggableResourceLocationCategory;
|
|
17
|
+
pool?: undefined;
|
|
18
|
+
allowTag?: boolean;
|
|
19
|
+
allowUnknown?: false;
|
|
20
|
+
} | {
|
|
21
|
+
category?: undefined;
|
|
22
|
+
pool: string[];
|
|
23
|
+
allowTag?: false;
|
|
24
|
+
allowUnknown?: boolean;
|
|
25
|
+
});
|
|
26
|
+
export interface ResourceLocationBaseNode extends AstNode {
|
|
27
|
+
readonly options: ResourceLocationOptions;
|
|
28
|
+
readonly isTag?: boolean;
|
|
29
|
+
readonly namespace?: string;
|
|
30
|
+
readonly path?: string[];
|
|
31
|
+
}
|
|
32
|
+
export interface ResourceLocationNode extends ResourceLocationBaseNode {
|
|
33
|
+
readonly type: 'resource_location';
|
|
34
|
+
}
|
|
35
|
+
export declare namespace ResourceLocationNode {
|
|
36
|
+
function is(obj: AstNode | undefined): obj is ResourceLocationNode;
|
|
37
|
+
function mock(range: RangeLike, options: ResourceLocationOptions): ResourceLocationNode;
|
|
38
|
+
function toString(node: ResourceLocationBaseNode, type?: 'full'): FullResourceLocation;
|
|
39
|
+
function toString(node: ResourceLocationBaseNode, type?: 'origin' | 'full' | 'short'): string;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=ResourceLocationNode.d.ts.map
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ResourceLocationNode = void 0;
|
|
4
|
+
const common_1 = require("../common");
|
|
5
|
+
const source_1 = require("../source");
|
|
6
|
+
var ResourceLocationNode;
|
|
7
|
+
(function (ResourceLocationNode) {
|
|
8
|
+
/**
|
|
9
|
+
* The prefix for tags.
|
|
10
|
+
*/
|
|
11
|
+
const TagPrefix = common_1.ResourceLocation.TagPrefix;
|
|
12
|
+
/**
|
|
13
|
+
* The seperator of namespace and path.
|
|
14
|
+
*/
|
|
15
|
+
const NamespacePathSep = common_1.ResourceLocation.NamespacePathSep;
|
|
16
|
+
/**
|
|
17
|
+
* The seperator between different path segments.
|
|
18
|
+
*/
|
|
19
|
+
const PathSep = common_1.ResourceLocation.PathSep;
|
|
20
|
+
const DefaultNamespace = common_1.ResourceLocation.DefaultNamespace;
|
|
21
|
+
/* istanbul ignore next */
|
|
22
|
+
function is(obj) {
|
|
23
|
+
return obj?.type === 'resource_location';
|
|
24
|
+
}
|
|
25
|
+
ResourceLocationNode.is = is;
|
|
26
|
+
function mock(range, options) {
|
|
27
|
+
return {
|
|
28
|
+
type: 'resource_location',
|
|
29
|
+
range: source_1.Range.get(range),
|
|
30
|
+
options,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
ResourceLocationNode.mock = mock;
|
|
34
|
+
function toString(node, type = 'origin') {
|
|
35
|
+
const path = node.path ? node.path.join(PathSep) : '';
|
|
36
|
+
let id;
|
|
37
|
+
/*
|
|
38
|
+
* `node.namespace` has four statuses here:
|
|
39
|
+
* - `minecraft`
|
|
40
|
+
* - `` (yes, empty string)
|
|
41
|
+
* - undefined
|
|
42
|
+
* - any other namespaces.
|
|
43
|
+
*
|
|
44
|
+
* Whether `node.namespace !== undefined` or simply `node.namespace` is used in the condition is carefully selected.
|
|
45
|
+
*/
|
|
46
|
+
switch (type) {
|
|
47
|
+
case 'origin':
|
|
48
|
+
// Use `node.namespace !== undefined`, so that empty namespaces can be correctly restored to string.
|
|
49
|
+
id = node.namespace !== undefined ? `${node.namespace}${NamespacePathSep}${path}` : path;
|
|
50
|
+
break;
|
|
51
|
+
case 'full':
|
|
52
|
+
// Use `node.namespace` before `||`, so that both undefined and empty value can result in the default namespace.
|
|
53
|
+
// Use `||` instead of `??`, so that empty namespaces can be converted to the default namespace.
|
|
54
|
+
id = `${node.namespace || DefaultNamespace}${NamespacePathSep}${path}`;
|
|
55
|
+
break;
|
|
56
|
+
case 'short':
|
|
57
|
+
// Use `node.namespace` before `&&` for the same reason stated above.
|
|
58
|
+
id = node.namespace && node.namespace !== DefaultNamespace ? `${node.namespace}${NamespacePathSep}${path}` : path;
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
return node.isTag ? `${TagPrefix}${id}` : id;
|
|
62
|
+
}
|
|
63
|
+
ResourceLocationNode.toString = toString;
|
|
64
|
+
})(ResourceLocationNode = exports.ResourceLocationNode || (exports.ResourceLocationNode = {}));
|
|
65
|
+
//# sourceMappingURL=ResourceLocationNode.js.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { AstNode } from '../node';
|
|
2
|
+
import type { Range } from '../source';
|
|
3
|
+
export interface SequenceNode<CN extends AstNode = AstNode> extends AstNode {
|
|
4
|
+
/**
|
|
5
|
+
* An array of `AstNode`s that fully make up this node.
|
|
6
|
+
*/
|
|
7
|
+
children: CN[];
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* A utility object for temporarily storing a sequence rule.
|
|
11
|
+
*
|
|
12
|
+
* @template CN Child node.
|
|
13
|
+
*/
|
|
14
|
+
export interface SequenceUtil<CN extends AstNode = AstNode> {
|
|
15
|
+
isSequenceUtil: true;
|
|
16
|
+
range: Range;
|
|
17
|
+
children: CN[];
|
|
18
|
+
}
|
|
19
|
+
export declare namespace SequenceUtil {
|
|
20
|
+
function is<CN extends AstNode>(obj: object | undefined): obj is SequenceUtil<CN>;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=Sequence.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SequenceUtil = void 0;
|
|
4
|
+
var SequenceUtil;
|
|
5
|
+
(function (SequenceUtil) {
|
|
6
|
+
function is(obj) {
|
|
7
|
+
return !!obj && obj.isSequenceUtil;
|
|
8
|
+
}
|
|
9
|
+
SequenceUtil.is = is;
|
|
10
|
+
})(SequenceUtil = exports.SequenceUtil || (exports.SequenceUtil = {}));
|
|
11
|
+
//# sourceMappingURL=Sequence.js.map
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { Parser } from '../parser';
|
|
2
|
+
import type { ColorTokenType } from '../processor';
|
|
3
|
+
import type { IndexMap, RangeLike } from '../source';
|
|
4
|
+
import type { AstNode } from './AstNode';
|
|
5
|
+
export declare const EscapeChars: readonly ["\"", "'", "\\", "b", "f", "n", "r", "t"];
|
|
6
|
+
export declare type EscapeChar = typeof EscapeChars[number];
|
|
7
|
+
export declare namespace EscapeChar {
|
|
8
|
+
function is(expected: EscapeChar[] | undefined, c: string): c is EscapeChar;
|
|
9
|
+
}
|
|
10
|
+
export declare const EscapeTable: Map<"b" | "f" | "'" | "\"" | "n" | "r" | "t" | "\\", string>;
|
|
11
|
+
export declare type Quote = "'" | '"';
|
|
12
|
+
export interface StringOptions {
|
|
13
|
+
colorTokenType?: ColorTokenType;
|
|
14
|
+
escapable?: {
|
|
15
|
+
/**
|
|
16
|
+
* A list of characters that can be escaped. The current quote of the string and backslash (`\`)
|
|
17
|
+
* will be added to this list automatically.
|
|
18
|
+
*/
|
|
19
|
+
characters?: EscapeChar[];
|
|
20
|
+
/**
|
|
21
|
+
* Whether escapes like `\u####` where #### is a hexdecimal numeral are allowed.
|
|
22
|
+
*/
|
|
23
|
+
unicode?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Whether unknown characters can be escaped, which would just result in the character itself.
|
|
26
|
+
*/
|
|
27
|
+
allowUnknown?: boolean;
|
|
28
|
+
} | false;
|
|
29
|
+
/**
|
|
30
|
+
* A list of characters that can serve as a quotation mark.
|
|
31
|
+
*/
|
|
32
|
+
quotes?: Quote[];
|
|
33
|
+
/**
|
|
34
|
+
* Whether this string could be an unquoted string. If yes, specify the list of allowed/disallowed characters that
|
|
35
|
+
* the string can contain. Otherwise set this to `false`.
|
|
36
|
+
*/
|
|
37
|
+
unquotable?: {
|
|
38
|
+
allowEmpty?: boolean;
|
|
39
|
+
allowList?: Set<string>;
|
|
40
|
+
blockList?: Set<string>;
|
|
41
|
+
} | false;
|
|
42
|
+
/**
|
|
43
|
+
* An optional object describing the content of the string.
|
|
44
|
+
*/
|
|
45
|
+
value?: {
|
|
46
|
+
parser: Parser;
|
|
47
|
+
type: AstNode['type'];
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export declare type QuoteTypeConfig = 'always double' | 'always single' | 'prefer double' | 'prefer single';
|
|
51
|
+
export interface StringBaseNode extends AstNode {
|
|
52
|
+
readonly options: StringOptions;
|
|
53
|
+
readonly value: string;
|
|
54
|
+
readonly valueMap: IndexMap;
|
|
55
|
+
}
|
|
56
|
+
export interface StringNode extends StringBaseNode {
|
|
57
|
+
readonly type: 'string';
|
|
58
|
+
}
|
|
59
|
+
export declare namespace StringNode {
|
|
60
|
+
function is(obj: object | undefined): obj is StringNode;
|
|
61
|
+
function mock(range: RangeLike, options: StringOptions): StringNode;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=StringNode.d.ts.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StringNode = exports.EscapeTable = exports.EscapeChar = exports.EscapeChars = void 0;
|
|
4
|
+
const source_1 = require("../source");
|
|
5
|
+
exports.EscapeChars = ['"', "'", '\\', 'b', 'f', 'n', 'r', 't'];
|
|
6
|
+
var EscapeChar;
|
|
7
|
+
(function (EscapeChar) {
|
|
8
|
+
/* istanbul ignore next */
|
|
9
|
+
function is(expected, c) {
|
|
10
|
+
return expected ? expected.includes(c) : false;
|
|
11
|
+
}
|
|
12
|
+
EscapeChar.is = is;
|
|
13
|
+
})(EscapeChar = exports.EscapeChar || (exports.EscapeChar = {}));
|
|
14
|
+
exports.EscapeTable = new Map([
|
|
15
|
+
['"', '"'],
|
|
16
|
+
["'", "'"],
|
|
17
|
+
['\\', '\\'],
|
|
18
|
+
['b', '\b'],
|
|
19
|
+
['f', '\f'],
|
|
20
|
+
['n', '\n'],
|
|
21
|
+
['r', '\r'],
|
|
22
|
+
['t', '\t'],
|
|
23
|
+
]);
|
|
24
|
+
var StringNode;
|
|
25
|
+
(function (StringNode) {
|
|
26
|
+
/* istanbul ignore next */
|
|
27
|
+
function is(obj) {
|
|
28
|
+
return obj?.type === 'string';
|
|
29
|
+
}
|
|
30
|
+
StringNode.is = is;
|
|
31
|
+
function mock(range, options) {
|
|
32
|
+
range = source_1.Range.get(range);
|
|
33
|
+
return {
|
|
34
|
+
type: 'string',
|
|
35
|
+
range,
|
|
36
|
+
options,
|
|
37
|
+
value: '',
|
|
38
|
+
valueMap: [{ inner: source_1.Range.create(0), outer: source_1.Range.create(range.start) }],
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
StringNode.mock = mock;
|
|
42
|
+
})(StringNode = exports.StringNode || (exports.StringNode = {}));
|
|
43
|
+
//# sourceMappingURL=StringNode.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { RangeLike } from '../source';
|
|
2
|
+
import type { SymbolAccessType, SymbolUsageType } from '../symbol';
|
|
3
|
+
import type { AstNode } from './AstNode';
|
|
4
|
+
export interface SymbolOptions {
|
|
5
|
+
category: string;
|
|
6
|
+
parentPath?: string[];
|
|
7
|
+
accessType?: SymbolAccessType;
|
|
8
|
+
usageType?: SymbolUsageType;
|
|
9
|
+
}
|
|
10
|
+
export interface SymbolBaseNode extends AstNode {
|
|
11
|
+
readonly options: SymbolOptions;
|
|
12
|
+
readonly value: string;
|
|
13
|
+
}
|
|
14
|
+
export interface SymbolNode extends SymbolBaseNode {
|
|
15
|
+
readonly type: 'symbol';
|
|
16
|
+
}
|
|
17
|
+
export declare namespace SymbolNode {
|
|
18
|
+
function is(obj: object): obj is SymbolNode;
|
|
19
|
+
function mock(range: RangeLike, options: SymbolOptions): SymbolNode;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=SymbolNode.d.ts.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SymbolNode = void 0;
|
|
4
|
+
const source_1 = require("../source");
|
|
5
|
+
var SymbolNode;
|
|
6
|
+
(function (SymbolNode) {
|
|
7
|
+
/* istanbul ignore next */
|
|
8
|
+
function is(obj) {
|
|
9
|
+
return obj.type === 'symbol';
|
|
10
|
+
}
|
|
11
|
+
SymbolNode.is = is;
|
|
12
|
+
function mock(range, options) {
|
|
13
|
+
return {
|
|
14
|
+
type: 'symbol',
|
|
15
|
+
range: source_1.Range.get(range),
|
|
16
|
+
options,
|
|
17
|
+
value: '',
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
SymbolNode.mock = mock;
|
|
21
|
+
})(SymbolNode = exports.SymbolNode || (exports.SymbolNode = {}));
|
|
22
|
+
//# sourceMappingURL=SymbolNode.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Range } from '../source';
|
|
2
|
+
import type { AstNode } from './AstNode';
|
|
3
|
+
export interface TableNode<K extends AstNode, V extends AstNode> extends AstNode {
|
|
4
|
+
readonly children: PairNode<K, V>[];
|
|
5
|
+
}
|
|
6
|
+
export interface PairNode<K extends AstNode, V extends AstNode> extends AstNode {
|
|
7
|
+
readonly type: 'pair';
|
|
8
|
+
readonly children?: [K, V] | [K] | [V];
|
|
9
|
+
readonly key?: K;
|
|
10
|
+
readonly sep?: Range;
|
|
11
|
+
readonly value?: V;
|
|
12
|
+
readonly end?: Range;
|
|
13
|
+
}
|
|
14
|
+
export declare namespace PairNode {
|
|
15
|
+
function is<K extends AstNode, V extends AstNode>(node: AstNode | undefined): node is PairNode<K, V>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=TableNode.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PairNode = void 0;
|
|
4
|
+
var PairNode;
|
|
5
|
+
(function (PairNode) {
|
|
6
|
+
function is(node) {
|
|
7
|
+
return node?.type === 'pair';
|
|
8
|
+
}
|
|
9
|
+
PairNode.is = is;
|
|
10
|
+
})(PairNode = exports.PairNode || (exports.PairNode = {}));
|
|
11
|
+
//# sourceMappingURL=TableNode.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export * from './AstNode';
|
|
2
|
+
export * from './BooleanNode';
|
|
3
|
+
export * from './CommentNode';
|
|
4
|
+
export * from './ErrorNode';
|
|
5
|
+
export * from './FileNode';
|
|
6
|
+
export * from './FloatNode';
|
|
7
|
+
export * from './IntegerNode';
|
|
8
|
+
export * from './ListNode';
|
|
9
|
+
export * from './LiteralNode';
|
|
10
|
+
export * from './LongNode';
|
|
11
|
+
export * from './RecordNode';
|
|
12
|
+
export * from './ResourceLocationNode';
|
|
13
|
+
export * from './Sequence';
|
|
14
|
+
export * from './StringNode';
|
|
15
|
+
export * from './SymbolNode';
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|