@spyglassmc/core 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/lib/browser.d.ts +2 -0
- package/lib/browser.js +2 -0
- package/lib/common/TwoWayMap.d.ts +21 -0
- package/lib/common/TwoWayMap.js +69 -0
- package/lib/common/externals/BrowserExternals.d.ts +3 -0
- package/lib/common/externals/BrowserExternals.js +191 -0
- package/lib/common/externals/NodeJsExternals.d.ts +3 -0
- package/lib/common/externals/NodeJsExternals.js +151 -0
- package/lib/common/externals/downloader.d.ts +31 -0
- package/lib/common/externals/downloader.js +32 -0
- package/lib/common/externals/index.d.ts +96 -0
- package/lib/common/externals/index.js +2 -0
- package/lib/common/index.d.ts +2 -1
- package/lib/common/index.js +2 -13
- package/lib/common/util.d.ts +17 -34
- package/lib/common/util.js +32 -113
- package/lib/index.d.ts +7 -7
- package/lib/index.js +7 -19
- package/lib/node/AstNode.d.ts +3 -3
- package/lib/node/AstNode.js +10 -16
- package/lib/node/BooleanNode.d.ts +2 -2
- package/lib/node/BooleanNode.js +4 -7
- package/lib/node/CommentNode.d.ts +1 -1
- package/lib/node/CommentNode.js +2 -5
- package/lib/node/ErrorNode.d.ts +1 -1
- package/lib/node/ErrorNode.js +2 -5
- package/lib/node/FileNode.d.ts +3 -3
- package/lib/node/FileNode.js +2 -5
- package/lib/node/FloatNode.d.ts +2 -2
- package/lib/node/FloatNode.js +4 -7
- package/lib/node/IntegerNode.d.ts +2 -2
- package/lib/node/IntegerNode.js +4 -7
- package/lib/node/ListNode.d.ts +2 -2
- package/lib/node/ListNode.js +2 -5
- package/lib/node/LiteralNode.d.ts +4 -4
- package/lib/node/LiteralNode.js +5 -8
- package/lib/node/LongNode.d.ts +2 -2
- package/lib/node/LongNode.js +4 -7
- package/lib/node/RecordNode.d.ts +2 -2
- package/lib/node/RecordNode.js +2 -5
- package/lib/node/ResourceLocationNode.d.ts +6 -8
- package/lib/node/ResourceLocationNode.js +9 -12
- package/lib/node/Sequence.d.ts +4 -3
- package/lib/node/Sequence.js +4 -6
- package/lib/node/StringNode.d.ts +5 -5
- package/lib/node/StringNode.js +9 -12
- package/lib/node/SymbolNode.d.ts +4 -4
- package/lib/node/SymbolNode.js +5 -8
- package/lib/node/index.d.ts +15 -15
- package/lib/node/index.js +15 -27
- package/lib/nodejs.d.ts +2 -0
- package/lib/nodejs.js +2 -0
- package/lib/parser/Parser.d.ts +3 -3
- package/lib/parser/Parser.js +1 -4
- package/lib/parser/boolean.d.ts +2 -2
- package/lib/parser/boolean.js +3 -6
- package/lib/parser/comment.d.ts +2 -2
- package/lib/parser/comment.js +5 -9
- package/lib/parser/empty.d.ts +1 -1
- package/lib/parser/empty.js +1 -5
- package/lib/parser/error.d.ts +2 -2
- package/lib/parser/error.js +5 -9
- package/lib/parser/file.d.ts +3 -3
- package/lib/parser/file.js +9 -13
- package/lib/parser/float.d.ts +4 -4
- package/lib/parser/float.js +12 -16
- package/lib/parser/index.d.ts +16 -16
- package/lib/parser/index.js +16 -34
- package/lib/parser/integer.d.ts +4 -4
- package/lib/parser/integer.js +10 -14
- package/lib/parser/list.d.ts +2 -2
- package/lib/parser/list.js +15 -19
- package/lib/parser/literal.d.ts +2 -2
- package/lib/parser/literal.js +5 -9
- package/lib/parser/long.d.ts +4 -4
- package/lib/parser/long.js +10 -14
- package/lib/parser/record.d.ts +3 -3
- package/lib/parser/record.js +20 -24
- package/lib/parser/resourceLocation.d.ts +2 -2
- package/lib/parser/resourceLocation.js +14 -18
- package/lib/parser/string.d.ts +7 -7
- package/lib/parser/string.js +40 -44
- package/lib/parser/symbol.d.ts +3 -3
- package/lib/parser/symbol.js +3 -7
- package/lib/parser/util.d.ts +30 -12
- package/lib/parser/util.js +78 -63
- package/lib/processor/ColorInfoProvider.d.ts +1 -1
- package/lib/processor/ColorInfoProvider.js +6 -9
- package/lib/processor/InlayHintProvider.d.ts +2 -2
- package/lib/processor/InlayHintProvider.js +1 -2
- package/lib/processor/SignatureHelpProvider.d.ts +2 -2
- package/lib/processor/SignatureHelpProvider.js +1 -2
- package/lib/processor/checker/Checker.d.ts +2 -2
- package/lib/processor/checker/Checker.js +1 -5
- package/lib/processor/checker/builtin.d.ts +5 -4
- package/lib/processor/checker/builtin.js +26 -28
- package/lib/processor/checker/index.d.ts +2 -2
- package/lib/processor/checker/index.js +2 -27
- package/lib/processor/colorizer/Colorizer.d.ts +4 -4
- package/lib/processor/colorizer/Colorizer.js +8 -11
- package/lib/processor/colorizer/builtin.d.ts +3 -3
- package/lib/processor/colorizer/builtin.js +33 -46
- package/lib/processor/colorizer/index.d.ts +2 -2
- package/lib/processor/colorizer/index.js +2 -27
- package/lib/processor/completer/Completer.d.ts +4 -4
- package/lib/processor/completer/Completer.js +14 -33
- package/lib/processor/completer/builtin.d.ts +7 -7
- package/lib/processor/completer/builtin.js +58 -74
- package/lib/processor/completer/index.d.ts +2 -2
- package/lib/processor/completer/index.js +2 -27
- package/lib/processor/formatter/Formatter.d.ts +2 -2
- package/lib/processor/formatter/Formatter.js +2 -7
- package/lib/processor/formatter/builtin.d.ts +3 -3
- package/lib/processor/formatter/builtin.js +22 -36
- package/lib/processor/formatter/index.d.ts +2 -2
- package/lib/processor/formatter/index.js +2 -27
- package/lib/processor/index.d.ts +9 -9
- package/lib/processor/index.js +9 -21
- package/lib/processor/linter/Linter.d.ts +2 -2
- package/lib/processor/linter/Linter.js +1 -2
- package/lib/processor/linter/builtin/undeclaredSymbol.d.ts +2 -2
- package/lib/processor/linter/builtin/undeclaredSymbol.js +23 -27
- package/lib/processor/linter/builtin.d.ts +3 -3
- package/lib/processor/linter/builtin.js +19 -31
- package/lib/processor/linter/index.d.ts +2 -2
- package/lib/processor/linter/index.js +2 -27
- package/lib/processor/util.d.ts +2 -2
- package/lib/processor/util.js +4 -9
- package/lib/service/CacheService.d.ts +6 -6
- package/lib/service/CacheService.js +38 -48
- package/lib/service/Config.d.ts +17 -16
- package/lib/service/Config.js +56 -51
- package/lib/service/Context.d.ts +14 -14
- package/lib/service/Context.js +30 -32
- package/lib/service/Dependency.js +2 -5
- package/lib/service/Downloader.d.ts +10 -39
- package/lib/service/Downloader.js +37 -106
- package/lib/service/ErrorReporter.d.ts +2 -2
- package/lib/service/ErrorReporter.js +11 -15
- package/lib/service/FileService.d.ts +41 -14
- package/lib/service/FileService.js +107 -81
- package/lib/service/Hover.d.ts +2 -2
- package/lib/service/Hover.js +4 -7
- package/lib/service/Logger.js +2 -5
- package/lib/service/MetaRegistry.d.ts +12 -12
- package/lib/service/MetaRegistry.js +62 -73
- package/lib/service/Operations.js +3 -9
- package/lib/service/Profiler.d.ts +1 -1
- package/lib/service/Profiler.js +25 -41
- package/lib/service/Project.d.ts +50 -51
- package/lib/service/Project.js +240 -238
- package/lib/service/Service.d.ts +19 -29
- package/lib/service/Service.js +57 -53
- package/lib/service/SymbolLocations.d.ts +3 -3
- package/lib/service/SymbolLocations.js +4 -7
- package/lib/service/SymbolRegistrar.d.ts +1 -1
- package/lib/service/SymbolRegistrar.js +1 -2
- package/lib/service/fileUtil.d.ts +21 -41
- package/lib/service/fileUtil.js +59 -129
- package/lib/service/index.d.ts +17 -17
- package/lib/service/index.js +17 -31
- package/lib/source/IndexMap.d.ts +1 -1
- package/lib/source/IndexMap.js +7 -10
- package/lib/source/LanguageError.d.ts +2 -2
- package/lib/source/LanguageError.js +3 -6
- package/lib/source/Location.d.ts +3 -3
- package/lib/source/Location.js +6 -9
- package/lib/source/Offset.d.ts +1 -1
- package/lib/source/Offset.js +4 -7
- package/lib/source/Position.js +2 -5
- package/lib/source/PositionRange.d.ts +2 -2
- package/lib/source/PositionRange.js +14 -17
- package/lib/source/Range.d.ts +1 -1
- package/lib/source/Range.js +7 -10
- package/lib/source/Source.d.ts +12 -4
- package/lib/source/Source.js +84 -29
- package/lib/source/index.d.ts +8 -8
- package/lib/source/index.js +8 -20
- package/lib/symbol/Symbol.d.ts +15 -15
- package/lib/symbol/Symbol.js +53 -68
- package/lib/symbol/SymbolUtil.d.ts +23 -33
- package/lib/symbol/SymbolUtil.js +162 -163
- package/lib/symbol/UriBinder.d.ts +1 -1
- package/lib/symbol/UriBinder.js +1 -2
- package/lib/symbol/index.d.ts +3 -3
- package/lib/symbol/index.js +3 -15
- package/package.json +7 -4
- package/lib/common/Heap.d.ts +0 -1
- package/lib/common/Heap.js +0 -2
- package/lib/node/TableNode.d.ts +0 -17
- package/lib/node/TableNode.js +0 -11
- package/lib/parser/table.d.ts +0 -22
- package/lib/parser/table.js +0 -97
- package/lib/service/CommandExecutor.d.ts +0 -3
- package/lib/service/CommandExecutor.js +0 -7
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ColorTokenType } from '../processor';
|
|
2
|
-
import type { RangeLike } from '../source';
|
|
3
|
-
import type { AstNode } from './AstNode';
|
|
1
|
+
import type { ColorTokenType } from '../processor/index.js';
|
|
2
|
+
import type { RangeLike } from '../source/index.js';
|
|
3
|
+
import type { AstNode } from './AstNode.js';
|
|
4
4
|
export interface LiteralOptions {
|
|
5
5
|
pool: string[];
|
|
6
6
|
colorTokenType?: ColorTokenType;
|
|
@@ -13,7 +13,7 @@ export interface LiteralNode extends LiteralBaseNode {
|
|
|
13
13
|
readonly type: 'literal';
|
|
14
14
|
}
|
|
15
15
|
export declare namespace LiteralNode {
|
|
16
|
-
function is(obj: object): obj is LiteralNode;
|
|
16
|
+
function is(obj: object | undefined): obj is LiteralNode;
|
|
17
17
|
function mock(range: RangeLike, options: LiteralOptions): LiteralNode;
|
|
18
18
|
}
|
|
19
19
|
//# sourceMappingURL=LiteralNode.d.ts.map
|
package/lib/node/LiteralNode.js
CHANGED
|
@@ -1,22 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.LiteralNode = void 0;
|
|
4
|
-
const source_1 = require("../source");
|
|
5
|
-
var LiteralNode;
|
|
1
|
+
import { Range } from '../source/index.js';
|
|
2
|
+
export var LiteralNode;
|
|
6
3
|
(function (LiteralNode) {
|
|
7
4
|
/* istanbul ignore next */
|
|
8
5
|
function is(obj) {
|
|
9
|
-
return obj
|
|
6
|
+
return obj?.type === 'literal';
|
|
10
7
|
}
|
|
11
8
|
LiteralNode.is = is;
|
|
12
9
|
function mock(range, options) {
|
|
13
10
|
return {
|
|
14
11
|
type: 'literal',
|
|
15
|
-
range:
|
|
12
|
+
range: Range.get(range),
|
|
16
13
|
options,
|
|
17
14
|
value: '',
|
|
18
15
|
};
|
|
19
16
|
}
|
|
20
17
|
LiteralNode.mock = mock;
|
|
21
|
-
})(LiteralNode
|
|
18
|
+
})(LiteralNode || (LiteralNode = {}));
|
|
22
19
|
//# sourceMappingURL=LiteralNode.js.map
|
package/lib/node/LongNode.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { RangeLike } from '../source';
|
|
2
|
-
import type { AstNode } from './AstNode';
|
|
1
|
+
import type { RangeLike } from '../source/index.js';
|
|
2
|
+
import type { AstNode } from './AstNode.js';
|
|
3
3
|
export interface LongBaseNode extends AstNode {
|
|
4
4
|
readonly value: bigint;
|
|
5
5
|
}
|
package/lib/node/LongNode.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.LongNode = void 0;
|
|
4
|
-
const source_1 = require("../source");
|
|
5
|
-
var LongNode;
|
|
1
|
+
import { Range } from '../source/index.js';
|
|
2
|
+
export var LongNode;
|
|
6
3
|
(function (LongNode) {
|
|
7
4
|
function is(obj) {
|
|
8
5
|
return obj.type === 'long';
|
|
@@ -11,10 +8,10 @@ var LongNode;
|
|
|
11
8
|
function mock(range) {
|
|
12
9
|
return {
|
|
13
10
|
type: 'long',
|
|
14
|
-
range:
|
|
11
|
+
range: Range.get(range),
|
|
15
12
|
value: 0n,
|
|
16
13
|
};
|
|
17
14
|
}
|
|
18
15
|
LongNode.mock = mock;
|
|
19
|
-
})(LongNode
|
|
16
|
+
})(LongNode || (LongNode = {}));
|
|
20
17
|
//# sourceMappingURL=LongNode.js.map
|
package/lib/node/RecordNode.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Range } from '../source';
|
|
2
|
-
import type { AstNode } from './AstNode';
|
|
1
|
+
import type { Range } from '../source/index.js';
|
|
2
|
+
import type { AstNode } from './AstNode.js';
|
|
3
3
|
export interface RecordBaseNode<K extends AstNode, V extends AstNode> extends AstNode {
|
|
4
4
|
readonly children: PairNode<K, V>[];
|
|
5
5
|
}
|
package/lib/node/RecordNode.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PairNode = void 0;
|
|
4
|
-
var PairNode;
|
|
1
|
+
export var PairNode;
|
|
5
2
|
(function (PairNode) {
|
|
6
3
|
function is(node) {
|
|
7
4
|
return node?.type === 'pair';
|
|
8
5
|
}
|
|
9
6
|
PairNode.is = is;
|
|
10
|
-
})(PairNode
|
|
7
|
+
})(PairNode || (PairNode = {}));
|
|
11
8
|
//# sourceMappingURL=RecordNode.js.map
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { FullResourceLocation } from '../common';
|
|
2
|
-
import
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
1
|
+
import type { FullResourceLocation } from '../common/index.js';
|
|
2
|
+
import { ResourceLocation } from '../common/index.js';
|
|
3
|
+
import type { RangeLike } from '../source/index.js';
|
|
4
|
+
import type { ResourceLocationCategory, SymbolAccessType, SymbolUsageType, TaggableResourceLocationCategory } from '../symbol/index.js';
|
|
5
|
+
import type { AstNode } from './AstNode.js';
|
|
5
6
|
export declare type ResourceLocationOptions = {
|
|
6
7
|
accessType?: SymbolAccessType;
|
|
7
8
|
isPredicate?: boolean;
|
|
@@ -23,11 +24,8 @@ export declare type ResourceLocationOptions = {
|
|
|
23
24
|
allowTag?: false;
|
|
24
25
|
allowUnknown?: boolean;
|
|
25
26
|
});
|
|
26
|
-
export interface ResourceLocationBaseNode extends AstNode {
|
|
27
|
+
export interface ResourceLocationBaseNode extends AstNode, Partial<ResourceLocation> {
|
|
27
28
|
readonly options: ResourceLocationOptions;
|
|
28
|
-
readonly isTag?: boolean;
|
|
29
|
-
readonly namespace?: string;
|
|
30
|
-
readonly path?: string[];
|
|
31
29
|
}
|
|
32
30
|
export interface ResourceLocationNode extends ResourceLocationBaseNode {
|
|
33
31
|
readonly type: 'resource_location';
|
|
@@ -1,23 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const common_1 = require("../common");
|
|
5
|
-
const source_1 = require("../source");
|
|
6
|
-
var ResourceLocationNode;
|
|
1
|
+
import { ResourceLocation } from '../common/index.js';
|
|
2
|
+
import { Range } from '../source/index.js';
|
|
3
|
+
export var ResourceLocationNode;
|
|
7
4
|
(function (ResourceLocationNode) {
|
|
8
5
|
/**
|
|
9
6
|
* The prefix for tags.
|
|
10
7
|
*/
|
|
11
|
-
const TagPrefix =
|
|
8
|
+
const TagPrefix = ResourceLocation.TagPrefix;
|
|
12
9
|
/**
|
|
13
10
|
* The seperator of namespace and path.
|
|
14
11
|
*/
|
|
15
|
-
const NamespacePathSep =
|
|
12
|
+
const NamespacePathSep = ResourceLocation.NamespacePathSep;
|
|
16
13
|
/**
|
|
17
14
|
* The seperator between different path segments.
|
|
18
15
|
*/
|
|
19
|
-
const PathSep =
|
|
20
|
-
const DefaultNamespace =
|
|
16
|
+
const PathSep = ResourceLocation.PathSep;
|
|
17
|
+
const DefaultNamespace = ResourceLocation.DefaultNamespace;
|
|
21
18
|
/* istanbul ignore next */
|
|
22
19
|
function is(obj) {
|
|
23
20
|
return obj?.type === 'resource_location';
|
|
@@ -26,7 +23,7 @@ var ResourceLocationNode;
|
|
|
26
23
|
function mock(range, options) {
|
|
27
24
|
return {
|
|
28
25
|
type: 'resource_location',
|
|
29
|
-
range:
|
|
26
|
+
range: Range.get(range),
|
|
30
27
|
options,
|
|
31
28
|
};
|
|
32
29
|
}
|
|
@@ -61,5 +58,5 @@ var ResourceLocationNode;
|
|
|
61
58
|
return node.isTag ? `${TagPrefix}${id}` : id;
|
|
62
59
|
}
|
|
63
60
|
ResourceLocationNode.toString = toString;
|
|
64
|
-
})(ResourceLocationNode
|
|
61
|
+
})(ResourceLocationNode || (ResourceLocationNode = {}));
|
|
65
62
|
//# sourceMappingURL=ResourceLocationNode.js.map
|
package/lib/node/Sequence.d.ts
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import type { AstNode } from '../node';
|
|
2
|
-
import type { Range } from '../source';
|
|
1
|
+
import type { AstNode } from '../node/index.js';
|
|
2
|
+
import type { Range } from '../source/index.js';
|
|
3
3
|
export interface SequenceNode<CN extends AstNode = AstNode> extends AstNode {
|
|
4
4
|
/**
|
|
5
5
|
* An array of `AstNode`s that fully make up this node.
|
|
6
6
|
*/
|
|
7
7
|
children: CN[];
|
|
8
8
|
}
|
|
9
|
+
export declare const SequenceUtilDiscriminator: unique symbol;
|
|
9
10
|
/**
|
|
10
11
|
* A utility object for temporarily storing a sequence rule.
|
|
11
12
|
*
|
|
12
13
|
* @template CN Child node.
|
|
13
14
|
*/
|
|
14
15
|
export interface SequenceUtil<CN extends AstNode = AstNode> {
|
|
15
|
-
|
|
16
|
+
[SequenceUtilDiscriminator]: true;
|
|
16
17
|
range: Range;
|
|
17
18
|
children: CN[];
|
|
18
19
|
}
|
package/lib/node/Sequence.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.SequenceUtil = void 0;
|
|
4
|
-
var SequenceUtil;
|
|
1
|
+
export const SequenceUtilDiscriminator = Symbol('SequenceUtilDiscriminator');
|
|
2
|
+
export var SequenceUtil;
|
|
5
3
|
(function (SequenceUtil) {
|
|
6
4
|
function is(obj) {
|
|
7
|
-
return !!obj && obj
|
|
5
|
+
return !!obj && obj[SequenceUtilDiscriminator];
|
|
8
6
|
}
|
|
9
7
|
SequenceUtil.is = is;
|
|
10
|
-
})(SequenceUtil
|
|
8
|
+
})(SequenceUtil || (SequenceUtil = {}));
|
|
11
9
|
//# sourceMappingURL=Sequence.js.map
|
package/lib/node/StringNode.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
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';
|
|
1
|
+
import type { Parser } from '../parser/index.js';
|
|
2
|
+
import type { ColorTokenType } from '../processor/index.js';
|
|
3
|
+
import type { IndexMap, RangeLike } from '../source/index.js';
|
|
4
|
+
import type { AstNode } from './AstNode.js';
|
|
5
5
|
export declare const EscapeChars: readonly ["\"", "'", "\\", "b", "f", "n", "r", "t"];
|
|
6
6
|
export declare type EscapeChar = typeof EscapeChars[number];
|
|
7
7
|
export declare namespace EscapeChar {
|
|
8
8
|
function is(expected: EscapeChar[] | undefined, c: string): c is EscapeChar;
|
|
9
9
|
}
|
|
10
|
-
export declare const EscapeTable: Map<"
|
|
10
|
+
export declare const EscapeTable: Map<"\"" | "'" | "b" | "f" | "n" | "r" | "t" | "\\", string>;
|
|
11
11
|
export declare type Quote = "'" | '"';
|
|
12
12
|
export interface StringOptions {
|
|
13
13
|
colorTokenType?: ColorTokenType;
|
package/lib/node/StringNode.js
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const source_1 = require("../source");
|
|
5
|
-
exports.EscapeChars = ['"', "'", '\\', 'b', 'f', 'n', 'r', 't'];
|
|
6
|
-
var EscapeChar;
|
|
1
|
+
import { Range } from '../source/index.js';
|
|
2
|
+
export const EscapeChars = ['"', "'", '\\', 'b', 'f', 'n', 'r', 't'];
|
|
3
|
+
export var EscapeChar;
|
|
7
4
|
(function (EscapeChar) {
|
|
8
5
|
/* istanbul ignore next */
|
|
9
6
|
function is(expected, c) {
|
|
10
7
|
return expected ? expected.includes(c) : false;
|
|
11
8
|
}
|
|
12
9
|
EscapeChar.is = is;
|
|
13
|
-
})(EscapeChar
|
|
14
|
-
|
|
10
|
+
})(EscapeChar || (EscapeChar = {}));
|
|
11
|
+
export const EscapeTable = new Map([
|
|
15
12
|
['"', '"'],
|
|
16
13
|
["'", "'"],
|
|
17
14
|
['\\', '\\'],
|
|
@@ -21,7 +18,7 @@ exports.EscapeTable = new Map([
|
|
|
21
18
|
['r', '\r'],
|
|
22
19
|
['t', '\t'],
|
|
23
20
|
]);
|
|
24
|
-
var StringNode;
|
|
21
|
+
export var StringNode;
|
|
25
22
|
(function (StringNode) {
|
|
26
23
|
/* istanbul ignore next */
|
|
27
24
|
function is(obj) {
|
|
@@ -29,15 +26,15 @@ var StringNode;
|
|
|
29
26
|
}
|
|
30
27
|
StringNode.is = is;
|
|
31
28
|
function mock(range, options) {
|
|
32
|
-
range =
|
|
29
|
+
range = Range.get(range);
|
|
33
30
|
return {
|
|
34
31
|
type: 'string',
|
|
35
32
|
range,
|
|
36
33
|
options,
|
|
37
34
|
value: '',
|
|
38
|
-
valueMap: [{ inner:
|
|
35
|
+
valueMap: [{ inner: Range.create(0), outer: Range.create(range.start) }],
|
|
39
36
|
};
|
|
40
37
|
}
|
|
41
38
|
StringNode.mock = mock;
|
|
42
|
-
})(StringNode
|
|
39
|
+
})(StringNode || (StringNode = {}));
|
|
43
40
|
//# sourceMappingURL=StringNode.js.map
|
package/lib/node/SymbolNode.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { RangeLike } from '../source';
|
|
2
|
-
import type { SymbolAccessType, SymbolUsageType } from '../symbol';
|
|
3
|
-
import type { AstNode } from './AstNode';
|
|
1
|
+
import type { RangeLike } from '../source/index.js';
|
|
2
|
+
import type { SymbolAccessType, SymbolUsageType } from '../symbol/index.js';
|
|
3
|
+
import type { AstNode } from './AstNode.js';
|
|
4
4
|
export interface SymbolOptions {
|
|
5
5
|
category: string;
|
|
6
6
|
parentPath?: string[];
|
|
@@ -15,7 +15,7 @@ export interface SymbolNode extends SymbolBaseNode {
|
|
|
15
15
|
readonly type: 'symbol';
|
|
16
16
|
}
|
|
17
17
|
export declare namespace SymbolNode {
|
|
18
|
-
function is(obj:
|
|
18
|
+
function is(obj: AstNode | undefined): obj is SymbolNode;
|
|
19
19
|
function mock(range: RangeLike, options: SymbolOptions): SymbolNode;
|
|
20
20
|
}
|
|
21
21
|
//# sourceMappingURL=SymbolNode.d.ts.map
|
package/lib/node/SymbolNode.js
CHANGED
|
@@ -1,22 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.SymbolNode = void 0;
|
|
4
|
-
const source_1 = require("../source");
|
|
5
|
-
var SymbolNode;
|
|
1
|
+
import { Range } from '../source/index.js';
|
|
2
|
+
export var SymbolNode;
|
|
6
3
|
(function (SymbolNode) {
|
|
7
4
|
/* istanbul ignore next */
|
|
8
5
|
function is(obj) {
|
|
9
|
-
return obj
|
|
6
|
+
return obj?.type === 'symbol';
|
|
10
7
|
}
|
|
11
8
|
SymbolNode.is = is;
|
|
12
9
|
function mock(range, options) {
|
|
13
10
|
return {
|
|
14
11
|
type: 'symbol',
|
|
15
|
-
range:
|
|
12
|
+
range: Range.get(range),
|
|
16
13
|
options,
|
|
17
14
|
value: '',
|
|
18
15
|
};
|
|
19
16
|
}
|
|
20
17
|
SymbolNode.mock = mock;
|
|
21
|
-
})(SymbolNode
|
|
18
|
+
})(SymbolNode || (SymbolNode = {}));
|
|
22
19
|
//# sourceMappingURL=SymbolNode.js.map
|
package/lib/node/index.d.ts
CHANGED
|
@@ -1,16 +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';
|
|
1
|
+
export * from './AstNode.js';
|
|
2
|
+
export * from './BooleanNode.js';
|
|
3
|
+
export * from './CommentNode.js';
|
|
4
|
+
export * from './ErrorNode.js';
|
|
5
|
+
export * from './FileNode.js';
|
|
6
|
+
export * from './FloatNode.js';
|
|
7
|
+
export * from './IntegerNode.js';
|
|
8
|
+
export * from './ListNode.js';
|
|
9
|
+
export * from './LiteralNode.js';
|
|
10
|
+
export * from './LongNode.js';
|
|
11
|
+
export * from './RecordNode.js';
|
|
12
|
+
export * from './ResourceLocationNode.js';
|
|
13
|
+
export * from './Sequence.js';
|
|
14
|
+
export * from './StringNode.js';
|
|
15
|
+
export * from './SymbolNode.js';
|
|
16
16
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/node/index.js
CHANGED
|
@@ -1,28 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
__exportStar(require("./ErrorNode"), exports);
|
|
17
|
-
__exportStar(require("./FileNode"), exports);
|
|
18
|
-
__exportStar(require("./FloatNode"), exports);
|
|
19
|
-
__exportStar(require("./IntegerNode"), exports);
|
|
20
|
-
__exportStar(require("./ListNode"), exports);
|
|
21
|
-
__exportStar(require("./LiteralNode"), exports);
|
|
22
|
-
__exportStar(require("./LongNode"), exports);
|
|
23
|
-
__exportStar(require("./RecordNode"), exports);
|
|
24
|
-
__exportStar(require("./ResourceLocationNode"), exports);
|
|
25
|
-
__exportStar(require("./Sequence"), exports);
|
|
26
|
-
__exportStar(require("./StringNode"), exports);
|
|
27
|
-
__exportStar(require("./SymbolNode"), exports);
|
|
1
|
+
export * from './AstNode.js';
|
|
2
|
+
export * from './BooleanNode.js';
|
|
3
|
+
export * from './CommentNode.js';
|
|
4
|
+
export * from './ErrorNode.js';
|
|
5
|
+
export * from './FileNode.js';
|
|
6
|
+
export * from './FloatNode.js';
|
|
7
|
+
export * from './IntegerNode.js';
|
|
8
|
+
export * from './ListNode.js';
|
|
9
|
+
export * from './LiteralNode.js';
|
|
10
|
+
export * from './LongNode.js';
|
|
11
|
+
export * from './RecordNode.js';
|
|
12
|
+
export * from './ResourceLocationNode.js';
|
|
13
|
+
export * from './Sequence.js';
|
|
14
|
+
export * from './StringNode.js';
|
|
15
|
+
export * from './SymbolNode.js';
|
|
28
16
|
//# sourceMappingURL=index.js.map
|
package/lib/nodejs.d.ts
ADDED
package/lib/nodejs.js
ADDED
package/lib/parser/Parser.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { AstNode } from '../node';
|
|
2
|
-
import type { ParserContext } from '../service';
|
|
3
|
-
import type { Source } from '../source';
|
|
1
|
+
import type { AstNode } from '../node/index.js';
|
|
2
|
+
import type { ParserContext } from '../service/index.js';
|
|
3
|
+
import type { Source } from '../source/index.js';
|
|
4
4
|
/**
|
|
5
5
|
* A parser.
|
|
6
6
|
*/
|
package/lib/parser/Parser.js
CHANGED
package/lib/parser/boolean.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BooleanNode } from '../node/BooleanNode';
|
|
2
|
-
import type { InfallibleParser } from './Parser';
|
|
1
|
+
import type { BooleanNode } from '../node/BooleanNode.js';
|
|
2
|
+
import type { InfallibleParser } from './Parser.js';
|
|
3
3
|
export declare const boolean: InfallibleParser<BooleanNode>;
|
|
4
4
|
//# sourceMappingURL=boolean.d.ts.map
|
package/lib/parser/boolean.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const literal_1 = require("./literal");
|
|
5
|
-
const util_1 = require("./util");
|
|
6
|
-
exports.boolean = (0, util_1.map)((0, literal_1.literal)('false', 'true'), res => ({
|
|
1
|
+
import { literal } from './literal.js';
|
|
2
|
+
import { map } from './util.js';
|
|
3
|
+
export const boolean = map(literal('false', 'true'), res => ({
|
|
7
4
|
type: 'boolean',
|
|
8
5
|
range: res.range,
|
|
9
6
|
value: res.value === '' ? undefined : res.value === 'true',
|
package/lib/parser/comment.d.ts
CHANGED
package/lib/parser/comment.js
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.comment = void 0;
|
|
4
|
-
const source_1 = require("../source");
|
|
5
|
-
const Parser_1 = require("./Parser");
|
|
1
|
+
import { Range } from '../source/index.js';
|
|
2
|
+
import { Failure } from './Parser.js';
|
|
6
3
|
/**
|
|
7
4
|
* `Failure` when three isn't a comment.
|
|
8
5
|
*/
|
|
9
|
-
function comment({ singleLinePrefixes, includesEol }) {
|
|
6
|
+
export function comment({ singleLinePrefixes, includesEol }) {
|
|
10
7
|
return (src, _ctx) => {
|
|
11
8
|
const start = src.cursor;
|
|
12
9
|
const ans = {
|
|
13
10
|
type: 'comment',
|
|
14
|
-
range:
|
|
11
|
+
range: Range.create(start),
|
|
15
12
|
comment: '',
|
|
16
13
|
};
|
|
17
14
|
for (const prefix of singleLinePrefixes) {
|
|
@@ -27,8 +24,7 @@ function comment({ singleLinePrefixes, includesEol }) {
|
|
|
27
24
|
return ans;
|
|
28
25
|
}
|
|
29
26
|
}
|
|
30
|
-
return
|
|
27
|
+
return Failure;
|
|
31
28
|
};
|
|
32
29
|
}
|
|
33
|
-
exports.comment = comment;
|
|
34
30
|
//# sourceMappingURL=comment.js.map
|
package/lib/parser/empty.d.ts
CHANGED
package/lib/parser/empty.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.empty = void 0;
|
|
4
1
|
/* istanbul ignore next */
|
|
5
|
-
const empty = () => undefined;
|
|
6
|
-
exports.empty = empty;
|
|
2
|
+
export const empty = () => undefined;
|
|
7
3
|
//# sourceMappingURL=empty.js.map
|
package/lib/parser/error.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ErrorNode } from '../node';
|
|
2
|
-
import type { InfallibleParser } from './Parser';
|
|
1
|
+
import type { ErrorNode } from '../node/index.js';
|
|
2
|
+
import type { InfallibleParser } from './Parser.js';
|
|
3
3
|
/**
|
|
4
4
|
* Returns an error node containing all the remaining text (including whitespace),
|
|
5
5
|
* or returns `undefined` if the `Source` has already reached its end.
|
package/lib/parser/error.js
CHANGED
|
@@ -1,22 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.error = void 0;
|
|
4
|
-
const locales_1 = require("@spyglassmc/locales");
|
|
5
|
-
const source_1 = require("../source");
|
|
1
|
+
import { localize } from '@spyglassmc/locales';
|
|
2
|
+
import { Range } from '../source/index.js';
|
|
6
3
|
/**
|
|
7
4
|
* Returns an error node containing all the remaining text (including whitespace),
|
|
8
5
|
* or returns `undefined` if the `Source` has already reached its end.
|
|
9
6
|
*/
|
|
10
|
-
const error = (src, ctx) => {
|
|
7
|
+
export const error = (src, ctx) => {
|
|
11
8
|
if (!src.canRead()) {
|
|
12
9
|
return undefined;
|
|
13
10
|
}
|
|
14
11
|
const ans = {
|
|
15
12
|
type: 'error',
|
|
16
|
-
range:
|
|
13
|
+
range: Range.create(src, () => src.skipRemaining()),
|
|
17
14
|
};
|
|
18
|
-
ctx.err.report(
|
|
15
|
+
ctx.err.report(localize('error.unparseable-content'), ans);
|
|
19
16
|
return ans;
|
|
20
17
|
};
|
|
21
|
-
exports.error = error;
|
|
22
18
|
//# sourceMappingURL=error.js.map
|
package/lib/parser/file.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { FileNode } from '../node';
|
|
2
|
-
import { AstNode } from '../node';
|
|
3
|
-
import type { InfallibleParser } from './Parser';
|
|
1
|
+
import type { FileNode } from '../node/index.js';
|
|
2
|
+
import { AstNode } from '../node/index.js';
|
|
3
|
+
import type { InfallibleParser } from './Parser.js';
|
|
4
4
|
/**
|
|
5
5
|
* Dispatches to the corresponding parser for the language.
|
|
6
6
|
* @throws If there's no parser registered for this language ID.
|
package/lib/parser/file.js
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const source_1 = require("../source");
|
|
6
|
-
const error_1 = require("./error");
|
|
7
|
-
const Parser_1 = require("./Parser");
|
|
1
|
+
import { AstNode } from '../node/index.js';
|
|
2
|
+
import { Range } from '../source/index.js';
|
|
3
|
+
import { error } from './error.js';
|
|
4
|
+
import { Failure } from './Parser.js';
|
|
8
5
|
/**
|
|
9
6
|
* Dispatches to the corresponding parser for the language.
|
|
10
7
|
* @throws If there's no parser registered for this language ID.
|
|
11
8
|
*/
|
|
12
|
-
function file() {
|
|
9
|
+
export function file() {
|
|
13
10
|
return (src, ctx) => {
|
|
14
|
-
const fullRange =
|
|
11
|
+
const fullRange = Range.create(src, src.string.length);
|
|
15
12
|
const ans = {
|
|
16
13
|
type: 'file',
|
|
17
14
|
range: fullRange,
|
|
@@ -22,16 +19,15 @@ function file() {
|
|
|
22
19
|
src.skipWhitespace();
|
|
23
20
|
const parser = ctx.meta.getParserForLanguageId(ctx.doc.languageId);
|
|
24
21
|
const result = parser(src, ctx);
|
|
25
|
-
if (result && result !==
|
|
22
|
+
if (result && result !== Failure) {
|
|
26
23
|
ans.children.push(result);
|
|
27
24
|
}
|
|
28
25
|
if (src.skipWhitespace().canRead()) {
|
|
29
|
-
ans.children.push(
|
|
26
|
+
ans.children.push(error(src, ctx));
|
|
30
27
|
}
|
|
31
|
-
|
|
28
|
+
AstNode.setParents(ans);
|
|
32
29
|
ans.parserErrors = ctx.err.dump();
|
|
33
30
|
return ans;
|
|
34
31
|
};
|
|
35
32
|
}
|
|
36
|
-
exports.file = file;
|
|
37
33
|
//# sourceMappingURL=file.js.map
|
package/lib/parser/float.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { FloatNode } from '../node';
|
|
2
|
-
import type { ParserContext } from '../service';
|
|
3
|
-
import { Source } from '../source';
|
|
4
|
-
import type { InfallibleParser, Parser } from './Parser';
|
|
1
|
+
import type { FloatNode } from '../node/index.js';
|
|
2
|
+
import type { ParserContext } from '../service/index.js';
|
|
3
|
+
import { Source } from '../source/index.js';
|
|
4
|
+
import type { InfallibleParser, Parser } from './Parser.js';
|
|
5
5
|
interface OptionsBase {
|
|
6
6
|
pattern: RegExp;
|
|
7
7
|
/**
|