@spyglassmc/core 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/lib/browser.d.ts +2 -0
- package/lib/browser.js +2 -0
- package/lib/common/TwoWayMap.js +4 -10
- package/lib/common/externals/BrowserExternals.d.ts +3 -0
- package/lib/common/externals/BrowserExternals.js +191 -0
- package/lib/common/externals/NodeJsExternals.d.ts +3 -0
- package/lib/common/externals/NodeJsExternals.js +151 -0
- package/lib/common/externals/downloader.d.ts +31 -0
- package/lib/common/externals/downloader.js +32 -0
- package/lib/common/externals/index.d.ts +96 -0
- package/lib/common/externals/index.js +2 -0
- package/lib/common/index.d.ts +2 -1
- package/lib/common/index.js +2 -17
- package/lib/common/util.d.ts +15 -15
- package/lib/common/util.js +30 -77
- package/lib/index.d.ts +7 -7
- package/lib/index.js +7 -23
- package/lib/node/AstNode.d.ts +3 -3
- package/lib/node/AstNode.js +10 -16
- package/lib/node/BooleanNode.d.ts +2 -2
- package/lib/node/BooleanNode.js +4 -7
- package/lib/node/CommentNode.d.ts +1 -1
- package/lib/node/CommentNode.js +2 -5
- package/lib/node/ErrorNode.d.ts +1 -1
- package/lib/node/ErrorNode.js +2 -5
- package/lib/node/FileNode.d.ts +3 -3
- package/lib/node/FileNode.js +2 -5
- package/lib/node/FloatNode.d.ts +2 -2
- package/lib/node/FloatNode.js +4 -7
- package/lib/node/IntegerNode.d.ts +2 -2
- package/lib/node/IntegerNode.js +4 -7
- package/lib/node/ListNode.d.ts +2 -2
- package/lib/node/ListNode.js +2 -5
- package/lib/node/LiteralNode.d.ts +3 -3
- package/lib/node/LiteralNode.js +4 -7
- package/lib/node/LongNode.d.ts +2 -2
- package/lib/node/LongNode.js +4 -7
- package/lib/node/RecordNode.d.ts +2 -2
- package/lib/node/RecordNode.js +2 -5
- package/lib/node/ResourceLocationNode.d.ts +5 -5
- package/lib/node/ResourceLocationNode.js +9 -12
- package/lib/node/Sequence.d.ts +2 -2
- package/lib/node/Sequence.js +4 -7
- package/lib/node/StringNode.d.ts +4 -4
- package/lib/node/StringNode.js +9 -12
- package/lib/node/SymbolNode.d.ts +3 -3
- package/lib/node/SymbolNode.js +4 -7
- package/lib/node/index.d.ts +15 -15
- package/lib/node/index.js +15 -31
- package/lib/nodejs.d.ts +2 -0
- package/lib/nodejs.js +2 -0
- package/lib/parser/Parser.d.ts +3 -3
- package/lib/parser/Parser.js +1 -4
- package/lib/parser/boolean.d.ts +2 -2
- package/lib/parser/boolean.js +3 -6
- package/lib/parser/comment.d.ts +2 -2
- package/lib/parser/comment.js +5 -9
- package/lib/parser/empty.d.ts +1 -1
- package/lib/parser/empty.js +1 -5
- package/lib/parser/error.d.ts +2 -2
- package/lib/parser/error.js +5 -9
- package/lib/parser/file.d.ts +3 -3
- package/lib/parser/file.js +9 -13
- package/lib/parser/float.d.ts +4 -4
- package/lib/parser/float.js +12 -16
- package/lib/parser/index.d.ts +16 -16
- package/lib/parser/index.js +16 -38
- package/lib/parser/integer.d.ts +4 -4
- package/lib/parser/integer.js +10 -14
- package/lib/parser/list.d.ts +2 -2
- package/lib/parser/list.js +15 -19
- package/lib/parser/literal.d.ts +2 -2
- package/lib/parser/literal.js +5 -9
- package/lib/parser/long.d.ts +4 -4
- package/lib/parser/long.js +10 -14
- package/lib/parser/record.d.ts +3 -3
- package/lib/parser/record.js +20 -24
- package/lib/parser/resourceLocation.d.ts +2 -2
- package/lib/parser/resourceLocation.js +14 -18
- package/lib/parser/string.d.ts +5 -5
- package/lib/parser/string.js +36 -42
- package/lib/parser/symbol.d.ts +3 -3
- package/lib/parser/symbol.js +3 -7
- package/lib/parser/util.d.ts +5 -5
- package/lib/parser/util.js +38 -56
- package/lib/processor/ColorInfoProvider.d.ts +1 -1
- package/lib/processor/ColorInfoProvider.js +6 -9
- package/lib/processor/InlayHintProvider.d.ts +2 -2
- package/lib/processor/InlayHintProvider.js +1 -2
- package/lib/processor/SignatureHelpProvider.d.ts +2 -2
- package/lib/processor/SignatureHelpProvider.js +1 -2
- package/lib/processor/checker/Checker.d.ts +2 -2
- package/lib/processor/checker/Checker.js +1 -5
- package/lib/processor/checker/builtin.d.ts +4 -4
- package/lib/processor/checker/builtin.js +19 -30
- package/lib/processor/checker/index.d.ts +2 -2
- package/lib/processor/checker/index.js +2 -31
- package/lib/processor/colorizer/Colorizer.d.ts +4 -4
- package/lib/processor/colorizer/Colorizer.js +8 -11
- package/lib/processor/colorizer/builtin.d.ts +3 -3
- package/lib/processor/colorizer/builtin.js +33 -46
- package/lib/processor/colorizer/index.d.ts +2 -2
- package/lib/processor/colorizer/index.js +2 -31
- package/lib/processor/completer/Completer.d.ts +4 -4
- package/lib/processor/completer/Completer.js +14 -33
- package/lib/processor/completer/builtin.d.ts +7 -7
- package/lib/processor/completer/builtin.js +46 -62
- package/lib/processor/completer/index.d.ts +2 -2
- package/lib/processor/completer/index.js +2 -31
- package/lib/processor/formatter/Formatter.d.ts +2 -2
- package/lib/processor/formatter/Formatter.js +2 -7
- package/lib/processor/formatter/builtin.d.ts +3 -3
- package/lib/processor/formatter/builtin.js +22 -36
- package/lib/processor/formatter/index.d.ts +2 -2
- package/lib/processor/formatter/index.js +2 -31
- package/lib/processor/index.d.ts +9 -9
- package/lib/processor/index.js +9 -25
- package/lib/processor/linter/Linter.d.ts +2 -2
- package/lib/processor/linter/Linter.js +1 -2
- package/lib/processor/linter/builtin/undeclaredSymbol.d.ts +2 -2
- package/lib/processor/linter/builtin/undeclaredSymbol.js +20 -24
- package/lib/processor/linter/builtin.d.ts +3 -3
- package/lib/processor/linter/builtin.js +19 -26
- package/lib/processor/linter/index.d.ts +2 -2
- package/lib/processor/linter/index.js +2 -31
- package/lib/processor/util.d.ts +2 -2
- package/lib/processor/util.js +4 -9
- package/lib/service/CacheService.d.ts +6 -6
- package/lib/service/CacheService.js +32 -56
- package/lib/service/Config.d.ts +11 -12
- package/lib/service/Config.js +50 -45
- package/lib/service/Context.d.ts +13 -13
- package/lib/service/Context.js +29 -32
- package/lib/service/Dependency.js +2 -5
- package/lib/service/Downloader.d.ts +10 -40
- package/lib/service/Downloader.js +37 -110
- package/lib/service/ErrorReporter.d.ts +2 -2
- package/lib/service/ErrorReporter.js +10 -14
- package/lib/service/FileService.d.ts +16 -14
- package/lib/service/FileService.js +55 -92
- package/lib/service/Hover.d.ts +2 -2
- package/lib/service/Hover.js +4 -7
- package/lib/service/Logger.js +2 -5
- package/lib/service/MetaRegistry.d.ts +12 -12
- package/lib/service/MetaRegistry.js +62 -73
- package/lib/service/Operations.js +3 -9
- package/lib/service/Profiler.d.ts +1 -1
- package/lib/service/Profiler.js +25 -41
- package/lib/service/Project.d.ts +47 -51
- package/lib/service/Project.js +199 -239
- package/lib/service/Service.d.ts +17 -27
- package/lib/service/Service.js +37 -43
- package/lib/service/SymbolLocations.d.ts +3 -3
- package/lib/service/SymbolLocations.js +4 -7
- package/lib/service/SymbolRegistrar.d.ts +1 -1
- package/lib/service/SymbolRegistrar.js +1 -2
- package/lib/service/fileUtil.d.ts +15 -45
- package/lib/service/fileUtil.js +38 -143
- package/lib/service/index.d.ts +17 -17
- package/lib/service/index.js +17 -35
- package/lib/source/IndexMap.d.ts +1 -1
- package/lib/source/IndexMap.js +7 -10
- package/lib/source/LanguageError.d.ts +2 -2
- package/lib/source/LanguageError.js +2 -5
- package/lib/source/Location.d.ts +3 -3
- package/lib/source/Location.js +6 -9
- package/lib/source/Offset.d.ts +1 -1
- package/lib/source/Offset.js +4 -7
- package/lib/source/Position.js +2 -5
- package/lib/source/PositionRange.d.ts +2 -2
- package/lib/source/PositionRange.js +14 -17
- package/lib/source/Range.d.ts +1 -1
- package/lib/source/Range.js +7 -10
- package/lib/source/Source.d.ts +3 -3
- package/lib/source/Source.js +28 -29
- package/lib/source/index.d.ts +8 -8
- package/lib/source/index.js +8 -24
- package/lib/symbol/Symbol.d.ts +2 -2
- package/lib/symbol/Symbol.js +49 -65
- package/lib/symbol/SymbolUtil.d.ts +22 -25
- package/lib/symbol/SymbolUtil.js +150 -151
- package/lib/symbol/UriBinder.d.ts +1 -1
- package/lib/symbol/UriBinder.js +1 -2
- package/lib/symbol/index.d.ts +3 -3
- package/lib/symbol/index.js +3 -19
- package/package.json +7 -4
package/lib/service/index.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
export * from './CacheService';
|
|
2
|
-
export * from './Config';
|
|
3
|
-
export * from './Context';
|
|
4
|
-
export * from './Dependency';
|
|
5
|
-
export * from './Downloader';
|
|
6
|
-
export * from './ErrorReporter';
|
|
7
|
-
export { FileService, UriProtocolSupporter } from './FileService';
|
|
8
|
-
export * from './fileUtil';
|
|
9
|
-
export * from './Hover';
|
|
10
|
-
export * from './Logger';
|
|
11
|
-
export * from './MetaRegistry';
|
|
12
|
-
export * from './Operations';
|
|
13
|
-
export * from './Profiler';
|
|
14
|
-
export * from './Project';
|
|
15
|
-
export * from './Service';
|
|
16
|
-
export * from './SymbolLocations';
|
|
17
|
-
export * from './SymbolRegistrar';
|
|
1
|
+
export * from './CacheService.js';
|
|
2
|
+
export * from './Config.js';
|
|
3
|
+
export * from './Context.js';
|
|
4
|
+
export * from './Dependency.js';
|
|
5
|
+
export * from './Downloader.js';
|
|
6
|
+
export * from './ErrorReporter.js';
|
|
7
|
+
export { FileService, UriProtocolSupporter } from './FileService.js';
|
|
8
|
+
export * from './fileUtil.js';
|
|
9
|
+
export * from './Hover.js';
|
|
10
|
+
export * from './Logger.js';
|
|
11
|
+
export * from './MetaRegistry.js';
|
|
12
|
+
export * from './Operations.js';
|
|
13
|
+
export * from './Profiler.js';
|
|
14
|
+
export * from './Project.js';
|
|
15
|
+
export * from './Service.js';
|
|
16
|
+
export * from './SymbolLocations.js';
|
|
17
|
+
export * from './SymbolRegistrar.js';
|
|
18
18
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/service/index.js
CHANGED
|
@@ -1,37 +1,19 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/* istanbul ignore file */
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
__exportStar(require("./Config"), exports);
|
|
21
|
-
__exportStar(require("./Context"), exports);
|
|
22
|
-
__exportStar(require("./Dependency"), exports);
|
|
23
|
-
__exportStar(require("./Downloader"), exports);
|
|
24
|
-
__exportStar(require("./ErrorReporter"), exports);
|
|
25
|
-
var FileService_1 = require("./FileService");
|
|
26
|
-
Object.defineProperty(exports, "FileService", { enumerable: true, get: function () { return FileService_1.FileService; } });
|
|
27
|
-
__exportStar(require("./fileUtil"), exports);
|
|
28
|
-
__exportStar(require("./Hover"), exports);
|
|
29
|
-
__exportStar(require("./Logger"), exports);
|
|
30
|
-
__exportStar(require("./MetaRegistry"), exports);
|
|
31
|
-
__exportStar(require("./Operations"), exports);
|
|
32
|
-
__exportStar(require("./Profiler"), exports);
|
|
33
|
-
__exportStar(require("./Project"), exports);
|
|
34
|
-
__exportStar(require("./Service"), exports);
|
|
35
|
-
__exportStar(require("./SymbolLocations"), exports);
|
|
36
|
-
__exportStar(require("./SymbolRegistrar"), exports);
|
|
2
|
+
export * from './CacheService.js';
|
|
3
|
+
export * from './Config.js';
|
|
4
|
+
export * from './Context.js';
|
|
5
|
+
export * from './Dependency.js';
|
|
6
|
+
export * from './Downloader.js';
|
|
7
|
+
export * from './ErrorReporter.js';
|
|
8
|
+
export { FileService } from './FileService.js';
|
|
9
|
+
export * from './fileUtil.js';
|
|
10
|
+
export * from './Hover.js';
|
|
11
|
+
export * from './Logger.js';
|
|
12
|
+
export * from './MetaRegistry.js';
|
|
13
|
+
export * from './Operations.js';
|
|
14
|
+
export * from './Profiler.js';
|
|
15
|
+
export * from './Project.js';
|
|
16
|
+
export * from './Service.js';
|
|
17
|
+
export * from './SymbolLocations.js';
|
|
18
|
+
export * from './SymbolRegistrar.js';
|
|
37
19
|
//# sourceMappingURL=index.js.map
|
package/lib/source/IndexMap.d.ts
CHANGED
package/lib/source/IndexMap.js
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.IndexMap = void 0;
|
|
4
|
-
const Range_1 = require("./Range");
|
|
5
|
-
var IndexMap;
|
|
1
|
+
import { Range } from './Range.js';
|
|
2
|
+
export var IndexMap;
|
|
6
3
|
(function (IndexMap) {
|
|
7
4
|
function convertOffset(map, offset, from, to, isEndOffset) {
|
|
8
5
|
let ans = offset;
|
|
9
6
|
for (const pair of map) {
|
|
10
|
-
if (
|
|
7
|
+
if (Range.contains(pair[from], offset, isEndOffset)) {
|
|
11
8
|
return isEndOffset ? pair[to].end : pair[to].start;
|
|
12
9
|
}
|
|
13
|
-
else if (
|
|
10
|
+
else if (Range.endsBefore(pair[from], offset)) {
|
|
14
11
|
ans = offset - pair[from].end + pair[to].end;
|
|
15
12
|
}
|
|
16
13
|
else {
|
|
@@ -24,7 +21,7 @@ var IndexMap;
|
|
|
24
21
|
}
|
|
25
22
|
IndexMap.toInnerOffset = toInnerOffset;
|
|
26
23
|
function toInnerRange(map, outer) {
|
|
27
|
-
return
|
|
24
|
+
return Range.create(toInnerOffset(map, outer.start), convertOffset(map, outer.end, 'outer', 'inner', true));
|
|
28
25
|
}
|
|
29
26
|
IndexMap.toInnerRange = toInnerRange;
|
|
30
27
|
function toOuterOffset(map, offset) {
|
|
@@ -32,7 +29,7 @@ var IndexMap;
|
|
|
32
29
|
}
|
|
33
30
|
IndexMap.toOuterOffset = toOuterOffset;
|
|
34
31
|
function toOuterRange(map, inner) {
|
|
35
|
-
return
|
|
32
|
+
return Range.create(toOuterOffset(map, inner.start), convertOffset(map, inner.end, 'inner', 'outer', true));
|
|
36
33
|
}
|
|
37
34
|
IndexMap.toOuterRange = toOuterRange;
|
|
38
35
|
function merge(outerMap, innerMap) {
|
|
@@ -42,5 +39,5 @@ var IndexMap;
|
|
|
42
39
|
}));
|
|
43
40
|
}
|
|
44
41
|
IndexMap.merge = merge;
|
|
45
|
-
})(IndexMap
|
|
42
|
+
})(IndexMap || (IndexMap = {}));
|
|
46
43
|
//# sourceMappingURL=IndexMap.js.map
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LanguageError = void 0;
|
|
4
|
-
var LanguageError;
|
|
1
|
+
export var LanguageError;
|
|
5
2
|
(function (LanguageError) {
|
|
6
3
|
function create(message, range, severity = 3 /* ErrorSeverity.Error */, info) {
|
|
7
4
|
const ans = { range, message, severity };
|
|
@@ -11,5 +8,5 @@ var LanguageError;
|
|
|
11
8
|
return ans;
|
|
12
9
|
}
|
|
13
10
|
LanguageError.create = create;
|
|
14
|
-
})(LanguageError
|
|
11
|
+
})(LanguageError || (LanguageError = {}));
|
|
15
12
|
//# sourceMappingURL=LanguageError.js.map
|
package/lib/source/Location.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { TextDocument } from 'vscode-languageserver-textdocument';
|
|
2
|
-
import { PositionRange } from './PositionRange';
|
|
3
|
-
import type { RangeLike } from './Range';
|
|
4
|
-
import { Range } from './Range';
|
|
2
|
+
import { PositionRange } from './PositionRange.js';
|
|
3
|
+
import type { RangeLike } from './Range.js';
|
|
4
|
+
import { Range } from './Range.js';
|
|
5
5
|
export interface Location {
|
|
6
6
|
uri: string;
|
|
7
7
|
range: Range;
|
package/lib/source/Location.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const PositionRange_1 = require("./PositionRange");
|
|
5
|
-
const Range_1 = require("./Range");
|
|
6
|
-
var Location;
|
|
1
|
+
import { PositionRange } from './PositionRange.js';
|
|
2
|
+
import { Range } from './Range.js';
|
|
3
|
+
export var Location;
|
|
7
4
|
(function (Location) {
|
|
8
5
|
function get(partial) {
|
|
9
6
|
return {
|
|
10
7
|
uri: partial.uri ?? '',
|
|
11
|
-
range:
|
|
8
|
+
range: Range.get(partial.range ?? { start: 0, end: 0 }),
|
|
12
9
|
posRange: partial.posRange ?? { start: { line: 0, character: 0 }, end: { line: 0, character: 0 } },
|
|
13
10
|
};
|
|
14
11
|
}
|
|
@@ -17,9 +14,9 @@ var Location;
|
|
|
17
14
|
return Location.get({
|
|
18
15
|
uri: doc.uri,
|
|
19
16
|
range,
|
|
20
|
-
posRange:
|
|
17
|
+
posRange: PositionRange.from(range, doc),
|
|
21
18
|
});
|
|
22
19
|
}
|
|
23
20
|
Location.create = create;
|
|
24
|
-
})(Location
|
|
21
|
+
})(Location || (Location = {}));
|
|
25
22
|
//# sourceMappingURL=Location.js.map
|
package/lib/source/Offset.d.ts
CHANGED
package/lib/source/Offset.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.Offset = void 0;
|
|
4
|
-
const Source_1 = require("./Source");
|
|
5
|
-
var Offset;
|
|
1
|
+
import { ReadonlySource } from './Source.js';
|
|
2
|
+
export var Offset;
|
|
6
3
|
(function (Offset) {
|
|
7
4
|
/**
|
|
8
5
|
* Get an offset from a `OffsetLike`.
|
|
@@ -15,11 +12,11 @@ var Offset;
|
|
|
15
12
|
if (typeof offset === 'function') {
|
|
16
13
|
offset = offset();
|
|
17
14
|
}
|
|
18
|
-
if (offset instanceof
|
|
15
|
+
if (offset instanceof ReadonlySource) {
|
|
19
16
|
offset = offset.cursor;
|
|
20
17
|
}
|
|
21
18
|
return offset;
|
|
22
19
|
}
|
|
23
20
|
Offset.get = get;
|
|
24
|
-
})(Offset
|
|
21
|
+
})(Offset || (Offset = {}));
|
|
25
22
|
//# sourceMappingURL=Offset.js.map
|
package/lib/source/Position.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Position = void 0;
|
|
4
|
-
var Position;
|
|
1
|
+
export var Position;
|
|
5
2
|
(function (Position) {
|
|
6
3
|
function create(param1, param2) {
|
|
7
4
|
if (typeof param1 === 'object') {
|
|
@@ -39,5 +36,5 @@ var Position;
|
|
|
39
36
|
(pos1.line === pos2.line && pos1.character < pos2.character));
|
|
40
37
|
}
|
|
41
38
|
Position.isBefore = isBefore;
|
|
42
|
-
})(Position
|
|
39
|
+
})(Position || (Position = {}));
|
|
43
40
|
//# sourceMappingURL=Position.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { TextDocument } from 'vscode-languageserver-textdocument';
|
|
2
|
-
import { Position } from './Position';
|
|
3
|
-
import type { RangeLike } from './Range';
|
|
2
|
+
import { Position } from './Position.js';
|
|
3
|
+
import type { RangeLike } from './Range.js';
|
|
4
4
|
export interface PositionRange {
|
|
5
5
|
start: Position;
|
|
6
6
|
end: Position;
|
|
@@ -1,28 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const Position_1 = require("./Position");
|
|
5
|
-
const Range_1 = require("./Range");
|
|
6
|
-
var PositionRange;
|
|
1
|
+
import { Position } from './Position.js';
|
|
2
|
+
import { Range } from './Range.js';
|
|
3
|
+
export var PositionRange;
|
|
7
4
|
(function (PositionRange) {
|
|
8
5
|
function create(param1, param2, param3, param4) {
|
|
9
6
|
if (typeof param1 === 'number') {
|
|
10
7
|
return {
|
|
11
|
-
start:
|
|
12
|
-
end:
|
|
8
|
+
start: Position.create(param1, param2),
|
|
9
|
+
end: Position.create(param3, param4),
|
|
13
10
|
};
|
|
14
11
|
}
|
|
15
12
|
else if (param2 !== undefined) {
|
|
16
13
|
return {
|
|
17
|
-
start:
|
|
18
|
-
end:
|
|
14
|
+
start: Position.create(param1),
|
|
15
|
+
end: Position.create(param2),
|
|
19
16
|
};
|
|
20
17
|
}
|
|
21
18
|
else {
|
|
22
19
|
const partial = param1;
|
|
23
20
|
return {
|
|
24
|
-
start:
|
|
25
|
-
end:
|
|
21
|
+
start: Position.create(partial.start ?? {}),
|
|
22
|
+
end: Position.create(partial.end ?? {}),
|
|
26
23
|
};
|
|
27
24
|
}
|
|
28
25
|
}
|
|
@@ -31,7 +28,7 @@ var PositionRange;
|
|
|
31
28
|
* @returns A `PositionRange` converted from a `RangeLike`.
|
|
32
29
|
*/
|
|
33
30
|
function from(range, doc) {
|
|
34
|
-
const _range =
|
|
31
|
+
const _range = Range.get(range);
|
|
35
32
|
const ans = {
|
|
36
33
|
start: doc.positionAt(_range.start),
|
|
37
34
|
end: doc.positionAt(_range.end),
|
|
@@ -56,9 +53,9 @@ var PositionRange;
|
|
|
56
53
|
* }
|
|
57
54
|
* ```
|
|
58
55
|
*/
|
|
59
|
-
PositionRange.Full = Object.freeze(PositionRange.create(
|
|
56
|
+
PositionRange.Full = Object.freeze(PositionRange.create(Position.Beginning, Position.Infinity));
|
|
60
57
|
function toString(range) {
|
|
61
|
-
return `[${
|
|
58
|
+
return `[${Position.toString(range.start)}, ${Position.toString(range.end)})`;
|
|
62
59
|
}
|
|
63
60
|
PositionRange.toString = toString;
|
|
64
61
|
function contains(range, pos) {
|
|
@@ -76,8 +73,8 @@ var PositionRange;
|
|
|
76
73
|
}
|
|
77
74
|
PositionRange.contains = contains;
|
|
78
75
|
function endsBefore(range, pos) {
|
|
79
|
-
return
|
|
76
|
+
return Position.isBefore(Position.create(range.end.line, range.end.character - 1), pos);
|
|
80
77
|
}
|
|
81
78
|
PositionRange.endsBefore = endsBefore;
|
|
82
|
-
})(PositionRange
|
|
79
|
+
})(PositionRange || (PositionRange = {}));
|
|
83
80
|
//# sourceMappingURL=PositionRange.js.map
|
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';
|
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,12 @@ class ReadonlySource {
|
|
|
69
68
|
return ans;
|
|
70
69
|
}
|
|
71
70
|
peekLine() {
|
|
72
|
-
return this.peekUntil(
|
|
71
|
+
return this.peekUntil(CR, LF);
|
|
73
72
|
}
|
|
74
73
|
hasNonSpaceAheadInLine() {
|
|
75
74
|
for (let cursor = this.innerCursor; cursor < this.string.length; cursor++) {
|
|
76
75
|
const c = this.string.charAt(cursor);
|
|
77
|
-
if (c ===
|
|
76
|
+
if (c === CR || c === LF) {
|
|
78
77
|
break;
|
|
79
78
|
}
|
|
80
79
|
if (!(c === ' ' || c === '\t')) {
|
|
@@ -85,20 +84,21 @@ class ReadonlySource {
|
|
|
85
84
|
}
|
|
86
85
|
slice(param0, end) {
|
|
87
86
|
if (typeof param0 === 'number') {
|
|
88
|
-
const innerStart =
|
|
89
|
-
const innerEnd = end !== undefined ?
|
|
87
|
+
const innerStart = IndexMap.toInnerOffset(this.indexMap, param0);
|
|
88
|
+
const innerEnd = end !== undefined ? IndexMap.toInnerOffset(this.indexMap, end) : undefined;
|
|
90
89
|
return this.string.slice(innerStart, innerEnd);
|
|
91
90
|
}
|
|
92
|
-
const range =
|
|
91
|
+
const range = IndexMap.toInnerRange(this.indexMap, Range.get(param0));
|
|
93
92
|
return this.string.slice(range.start, range.end);
|
|
94
93
|
}
|
|
95
94
|
sliceToCursor(start) {
|
|
96
|
-
const innerStart =
|
|
95
|
+
const innerStart = IndexMap.toInnerOffset(this.indexMap, start);
|
|
97
96
|
return this.string.slice(innerStart, this.innerCursor);
|
|
98
97
|
}
|
|
99
98
|
}
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
export class Source extends ReadonlySource {
|
|
100
|
+
string;
|
|
101
|
+
indexMap;
|
|
102
102
|
constructor(string, indexMap = []) {
|
|
103
103
|
super(string, indexMap);
|
|
104
104
|
this.string = string;
|
|
@@ -108,7 +108,7 @@ class Source extends ReadonlySource {
|
|
|
108
108
|
return super.cursor;
|
|
109
109
|
}
|
|
110
110
|
set cursor(cursor) {
|
|
111
|
-
this.innerCursor =
|
|
111
|
+
this.innerCursor = IndexMap.toInnerOffset(this.indexMap, cursor);
|
|
112
112
|
}
|
|
113
113
|
clone() {
|
|
114
114
|
const ans = new Source(this.string, this.indexMap);
|
|
@@ -119,7 +119,7 @@ class Source extends ReadonlySource {
|
|
|
119
119
|
return this.innerCursor + length <= this.string.length;
|
|
120
120
|
}
|
|
121
121
|
canReadInLine() {
|
|
122
|
-
return this.canRead() && this.peek() !==
|
|
122
|
+
return this.canRead() && this.peek() !== CR && this.peek() !== LF;
|
|
123
123
|
}
|
|
124
124
|
read() {
|
|
125
125
|
return this.string.charAt(this.innerCursor++);
|
|
@@ -157,7 +157,7 @@ class Source extends ReadonlySource {
|
|
|
157
157
|
* Reads until the end of this line.
|
|
158
158
|
*/
|
|
159
159
|
readLine() {
|
|
160
|
-
return this.readUntil(
|
|
160
|
+
return this.readUntil(CR, LF);
|
|
161
161
|
}
|
|
162
162
|
/**
|
|
163
163
|
* Skips until the end of this line.
|
|
@@ -171,10 +171,10 @@ class Source extends ReadonlySource {
|
|
|
171
171
|
*/
|
|
172
172
|
nextLine() {
|
|
173
173
|
this.skipLine();
|
|
174
|
-
if (this.peek(2) ===
|
|
174
|
+
if (this.peek(2) === CRLF) {
|
|
175
175
|
this.skip(2);
|
|
176
176
|
}
|
|
177
|
-
else if (this.peek() ===
|
|
177
|
+
else if (this.peek() === CR || this.peek() === LF) {
|
|
178
178
|
this.skip();
|
|
179
179
|
}
|
|
180
180
|
return this;
|
|
@@ -244,10 +244,10 @@ class Source extends ReadonlySource {
|
|
|
244
244
|
return this;
|
|
245
245
|
}
|
|
246
246
|
readUntilLineEnd() {
|
|
247
|
-
return this.readUntil(
|
|
247
|
+
return this.readUntil(CR, LF);
|
|
248
248
|
}
|
|
249
249
|
skipUntilLineEnd() {
|
|
250
|
-
return this.skipUntilOrEnd(
|
|
250
|
+
return this.skipUntilOrEnd(CR, LF);
|
|
251
251
|
}
|
|
252
252
|
readRemaining() {
|
|
253
253
|
const start = this.innerCursor;
|
|
@@ -274,5 +274,4 @@ class Source extends ReadonlySource {
|
|
|
274
274
|
return Source.isSpace(c) || Source.isNewline(c);
|
|
275
275
|
}
|
|
276
276
|
}
|
|
277
|
-
exports.Source = Source;
|
|
278
277
|
//# 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,6 @@
|
|
|
1
1
|
import type { TextDocument } from 'vscode-languageserver-textdocument';
|
|
2
|
-
import type { RangeLike } from '../source';
|
|
3
|
-
import { PositionRange, Range } from '../source';
|
|
2
|
+
import type { RangeLike } from '../source/index.js';
|
|
3
|
+
import { PositionRange, Range } from '../source/index.js';
|
|
4
4
|
export declare const McdocCategories: readonly ["mcdoc", "mcdoc/dispatcher"];
|
|
5
5
|
export declare type McdocCategory = typeof McdocCategories[number];
|
|
6
6
|
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"];
|