@spyglassmc/core 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -0
- package/lib/common/Heap.d.ts +1 -0
- package/lib/common/Heap.js +2 -0
- package/lib/common/index.d.ts +2 -0
- package/lib/common/index.js +14 -0
- package/lib/common/util.d.ts +120 -0
- package/lib/common/util.js +292 -0
- package/lib/index.d.ts +8 -0
- package/lib/index.js +20 -0
- package/lib/node/AstNode.d.ts +64 -0
- package/lib/node/AstNode.js +108 -0
- package/lib/node/BooleanNode.d.ts +13 -0
- package/lib/node/BooleanNode.js +20 -0
- package/lib/node/CommentNode.d.ts +12 -0
- package/lib/node/CommentNode.js +11 -0
- package/lib/node/ErrorNode.d.ts +8 -0
- package/lib/node/ErrorNode.js +12 -0
- package/lib/node/FileNode.d.ts +21 -0
- package/lib/node/FileNode.js +11 -0
- package/lib/node/FloatNode.d.ts +13 -0
- package/lib/node/FloatNode.js +21 -0
- package/lib/node/IntegerNode.d.ts +13 -0
- package/lib/node/IntegerNode.js +20 -0
- package/lib/node/ListNode.d.ts +15 -0
- package/lib/node/ListNode.js +11 -0
- package/lib/node/LiteralNode.d.ts +19 -0
- package/lib/node/LiteralNode.js +22 -0
- package/lib/node/LongNode.d.ts +13 -0
- package/lib/node/LongNode.js +20 -0
- package/lib/node/RecordNode.d.ts +20 -0
- package/lib/node/RecordNode.js +11 -0
- package/lib/node/ResourceLocationNode.d.ts +41 -0
- package/lib/node/ResourceLocationNode.js +65 -0
- package/lib/node/Sequence.d.ts +22 -0
- package/lib/node/Sequence.js +11 -0
- package/lib/node/StringNode.d.ts +63 -0
- package/lib/node/StringNode.js +43 -0
- package/lib/node/SymbolNode.d.ts +21 -0
- package/lib/node/SymbolNode.js +22 -0
- package/lib/node/TableNode.d.ts +17 -0
- package/lib/node/TableNode.js +11 -0
- package/lib/node/index.d.ts +16 -0
- package/lib/node/index.js +28 -0
- package/lib/parser/Parser.d.ts +16 -0
- package/lib/parser/Parser.js +5 -0
- package/lib/parser/boolean.d.ts +4 -0
- package/lib/parser/boolean.js +11 -0
- package/lib/parser/comment.d.ts +12 -0
- package/lib/parser/comment.js +34 -0
- package/lib/parser/empty.d.ts +3 -0
- package/lib/parser/empty.js +7 -0
- package/lib/parser/error.d.ts +8 -0
- package/lib/parser/error.js +22 -0
- package/lib/parser/file.d.ts +9 -0
- package/lib/parser/file.js +37 -0
- package/lib/parser/float.d.ts +33 -0
- package/lib/parser/float.js +57 -0
- package/lib/parser/index.d.ts +17 -0
- package/lib/parser/index.js +36 -0
- package/lib/parser/integer.d.ts +33 -0
- package/lib/parser/integer.js +46 -0
- package/lib/parser/list.d.ts +12 -0
- package/lib/parser/list.js +70 -0
- package/lib/parser/literal.d.ts +5 -0
- package/lib/parser/literal.js +41 -0
- package/lib/parser/long.d.ts +33 -0
- package/lib/parser/long.js +50 -0
- package/lib/parser/record.d.ts +22 -0
- package/lib/parser/record.js +97 -0
- package/lib/parser/resourceLocation.d.ts +4 -0
- package/lib/parser/resourceLocation.js +67 -0
- package/lib/parser/string.d.ts +18 -0
- package/lib/parser/string.js +129 -0
- package/lib/parser/symbol.d.ts +12 -0
- package/lib/parser/symbol.js +33 -0
- package/lib/parser/table.d.ts +22 -0
- package/lib/parser/table.js +97 -0
- package/lib/parser/util.d.ts +134 -0
- package/lib/parser/util.js +224 -0
- package/lib/processor/ColorInfoProvider.d.ts +87 -0
- package/lib/processor/ColorInfoProvider.js +141 -0
- package/lib/processor/InlayHintProvider.d.ts +8 -0
- package/lib/processor/InlayHintProvider.js +3 -0
- package/lib/processor/SignatureHelpProvider.d.ts +18 -0
- package/lib/processor/SignatureHelpProvider.js +3 -0
- package/lib/processor/checker/Checker.d.ts +7 -0
- package/lib/processor/checker/Checker.js +7 -0
- package/lib/processor/checker/builtin.d.ts +23 -0
- package/lib/processor/checker/builtin.js +83 -0
- package/lib/processor/checker/index.d.ts +3 -0
- package/lib/processor/checker/index.js +28 -0
- package/lib/processor/colorizer/Colorizer.d.ts +23 -0
- package/lib/processor/colorizer/Colorizer.js +70 -0
- package/lib/processor/colorizer/builtin.d.ts +17 -0
- package/lib/processor/colorizer/builtin.js +84 -0
- package/lib/processor/colorizer/index.d.ts +3 -0
- package/lib/processor/colorizer/index.js +28 -0
- package/lib/processor/completer/Completer.d.ts +75 -0
- package/lib/processor/completer/Completer.js +92 -0
- package/lib/processor/completer/builtin.d.ts +30 -0
- package/lib/processor/completer/builtin.js +172 -0
- package/lib/processor/completer/index.d.ts +3 -0
- package/lib/processor/completer/index.js +28 -0
- package/lib/processor/formatter/Formatter.d.ts +6 -0
- package/lib/processor/formatter/Formatter.js +19 -0
- package/lib/processor/formatter/builtin.d.ts +15 -0
- package/lib/processor/formatter/builtin.js +60 -0
- package/lib/processor/formatter/index.d.ts +3 -0
- package/lib/processor/formatter/index.js +28 -0
- package/lib/processor/index.d.ts +10 -0
- package/lib/processor/index.js +22 -0
- package/lib/processor/linter/Linter.d.ts +4 -0
- package/lib/processor/linter/Linter.js +3 -0
- package/lib/processor/linter/builtin/undeclaredSymbol.d.ts +4 -0
- package/lib/processor/linter/builtin/undeclaredSymbol.js +73 -0
- package/lib/processor/linter/builtin.d.ts +15 -0
- package/lib/processor/linter/builtin.js +120 -0
- package/lib/processor/linter/index.d.ts +3 -0
- package/lib/processor/linter/index.js +28 -0
- package/lib/processor/util.d.ts +17 -0
- package/lib/processor/util.js +32 -0
- package/lib/service/CacheService.d.ts +54 -0
- package/lib/service/CacheService.js +195 -0
- package/lib/service/CommandExecutor.d.ts +3 -0
- package/lib/service/CommandExecutor.js +7 -0
- package/lib/service/Config.d.ts +218 -0
- package/lib/service/Config.js +264 -0
- package/lib/service/Context.d.ts +143 -0
- package/lib/service/Context.js +143 -0
- package/lib/service/Dependency.d.ts +10 -0
- package/lib/service/Dependency.js +11 -0
- package/lib/service/Downloader.d.ts +67 -0
- package/lib/service/Downloader.js +185 -0
- package/lib/service/ErrorReporter.d.ts +27 -0
- package/lib/service/ErrorReporter.js +49 -0
- package/lib/service/FileService.d.ts +96 -0
- package/lib/service/FileService.js +224 -0
- package/lib/service/Hover.d.ts +10 -0
- package/lib/service/Hover.js +16 -0
- package/lib/service/Logger.d.ts +31 -0
- package/lib/service/Logger.js +30 -0
- package/lib/service/MetaRegistry.d.ts +106 -0
- package/lib/service/MetaRegistry.js +192 -0
- package/lib/service/Operations.d.ts +8 -0
- package/lib/service/Operations.js +26 -0
- package/lib/service/Profiler.d.ts +33 -0
- package/lib/service/Profiler.js +76 -0
- package/lib/service/Project.d.ts +173 -0
- package/lib/service/Project.js +593 -0
- package/lib/service/Service.d.ts +55 -0
- package/lib/service/Service.js +207 -0
- package/lib/service/SymbolLocations.d.ts +17 -0
- package/lib/service/SymbolLocations.js +16 -0
- package/lib/service/SymbolRegistrar.d.ts +5 -0
- package/lib/service/SymbolRegistrar.js +3 -0
- package/lib/service/fileUtil.d.ts +121 -0
- package/lib/service/fileUtil.js +268 -0
- package/lib/service/index.d.ts +18 -0
- package/lib/service/index.js +33 -0
- package/lib/source/IndexMap.d.ts +16 -0
- package/lib/source/IndexMap.js +46 -0
- package/lib/source/LanguageError.d.ts +27 -0
- package/lib/source/LanguageError.js +15 -0
- package/lib/source/Location.d.ts +19 -0
- package/lib/source/Location.js +25 -0
- package/lib/source/Offset.d.ts +13 -0
- package/lib/source/Offset.js +25 -0
- package/lib/source/Position.d.ts +23 -0
- package/lib/source/Position.js +43 -0
- package/lib/source/PositionRange.d.ts +38 -0
- package/lib/source/PositionRange.js +83 -0
- package/lib/source/Range.d.ts +68 -0
- package/lib/source/Range.js +155 -0
- package/lib/source/Source.d.ts +110 -0
- package/lib/source/Source.js +222 -0
- package/lib/source/index.d.ts +9 -0
- package/lib/source/index.js +21 -0
- package/lib/symbol/Symbol.d.ts +219 -0
- package/lib/symbol/Symbol.js +324 -0
- package/lib/symbol/SymbolUtil.d.ts +407 -0
- package/lib/symbol/SymbolUtil.js +880 -0
- package/lib/symbol/UriBinder.d.ts +3 -0
- package/lib/symbol/UriBinder.js +3 -0
- package/lib/symbol/index.d.ts +4 -0
- package/lib/symbol/index.js +16 -0
- package/package.json +41 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* istanbul ignore file */
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
6
|
+
}) : (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
o[k2] = m[k];
|
|
9
|
+
}));
|
|
10
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
11
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.FileService = void 0;
|
|
15
|
+
__exportStar(require("./CacheService"), exports);
|
|
16
|
+
__exportStar(require("./Config"), exports);
|
|
17
|
+
__exportStar(require("./Context"), exports);
|
|
18
|
+
__exportStar(require("./Dependency"), exports);
|
|
19
|
+
__exportStar(require("./Downloader"), exports);
|
|
20
|
+
__exportStar(require("./ErrorReporter"), exports);
|
|
21
|
+
var FileService_1 = require("./FileService");
|
|
22
|
+
Object.defineProperty(exports, "FileService", { enumerable: true, get: function () { return FileService_1.FileService; } });
|
|
23
|
+
__exportStar(require("./fileUtil"), exports);
|
|
24
|
+
__exportStar(require("./Hover"), exports);
|
|
25
|
+
__exportStar(require("./Logger"), exports);
|
|
26
|
+
__exportStar(require("./MetaRegistry"), exports);
|
|
27
|
+
__exportStar(require("./Operations"), exports);
|
|
28
|
+
__exportStar(require("./Profiler"), exports);
|
|
29
|
+
__exportStar(require("./Project"), exports);
|
|
30
|
+
__exportStar(require("./Service"), exports);
|
|
31
|
+
__exportStar(require("./SymbolLocations"), exports);
|
|
32
|
+
__exportStar(require("./SymbolRegistrar"), exports);
|
|
33
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Range } from './Range';
|
|
2
|
+
/**
|
|
3
|
+
* The pairs should be in ascending order.
|
|
4
|
+
*/
|
|
5
|
+
export declare type IndexMap = {
|
|
6
|
+
outer: Range;
|
|
7
|
+
inner: Range;
|
|
8
|
+
}[];
|
|
9
|
+
export declare namespace IndexMap {
|
|
10
|
+
function toInnerOffset(map: IndexMap, offset: number): number;
|
|
11
|
+
function toInnerRange(map: IndexMap, outer: Range): Range;
|
|
12
|
+
function toOuterOffset(map: IndexMap, offset: number): number;
|
|
13
|
+
function toOuterRange(map: IndexMap, inner: Range): Range;
|
|
14
|
+
function merge(outerMap: IndexMap, innerMap: IndexMap): IndexMap;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=IndexMap.d.ts.map
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IndexMap = void 0;
|
|
4
|
+
const Range_1 = require("./Range");
|
|
5
|
+
var IndexMap;
|
|
6
|
+
(function (IndexMap) {
|
|
7
|
+
function convertOffset(map, offset, from, to, isEndOffset) {
|
|
8
|
+
let ans = offset;
|
|
9
|
+
for (const pair of map) {
|
|
10
|
+
if (Range_1.Range.contains(pair[from], offset, isEndOffset)) {
|
|
11
|
+
return isEndOffset ? pair[to].end : pair[to].start;
|
|
12
|
+
}
|
|
13
|
+
else if (Range_1.Range.endsBefore(pair[from], offset)) {
|
|
14
|
+
ans = offset - pair[from].end + pair[to].end;
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
break;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return ans;
|
|
21
|
+
}
|
|
22
|
+
function toInnerOffset(map, offset) {
|
|
23
|
+
return convertOffset(map, offset, 'outer', 'inner', false);
|
|
24
|
+
}
|
|
25
|
+
IndexMap.toInnerOffset = toInnerOffset;
|
|
26
|
+
function toInnerRange(map, outer) {
|
|
27
|
+
return Range_1.Range.create(toInnerOffset(map, outer.start), convertOffset(map, outer.end, 'outer', 'inner', true));
|
|
28
|
+
}
|
|
29
|
+
IndexMap.toInnerRange = toInnerRange;
|
|
30
|
+
function toOuterOffset(map, offset) {
|
|
31
|
+
return convertOffset(map, offset, 'inner', 'outer', false);
|
|
32
|
+
}
|
|
33
|
+
IndexMap.toOuterOffset = toOuterOffset;
|
|
34
|
+
function toOuterRange(map, inner) {
|
|
35
|
+
return Range_1.Range.create(toOuterOffset(map, inner.start), convertOffset(map, inner.end, 'inner', 'outer', true));
|
|
36
|
+
}
|
|
37
|
+
IndexMap.toOuterRange = toOuterRange;
|
|
38
|
+
function merge(outerMap, innerMap) {
|
|
39
|
+
return innerMap.map(p => ({
|
|
40
|
+
inner: p.inner,
|
|
41
|
+
outer: toOuterRange(outerMap, p.outer),
|
|
42
|
+
}));
|
|
43
|
+
}
|
|
44
|
+
IndexMap.merge = merge;
|
|
45
|
+
})(IndexMap = exports.IndexMap || (exports.IndexMap = {}));
|
|
46
|
+
//# sourceMappingURL=IndexMap.js.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Location } from './Location';
|
|
2
|
+
import type { Range } from './Range';
|
|
3
|
+
export interface LanguageError {
|
|
4
|
+
message: string;
|
|
5
|
+
range: Range;
|
|
6
|
+
severity: ErrorSeverity;
|
|
7
|
+
info?: LanguageErrorInfo;
|
|
8
|
+
}
|
|
9
|
+
export declare namespace LanguageError {
|
|
10
|
+
function create(message: string, range: Range, severity?: ErrorSeverity, info?: LanguageErrorInfo): LanguageError;
|
|
11
|
+
}
|
|
12
|
+
export declare const enum ErrorSeverity {
|
|
13
|
+
Hint = 0,
|
|
14
|
+
Information = 1,
|
|
15
|
+
Warning = 2,
|
|
16
|
+
Error = 3
|
|
17
|
+
}
|
|
18
|
+
export interface LanguageErrorInfo {
|
|
19
|
+
codeAction?: string;
|
|
20
|
+
deprecated?: boolean;
|
|
21
|
+
unnecessary?: boolean;
|
|
22
|
+
related?: {
|
|
23
|
+
location: Location;
|
|
24
|
+
message: string;
|
|
25
|
+
}[];
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=LanguageError.d.ts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LanguageError = void 0;
|
|
4
|
+
var LanguageError;
|
|
5
|
+
(function (LanguageError) {
|
|
6
|
+
function create(message, range, severity = 3 /* Error */, info) {
|
|
7
|
+
const ans = { range, message, severity };
|
|
8
|
+
if (info) {
|
|
9
|
+
ans.info = info;
|
|
10
|
+
}
|
|
11
|
+
return ans;
|
|
12
|
+
}
|
|
13
|
+
LanguageError.create = create;
|
|
14
|
+
})(LanguageError = exports.LanguageError || (exports.LanguageError = {}));
|
|
15
|
+
//# sourceMappingURL=LanguageError.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { TextDocument } from 'vscode-languageserver-textdocument';
|
|
2
|
+
import { PositionRange } from './PositionRange';
|
|
3
|
+
import type { RangeLike } from './Range';
|
|
4
|
+
import { Range } from './Range';
|
|
5
|
+
export interface Location {
|
|
6
|
+
uri: string;
|
|
7
|
+
range: Range;
|
|
8
|
+
posRange: PositionRange;
|
|
9
|
+
}
|
|
10
|
+
export declare type LocationLike = Partial<{
|
|
11
|
+
uri: string;
|
|
12
|
+
range: RangeLike;
|
|
13
|
+
posRange: PositionRange;
|
|
14
|
+
}>;
|
|
15
|
+
export declare namespace Location {
|
|
16
|
+
function get(partial: LocationLike): Location;
|
|
17
|
+
function create(doc: TextDocument, range: RangeLike): Location;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=Location.d.ts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Location = void 0;
|
|
4
|
+
const PositionRange_1 = require("./PositionRange");
|
|
5
|
+
const Range_1 = require("./Range");
|
|
6
|
+
var Location;
|
|
7
|
+
(function (Location) {
|
|
8
|
+
function get(partial) {
|
|
9
|
+
return {
|
|
10
|
+
uri: partial.uri ?? '',
|
|
11
|
+
range: Range_1.Range.get(partial.range ?? { start: 0, end: 0 }),
|
|
12
|
+
posRange: partial.posRange ?? { start: { line: 0, character: 0 }, end: { line: 0, character: 0 } },
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
Location.get = get;
|
|
16
|
+
function create(doc, range) {
|
|
17
|
+
return Location.get({
|
|
18
|
+
uri: doc.uri,
|
|
19
|
+
range,
|
|
20
|
+
posRange: PositionRange_1.PositionRange.from(range, doc),
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
Location.create = create;
|
|
24
|
+
})(Location = exports.Location || (exports.Location = {}));
|
|
25
|
+
//# sourceMappingURL=Location.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ReadonlySource } from './Source';
|
|
2
|
+
export declare type OffsetLike = number | ReadonlySource | ((this: void) => number | ReadonlySource);
|
|
3
|
+
export declare namespace Offset {
|
|
4
|
+
/**
|
|
5
|
+
* Get an offset from a `OffsetLike`.
|
|
6
|
+
*
|
|
7
|
+
* @returns
|
|
8
|
+
* - `number`: itself.
|
|
9
|
+
* - `Source`: its `cursor`.
|
|
10
|
+
*/
|
|
11
|
+
function get(offset: OffsetLike): number;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=Offset.d.ts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Offset = void 0;
|
|
4
|
+
const Source_1 = require("./Source");
|
|
5
|
+
var Offset;
|
|
6
|
+
(function (Offset) {
|
|
7
|
+
/**
|
|
8
|
+
* Get an offset from a `OffsetLike`.
|
|
9
|
+
*
|
|
10
|
+
* @returns
|
|
11
|
+
* - `number`: itself.
|
|
12
|
+
* - `Source`: its `cursor`.
|
|
13
|
+
*/
|
|
14
|
+
function get(offset) {
|
|
15
|
+
if (typeof offset === 'function') {
|
|
16
|
+
offset = offset();
|
|
17
|
+
}
|
|
18
|
+
if (offset instanceof Source_1.ReadonlySource) {
|
|
19
|
+
offset = offset.cursor;
|
|
20
|
+
}
|
|
21
|
+
return offset;
|
|
22
|
+
}
|
|
23
|
+
Offset.get = get;
|
|
24
|
+
})(Offset = exports.Offset || (exports.Offset = {}));
|
|
25
|
+
//# sourceMappingURL=Offset.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface Position {
|
|
2
|
+
line: number;
|
|
3
|
+
character: number;
|
|
4
|
+
}
|
|
5
|
+
export declare namespace Position {
|
|
6
|
+
function create(line: number, character: number): Position;
|
|
7
|
+
function create(partial: Partial<Position>): Position;
|
|
8
|
+
/**
|
|
9
|
+
* ```typescript
|
|
10
|
+
* { line: 0, character: 0 }
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
const Beginning: Position;
|
|
14
|
+
/**
|
|
15
|
+
* ```typescript
|
|
16
|
+
* { line: Infinity, character: Infinity }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
const Infinity: Position;
|
|
20
|
+
function toString(pos: Position): string;
|
|
21
|
+
function isBefore(pos1: Position, pos2: Position): boolean;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=Position.d.ts.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Position = void 0;
|
|
4
|
+
var Position;
|
|
5
|
+
(function (Position) {
|
|
6
|
+
function create(param1, param2) {
|
|
7
|
+
if (typeof param1 === 'object') {
|
|
8
|
+
return _createFromPartial(param1);
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
return _createFromNumbers(param1, param2);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
Position.create = create;
|
|
15
|
+
function _createFromPartial(partial) {
|
|
16
|
+
return { line: partial.line ?? 0, character: partial.character ?? 0 };
|
|
17
|
+
}
|
|
18
|
+
function _createFromNumbers(line, character) {
|
|
19
|
+
return _createFromPartial({ line, character });
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* ```typescript
|
|
23
|
+
* { line: 0, character: 0 }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
Position.Beginning = Position.create(0, 0);
|
|
27
|
+
/**
|
|
28
|
+
* ```typescript
|
|
29
|
+
* { line: Infinity, character: Infinity }
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
Position.Infinity = Position.create(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY);
|
|
33
|
+
function toString(pos) {
|
|
34
|
+
return `<${pos.line}, ${pos.character}>`;
|
|
35
|
+
}
|
|
36
|
+
Position.toString = toString;
|
|
37
|
+
function isBefore(pos1, pos2) {
|
|
38
|
+
return (pos1.line < pos2.line ||
|
|
39
|
+
(pos1.line === pos2.line && pos1.character < pos2.character));
|
|
40
|
+
}
|
|
41
|
+
Position.isBefore = isBefore;
|
|
42
|
+
})(Position = exports.Position || (exports.Position = {}));
|
|
43
|
+
//# sourceMappingURL=Position.js.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { TextDocument } from 'vscode-languageserver-textdocument';
|
|
2
|
+
import { Position } from './Position';
|
|
3
|
+
import type { RangeLike } from './Range';
|
|
4
|
+
export interface PositionRange {
|
|
5
|
+
start: Position;
|
|
6
|
+
end: Position;
|
|
7
|
+
}
|
|
8
|
+
export declare namespace PositionRange {
|
|
9
|
+
function create(startLine: number, startCharacter: number, endLine: number, endCharacter: number): PositionRange;
|
|
10
|
+
function create(start: Position, end: Position): PositionRange;
|
|
11
|
+
function create(partial: Partial<PositionRange>): PositionRange;
|
|
12
|
+
/**
|
|
13
|
+
* @returns A `PositionRange` converted from a `RangeLike`.
|
|
14
|
+
*/
|
|
15
|
+
function from(range: RangeLike, doc: TextDocument): PositionRange;
|
|
16
|
+
/**
|
|
17
|
+
* ```typescript
|
|
18
|
+
* {
|
|
19
|
+
* start: { line: 0, character: 0 },
|
|
20
|
+
* end: { line: 0, character: 1 }
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
const Beginning: Readonly<PositionRange>;
|
|
25
|
+
/**
|
|
26
|
+
* ```typescript
|
|
27
|
+
* {
|
|
28
|
+
* start: { line: 0, character: 0 },
|
|
29
|
+
* end: { line: Infinity, character: Infinity }
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
const Full: Readonly<PositionRange>;
|
|
34
|
+
function toString(range: PositionRange): string;
|
|
35
|
+
function contains(range: PositionRange, pos: Position): boolean;
|
|
36
|
+
function endsBefore(range: PositionRange, pos: Position): boolean;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=PositionRange.d.ts.map
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PositionRange = void 0;
|
|
4
|
+
const Position_1 = require("./Position");
|
|
5
|
+
const Range_1 = require("./Range");
|
|
6
|
+
var PositionRange;
|
|
7
|
+
(function (PositionRange) {
|
|
8
|
+
function create(param1, param2, param3, param4) {
|
|
9
|
+
if (typeof param1 === 'number') {
|
|
10
|
+
return {
|
|
11
|
+
start: Position_1.Position.create(param1, param2),
|
|
12
|
+
end: Position_1.Position.create(param3, param4),
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
else if (param2 !== undefined) {
|
|
16
|
+
return {
|
|
17
|
+
start: Position_1.Position.create(param1),
|
|
18
|
+
end: Position_1.Position.create(param2),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
const partial = param1;
|
|
23
|
+
return {
|
|
24
|
+
start: Position_1.Position.create(partial.start ?? {}),
|
|
25
|
+
end: Position_1.Position.create(partial.end ?? {}),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
PositionRange.create = create;
|
|
30
|
+
/**
|
|
31
|
+
* @returns A `PositionRange` converted from a `RangeLike`.
|
|
32
|
+
*/
|
|
33
|
+
function from(range, doc) {
|
|
34
|
+
const _range = Range_1.Range.get(range);
|
|
35
|
+
const ans = {
|
|
36
|
+
start: doc.positionAt(_range.start),
|
|
37
|
+
end: doc.positionAt(_range.end),
|
|
38
|
+
};
|
|
39
|
+
return ans;
|
|
40
|
+
}
|
|
41
|
+
PositionRange.from = from;
|
|
42
|
+
/**
|
|
43
|
+
* ```typescript
|
|
44
|
+
* {
|
|
45
|
+
* start: { line: 0, character: 0 },
|
|
46
|
+
* end: { line: 0, character: 1 }
|
|
47
|
+
* }
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
PositionRange.Beginning = Object.freeze(PositionRange.create(0, 0, 0, 1));
|
|
51
|
+
/**
|
|
52
|
+
* ```typescript
|
|
53
|
+
* {
|
|
54
|
+
* start: { line: 0, character: 0 },
|
|
55
|
+
* end: { line: Infinity, character: Infinity }
|
|
56
|
+
* }
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
PositionRange.Full = Object.freeze(PositionRange.create(Position_1.Position.Beginning, Position_1.Position.Infinity));
|
|
60
|
+
function toString(range) {
|
|
61
|
+
return `[${Position_1.Position.toString(range.start)}, ${Position_1.Position.toString(range.end)})`;
|
|
62
|
+
}
|
|
63
|
+
PositionRange.toString = toString;
|
|
64
|
+
function contains(range, pos) {
|
|
65
|
+
const { start, end } = range;
|
|
66
|
+
// Check range of line number.
|
|
67
|
+
if (pos.line < start.line || pos.line > end.line) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
if (start.line < pos.line && pos.line < end.line) {
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
// Now `pos` is in the same line as `start` and/or `end`.
|
|
74
|
+
return ((pos.line === start.line ? pos.character >= start.character : true) &&
|
|
75
|
+
(pos.line === end.line ? pos.character < end.character : true));
|
|
76
|
+
}
|
|
77
|
+
PositionRange.contains = contains;
|
|
78
|
+
function endsBefore(range, pos) {
|
|
79
|
+
return Position_1.Position.isBefore(Position_1.Position.create(range.end.line, range.end.character - 1), pos);
|
|
80
|
+
}
|
|
81
|
+
PositionRange.endsBefore = endsBefore;
|
|
82
|
+
})(PositionRange = exports.PositionRange || (exports.PositionRange = {}));
|
|
83
|
+
//# sourceMappingURL=PositionRange.js.map
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { OffsetLike } from './Offset';
|
|
2
|
+
export declare type RangeLike = Range | RangeContainer | OffsetLike | ((this: void) => Range | RangeContainer | OffsetLike);
|
|
3
|
+
export interface Range {
|
|
4
|
+
start: number;
|
|
5
|
+
end: number;
|
|
6
|
+
}
|
|
7
|
+
export declare namespace Range {
|
|
8
|
+
/**
|
|
9
|
+
* Gets a range from `RangeLike`.
|
|
10
|
+
*
|
|
11
|
+
* @returns
|
|
12
|
+
* - `Range`: a clone of it.
|
|
13
|
+
* - `RangeContainer`: a clone of its range.
|
|
14
|
+
* - `OffsetLike`: a range with both positions set to the offset.
|
|
15
|
+
*/
|
|
16
|
+
function get(range: RangeLike): Range;
|
|
17
|
+
/**
|
|
18
|
+
* Creates a range from `OffsetLike`. If only `start` is passed in, `end` will be the same value as `start`.
|
|
19
|
+
*/
|
|
20
|
+
function create(start: OffsetLike, end?: OffsetLike): Range;
|
|
21
|
+
/**
|
|
22
|
+
* Creates a range that covers the area between `from.start` and `to.end`.
|
|
23
|
+
*/
|
|
24
|
+
function span(from: RangeLike, to: RangeLike): Range;
|
|
25
|
+
function is(obj: unknown): obj is Range;
|
|
26
|
+
/**
|
|
27
|
+
* ```typescript
|
|
28
|
+
* { start: 0, end: 1 }
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
const Beginning: Readonly<Range>;
|
|
32
|
+
/**
|
|
33
|
+
* ```typescript
|
|
34
|
+
* { start: 0, end: Infinity }
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
const Full: Readonly<Range>;
|
|
38
|
+
function toString(range: Range): string;
|
|
39
|
+
function contains(range: RangeLike, offset: number, endInclusive?: boolean): boolean;
|
|
40
|
+
function containsRange(a: RangeLike, b: RangeLike, endInclusive?: boolean): boolean;
|
|
41
|
+
function intersects(a: Range, b: Range): boolean;
|
|
42
|
+
function equals(a: Range, b: Range): boolean;
|
|
43
|
+
function endsBefore(range: Range, target: RangeLike, endInclusive?: boolean): boolean;
|
|
44
|
+
function isEmpty(range: RangeLike): boolean;
|
|
45
|
+
function length(range: Range): number;
|
|
46
|
+
/**
|
|
47
|
+
* @returns Negative when `a` is before `b`, `0` if they intersect, and positive if it's after.
|
|
48
|
+
*/
|
|
49
|
+
function compare(a: Range, b: Range, endInclusive?: boolean): number;
|
|
50
|
+
/**
|
|
51
|
+
* @returns Negative when `range` is before `offset`, `0` if it {@link contains} `offset`, and positive if it's after.
|
|
52
|
+
*/
|
|
53
|
+
function compareOffset(range: Range, offset: number, endInclusive?: boolean): number;
|
|
54
|
+
/**
|
|
55
|
+
* @param startOffset The number to offset the start of the `range`.
|
|
56
|
+
* @param endOffset The number to offset the end of the `range`. Default: `startOffset`.
|
|
57
|
+
* @returns A copy of `range`.
|
|
58
|
+
*/
|
|
59
|
+
function translate(range: RangeLike, startOffset: number, endOffset?: number): Range;
|
|
60
|
+
}
|
|
61
|
+
export interface RangeContainer {
|
|
62
|
+
range: Range;
|
|
63
|
+
[key: string]: any;
|
|
64
|
+
}
|
|
65
|
+
export declare namespace RangeContainer {
|
|
66
|
+
function is(obj: unknown): obj is RangeContainer;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=Range.d.ts.map
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RangeContainer = exports.Range = void 0;
|
|
4
|
+
const Offset_1 = require("./Offset");
|
|
5
|
+
var Range;
|
|
6
|
+
(function (Range) {
|
|
7
|
+
/**
|
|
8
|
+
* Gets a range from `RangeLike`.
|
|
9
|
+
*
|
|
10
|
+
* @returns
|
|
11
|
+
* - `Range`: a clone of it.
|
|
12
|
+
* - `RangeContainer`: a clone of its range.
|
|
13
|
+
* - `OffsetLike`: a range with both positions set to the offset.
|
|
14
|
+
*/
|
|
15
|
+
function get(range) {
|
|
16
|
+
const evaluated = typeof range === 'function' ? range() : range;
|
|
17
|
+
if (Range.is(evaluated)) {
|
|
18
|
+
return Range.create(evaluated.start, evaluated.end);
|
|
19
|
+
}
|
|
20
|
+
if (RangeContainer.is(evaluated)) {
|
|
21
|
+
return Range.create(evaluated.range.start, evaluated.range.end);
|
|
22
|
+
}
|
|
23
|
+
return Range.create(evaluated);
|
|
24
|
+
}
|
|
25
|
+
Range.get = get;
|
|
26
|
+
/**
|
|
27
|
+
* Creates a range from `OffsetLike`. If only `start` is passed in, `end` will be the same value as `start`.
|
|
28
|
+
*/
|
|
29
|
+
function create(start, end) {
|
|
30
|
+
start = Offset_1.Offset.get(start);
|
|
31
|
+
return {
|
|
32
|
+
start,
|
|
33
|
+
end: end !== undefined ? Offset_1.Offset.get(end) : start,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
Range.create = create;
|
|
37
|
+
/**
|
|
38
|
+
* Creates a range that covers the area between `from.start` and `to.end`.
|
|
39
|
+
*/
|
|
40
|
+
function span(from, to) {
|
|
41
|
+
return {
|
|
42
|
+
start: Range.get(from).start,
|
|
43
|
+
end: Range.get(to).end,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
Range.span = span;
|
|
47
|
+
function is(obj) {
|
|
48
|
+
return (!!obj && typeof obj === 'object' &&
|
|
49
|
+
typeof obj.start === 'number' &&
|
|
50
|
+
typeof obj.end === 'number');
|
|
51
|
+
}
|
|
52
|
+
Range.is = is;
|
|
53
|
+
/**
|
|
54
|
+
* ```typescript
|
|
55
|
+
* { start: 0, end: 1 }
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
Range.Beginning = Object.freeze(Range.create(0, 1));
|
|
59
|
+
/**
|
|
60
|
+
* ```typescript
|
|
61
|
+
* { start: 0, end: Infinity }
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
Range.Full = Object.freeze(Range.create(0, Number.POSITIVE_INFINITY));
|
|
65
|
+
function toString(range) {
|
|
66
|
+
return `[${range.start}, ${range.end})`;
|
|
67
|
+
}
|
|
68
|
+
Range.toString = toString;
|
|
69
|
+
function contains(range, offset, endInclusive = false) {
|
|
70
|
+
range = get(range);
|
|
71
|
+
return range.start <= offset && (endInclusive ? offset <= range.end : offset < range.end);
|
|
72
|
+
}
|
|
73
|
+
Range.contains = contains;
|
|
74
|
+
function containsRange(a, b, endInclusive = false) {
|
|
75
|
+
a = get(a);
|
|
76
|
+
b = get(b);
|
|
77
|
+
return contains(a, b.start, endInclusive) && contains(a, b.end, true);
|
|
78
|
+
}
|
|
79
|
+
Range.containsRange = containsRange;
|
|
80
|
+
function intersects(a, b) {
|
|
81
|
+
return Range.contains(a, b.start) || Range.contains(b, a.start);
|
|
82
|
+
}
|
|
83
|
+
Range.intersects = intersects;
|
|
84
|
+
function equals(a, b) {
|
|
85
|
+
return a.start === b.start && a.end === b.end;
|
|
86
|
+
}
|
|
87
|
+
Range.equals = equals;
|
|
88
|
+
function endsBefore(range, target, endInclusive = false) {
|
|
89
|
+
return endInclusive
|
|
90
|
+
? range.end < Range.get(target).start
|
|
91
|
+
: range.end <= Range.get(target).start;
|
|
92
|
+
}
|
|
93
|
+
Range.endsBefore = endsBefore;
|
|
94
|
+
function isEmpty(range) {
|
|
95
|
+
range = get(range);
|
|
96
|
+
return range.start === range.end;
|
|
97
|
+
}
|
|
98
|
+
Range.isEmpty = isEmpty;
|
|
99
|
+
function length(range) {
|
|
100
|
+
return range.end - range.start;
|
|
101
|
+
}
|
|
102
|
+
Range.length = length;
|
|
103
|
+
/**
|
|
104
|
+
* @returns Negative when `a` is before `b`, `0` if they intersect, and positive if it's after.
|
|
105
|
+
*/
|
|
106
|
+
function compare(a, b, endInclusive = false) {
|
|
107
|
+
if (endInclusive ? a.end < b.start : a.end <= b.start) {
|
|
108
|
+
return -1;
|
|
109
|
+
}
|
|
110
|
+
else if (endInclusive ? a.start > b.end : a.start >= b.end) {
|
|
111
|
+
return 1;
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
return 0;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
Range.compare = compare;
|
|
118
|
+
/**
|
|
119
|
+
* @returns Negative when `range` is before `offset`, `0` if it {@link contains} `offset`, and positive if it's after.
|
|
120
|
+
*/
|
|
121
|
+
function compareOffset(range, offset, endInclusive = false) {
|
|
122
|
+
if (endInclusive ? range.end < offset : range.end <= offset) {
|
|
123
|
+
return -1;
|
|
124
|
+
}
|
|
125
|
+
else if (range.start > offset) {
|
|
126
|
+
return 1;
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
return 0;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
Range.compareOffset = compareOffset;
|
|
133
|
+
/**
|
|
134
|
+
* @param startOffset The number to offset the start of the `range`.
|
|
135
|
+
* @param endOffset The number to offset the end of the `range`. Default: `startOffset`.
|
|
136
|
+
* @returns A copy of `range`.
|
|
137
|
+
*/
|
|
138
|
+
function translate(range, startOffset, endOffset = startOffset) {
|
|
139
|
+
range = get(range);
|
|
140
|
+
return {
|
|
141
|
+
start: range.start + startOffset,
|
|
142
|
+
end: range.end + endOffset,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
Range.translate = translate;
|
|
146
|
+
})(Range = exports.Range || (exports.Range = {}));
|
|
147
|
+
var RangeContainer;
|
|
148
|
+
(function (RangeContainer) {
|
|
149
|
+
function is(obj) {
|
|
150
|
+
return (!!obj && typeof obj === 'object' &&
|
|
151
|
+
Range.is(obj.range));
|
|
152
|
+
}
|
|
153
|
+
RangeContainer.is = is;
|
|
154
|
+
})(RangeContainer = exports.RangeContainer || (exports.RangeContainer = {}));
|
|
155
|
+
//# sourceMappingURL=Range.js.map
|