@spyglassmc/core 0.1.2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/lib/browser.d.ts +2 -0
- package/lib/browser.js +2 -0
- package/lib/common/Dev.d.ts +11 -0
- package/lib/common/Dev.js +90 -0
- package/lib/{service → common}/Logger.d.ts +0 -0
- package/lib/{service → common}/Logger.js +2 -5
- package/lib/common/Operations.d.ts +12 -0
- package/lib/common/Operations.js +33 -0
- package/lib/common/ReadonlyProxy.d.ts +9 -0
- package/lib/common/ReadonlyProxy.js +23 -0
- package/lib/common/StateProxy.d.ts +35 -0
- package/lib/common/StateProxy.js +69 -0
- package/lib/common/TwoWayMap.js +4 -10
- package/lib/common/externals/BrowserExternals.d.ts +3 -0
- package/lib/common/externals/BrowserExternals.js +191 -0
- package/lib/common/externals/NodeJsExternals.d.ts +3 -0
- package/lib/common/externals/NodeJsExternals.js +152 -0
- package/lib/common/externals/downloader.d.ts +31 -0
- package/lib/common/externals/downloader.js +32 -0
- package/lib/common/externals/index.d.ts +96 -0
- package/lib/common/externals/index.js +2 -0
- package/lib/common/index.d.ts +8 -1
- package/lib/common/index.js +8 -17
- package/lib/common/util.d.ts +48 -20
- package/lib/common/util.js +71 -86
- package/lib/index.d.ts +7 -7
- package/lib/index.js +7 -23
- package/lib/node/AstNode.d.ts +12 -11
- package/lib/node/AstNode.js +10 -16
- package/lib/node/BooleanNode.d.ts +2 -2
- package/lib/node/BooleanNode.js +4 -7
- package/lib/node/CommentNode.d.ts +6 -5
- package/lib/node/CommentNode.js +4 -9
- package/lib/node/ErrorNode.d.ts +1 -1
- package/lib/node/ErrorNode.js +2 -5
- package/lib/node/FileNode.d.ts +8 -4
- package/lib/node/FileNode.js +3 -6
- package/lib/node/FloatNode.d.ts +3 -3
- package/lib/node/FloatNode.js +4 -7
- package/lib/node/IntegerNode.d.ts +3 -3
- package/lib/node/IntegerNode.js +4 -7
- package/lib/node/ListNode.d.ts +2 -2
- package/lib/node/ListNode.js +2 -5
- package/lib/node/LiteralNode.d.ts +4 -4
- package/lib/node/LiteralNode.js +4 -7
- package/lib/node/LongNode.d.ts +3 -3
- package/lib/node/LongNode.js +4 -7
- package/lib/node/RecordNode.d.ts +2 -2
- package/lib/node/RecordNode.js +2 -5
- package/lib/node/ResourceLocationNode.d.ts +7 -7
- package/lib/node/ResourceLocationNode.js +9 -12
- package/lib/node/Sequence.d.ts +2 -2
- package/lib/node/Sequence.js +4 -7
- package/lib/node/StringNode.d.ts +5 -5
- package/lib/node/StringNode.js +9 -12
- package/lib/node/SymbolNode.d.ts +4 -4
- package/lib/node/SymbolNode.js +4 -7
- package/lib/node/index.d.ts +15 -15
- package/lib/node/index.js +15 -31
- package/lib/nodejs.d.ts +2 -0
- package/lib/nodejs.js +2 -0
- package/lib/parser/Parser.d.ts +3 -3
- package/lib/parser/Parser.js +1 -4
- package/lib/parser/boolean.d.ts +2 -2
- package/lib/parser/boolean.js +3 -6
- package/lib/parser/comment.d.ts +2 -2
- package/lib/parser/comment.js +5 -9
- package/lib/parser/empty.d.ts +1 -1
- package/lib/parser/empty.js +1 -5
- package/lib/parser/error.d.ts +2 -2
- package/lib/parser/error.js +5 -9
- package/lib/parser/file.d.ts +3 -3
- package/lib/parser/file.js +9 -13
- package/lib/parser/float.d.ts +4 -4
- package/lib/parser/float.js +12 -16
- package/lib/parser/index.d.ts +16 -16
- package/lib/parser/index.js +16 -38
- package/lib/parser/integer.d.ts +4 -4
- package/lib/parser/integer.js +10 -14
- package/lib/parser/list.d.ts +2 -2
- package/lib/parser/list.js +15 -19
- package/lib/parser/literal.d.ts +2 -2
- package/lib/parser/literal.js +5 -9
- package/lib/parser/long.d.ts +4 -4
- package/lib/parser/long.js +10 -14
- package/lib/parser/record.d.ts +3 -3
- package/lib/parser/record.js +20 -24
- package/lib/parser/resourceLocation.d.ts +2 -2
- package/lib/parser/resourceLocation.js +12 -24
- package/lib/parser/string.d.ts +7 -7
- package/lib/parser/string.js +36 -42
- package/lib/parser/symbol.d.ts +3 -3
- package/lib/parser/symbol.js +4 -14
- package/lib/parser/util.d.ts +6 -5
- package/lib/parser/util.js +40 -60
- package/lib/processor/ColorInfoProvider.d.ts +1 -1
- package/lib/processor/ColorInfoProvider.js +6 -9
- package/lib/processor/InlayHintProvider.d.ts +4 -3
- package/lib/processor/InlayHintProvider.js +1 -2
- package/lib/processor/SignatureHelpProvider.d.ts +4 -3
- package/lib/processor/SignatureHelpProvider.js +1 -2
- package/lib/processor/binder/Binder.d.ts +26 -0
- package/lib/processor/binder/Binder.js +18 -0
- package/lib/processor/binder/builtin.d.ts +27 -0
- package/lib/processor/binder/builtin.js +116 -0
- package/lib/processor/binder/index.d.ts +3 -0
- package/lib/processor/binder/index.js +3 -0
- package/lib/processor/checker/Checker.d.ts +2 -2
- package/lib/processor/checker/Checker.js +1 -5
- package/lib/processor/checker/builtin.d.ts +4 -4
- package/lib/processor/checker/builtin.js +22 -33
- package/lib/processor/checker/index.d.ts +2 -2
- package/lib/processor/checker/index.js +2 -31
- package/lib/processor/colorizer/Colorizer.d.ts +6 -5
- package/lib/processor/colorizer/Colorizer.js +8 -11
- package/lib/processor/colorizer/builtin.d.ts +3 -3
- package/lib/processor/colorizer/builtin.js +34 -46
- package/lib/processor/colorizer/index.d.ts +2 -2
- package/lib/processor/colorizer/index.js +2 -31
- package/lib/processor/completer/Completer.d.ts +6 -5
- package/lib/processor/completer/Completer.js +14 -33
- package/lib/processor/completer/builtin.d.ts +10 -9
- package/lib/processor/completer/builtin.js +47 -63
- package/lib/processor/completer/index.d.ts +2 -2
- package/lib/processor/completer/index.js +2 -31
- package/lib/processor/formatter/Formatter.d.ts +4 -3
- package/lib/processor/formatter/Formatter.js +2 -7
- package/lib/processor/formatter/builtin.d.ts +3 -3
- package/lib/processor/formatter/builtin.js +22 -36
- package/lib/processor/formatter/index.d.ts +2 -2
- package/lib/processor/formatter/index.js +2 -31
- package/lib/processor/index.d.ts +10 -9
- package/lib/processor/index.js +10 -25
- package/lib/processor/linter/Linter.d.ts +4 -3
- package/lib/processor/linter/Linter.js +1 -2
- package/lib/processor/linter/builtin/undeclaredSymbol.d.ts +2 -2
- package/lib/processor/linter/builtin/undeclaredSymbol.js +20 -24
- package/lib/processor/linter/builtin.d.ts +4 -3
- package/lib/processor/linter/builtin.js +19 -26
- package/lib/processor/linter/index.d.ts +2 -2
- package/lib/processor/linter/index.js +2 -31
- package/lib/processor/util.d.ts +4 -14
- package/lib/processor/util.js +1 -16
- package/lib/service/CacheService.d.ts +13 -8
- package/lib/service/CacheService.js +45 -57
- package/lib/service/Config.d.ts +11 -12
- package/lib/service/Config.js +50 -45
- package/lib/service/Context.d.ts +23 -20
- package/lib/service/Context.js +39 -36
- package/lib/service/Dependency.js +2 -5
- package/lib/service/Downloader.d.ts +9 -40
- package/lib/service/Downloader.js +37 -110
- package/lib/service/ErrorReporter.d.ts +2 -2
- package/lib/service/ErrorReporter.js +10 -14
- package/lib/service/FileService.d.ts +15 -14
- package/lib/service/FileService.js +55 -92
- package/lib/service/Hover.d.ts +2 -2
- package/lib/service/Hover.js +4 -7
- package/lib/service/MetaRegistry.d.ts +22 -12
- package/lib/service/MetaRegistry.js +81 -73
- package/lib/service/Profiler.d.ts +3 -2
- package/lib/service/Profiler.js +81 -45
- package/lib/service/Project.d.ts +105 -76
- package/lib/service/Project.js +449 -370
- package/lib/service/Service.d.ts +17 -27
- package/lib/service/Service.js +37 -43
- package/lib/service/SymbolLocations.d.ts +3 -3
- package/lib/service/SymbolLocations.js +4 -7
- package/lib/service/SymbolRegistrar.d.ts +1 -1
- package/lib/service/SymbolRegistrar.js +1 -2
- package/lib/service/UriProcessor.d.ts +5 -0
- package/lib/service/UriProcessor.js +2 -0
- package/lib/service/fileUtil.d.ts +15 -45
- package/lib/service/fileUtil.js +38 -143
- package/lib/service/index.d.ts +16 -17
- package/lib/service/index.js +16 -35
- package/lib/source/IndexMap.d.ts +1 -1
- package/lib/source/IndexMap.js +7 -10
- package/lib/source/LanguageError.d.ts +20 -6
- package/lib/source/LanguageError.js +16 -9
- package/lib/source/Location.d.ts +3 -3
- package/lib/source/Location.js +6 -9
- package/lib/source/Offset.d.ts +1 -1
- package/lib/source/Offset.js +4 -7
- package/lib/source/Position.js +2 -5
- package/lib/source/PositionRange.d.ts +3 -3
- package/lib/source/PositionRange.js +17 -20
- package/lib/source/Range.d.ts +1 -1
- package/lib/source/Range.js +7 -10
- package/lib/source/Source.d.ts +5 -3
- package/lib/source/Source.js +34 -29
- package/lib/source/index.d.ts +8 -8
- package/lib/source/index.js +8 -24
- package/lib/symbol/Symbol.d.ts +5 -4
- package/lib/symbol/Symbol.js +49 -65
- package/lib/symbol/SymbolUtil.d.ts +29 -31
- package/lib/symbol/SymbolUtil.js +178 -157
- package/lib/symbol/index.d.ts +2 -3
- package/lib/symbol/index.js +2 -19
- package/package.json +7 -4
- package/lib/service/Operations.d.ts +0 -8
- package/lib/service/Operations.js +0 -26
- package/lib/symbol/UriBinder.d.ts +0 -3
- package/lib/symbol/UriBinder.js +0 -3
package/lib/source/Range.d.ts
CHANGED
package/lib/source/Range.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.RangeContainer = exports.Range = void 0;
|
|
4
|
-
const Offset_1 = require("./Offset");
|
|
5
|
-
var Range;
|
|
1
|
+
import { Offset } from './Offset.js';
|
|
2
|
+
export var Range;
|
|
6
3
|
(function (Range) {
|
|
7
4
|
/**
|
|
8
5
|
* Gets a range from `RangeLike`.
|
|
@@ -27,10 +24,10 @@ var Range;
|
|
|
27
24
|
* Creates a range from `OffsetLike`. If only `start` is passed in, `end` will be the same value as `start`.
|
|
28
25
|
*/
|
|
29
26
|
function create(start, end) {
|
|
30
|
-
start =
|
|
27
|
+
start = Offset.get(start);
|
|
31
28
|
return {
|
|
32
29
|
start,
|
|
33
|
-
end: end !== undefined ?
|
|
30
|
+
end: end !== undefined ? Offset.get(end) : start,
|
|
34
31
|
};
|
|
35
32
|
}
|
|
36
33
|
Range.create = create;
|
|
@@ -143,13 +140,13 @@ var Range;
|
|
|
143
140
|
};
|
|
144
141
|
}
|
|
145
142
|
Range.translate = translate;
|
|
146
|
-
})(Range
|
|
147
|
-
var RangeContainer;
|
|
143
|
+
})(Range || (Range = {}));
|
|
144
|
+
export var RangeContainer;
|
|
148
145
|
(function (RangeContainer) {
|
|
149
146
|
function is(obj) {
|
|
150
147
|
return (!!obj && typeof obj === 'object' &&
|
|
151
148
|
Range.is(obj.range));
|
|
152
149
|
}
|
|
153
150
|
RangeContainer.is = is;
|
|
154
|
-
})(RangeContainer
|
|
151
|
+
})(RangeContainer || (RangeContainer = {}));
|
|
155
152
|
//# sourceMappingURL=Range.js.map
|
package/lib/source/Source.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { IndexMap } from '.';
|
|
2
|
-
import type { RangeContainer } from './Range';
|
|
3
|
-
import { Range } from './Range';
|
|
1
|
+
import { IndexMap } from './IndexMap.js';
|
|
2
|
+
import type { RangeContainer } from './Range.js';
|
|
3
|
+
import { Range } from './Range.js';
|
|
4
4
|
declare type Digit = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9';
|
|
5
5
|
declare type Space = ' ' | '\t';
|
|
6
6
|
declare type Newline = '\r\n' | '\r' | '\n';
|
|
@@ -43,6 +43,8 @@ export declare class ReadonlySource {
|
|
|
43
43
|
tryPeekAfterWhitespace(expectedValue: string): boolean;
|
|
44
44
|
peekUntil(...terminators: string[]): string;
|
|
45
45
|
peekLine(): string;
|
|
46
|
+
peekRemaining(): string;
|
|
47
|
+
matchPattern(regex: RegExp): boolean;
|
|
46
48
|
hasNonSpaceAheadInLine(): boolean;
|
|
47
49
|
slice(start: number, end?: number): string;
|
|
48
50
|
slice(rangeLike: Range | RangeContainer): string;
|
package/lib/source/Source.js
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { IndexMap } from './IndexMap.js';
|
|
2
|
+
import { Range } from './Range.js';
|
|
3
|
+
export const CRLF = '\r\n';
|
|
4
|
+
export const CR = '\r';
|
|
5
|
+
export const LF = '\n';
|
|
6
|
+
export const Whitespaces = Object.freeze([' ', '\n', '\r', '\t']);
|
|
7
|
+
export class ReadonlySource {
|
|
8
|
+
string;
|
|
9
|
+
indexMap;
|
|
10
|
+
innerCursor = 0;
|
|
11
11
|
constructor(string, indexMap = []) {
|
|
12
12
|
this.string = string;
|
|
13
13
|
this.indexMap = indexMap;
|
|
14
|
-
this.innerCursor = 0;
|
|
15
14
|
}
|
|
16
15
|
get cursor() {
|
|
17
|
-
return
|
|
16
|
+
return IndexMap.toOuterOffset(this.indexMap, this.innerCursor);
|
|
18
17
|
}
|
|
19
18
|
/**
|
|
20
19
|
* @param offset The index to offset from cursor. Defaults to 0.
|
|
@@ -27,7 +26,7 @@ class ReadonlySource {
|
|
|
27
26
|
* getCharRange(1) // Returns the range of the character after cursor.
|
|
28
27
|
*/
|
|
29
28
|
getCharRange(offset = 0) {
|
|
30
|
-
return
|
|
29
|
+
return IndexMap.toOuterRange(this.indexMap, Range.create(this.innerCursor + offset, this.innerCursor + offset + 1));
|
|
31
30
|
}
|
|
32
31
|
/**
|
|
33
32
|
* Peeks a substring from the current cursor.
|
|
@@ -69,12 +68,18 @@ class ReadonlySource {
|
|
|
69
68
|
return ans;
|
|
70
69
|
}
|
|
71
70
|
peekLine() {
|
|
72
|
-
return this.peekUntil(
|
|
71
|
+
return this.peekUntil(CR, LF);
|
|
72
|
+
}
|
|
73
|
+
peekRemaining() {
|
|
74
|
+
return this.string.slice(this.innerCursor);
|
|
75
|
+
}
|
|
76
|
+
matchPattern(regex) {
|
|
77
|
+
return regex.test(this.peekRemaining());
|
|
73
78
|
}
|
|
74
79
|
hasNonSpaceAheadInLine() {
|
|
75
80
|
for (let cursor = this.innerCursor; cursor < this.string.length; cursor++) {
|
|
76
81
|
const c = this.string.charAt(cursor);
|
|
77
|
-
if (c ===
|
|
82
|
+
if (c === CR || c === LF) {
|
|
78
83
|
break;
|
|
79
84
|
}
|
|
80
85
|
if (!(c === ' ' || c === '\t')) {
|
|
@@ -85,20 +90,21 @@ class ReadonlySource {
|
|
|
85
90
|
}
|
|
86
91
|
slice(param0, end) {
|
|
87
92
|
if (typeof param0 === 'number') {
|
|
88
|
-
const innerStart =
|
|
89
|
-
const innerEnd = end !== undefined ?
|
|
93
|
+
const innerStart = IndexMap.toInnerOffset(this.indexMap, param0);
|
|
94
|
+
const innerEnd = end !== undefined ? IndexMap.toInnerOffset(this.indexMap, end) : undefined;
|
|
90
95
|
return this.string.slice(innerStart, innerEnd);
|
|
91
96
|
}
|
|
92
|
-
const range =
|
|
97
|
+
const range = IndexMap.toInnerRange(this.indexMap, Range.get(param0));
|
|
93
98
|
return this.string.slice(range.start, range.end);
|
|
94
99
|
}
|
|
95
100
|
sliceToCursor(start) {
|
|
96
|
-
const innerStart =
|
|
101
|
+
const innerStart = IndexMap.toInnerOffset(this.indexMap, start);
|
|
97
102
|
return this.string.slice(innerStart, this.innerCursor);
|
|
98
103
|
}
|
|
99
104
|
}
|
|
100
|
-
|
|
101
|
-
|
|
105
|
+
export class Source extends ReadonlySource {
|
|
106
|
+
string;
|
|
107
|
+
indexMap;
|
|
102
108
|
constructor(string, indexMap = []) {
|
|
103
109
|
super(string, indexMap);
|
|
104
110
|
this.string = string;
|
|
@@ -108,7 +114,7 @@ class Source extends ReadonlySource {
|
|
|
108
114
|
return super.cursor;
|
|
109
115
|
}
|
|
110
116
|
set cursor(cursor) {
|
|
111
|
-
this.innerCursor =
|
|
117
|
+
this.innerCursor = IndexMap.toInnerOffset(this.indexMap, cursor);
|
|
112
118
|
}
|
|
113
119
|
clone() {
|
|
114
120
|
const ans = new Source(this.string, this.indexMap);
|
|
@@ -119,7 +125,7 @@ class Source extends ReadonlySource {
|
|
|
119
125
|
return this.innerCursor + length <= this.string.length;
|
|
120
126
|
}
|
|
121
127
|
canReadInLine() {
|
|
122
|
-
return this.canRead() && this.peek() !==
|
|
128
|
+
return this.canRead() && this.peek() !== CR && this.peek() !== LF;
|
|
123
129
|
}
|
|
124
130
|
read() {
|
|
125
131
|
return this.string.charAt(this.innerCursor++);
|
|
@@ -157,7 +163,7 @@ class Source extends ReadonlySource {
|
|
|
157
163
|
* Reads until the end of this line.
|
|
158
164
|
*/
|
|
159
165
|
readLine() {
|
|
160
|
-
return this.readUntil(
|
|
166
|
+
return this.readUntil(CR, LF);
|
|
161
167
|
}
|
|
162
168
|
/**
|
|
163
169
|
* Skips until the end of this line.
|
|
@@ -171,10 +177,10 @@ class Source extends ReadonlySource {
|
|
|
171
177
|
*/
|
|
172
178
|
nextLine() {
|
|
173
179
|
this.skipLine();
|
|
174
|
-
if (this.peek(2) ===
|
|
180
|
+
if (this.peek(2) === CRLF) {
|
|
175
181
|
this.skip(2);
|
|
176
182
|
}
|
|
177
|
-
else if (this.peek() ===
|
|
183
|
+
else if (this.peek() === CR || this.peek() === LF) {
|
|
178
184
|
this.skip();
|
|
179
185
|
}
|
|
180
186
|
return this;
|
|
@@ -244,10 +250,10 @@ class Source extends ReadonlySource {
|
|
|
244
250
|
return this;
|
|
245
251
|
}
|
|
246
252
|
readUntilLineEnd() {
|
|
247
|
-
return this.readUntil(
|
|
253
|
+
return this.readUntil(CR, LF);
|
|
248
254
|
}
|
|
249
255
|
skipUntilLineEnd() {
|
|
250
|
-
return this.skipUntilOrEnd(
|
|
256
|
+
return this.skipUntilOrEnd(CR, LF);
|
|
251
257
|
}
|
|
252
258
|
readRemaining() {
|
|
253
259
|
const start = this.innerCursor;
|
|
@@ -274,5 +280,4 @@ class Source extends ReadonlySource {
|
|
|
274
280
|
return Source.isSpace(c) || Source.isNewline(c);
|
|
275
281
|
}
|
|
276
282
|
}
|
|
277
|
-
exports.Source = Source;
|
|
278
283
|
//# sourceMappingURL=Source.js.map
|
package/lib/source/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export * from './IndexMap';
|
|
2
|
-
export * from './LanguageError';
|
|
3
|
-
export * from './Location';
|
|
4
|
-
export * from './Offset';
|
|
5
|
-
export * from './Position';
|
|
6
|
-
export * from './PositionRange';
|
|
7
|
-
export * from './Range';
|
|
8
|
-
export * from './Source';
|
|
1
|
+
export * from './IndexMap.js';
|
|
2
|
+
export * from './LanguageError.js';
|
|
3
|
+
export * from './Location.js';
|
|
4
|
+
export * from './Offset.js';
|
|
5
|
+
export * from './Position.js';
|
|
6
|
+
export * from './PositionRange.js';
|
|
7
|
+
export * from './Range.js';
|
|
8
|
+
export * from './Source.js';
|
|
9
9
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/source/index.js
CHANGED
|
@@ -1,25 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./IndexMap"), exports);
|
|
18
|
-
__exportStar(require("./LanguageError"), exports);
|
|
19
|
-
__exportStar(require("./Location"), exports);
|
|
20
|
-
__exportStar(require("./Offset"), exports);
|
|
21
|
-
__exportStar(require("./Position"), exports);
|
|
22
|
-
__exportStar(require("./PositionRange"), exports);
|
|
23
|
-
__exportStar(require("./Range"), exports);
|
|
24
|
-
__exportStar(require("./Source"), exports);
|
|
1
|
+
export * from './IndexMap.js';
|
|
2
|
+
export * from './LanguageError.js';
|
|
3
|
+
export * from './Location.js';
|
|
4
|
+
export * from './Offset.js';
|
|
5
|
+
export * from './Position.js';
|
|
6
|
+
export * from './PositionRange.js';
|
|
7
|
+
export * from './Range.js';
|
|
8
|
+
export * from './Source.js';
|
|
25
9
|
//# sourceMappingURL=index.js.map
|
package/lib/symbol/Symbol.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { TextDocument } from 'vscode-languageserver-textdocument';
|
|
2
|
-
import type {
|
|
3
|
-
import {
|
|
2
|
+
import type { DeepReadonly } from '../common/index.js';
|
|
3
|
+
import type { RangeLike } from '../source/index.js';
|
|
4
|
+
import { PositionRange, Range } from '../source/index.js';
|
|
4
5
|
export declare const McdocCategories: readonly ["mcdoc", "mcdoc/dispatcher"];
|
|
5
6
|
export declare type McdocCategory = typeof McdocCategories[number];
|
|
6
7
|
export declare const RegistryCategories: readonly ["activity", "attribute", "block", "block_entity_type", "block_predicate_type", "chunk_status", "custom_stat", "enchantment", "entity_type", "float_provider_type", "fluid", "game_event", "height_provider_type", "int_provider_type", "item", "loot_condition_type", "loot_function_type", "loot_nbt_provider_type", "loot_number_provider_type", "loot_pool_entry_type", "loot_score_provider_type", "memory_module_type", "menu", "mob_effect", "motive", "particle_type", "point_of_interest_type", "pos_rule_test", "position_source_type", "potion", "recipe_serializer", "recipe_type", "rule_test", "schedule", "sensor_type", "sound_event", "stat_type", "villager_profession", "villager_type", "worldgen/biome_source", "worldgen/block_placer_type", "worldgen/block_state_provider_type", "worldgen/carver", "worldgen/chunk_generator", "worldgen/decorator", "worldgen/feature", "worldgen/feature_size_type", "worldgen/foliage_placer_type", "worldgen/material_condition", "worldgen/material_rule", "worldgen/placement_modifier_type", "worldgen/structure_feature", "worldgen/structure_piece", "worldgen/structure_pool_element", "worldgen/structure_processor", "worldgen/surface_builder", "worldgen/tree_decorator_type", "worldgen/trunk_placer_type"];
|
|
@@ -39,8 +40,8 @@ export interface SymbolPath {
|
|
|
39
40
|
path: readonly string[];
|
|
40
41
|
}
|
|
41
42
|
export declare namespace SymbolPath {
|
|
42
|
-
function fromSymbol(symbol: Symbol): SymbolPath;
|
|
43
|
-
function fromSymbol(symbol: Symbol | undefined): SymbolPath | undefined;
|
|
43
|
+
function fromSymbol(symbol: DeepReadonly<Symbol>): SymbolPath;
|
|
44
|
+
function fromSymbol(symbol: DeepReadonly<Symbol> | undefined): SymbolPath | undefined;
|
|
44
45
|
/**
|
|
45
46
|
* Equivalent {@link SymbolPath}s will always be serialized into the same string value.
|
|
46
47
|
*/
|
package/lib/symbol/Symbol.js
CHANGED
|
@@ -1,27 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
8
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
9
|
-
};
|
|
10
|
-
var _SymbolPathCollector_set;
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.SymbolTable = exports.SymbolLocation = exports.Symbol = exports.SymbolUsageType = exports.SymbolUsageTypes = exports.SymbolPathCollector = exports.SymbolPath = exports.ResourceLocationCategory = exports.ResourceLocationCategories = exports.AllCategories = exports.DatapackCategories = exports.MiscCategories = exports.FileCategories = exports.TagFileCategories = exports.TaggableResourceLocationCategories = exports.WorldgenFileCategories = exports.RegistryCategories = exports.McdocCategories = void 0;
|
|
13
|
-
const rfdc_1 = __importDefault(require("rfdc"));
|
|
14
|
-
const common_1 = require("../common");
|
|
15
|
-
const source_1 = require("../source");
|
|
1
|
+
import rfdc from 'rfdc';
|
|
2
|
+
import { isIterable } from '../common/index.js';
|
|
3
|
+
import { Location, PositionRange, Range } from '../source/index.js';
|
|
16
4
|
//#region Mcdoc Categories
|
|
17
|
-
|
|
5
|
+
export const McdocCategories = Object.freeze([
|
|
18
6
|
'mcdoc',
|
|
19
7
|
'mcdoc/dispatcher',
|
|
20
8
|
]);
|
|
21
9
|
//#endregion
|
|
22
10
|
//#region Registry Categories
|
|
23
11
|
// Data in `java-edition/src/binder/index.ts` may need to be updated when this section is changed.
|
|
24
|
-
|
|
12
|
+
export const RegistryCategories = Object.freeze([
|
|
25
13
|
'activity',
|
|
26
14
|
'attribute',
|
|
27
15
|
'block',
|
|
@@ -83,7 +71,7 @@ exports.RegistryCategories = Object.freeze([
|
|
|
83
71
|
]);
|
|
84
72
|
//#endregion
|
|
85
73
|
//#region Data Pack Categories
|
|
86
|
-
|
|
74
|
+
export const WorldgenFileCategories = Object.freeze([
|
|
87
75
|
'worldgen/biome',
|
|
88
76
|
'worldgen/configured_carver',
|
|
89
77
|
'worldgen/configured_feature',
|
|
@@ -95,13 +83,13 @@ exports.WorldgenFileCategories = Object.freeze([
|
|
|
95
83
|
'worldgen/processor_list',
|
|
96
84
|
'worldgen/template_pool',
|
|
97
85
|
]);
|
|
98
|
-
|
|
86
|
+
export const TaggableResourceLocationCategories = Object.freeze([
|
|
99
87
|
'function',
|
|
100
|
-
...
|
|
101
|
-
...
|
|
88
|
+
...RegistryCategories,
|
|
89
|
+
...WorldgenFileCategories,
|
|
102
90
|
]);
|
|
103
|
-
|
|
104
|
-
|
|
91
|
+
export const TagFileCategories = Object.freeze(TaggableResourceLocationCategories.map(key => `tag/${key}`));
|
|
92
|
+
export const FileCategories = Object.freeze([
|
|
105
93
|
'advancement',
|
|
106
94
|
'dimension',
|
|
107
95
|
'dimension_type',
|
|
@@ -111,10 +99,10 @@ exports.FileCategories = Object.freeze([
|
|
|
111
99
|
'predicate',
|
|
112
100
|
'recipe',
|
|
113
101
|
'structure',
|
|
114
|
-
...
|
|
115
|
-
...
|
|
102
|
+
...TagFileCategories,
|
|
103
|
+
...WorldgenFileCategories,
|
|
116
104
|
]);
|
|
117
|
-
|
|
105
|
+
export const MiscCategories = Object.freeze([
|
|
118
106
|
'attribute_modifier_uuid',
|
|
119
107
|
'bossbar',
|
|
120
108
|
'objective',
|
|
@@ -123,31 +111,31 @@ exports.MiscCategories = Object.freeze([
|
|
|
123
111
|
'tag',
|
|
124
112
|
'team',
|
|
125
113
|
]);
|
|
126
|
-
|
|
127
|
-
...
|
|
128
|
-
...
|
|
114
|
+
export const DatapackCategories = Object.freeze([
|
|
115
|
+
...FileCategories,
|
|
116
|
+
...MiscCategories,
|
|
129
117
|
]);
|
|
130
118
|
//#endregion
|
|
131
|
-
|
|
132
|
-
...
|
|
133
|
-
...
|
|
134
|
-
...
|
|
119
|
+
export const AllCategories = Object.freeze([
|
|
120
|
+
...DatapackCategories,
|
|
121
|
+
...McdocCategories,
|
|
122
|
+
...RegistryCategories,
|
|
135
123
|
]);
|
|
136
|
-
|
|
124
|
+
export const ResourceLocationCategories = Object.freeze([
|
|
137
125
|
'bossbar',
|
|
138
126
|
'storage',
|
|
139
127
|
'mcdoc/dispatcher',
|
|
140
|
-
...
|
|
141
|
-
...
|
|
128
|
+
...FileCategories,
|
|
129
|
+
...RegistryCategories,
|
|
142
130
|
]);
|
|
143
|
-
var ResourceLocationCategory;
|
|
131
|
+
export var ResourceLocationCategory;
|
|
144
132
|
(function (ResourceLocationCategory) {
|
|
145
133
|
function is(category) {
|
|
146
|
-
return
|
|
134
|
+
return ResourceLocationCategories.includes(category);
|
|
147
135
|
}
|
|
148
136
|
ResourceLocationCategory.is = is;
|
|
149
|
-
})(ResourceLocationCategory
|
|
150
|
-
var SymbolPath;
|
|
137
|
+
})(ResourceLocationCategory || (ResourceLocationCategory = {}));
|
|
138
|
+
export var SymbolPath;
|
|
151
139
|
(function (SymbolPath) {
|
|
152
140
|
function fromSymbol(symbol) {
|
|
153
141
|
return symbol
|
|
@@ -166,38 +154,34 @@ var SymbolPath;
|
|
|
166
154
|
return JSON.parse(value);
|
|
167
155
|
}
|
|
168
156
|
SymbolPath.fromString = fromString;
|
|
169
|
-
})(SymbolPath
|
|
170
|
-
class SymbolPathCollector {
|
|
171
|
-
|
|
172
|
-
_SymbolPathCollector_set.set(this, new Set());
|
|
173
|
-
}
|
|
157
|
+
})(SymbolPath || (SymbolPath = {}));
|
|
158
|
+
export class SymbolPathCollector {
|
|
159
|
+
#set = new Set();
|
|
174
160
|
add(path) {
|
|
175
161
|
if (!path) {
|
|
176
162
|
return;
|
|
177
163
|
}
|
|
178
|
-
|
|
164
|
+
this.#set.add(SymbolPath.toString(path));
|
|
179
165
|
}
|
|
180
166
|
has(path) {
|
|
181
|
-
return
|
|
167
|
+
return this.#set.has(SymbolPath.toString(path));
|
|
182
168
|
}
|
|
183
169
|
collect() {
|
|
184
|
-
return [...
|
|
170
|
+
return [...this.#set].map(SymbolPath.fromString);
|
|
185
171
|
}
|
|
186
172
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
exports.SymbolUsageTypes = Object.freeze(['definition', 'declaration', 'implementation', 'reference', 'typeDefinition']);
|
|
190
|
-
var SymbolUsageType;
|
|
173
|
+
export const SymbolUsageTypes = Object.freeze(['definition', 'declaration', 'implementation', 'reference', 'typeDefinition']);
|
|
174
|
+
export var SymbolUsageType;
|
|
191
175
|
(function (SymbolUsageType) {
|
|
192
176
|
function is(value) {
|
|
193
|
-
return
|
|
177
|
+
return SymbolUsageTypes.includes(value);
|
|
194
178
|
}
|
|
195
179
|
SymbolUsageType.is = is;
|
|
196
|
-
})(SymbolUsageType
|
|
197
|
-
var Symbol;
|
|
180
|
+
})(SymbolUsageType || (SymbolUsageType = {}));
|
|
181
|
+
export var Symbol;
|
|
198
182
|
(function (Symbol) {
|
|
199
183
|
function get(table, category, ...path) {
|
|
200
|
-
if (
|
|
184
|
+
if (isIterable(table)) {
|
|
201
185
|
for (const t of table) {
|
|
202
186
|
const result = get(t, category, ...path);
|
|
203
187
|
if (result) {
|
|
@@ -212,21 +196,21 @@ var Symbol;
|
|
|
212
196
|
return undefined;
|
|
213
197
|
}
|
|
214
198
|
Symbol.get = get;
|
|
215
|
-
})(Symbol
|
|
216
|
-
var SymbolLocation;
|
|
199
|
+
})(Symbol || (Symbol = {}));
|
|
200
|
+
export var SymbolLocation;
|
|
217
201
|
(function (SymbolLocation) {
|
|
218
202
|
/* istanbul ignore next */
|
|
219
203
|
function create(doc, range, fullRange, contributor, additional) {
|
|
220
204
|
return {
|
|
221
|
-
...
|
|
222
|
-
...fullRange ? { fullRange:
|
|
205
|
+
...Location.create(doc, range),
|
|
206
|
+
...fullRange ? { fullRange: Range.get(fullRange), fullPosRange: PositionRange.from(fullRange, doc) } : {},
|
|
223
207
|
...contributor ? { contributor } : {},
|
|
224
208
|
...additional ? additional : {},
|
|
225
209
|
};
|
|
226
210
|
}
|
|
227
211
|
SymbolLocation.create = create;
|
|
228
|
-
})(SymbolLocation
|
|
229
|
-
var SymbolTable;
|
|
212
|
+
})(SymbolLocation || (SymbolLocation = {}));
|
|
213
|
+
export var SymbolTable;
|
|
230
214
|
(function (SymbolTable) {
|
|
231
215
|
/**
|
|
232
216
|
* The passed-in parameter `table` won't be mutated.
|
|
@@ -252,7 +236,7 @@ var SymbolTable;
|
|
|
252
236
|
linkSymbol(childSymbol, map, parentSymbol, category, [...path, identifier]);
|
|
253
237
|
}
|
|
254
238
|
};
|
|
255
|
-
const ans = (
|
|
239
|
+
const ans = rfdc()(table);
|
|
256
240
|
for (const [category, map] of Object.entries(ans)) {
|
|
257
241
|
linkSymbolMap(map, undefined, category, []);
|
|
258
242
|
}
|
|
@@ -281,7 +265,7 @@ var SymbolTable;
|
|
|
281
265
|
unlinkSymbol(childSymbol);
|
|
282
266
|
}
|
|
283
267
|
};
|
|
284
|
-
const ans = (
|
|
268
|
+
const ans = rfdc({ circles: true })(table);
|
|
285
269
|
for (const map of Object.values(ans)) {
|
|
286
270
|
unlinkSymbolMap(map);
|
|
287
271
|
}
|
|
@@ -303,7 +287,7 @@ var SymbolTable;
|
|
|
303
287
|
return link(JSON.parse(json));
|
|
304
288
|
}
|
|
305
289
|
SymbolTable.deserialize = deserialize;
|
|
306
|
-
})(SymbolTable
|
|
290
|
+
})(SymbolTable || (SymbolTable = {}));
|
|
307
291
|
// interface SymbolEvent {
|
|
308
292
|
// symbol: Symbol,
|
|
309
293
|
// }
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import EventEmitter from 'events';
|
|
3
1
|
import { TextDocument } from 'vscode-languageserver-textdocument';
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
6
|
-
import type {
|
|
7
|
-
import {
|
|
2
|
+
import type { DeepReadonly, ExternalEventEmitter, Externals } from '../common/index.js';
|
|
3
|
+
import type { AstNode } from '../node/index.js';
|
|
4
|
+
import type { RangeLike } from '../source/index.js';
|
|
5
|
+
import type { AllCategory, Symbol, SymbolLocationBuiltInContributor, SymbolLocationMetadata, SymbolMap, SymbolMetadata, SymbolTable, SymbolUsageType } from './Symbol.js';
|
|
6
|
+
import { SymbolLocation, SymbolVisibility } from './Symbol.js';
|
|
8
7
|
export interface LookupResult {
|
|
9
8
|
/**
|
|
10
9
|
* The {@link SymbolMap} that contains the symbol. If `symbol` is `undefined`, this property will be the map that could
|
|
@@ -28,28 +27,11 @@ interface SymbolLocationEvent extends SymbolEvent {
|
|
|
28
27
|
type: SymbolUsageType;
|
|
29
28
|
location: SymbolLocation;
|
|
30
29
|
}
|
|
31
|
-
export interface SymbolUtil {
|
|
32
|
-
on(event: 'symbolCreated', callbackFn: (data: SymbolEvent) => void): this;
|
|
33
|
-
on(event: 'symbolAmended', callbackFn: (data: SymbolEvent) => void): this;
|
|
34
|
-
on(event: 'symbolRemoved', callbackFn: (data: SymbolEvent) => void): this;
|
|
35
|
-
on(event: 'symbolLocationCreated', callbackFn: (data: SymbolLocationEvent) => void): this;
|
|
36
|
-
on(event: 'symbolLocationRemoved', callbackFn: (data: SymbolLocationEvent) => void): this;
|
|
37
|
-
once(event: 'symbolCreated', callbackFn: (data: SymbolEvent) => void): this;
|
|
38
|
-
once(event: 'symbolAmended', callbackFn: (data: SymbolEvent) => void): this;
|
|
39
|
-
once(event: 'symbolRemoved', callbackFn: (data: SymbolEvent) => void): this;
|
|
40
|
-
once(event: 'symbolLocationCreated', callbackFn: (data: SymbolLocationEvent) => void): this;
|
|
41
|
-
once(event: 'symbolLocationRemoved', callbackFn: (data: SymbolLocationEvent) => void): this;
|
|
42
|
-
emit(event: 'symbolCreated', data: SymbolEvent): boolean;
|
|
43
|
-
emit(event: 'symbolAmended', data: SymbolEvent): boolean;
|
|
44
|
-
emit(event: 'symbolRemoved', data: SymbolEvent): boolean;
|
|
45
|
-
emit(event: 'symbolLocationCreated', data: SymbolLocationEvent): boolean;
|
|
46
|
-
emit(event: 'symbolLocationRemoved', data: SymbolLocationEvent): boolean;
|
|
47
|
-
}
|
|
48
30
|
interface DocAndNode {
|
|
49
31
|
doc: TextDocument;
|
|
50
32
|
node: AstNode;
|
|
51
33
|
}
|
|
52
|
-
export declare class SymbolUtil
|
|
34
|
+
export declare class SymbolUtil implements ExternalEventEmitter {
|
|
53
35
|
#private;
|
|
54
36
|
/**
|
|
55
37
|
* @internal
|
|
@@ -60,11 +42,26 @@ export declare class SymbolUtil extends EventEmitter {
|
|
|
60
42
|
*/
|
|
61
43
|
_inDelayMode: boolean;
|
|
62
44
|
get global(): SymbolTable;
|
|
63
|
-
constructor(global: SymbolTable,
|
|
45
|
+
constructor(global: SymbolTable, eventEmitterConstructor: Externals['event']['EventEmitter'],
|
|
64
46
|
/** @internal */
|
|
65
47
|
_currentContributor?: string,
|
|
66
48
|
/** @internal */
|
|
67
49
|
_inDelayMode?: boolean);
|
|
50
|
+
on(event: 'symbolCreated', callbackFn: (data: SymbolEvent) => void): this;
|
|
51
|
+
on(event: 'symbolAmended', callbackFn: (data: SymbolEvent) => void): this;
|
|
52
|
+
on(event: 'symbolRemoved', callbackFn: (data: SymbolEvent) => void): this;
|
|
53
|
+
on(event: 'symbolLocationCreated', callbackFn: (data: SymbolLocationEvent) => void): this;
|
|
54
|
+
on(event: 'symbolLocationRemoved', callbackFn: (data: SymbolLocationEvent) => void): this;
|
|
55
|
+
once(event: 'symbolCreated', callbackFn: (data: SymbolEvent) => void): this;
|
|
56
|
+
once(event: 'symbolAmended', callbackFn: (data: SymbolEvent) => void): this;
|
|
57
|
+
once(event: 'symbolRemoved', callbackFn: (data: SymbolEvent) => void): this;
|
|
58
|
+
once(event: 'symbolLocationCreated', callbackFn: (data: SymbolLocationEvent) => void): this;
|
|
59
|
+
once(event: 'symbolLocationRemoved', callbackFn: (data: SymbolLocationEvent) => void): this;
|
|
60
|
+
emit(event: 'symbolCreated', data: SymbolEvent): boolean;
|
|
61
|
+
emit(event: 'symbolAmended', data: SymbolEvent): boolean;
|
|
62
|
+
emit(event: 'symbolRemoved', data: SymbolEvent): boolean;
|
|
63
|
+
emit(event: 'symbolLocationCreated', data: SymbolLocationEvent): boolean;
|
|
64
|
+
emit(event: 'symbolLocationRemoved', data: SymbolLocationEvent): boolean;
|
|
68
65
|
/**
|
|
69
66
|
* Build the internal cache of the SymbolUtil according to the current global symbol table.
|
|
70
67
|
*/
|
|
@@ -182,27 +179,27 @@ export declare class SymbolUtil extends EventEmitter {
|
|
|
182
179
|
/**
|
|
183
180
|
* @returns If the symbol has declarations or definitions.
|
|
184
181
|
*/
|
|
185
|
-
static isDeclared(symbol: Symbol | undefined): boolean;
|
|
182
|
+
static isDeclared(symbol: DeepReadonly<Symbol> | undefined): boolean;
|
|
186
183
|
/**
|
|
187
184
|
* @returns If the symbol has definitions, or declarations and implementations.
|
|
188
185
|
*/
|
|
189
|
-
static isDefined(symbol: Symbol | undefined): symbol is Symbol;
|
|
186
|
+
static isDefined(symbol: DeepReadonly<Symbol> | undefined): symbol is Symbol;
|
|
190
187
|
/**
|
|
191
188
|
* @returns If the symbol has implementations or definitions.
|
|
192
189
|
*/
|
|
193
|
-
static isImplemented(symbol: Symbol | undefined): symbol is Symbol;
|
|
190
|
+
static isImplemented(symbol: DeepReadonly<Symbol> | undefined): symbol is Symbol;
|
|
194
191
|
/**
|
|
195
192
|
* @returns If the symbol has references.
|
|
196
193
|
*/
|
|
197
|
-
static isReferenced(symbol: Symbol | undefined): symbol is Symbol;
|
|
194
|
+
static isReferenced(symbol: DeepReadonly<Symbol> | undefined): symbol is Symbol;
|
|
198
195
|
/**
|
|
199
196
|
* @returns If the symbol has type definitions.
|
|
200
197
|
*/
|
|
201
|
-
static isTypeDefined(symbol: Symbol | undefined): symbol is Symbol;
|
|
198
|
+
static isTypeDefined(symbol: DeepReadonly<Symbol> | undefined): symbol is Symbol;
|
|
202
199
|
/**
|
|
203
200
|
* @throws If the symbol does not have any declarations or definitions.
|
|
204
201
|
*/
|
|
205
|
-
static getDeclaredLocation(symbol: Symbol): SymbolLocation;
|
|
202
|
+
static getDeclaredLocation(symbol: DeepReadonly<Symbol>): SymbolLocation;
|
|
206
203
|
static forEachSymbolInMap(map: SymbolMap, fn: (symbol: Symbol) => unknown): void;
|
|
207
204
|
static forEachSymbol(table: SymbolTable, fn: (symbol: Symbol) => unknown): void;
|
|
208
205
|
static forEachLocationOfSymbol(symbol: Symbol, fn: (data: {
|
|
@@ -296,6 +293,7 @@ export declare class SymbolQuery {
|
|
|
296
293
|
util: SymbolUtil;
|
|
297
294
|
});
|
|
298
295
|
heyGimmeDaSymbol(): Symbol | undefined;
|
|
296
|
+
getData<T>(predicate: (this: void, value: unknown) => value is T): T | undefined;
|
|
299
297
|
with(fn: QueryMemberCallback): this;
|
|
300
298
|
if(predicate: (this: void, symbol: Symbol | undefined) => symbol is undefined, fn: QueryCallback<undefined>): this;
|
|
301
299
|
if(predicate: (this: void, symbol: Symbol | undefined) => symbol is Symbol, fn: QueryCallback<Symbol>): this;
|