@spyglassmc/core 0.1.1 → 0.3.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.d.ts +21 -0
- package/lib/common/TwoWayMap.js +69 -0
- package/lib/common/externals/BrowserExternals.d.ts +3 -0
- package/lib/common/externals/BrowserExternals.js +191 -0
- package/lib/common/externals/NodeJsExternals.d.ts +3 -0
- package/lib/common/externals/NodeJsExternals.js +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 -13
- package/lib/common/util.d.ts +50 -39
- package/lib/common/util.js +73 -122
- package/lib/index.d.ts +7 -7
- package/lib/index.js +7 -19
- 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 +5 -5
- package/lib/node/LiteralNode.js +5 -8
- 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 +8 -10
- package/lib/node/ResourceLocationNode.js +9 -12
- package/lib/node/Sequence.d.ts +4 -3
- package/lib/node/Sequence.js +4 -6
- package/lib/node/StringNode.d.ts +5 -5
- package/lib/node/StringNode.js +9 -12
- package/lib/node/SymbolNode.d.ts +5 -5
- package/lib/node/SymbolNode.js +5 -8
- package/lib/node/index.d.ts +15 -15
- package/lib/node/index.js +15 -27
- package/lib/nodejs.d.ts +2 -0
- package/lib/nodejs.js +2 -0
- package/lib/parser/Parser.d.ts +3 -3
- package/lib/parser/Parser.js +1 -4
- package/lib/parser/boolean.d.ts +2 -2
- package/lib/parser/boolean.js +3 -6
- package/lib/parser/comment.d.ts +2 -2
- package/lib/parser/comment.js +5 -9
- package/lib/parser/empty.d.ts +1 -1
- package/lib/parser/empty.js +1 -5
- package/lib/parser/error.d.ts +2 -2
- package/lib/parser/error.js +5 -9
- package/lib/parser/file.d.ts +3 -3
- package/lib/parser/file.js +9 -13
- package/lib/parser/float.d.ts +4 -4
- package/lib/parser/float.js +12 -16
- package/lib/parser/index.d.ts +16 -16
- package/lib/parser/index.js +16 -34
- package/lib/parser/integer.d.ts +4 -4
- package/lib/parser/integer.js +10 -14
- package/lib/parser/list.d.ts +2 -2
- package/lib/parser/list.js +15 -19
- package/lib/parser/literal.d.ts +2 -2
- package/lib/parser/literal.js +5 -9
- package/lib/parser/long.d.ts +4 -4
- package/lib/parser/long.js +10 -14
- package/lib/parser/record.d.ts +3 -3
- package/lib/parser/record.js +20 -24
- package/lib/parser/resourceLocation.d.ts +2 -2
- package/lib/parser/resourceLocation.js +12 -24
- package/lib/parser/string.d.ts +7 -7
- package/lib/parser/string.js +40 -44
- package/lib/parser/symbol.d.ts +3 -3
- package/lib/parser/symbol.js +4 -14
- package/lib/parser/util.d.ts +30 -12
- package/lib/parser/util.js +78 -65
- 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 -27
- 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 +33 -46
- package/lib/processor/colorizer/index.d.ts +2 -2
- package/lib/processor/colorizer/index.js +2 -27
- package/lib/processor/completer/Completer.d.ts +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 +59 -75
- package/lib/processor/completer/index.d.ts +2 -2
- package/lib/processor/completer/index.js +2 -27
- 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 -27
- package/lib/processor/index.d.ts +10 -9
- package/lib/processor/index.js +10 -21
- 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 +23 -27
- 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 -27
- package/lib/processor/util.d.ts +4 -14
- package/lib/processor/util.js +1 -16
- package/lib/service/CacheService.d.ts +8 -6
- package/lib/service/CacheService.js +35 -56
- package/lib/service/Config.d.ts +17 -16
- package/lib/service/Config.js +56 -51
- package/lib/service/Context.d.ts +24 -21
- package/lib/service/Context.js +40 -36
- package/lib/service/Dependency.js +2 -5
- package/lib/service/Downloader.d.ts +9 -39
- package/lib/service/Downloader.js +37 -106
- package/lib/service/ErrorReporter.d.ts +2 -2
- package/lib/service/ErrorReporter.js +11 -15
- package/lib/service/FileService.d.ts +40 -14
- package/lib/service/FileService.js +107 -81
- package/lib/service/Hover.d.ts +2 -2
- package/lib/service/Hover.js +4 -7
- package/lib/service/MetaRegistry.d.ts +17 -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 +101 -73
- package/lib/service/Project.js +438 -367
- package/lib/service/Service.d.ts +19 -29
- package/lib/service/Service.js +57 -53
- package/lib/service/SymbolLocations.d.ts +3 -3
- package/lib/service/SymbolLocations.js +4 -7
- package/lib/service/SymbolRegistrar.d.ts +1 -1
- package/lib/service/SymbolRegistrar.js +1 -2
- package/lib/service/UriProcessor.d.ts +5 -0
- package/lib/service/UriProcessor.js +2 -0
- package/lib/service/fileUtil.d.ts +21 -41
- package/lib/service/fileUtil.js +59 -129
- package/lib/service/index.d.ts +16 -17
- package/lib/service/index.js +16 -31
- package/lib/source/IndexMap.d.ts +1 -1
- package/lib/source/IndexMap.js +7 -10
- package/lib/source/LanguageError.d.ts +2 -2
- package/lib/source/LanguageError.js +3 -6
- package/lib/source/Location.d.ts +3 -3
- package/lib/source/Location.js +6 -9
- package/lib/source/Offset.d.ts +1 -1
- package/lib/source/Offset.js +4 -7
- package/lib/source/Position.js +2 -5
- package/lib/source/PositionRange.d.ts +2 -2
- package/lib/source/PositionRange.js +14 -17
- package/lib/source/Range.d.ts +1 -1
- package/lib/source/Range.js +7 -10
- package/lib/source/Source.d.ts +9 -4
- package/lib/source/Source.js +58 -31
- package/lib/source/index.d.ts +8 -8
- package/lib/source/index.js +8 -20
- package/lib/symbol/Symbol.d.ts +15 -14
- package/lib/symbol/Symbol.js +53 -68
- package/lib/symbol/SymbolUtil.d.ts +30 -39
- package/lib/symbol/SymbolUtil.js +189 -168
- package/lib/symbol/index.d.ts +2 -3
- package/lib/symbol/index.js +2 -15
- 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/service/Config.js
CHANGED
|
@@ -1,15 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.ConfigService = exports.VanillaConfig = exports.SymbolLinterConfig = exports.LinterConfigValue = exports.LinterSeverity = void 0;
|
|
7
|
-
const events_1 = __importDefault(require("events"));
|
|
8
|
-
const fs_1 = require("fs");
|
|
9
|
-
const rfdc_1 = __importDefault(require("rfdc"));
|
|
10
|
-
const common_1 = require("../common");
|
|
11
|
-
const symbol_1 = require("../symbol");
|
|
12
|
-
var LinterSeverity;
|
|
1
|
+
import rfdc from 'rfdc';
|
|
2
|
+
import { Arrayable, bufferToString, TypePredicates } from '../common/index.js';
|
|
3
|
+
import { FileCategories, RegistryCategories } from '../symbol/index.js';
|
|
4
|
+
export var LinterSeverity;
|
|
13
5
|
(function (LinterSeverity) {
|
|
14
6
|
function is(value) {
|
|
15
7
|
return value === 'hint' ||
|
|
@@ -21,18 +13,18 @@ var LinterSeverity;
|
|
|
21
13
|
function toErrorSeverity(value) {
|
|
22
14
|
switch (value) {
|
|
23
15
|
case 'error':
|
|
24
|
-
return 3 /* Error */;
|
|
16
|
+
return 3 /* ErrorSeverity.Error */;
|
|
25
17
|
case 'hint':
|
|
26
|
-
return 0 /* Hint */;
|
|
18
|
+
return 0 /* ErrorSeverity.Hint */;
|
|
27
19
|
case 'information':
|
|
28
|
-
return 1 /* Information */;
|
|
20
|
+
return 1 /* ErrorSeverity.Information */;
|
|
29
21
|
case 'warning':
|
|
30
|
-
return 2 /* Warning */;
|
|
22
|
+
return 2 /* ErrorSeverity.Warning */;
|
|
31
23
|
}
|
|
32
24
|
}
|
|
33
25
|
LinterSeverity.toErrorSeverity = toErrorSeverity;
|
|
34
|
-
})(LinterSeverity
|
|
35
|
-
var LinterConfigValue;
|
|
26
|
+
})(LinterSeverity || (LinterSeverity = {}));
|
|
27
|
+
export var LinterConfigValue;
|
|
36
28
|
(function (LinterConfigValue) {
|
|
37
29
|
function destruct(value) {
|
|
38
30
|
if (value === null || value === undefined) {
|
|
@@ -51,16 +43,16 @@ var LinterConfigValue;
|
|
|
51
43
|
};
|
|
52
44
|
}
|
|
53
45
|
return {
|
|
54
|
-
ruleSeverity: 2 /* Warning */,
|
|
46
|
+
ruleSeverity: 2 /* ErrorSeverity.Warning */,
|
|
55
47
|
ruleValue: value,
|
|
56
48
|
};
|
|
57
49
|
}
|
|
58
50
|
LinterConfigValue.destruct = destruct;
|
|
59
|
-
})(LinterConfigValue
|
|
60
|
-
var SymbolLinterConfig;
|
|
51
|
+
})(LinterConfigValue || (LinterConfigValue = {}));
|
|
52
|
+
export var SymbolLinterConfig;
|
|
61
53
|
(function (SymbolLinterConfig) {
|
|
62
54
|
function is(value) {
|
|
63
|
-
return
|
|
55
|
+
return Arrayable.is(value, Complex.is) || Action.is(value);
|
|
64
56
|
}
|
|
65
57
|
SymbolLinterConfig.is = is;
|
|
66
58
|
let Complex;
|
|
@@ -70,9 +62,9 @@ var SymbolLinterConfig;
|
|
|
70
62
|
return false;
|
|
71
63
|
}
|
|
72
64
|
const value = v;
|
|
73
|
-
return ((value.if === undefined ||
|
|
65
|
+
return ((value.if === undefined || Arrayable.is(value.if, Condition.is)) &&
|
|
74
66
|
(value.then === undefined || Action.is(value.then)) &&
|
|
75
|
-
(value.override === undefined ||
|
|
67
|
+
(value.override === undefined || Arrayable.is(value.override, Complex.is)));
|
|
76
68
|
}
|
|
77
69
|
Complex.is = is;
|
|
78
70
|
})(Complex = SymbolLinterConfig.Complex || (SymbolLinterConfig.Complex = {}));
|
|
@@ -83,11 +75,11 @@ var SymbolLinterConfig;
|
|
|
83
75
|
return false;
|
|
84
76
|
}
|
|
85
77
|
const value = v;
|
|
86
|
-
return ((value.category === undefined ||
|
|
87
|
-
(value.pattern === undefined ||
|
|
88
|
-
(value.excludePattern === undefined ||
|
|
89
|
-
(value.namespace === undefined ||
|
|
90
|
-
(value.excludeNamespace === undefined ||
|
|
78
|
+
return ((value.category === undefined || Arrayable.is(value.category, TypePredicates.isString)) &&
|
|
79
|
+
(value.pattern === undefined || Arrayable.is(value.pattern, TypePredicates.isString)) &&
|
|
80
|
+
(value.excludePattern === undefined || Arrayable.is(value.excludePattern, TypePredicates.isString)) &&
|
|
81
|
+
(value.namespace === undefined || Arrayable.is(value.namespace, TypePredicates.isString)) &&
|
|
82
|
+
(value.excludeNamespace === undefined || Arrayable.is(value.excludeNamespace, TypePredicates.isString)));
|
|
91
83
|
}
|
|
92
84
|
Condition.is = is;
|
|
93
85
|
})(Condition = SymbolLinterConfig.Condition || (SymbolLinterConfig.Condition = {}));
|
|
@@ -110,15 +102,15 @@ var SymbolLinterConfig;
|
|
|
110
102
|
}
|
|
111
103
|
Action.is = is;
|
|
112
104
|
})(Action = SymbolLinterConfig.Action || (SymbolLinterConfig.Action = {}));
|
|
113
|
-
})(SymbolLinterConfig
|
|
105
|
+
})(SymbolLinterConfig || (SymbolLinterConfig = {}));
|
|
114
106
|
/**
|
|
115
107
|
* Config which simulates the default vanilla command system.
|
|
116
108
|
*/
|
|
117
|
-
|
|
109
|
+
export const VanillaConfig = {
|
|
118
110
|
env: {
|
|
119
111
|
dataSource: 'GitHub',
|
|
120
112
|
dependencies: [
|
|
121
|
-
'@
|
|
113
|
+
'@vanilla-mcdoc',
|
|
122
114
|
],
|
|
123
115
|
feature: {
|
|
124
116
|
codeActions: true,
|
|
@@ -195,8 +187,8 @@ exports.VanillaConfig = {
|
|
|
195
187
|
undeclaredSymbol: [
|
|
196
188
|
{
|
|
197
189
|
if: [
|
|
198
|
-
{ category:
|
|
199
|
-
{ category: [...
|
|
190
|
+
{ category: RegistryCategories, namespace: 'minecraft' },
|
|
191
|
+
{ category: [...FileCategories, 'bossbar', 'objective', 'team'] },
|
|
200
192
|
],
|
|
201
193
|
then: { report: 'warning' },
|
|
202
194
|
},
|
|
@@ -210,10 +202,18 @@ exports.VanillaConfig = {
|
|
|
210
202
|
summonAec: 'summon minecraft:area_effect_cloud ~ ~ ~ {Age: -2147483648, Duration: -1, WaitTime: -2147483648, Tags: ["${1:tag}"]}',
|
|
211
203
|
},
|
|
212
204
|
};
|
|
213
|
-
class ConfigService
|
|
214
|
-
|
|
215
|
-
|
|
205
|
+
export class ConfigService {
|
|
206
|
+
project;
|
|
207
|
+
defaultConfig;
|
|
208
|
+
static ConfigFileNames = Object.freeze([
|
|
209
|
+
'spyglass.json',
|
|
210
|
+
'.spyglassrc.json',
|
|
211
|
+
]);
|
|
212
|
+
#eventEmitter;
|
|
213
|
+
constructor(project, defaultConfig = VanillaConfig) {
|
|
216
214
|
this.project = project;
|
|
215
|
+
this.defaultConfig = defaultConfig;
|
|
216
|
+
this.#eventEmitter = new project.externals.event.EventEmitter();
|
|
217
217
|
const handler = async ({ uri }) => {
|
|
218
218
|
if (ConfigService.isConfigFile(uri)) {
|
|
219
219
|
this.emit('changed', { config: await this.load() });
|
|
@@ -223,31 +223,41 @@ class ConfigService extends events_1.default {
|
|
|
223
223
|
project.on('fileModified', handler);
|
|
224
224
|
project.on('fileDeleted', handler);
|
|
225
225
|
}
|
|
226
|
+
on(event, callbackFn) {
|
|
227
|
+
this.#eventEmitter.on(event, callbackFn);
|
|
228
|
+
return this;
|
|
229
|
+
}
|
|
230
|
+
once(event, callbackFn) {
|
|
231
|
+
this.#eventEmitter.once(event, callbackFn);
|
|
232
|
+
return this;
|
|
233
|
+
}
|
|
234
|
+
emit(event, ...args) {
|
|
235
|
+
return this.#eventEmitter.emit(event, ...args);
|
|
236
|
+
}
|
|
226
237
|
async load() {
|
|
227
|
-
let ans =
|
|
238
|
+
let ans = this.defaultConfig;
|
|
228
239
|
for (const name of ConfigService.ConfigFileNames) {
|
|
229
|
-
const
|
|
230
|
-
const uri = new common_1.Uri(uriString);
|
|
240
|
+
const uri = this.project.projectRoot + name;
|
|
231
241
|
try {
|
|
232
|
-
ans = JSON.parse(
|
|
242
|
+
ans = JSON.parse(bufferToString(await this.project.externals.fs.readFile(uri)));
|
|
233
243
|
}
|
|
234
244
|
catch (e) {
|
|
235
|
-
if ((
|
|
245
|
+
if (this.project.externals.error.isKind(e, 'ENOENT')) {
|
|
236
246
|
// File doesn't exist.
|
|
237
247
|
continue;
|
|
238
248
|
}
|
|
239
|
-
this.emit('error', { error: e, uri
|
|
249
|
+
this.emit('error', { error: e, uri });
|
|
240
250
|
}
|
|
241
251
|
break;
|
|
242
252
|
}
|
|
243
|
-
return
|
|
253
|
+
return ConfigService.merge(this.defaultConfig, ans);
|
|
244
254
|
}
|
|
245
255
|
static isConfigFile(uri) {
|
|
246
256
|
return ConfigService.ConfigFileNames.some(n => uri.endsWith(`/${n}`));
|
|
247
257
|
}
|
|
248
|
-
merge(base, ...overrides) {
|
|
258
|
+
static merge(base, ...overrides) {
|
|
249
259
|
// FIXME
|
|
250
|
-
const ans = (
|
|
260
|
+
const ans = rfdc()(base);
|
|
251
261
|
for (const override of overrides) {
|
|
252
262
|
for (const key of ['env', 'format', 'lint', 'snippet']) {
|
|
253
263
|
ans[key] = { ...ans[key], ...override[key] };
|
|
@@ -256,9 +266,4 @@ class ConfigService extends events_1.default {
|
|
|
256
266
|
return ans;
|
|
257
267
|
}
|
|
258
268
|
}
|
|
259
|
-
exports.ConfigService = ConfigService;
|
|
260
|
-
ConfigService.ConfigFileNames = Object.freeze([
|
|
261
|
-
'spyglass.json',
|
|
262
|
-
'.spyglassrc.json',
|
|
263
|
-
]);
|
|
264
269
|
//# sourceMappingURL=Config.js.map
|
package/lib/service/Context.d.ts
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
import type { TextDocument } from 'vscode-languageserver-textdocument';
|
|
2
|
-
import type {
|
|
3
|
-
import type { Range } from '../source';
|
|
4
|
-
import { ReadonlySource } from '../source';
|
|
5
|
-
import type {
|
|
6
|
-
import type { Config } from './Config';
|
|
7
|
-
import { ErrorReporter } from './ErrorReporter';
|
|
8
|
-
import type { FileService } from './FileService';
|
|
9
|
-
import type { RootUriString } from './fileUtil';
|
|
10
|
-
import type {
|
|
11
|
-
import type { MetaRegistry } from './MetaRegistry';
|
|
12
|
-
import {
|
|
13
|
-
import type {
|
|
2
|
+
import type { Logger } from '../common/index.js';
|
|
3
|
+
import type { Range } from '../source/index.js';
|
|
4
|
+
import { ReadonlySource } from '../source/index.js';
|
|
5
|
+
import type { SymbolUtil } from '../symbol/index.js';
|
|
6
|
+
import type { Config } from './Config.js';
|
|
7
|
+
import { ErrorReporter } from './ErrorReporter.js';
|
|
8
|
+
import type { FileService } from './FileService.js';
|
|
9
|
+
import type { RootUriString } from './fileUtil.js';
|
|
10
|
+
import type { LinterErrorReporter } from './index.js';
|
|
11
|
+
import type { MetaRegistry } from './MetaRegistry.js';
|
|
12
|
+
import type { ProfilerFactory } from './Profiler.js';
|
|
13
|
+
import type { ProjectData } from './Project.js';
|
|
14
14
|
export interface ContextBase {
|
|
15
15
|
fs: FileService;
|
|
16
|
-
getDocAndNode: (uri: string) => DocAndNode | undefined;
|
|
17
|
-
global: SymbolTable;
|
|
18
16
|
logger: Logger;
|
|
19
17
|
meta: MetaRegistry;
|
|
18
|
+
profilers: ProfilerFactory;
|
|
20
19
|
project: Record<string, string>;
|
|
21
20
|
roots: readonly RootUriString[];
|
|
22
21
|
}
|
|
@@ -27,8 +26,6 @@ export interface ParserContext extends ContextBase {
|
|
|
27
26
|
config: Config;
|
|
28
27
|
doc: TextDocument;
|
|
29
28
|
err: ErrorReporter;
|
|
30
|
-
/** @deprecated */
|
|
31
|
-
symbols: SymbolUtil;
|
|
32
29
|
}
|
|
33
30
|
interface ParserContextOptions {
|
|
34
31
|
doc: TextDocument;
|
|
@@ -41,7 +38,6 @@ export interface ProcessorContext extends ContextBase {
|
|
|
41
38
|
config: Config;
|
|
42
39
|
doc: TextDocument;
|
|
43
40
|
src: ReadonlySource;
|
|
44
|
-
/** @deprecated */
|
|
45
41
|
symbols: SymbolUtil;
|
|
46
42
|
}
|
|
47
43
|
interface ProcessorContextOptions {
|
|
@@ -69,14 +65,22 @@ interface ProcessorWithOffsetContextOptions extends ProcessorContextOptions {
|
|
|
69
65
|
declare namespace ProcessorWithOffsetContext {
|
|
70
66
|
function create(project: ProjectData, opts: ProcessorWithOffsetContextOptions): ProcessorWithOffsetContext;
|
|
71
67
|
}
|
|
68
|
+
export interface BinderContext extends ProcessorContext {
|
|
69
|
+
err: ErrorReporter;
|
|
70
|
+
ensureBindingStarted: (this: void, uri: string) => Promise<unknown>;
|
|
71
|
+
}
|
|
72
|
+
interface BinderContextOptions extends ProcessorContextOptions {
|
|
73
|
+
err?: ErrorReporter;
|
|
74
|
+
}
|
|
75
|
+
export declare namespace BinderContext {
|
|
76
|
+
function create(project: ProjectData, opts: BinderContextOptions): BinderContext;
|
|
77
|
+
}
|
|
72
78
|
export interface CheckerContext extends ProcessorContext {
|
|
73
79
|
err: ErrorReporter;
|
|
74
|
-
|
|
75
|
-
ensureChecked: (this: void, uri: string) => Promise<unknown>;
|
|
80
|
+
ensureBindingStarted: (this: void, uri: string) => Promise<unknown>;
|
|
76
81
|
}
|
|
77
82
|
interface CheckerContextOptions extends ProcessorContextOptions {
|
|
78
83
|
err?: ErrorReporter;
|
|
79
|
-
ops?: Operations;
|
|
80
84
|
}
|
|
81
85
|
export declare namespace CheckerContext {
|
|
82
86
|
function create(project: ProjectData, opts: CheckerContextOptions): CheckerContext;
|
|
@@ -133,7 +137,6 @@ export declare namespace SignatureHelpProviderContext {
|
|
|
133
137
|
function create(project: ProjectData, opts: SignatureHelpProviderContextOptions): SignatureHelpProviderContext;
|
|
134
138
|
}
|
|
135
139
|
export interface UriBinderContext extends ContextBase {
|
|
136
|
-
/** @deprecated */
|
|
137
140
|
symbols: SymbolUtil;
|
|
138
141
|
}
|
|
139
142
|
export declare namespace UriBinderContext {
|
package/lib/service/Context.js
CHANGED
|
@@ -1,52 +1,46 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/* istanbul ignore file */
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const ErrorReporter_1 = require("./ErrorReporter");
|
|
8
|
-
const Operations_1 = require("./Operations");
|
|
9
|
-
var ContextBase;
|
|
2
|
+
import { formatterContextIndentation } from '../processor/index.js';
|
|
3
|
+
import { ReadonlySource } from '../source/index.js';
|
|
4
|
+
import { ErrorReporter } from './ErrorReporter.js';
|
|
5
|
+
export var ContextBase;
|
|
10
6
|
(function (ContextBase) {
|
|
11
7
|
function create(project) {
|
|
12
8
|
return {
|
|
13
9
|
fs: project.fs,
|
|
14
|
-
getDocAndNode: project.get.bind(project),
|
|
15
|
-
global: project.symbols.global,
|
|
16
10
|
logger: project.logger,
|
|
17
11
|
meta: project.meta,
|
|
12
|
+
profilers: project.profilers,
|
|
18
13
|
roots: project.roots,
|
|
19
14
|
project: project.ctx,
|
|
20
15
|
};
|
|
21
16
|
}
|
|
22
17
|
ContextBase.create = create;
|
|
23
|
-
})(ContextBase
|
|
24
|
-
var ParserContext;
|
|
18
|
+
})(ContextBase || (ContextBase = {}));
|
|
19
|
+
export var ParserContext;
|
|
25
20
|
(function (ParserContext) {
|
|
26
21
|
function create(project, opts) {
|
|
27
22
|
return {
|
|
28
23
|
...ContextBase.create(project),
|
|
29
24
|
config: project.config,
|
|
30
25
|
doc: opts.doc,
|
|
31
|
-
err: opts.err ?? new
|
|
32
|
-
symbols: project.symbols,
|
|
26
|
+
err: opts.err ?? new ErrorReporter(),
|
|
33
27
|
};
|
|
34
28
|
}
|
|
35
29
|
ParserContext.create = create;
|
|
36
|
-
})(ParserContext
|
|
37
|
-
var ProcessorContext;
|
|
30
|
+
})(ParserContext || (ParserContext = {}));
|
|
31
|
+
export var ProcessorContext;
|
|
38
32
|
(function (ProcessorContext) {
|
|
39
33
|
function create(project, opts) {
|
|
40
34
|
return {
|
|
41
35
|
...ContextBase.create(project),
|
|
42
36
|
config: project.config,
|
|
43
37
|
doc: opts.doc,
|
|
44
|
-
src: opts.src ?? new
|
|
38
|
+
src: opts.src ?? new ReadonlySource(opts.doc.getText()),
|
|
45
39
|
symbols: project.symbols,
|
|
46
40
|
};
|
|
47
41
|
}
|
|
48
42
|
ProcessorContext.create = create;
|
|
49
|
-
})(ProcessorContext
|
|
43
|
+
})(ProcessorContext || (ProcessorContext = {}));
|
|
50
44
|
var ProcessorWithRangeContext;
|
|
51
45
|
(function (ProcessorWithRangeContext) {
|
|
52
46
|
function create(project, opts) {
|
|
@@ -67,19 +61,29 @@ var ProcessorWithOffsetContext;
|
|
|
67
61
|
}
|
|
68
62
|
ProcessorWithOffsetContext.create = create;
|
|
69
63
|
})(ProcessorWithOffsetContext || (ProcessorWithOffsetContext = {}));
|
|
70
|
-
var
|
|
64
|
+
export var BinderContext;
|
|
65
|
+
(function (BinderContext) {
|
|
66
|
+
function create(project, opts) {
|
|
67
|
+
return {
|
|
68
|
+
...ProcessorContext.create(project, opts),
|
|
69
|
+
err: opts.err ?? new ErrorReporter(),
|
|
70
|
+
ensureBindingStarted: project.ensureBindingStarted?.bind(project),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
BinderContext.create = create;
|
|
74
|
+
})(BinderContext || (BinderContext = {}));
|
|
75
|
+
export var CheckerContext;
|
|
71
76
|
(function (CheckerContext) {
|
|
72
77
|
function create(project, opts) {
|
|
73
78
|
return {
|
|
74
79
|
...ProcessorContext.create(project, opts),
|
|
75
|
-
err: opts.err ?? new
|
|
76
|
-
|
|
77
|
-
ensureChecked: project.ensureParsedAndChecked?.bind(project),
|
|
80
|
+
err: opts.err ?? new ErrorReporter(),
|
|
81
|
+
ensureBindingStarted: project.ensureBindingStarted?.bind(project),
|
|
78
82
|
};
|
|
79
83
|
}
|
|
80
84
|
CheckerContext.create = create;
|
|
81
|
-
})(CheckerContext
|
|
82
|
-
var LinterContext;
|
|
85
|
+
})(CheckerContext || (CheckerContext = {}));
|
|
86
|
+
export var LinterContext;
|
|
83
87
|
(function (LinterContext) {
|
|
84
88
|
function create(project, opts) {
|
|
85
89
|
return {
|
|
@@ -90,8 +94,8 @@ var LinterContext;
|
|
|
90
94
|
};
|
|
91
95
|
}
|
|
92
96
|
LinterContext.create = create;
|
|
93
|
-
})(LinterContext
|
|
94
|
-
var FormatterContext;
|
|
97
|
+
})(LinterContext || (LinterContext = {}));
|
|
98
|
+
export var FormatterContext;
|
|
95
99
|
(function (FormatterContext) {
|
|
96
100
|
function create(project, opts) {
|
|
97
101
|
return {
|
|
@@ -99,20 +103,20 @@ var FormatterContext;
|
|
|
99
103
|
...opts,
|
|
100
104
|
indentLevel: 0,
|
|
101
105
|
indent(additionalLevels) {
|
|
102
|
-
return
|
|
106
|
+
return formatterContextIndentation(this, additionalLevels);
|
|
103
107
|
},
|
|
104
108
|
};
|
|
105
109
|
}
|
|
106
110
|
FormatterContext.create = create;
|
|
107
|
-
})(FormatterContext
|
|
108
|
-
var ColorizerContext;
|
|
111
|
+
})(FormatterContext || (FormatterContext = {}));
|
|
112
|
+
export var ColorizerContext;
|
|
109
113
|
(function (ColorizerContext) {
|
|
110
114
|
function create(project, opts) {
|
|
111
115
|
return ProcessorWithRangeContext.create(project, opts);
|
|
112
116
|
}
|
|
113
117
|
ColorizerContext.create = create;
|
|
114
|
-
})(ColorizerContext
|
|
115
|
-
var CompleterContext;
|
|
118
|
+
})(ColorizerContext || (ColorizerContext = {}));
|
|
119
|
+
export var CompleterContext;
|
|
116
120
|
(function (CompleterContext) {
|
|
117
121
|
function create(project, opts) {
|
|
118
122
|
return {
|
|
@@ -122,15 +126,15 @@ var CompleterContext;
|
|
|
122
126
|
};
|
|
123
127
|
}
|
|
124
128
|
CompleterContext.create = create;
|
|
125
|
-
})(CompleterContext
|
|
126
|
-
var SignatureHelpProviderContext;
|
|
129
|
+
})(CompleterContext || (CompleterContext = {}));
|
|
130
|
+
export var SignatureHelpProviderContext;
|
|
127
131
|
(function (SignatureHelpProviderContext) {
|
|
128
132
|
function create(project, opts) {
|
|
129
133
|
return ProcessorWithOffsetContext.create(project, opts);
|
|
130
134
|
}
|
|
131
135
|
SignatureHelpProviderContext.create = create;
|
|
132
|
-
})(SignatureHelpProviderContext
|
|
133
|
-
var UriBinderContext;
|
|
136
|
+
})(SignatureHelpProviderContext || (SignatureHelpProviderContext = {}));
|
|
137
|
+
export var UriBinderContext;
|
|
134
138
|
(function (UriBinderContext) {
|
|
135
139
|
function create(project) {
|
|
136
140
|
return {
|
|
@@ -139,5 +143,5 @@ var UriBinderContext;
|
|
|
139
143
|
};
|
|
140
144
|
}
|
|
141
145
|
UriBinderContext.create = create;
|
|
142
|
-
})(UriBinderContext
|
|
146
|
+
})(UriBinderContext || (UriBinderContext = {}));
|
|
143
147
|
//# sourceMappingURL=Context.js.map
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DependencyKey = void 0;
|
|
4
|
-
var DependencyKey;
|
|
1
|
+
export var DependencyKey;
|
|
5
2
|
(function (DependencyKey) {
|
|
6
3
|
function is(value) {
|
|
7
4
|
return value.startsWith('@');
|
|
8
5
|
}
|
|
9
6
|
DependencyKey.is = is;
|
|
10
|
-
})(DependencyKey
|
|
7
|
+
})(DependencyKey || (DependencyKey = {}));
|
|
11
8
|
//# sourceMappingURL=Dependency.js.map
|
|
@@ -1,20 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
import type {
|
|
3
|
-
declare type RemoteProtocol = 'http:' | 'https:';
|
|
4
|
-
export declare type RemoteUriString = `${RemoteProtocol}${string}`;
|
|
5
|
-
export declare namespace RemoteUriString {
|
|
6
|
-
function getProtocol(uri: RemoteUriString): RemoteProtocol;
|
|
7
|
-
}
|
|
1
|
+
import type { ExternalDownloaderOptions, Externals, Logger, RemoteUriString } from '../common/index.js';
|
|
2
|
+
import type { RootUriString } from './fileUtil.js';
|
|
8
3
|
export interface DownloaderDownloadOut {
|
|
9
|
-
|
|
4
|
+
cacheUri?: string;
|
|
10
5
|
checksum?: string;
|
|
11
6
|
}
|
|
12
7
|
export declare class Downloader {
|
|
13
8
|
#private;
|
|
14
9
|
private readonly cacheRoot;
|
|
10
|
+
private readonly externals;
|
|
15
11
|
private readonly logger;
|
|
16
|
-
|
|
17
|
-
constructor(cacheRoot: string, logger: Logger, lld?: LowLevelDownloader);
|
|
12
|
+
constructor(cacheRoot: RootUriString, externals: Externals, logger: Logger);
|
|
18
13
|
download<R>(job: Job<R>, out?: DownloaderDownloadOut): Promise<R | undefined>;
|
|
19
14
|
}
|
|
20
15
|
interface Job<R> {
|
|
@@ -31,37 +26,12 @@ interface Job<R> {
|
|
|
31
26
|
*/
|
|
32
27
|
checksumJob: Omit<Job<string>, 'cache' | 'id'>;
|
|
33
28
|
checksumExtension: `.${string}`;
|
|
34
|
-
serializer?: (data:
|
|
35
|
-
deserializer?: (cache:
|
|
29
|
+
serializer?: (data: Uint8Array) => Uint8Array;
|
|
30
|
+
deserializer?: (cache: Uint8Array) => Uint8Array;
|
|
36
31
|
};
|
|
37
|
-
transformer: (data:
|
|
38
|
-
options?:
|
|
32
|
+
transformer: (data: Uint8Array) => PromiseLike<R> | R;
|
|
33
|
+
options?: ExternalDownloaderOptions;
|
|
39
34
|
ttl?: number;
|
|
40
35
|
}
|
|
41
|
-
interface LowLevelDownloadOptions {
|
|
42
|
-
/**
|
|
43
|
-
* Use an string array to set multiple values to the header.
|
|
44
|
-
*/
|
|
45
|
-
headers?: Record<string, string | string[]>;
|
|
46
|
-
timeout?: number;
|
|
47
|
-
}
|
|
48
|
-
export interface LowLevelDownloader {
|
|
49
|
-
/**
|
|
50
|
-
* @throws
|
|
51
|
-
*/
|
|
52
|
-
get(uri: RemoteUriString, options?: LowLevelDownloadOptions): Promise<Buffer>;
|
|
53
|
-
}
|
|
54
|
-
export declare namespace LowLevelDownloader {
|
|
55
|
-
function create(): LowLevelDownloader;
|
|
56
|
-
function mock(options: LowLevelDownloaderMockOptions): LowLevelDownloader;
|
|
57
|
-
}
|
|
58
|
-
interface LowLevelDownloaderMockOptions {
|
|
59
|
-
/**
|
|
60
|
-
* A record from URIs to fixture data. The {@link LowLevelDownloader.get} only returns a {@link Buffer},
|
|
61
|
-
* therefore `string` fixtures will be turned into a `Buffer` and `object` fixtures will be transformed
|
|
62
|
-
* into JSON and then turned into a `Buffer`.
|
|
63
|
-
*/
|
|
64
|
-
fixtures: Record<RemoteUriString, string | Buffer | object>;
|
|
65
|
-
}
|
|
66
36
|
export {};
|
|
67
37
|
//# sourceMappingURL=Downloader.d.ts.map
|