@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
|
@@ -1,64 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
10
|
-
var _Downloader_memoryCache;
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.LowLevelDownloader = exports.Downloader = exports.RemoteUriString = void 0;
|
|
13
|
-
const follow_redirects_1 = require("follow-redirects");
|
|
14
|
-
const fs_1 = require("fs");
|
|
15
|
-
const path_1 = __importDefault(require("path"));
|
|
16
|
-
const perf_hooks_1 = require("perf_hooks");
|
|
17
|
-
const common_1 = require("../common");
|
|
18
|
-
const fileUtil_1 = require("./fileUtil");
|
|
19
|
-
var RemoteUriString;
|
|
20
|
-
(function (RemoteUriString) {
|
|
21
|
-
function getProtocol(uri) {
|
|
22
|
-
return uri.slice(0, uri.indexOf(':') + 1);
|
|
23
|
-
}
|
|
24
|
-
RemoteUriString.getProtocol = getProtocol;
|
|
25
|
-
})(RemoteUriString = exports.RemoteUriString || (exports.RemoteUriString = {}));
|
|
26
|
-
class Downloader {
|
|
27
|
-
constructor(cacheRoot, logger, lld = LowLevelDownloader.create()) {
|
|
1
|
+
import { bufferToString, Uri } from '../common/index.js';
|
|
2
|
+
import { fileUtil } from './fileUtil.js';
|
|
3
|
+
export class Downloader {
|
|
4
|
+
cacheRoot;
|
|
5
|
+
externals;
|
|
6
|
+
logger;
|
|
7
|
+
#memoryCache = new Map();
|
|
8
|
+
constructor(cacheRoot, externals, logger) {
|
|
28
9
|
this.cacheRoot = cacheRoot;
|
|
10
|
+
this.externals = externals;
|
|
29
11
|
this.logger = logger;
|
|
30
|
-
this.lld = lld;
|
|
31
|
-
_Downloader_memoryCache.set(this, new Map());
|
|
32
12
|
}
|
|
33
13
|
async download(job, out = {}) {
|
|
34
14
|
const { id, cache, uri, options, transformer, ttl } = job;
|
|
35
|
-
if (ttl &&
|
|
36
|
-
const { buffer, time } =
|
|
37
|
-
if (time <=
|
|
15
|
+
if (ttl && this.#memoryCache.has(uri)) {
|
|
16
|
+
const { buffer, time } = this.#memoryCache.get(uri);
|
|
17
|
+
if (time <= performance.now() + ttl) {
|
|
38
18
|
this.logger.info(`[Downloader] [${id}] Skipped thanks to valid cache in memory`);
|
|
39
19
|
return await transformer(buffer);
|
|
40
20
|
}
|
|
41
21
|
else {
|
|
42
|
-
|
|
22
|
+
this.#memoryCache.delete(uri);
|
|
43
23
|
}
|
|
44
24
|
}
|
|
45
25
|
let checksum;
|
|
46
|
-
let
|
|
47
|
-
let
|
|
26
|
+
let cacheUri;
|
|
27
|
+
let cacheChecksumUri;
|
|
48
28
|
if (cache) {
|
|
49
29
|
const { checksumJob, checksumExtension } = cache;
|
|
50
|
-
out.
|
|
51
|
-
|
|
30
|
+
out.cacheUri = cacheUri = new Uri(`downloader/${id}`, this.cacheRoot).toString();
|
|
31
|
+
cacheChecksumUri = new Uri(`downloader/${id}${checksumExtension}`, this.cacheRoot).toString();
|
|
52
32
|
try {
|
|
53
33
|
out.checksum = checksum = await this.download({ ...checksumJob, id: id + checksumExtension });
|
|
54
34
|
try {
|
|
55
|
-
const cacheChecksum =
|
|
35
|
+
const cacheChecksum = bufferToString(await fileUtil.readFile(this.externals, cacheChecksumUri))
|
|
56
36
|
.slice(0, -1); // Remove ending newline
|
|
57
37
|
if (checksum === cacheChecksum) {
|
|
58
38
|
try {
|
|
59
|
-
const cachedBuffer = await
|
|
39
|
+
const cachedBuffer = await fileUtil.readFile(this.externals, cacheUri);
|
|
60
40
|
if (ttl) {
|
|
61
|
-
|
|
41
|
+
this.#memoryCache.set(uri, { buffer: cachedBuffer, time: performance.now() });
|
|
62
42
|
}
|
|
63
43
|
const deserializer = cache.deserializer ?? (b => b);
|
|
64
44
|
const ans = await transformer(deserializer(cachedBuffer));
|
|
@@ -66,23 +46,23 @@ class Downloader {
|
|
|
66
46
|
return ans;
|
|
67
47
|
}
|
|
68
48
|
catch (e) {
|
|
69
|
-
this.logger.error(`[Downloader] [${id}] Loading cached file “${
|
|
70
|
-
if ((
|
|
49
|
+
this.logger.error(`[Downloader] [${id}] Loading cached file “${cacheUri}”`, e);
|
|
50
|
+
if (this.externals.error.isKind(e, 'ENOENT')) {
|
|
71
51
|
// Cache checksum exists, but cached file doesn't.
|
|
72
52
|
// Remove the invalid cache checksum.
|
|
73
53
|
try {
|
|
74
|
-
await
|
|
54
|
+
await this.externals.fs.unlink(cacheChecksumUri);
|
|
75
55
|
}
|
|
76
56
|
catch (e) {
|
|
77
|
-
this.logger.error(`[Downloader] [${id}] Removing invalid cache checksum “${
|
|
57
|
+
this.logger.error(`[Downloader] [${id}] Removing invalid cache checksum “${cacheChecksumUri}”`, e);
|
|
78
58
|
}
|
|
79
59
|
}
|
|
80
60
|
}
|
|
81
61
|
}
|
|
82
62
|
}
|
|
83
63
|
catch (e) {
|
|
84
|
-
if (!(
|
|
85
|
-
this.logger.error(`[Downloader] [${id}] Loading cache checksum “${
|
|
64
|
+
if (!this.externals.error.isKind(e, 'ENOENT')) {
|
|
65
|
+
this.logger.error(`[Downloader] [${id}] Loading cache checksum “${cacheChecksumUri}”`, e);
|
|
86
66
|
}
|
|
87
67
|
}
|
|
88
68
|
}
|
|
@@ -91,25 +71,25 @@ class Downloader {
|
|
|
91
71
|
}
|
|
92
72
|
}
|
|
93
73
|
try {
|
|
94
|
-
const buffer = await this.
|
|
74
|
+
const buffer = await this.externals.downloader.get(uri, options);
|
|
95
75
|
if (ttl) {
|
|
96
|
-
|
|
76
|
+
this.#memoryCache.set(uri, { buffer, time: performance.now() });
|
|
97
77
|
}
|
|
98
|
-
if (cache &&
|
|
78
|
+
if (cache && cacheUri && cacheChecksumUri) {
|
|
99
79
|
if (checksum) {
|
|
100
80
|
try {
|
|
101
|
-
await
|
|
81
|
+
await fileUtil.writeFile(this.externals, cacheChecksumUri, `${checksum}\n`);
|
|
102
82
|
}
|
|
103
83
|
catch (e) {
|
|
104
|
-
this.logger.error(`[Downloader] [${id}] Saving cache checksum “${
|
|
84
|
+
this.logger.error(`[Downloader] [${id}] Saving cache checksum “${cacheChecksumUri}”`, e);
|
|
105
85
|
}
|
|
106
86
|
}
|
|
107
87
|
try {
|
|
108
88
|
const serializer = cache.serializer ?? (b => b);
|
|
109
|
-
await
|
|
89
|
+
await fileUtil.writeFile(this.externals, cacheUri, serializer(buffer));
|
|
110
90
|
}
|
|
111
91
|
catch (e) {
|
|
112
|
-
this.logger.error(`[Downloader] [${id}] Caching file “${
|
|
92
|
+
this.logger.error(`[Downloader] [${id}] Caching file “${cacheUri}”`, e);
|
|
113
93
|
}
|
|
114
94
|
}
|
|
115
95
|
this.logger.info(`[Downloader] [${id}] Downloaded from “${uri}”`);
|
|
@@ -117,69 +97,20 @@ class Downloader {
|
|
|
117
97
|
}
|
|
118
98
|
catch (e) {
|
|
119
99
|
this.logger.error(`[Downloader] [${id}] Downloading “${uri}”`, e);
|
|
120
|
-
if (cache &&
|
|
100
|
+
if (cache && cacheUri) {
|
|
121
101
|
try {
|
|
122
|
-
const cachedBuffer = await
|
|
102
|
+
const cachedBuffer = await fileUtil.readFile(this.externals, cacheUri);
|
|
123
103
|
const deserializer = cache.deserializer ?? (b => b);
|
|
124
104
|
const ans = await transformer(deserializer(cachedBuffer));
|
|
125
|
-
this.logger.warn(`[Downloader] [${id}] Fell back to cached file “${
|
|
105
|
+
this.logger.warn(`[Downloader] [${id}] Fell back to cached file “${cacheUri}”`);
|
|
126
106
|
return ans;
|
|
127
107
|
}
|
|
128
108
|
catch (e) {
|
|
129
|
-
this.logger.error(`[Downloader] [${id}] Fallback: loading cached file “${
|
|
109
|
+
this.logger.error(`[Downloader] [${id}] Fallback: loading cached file “${cacheUri}”`, e);
|
|
130
110
|
}
|
|
131
111
|
}
|
|
132
112
|
}
|
|
133
113
|
return undefined;
|
|
134
114
|
}
|
|
135
115
|
}
|
|
136
|
-
exports.Downloader = Downloader;
|
|
137
|
-
_Downloader_memoryCache = new WeakMap();
|
|
138
|
-
var LowLevelDownloader;
|
|
139
|
-
(function (LowLevelDownloader) {
|
|
140
|
-
function create() {
|
|
141
|
-
return new LowLevelDownloaderImpl();
|
|
142
|
-
}
|
|
143
|
-
LowLevelDownloader.create = create;
|
|
144
|
-
function mock(options) {
|
|
145
|
-
return new LowLevelDownloaderMock(options);
|
|
146
|
-
}
|
|
147
|
-
LowLevelDownloader.mock = mock;
|
|
148
|
-
})(LowLevelDownloader = exports.LowLevelDownloader || (exports.LowLevelDownloader = {}));
|
|
149
|
-
class LowLevelDownloaderImpl {
|
|
150
|
-
get(uri, options = {}) {
|
|
151
|
-
const protocol = RemoteUriString.getProtocol(uri);
|
|
152
|
-
return new Promise((resolve, reject) => {
|
|
153
|
-
const backend = protocol === 'http:' ? follow_redirects_1.http : follow_redirects_1.https;
|
|
154
|
-
backend.get(uri, options, (res) => {
|
|
155
|
-
if (res.statusCode !== 200) {
|
|
156
|
-
reject(new Error(`Status code ${res.statusCode}: ${res.statusMessage}`));
|
|
157
|
-
}
|
|
158
|
-
else {
|
|
159
|
-
resolve((0, common_1.promisifyAsyncIterable)(res, chunks => Buffer.concat(chunks)));
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
class LowLevelDownloaderMock {
|
|
166
|
-
constructor(options) {
|
|
167
|
-
this.options = options;
|
|
168
|
-
}
|
|
169
|
-
async get(uri) {
|
|
170
|
-
if (!this.options.fixtures[uri]) {
|
|
171
|
-
throw new Error(`404 not found: ${uri}`);
|
|
172
|
-
}
|
|
173
|
-
const fixture = this.options.fixtures[uri];
|
|
174
|
-
if (Buffer.isBuffer(fixture)) {
|
|
175
|
-
return fixture;
|
|
176
|
-
}
|
|
177
|
-
else if (typeof fixture === 'string') {
|
|
178
|
-
return Buffer.from(fixture, 'utf-8');
|
|
179
|
-
}
|
|
180
|
-
else {
|
|
181
|
-
return Buffer.from(JSON.stringify(fixture), 'utf-8');
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
116
|
//# sourceMappingURL=Downloader.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { LanguageErrorInfo, RangeLike } from '../source';
|
|
2
|
-
import { ErrorSeverity, LanguageError } from '../source';
|
|
1
|
+
import type { LanguageErrorInfo, RangeLike } from '../source/index.js';
|
|
2
|
+
import { ErrorSeverity, LanguageError } from '../source/index.js';
|
|
3
3
|
export declare class ErrorReporter {
|
|
4
4
|
errors: LanguageError[];
|
|
5
5
|
constructor();
|
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class ErrorReporter {
|
|
7
|
-
constructor() {
|
|
8
|
-
this.errors = [];
|
|
9
|
-
}
|
|
1
|
+
import { localize } from '@spyglassmc/locales';
|
|
2
|
+
import { LanguageError, Range } from '../source/index.js';
|
|
3
|
+
export class ErrorReporter {
|
|
4
|
+
errors = [];
|
|
5
|
+
constructor() { }
|
|
10
6
|
/**
|
|
11
7
|
* Reports a new error.
|
|
12
8
|
*/
|
|
13
|
-
report(message, range, severity = 3 /* Error */, info) {
|
|
14
|
-
this.errors.push(
|
|
9
|
+
report(message, range, severity = 3 /* ErrorSeverity.Error */, info) {
|
|
10
|
+
this.errors.push(LanguageError.create(message, Range.get(range), severity, info));
|
|
15
11
|
}
|
|
16
12
|
/**
|
|
17
13
|
* @returns All reported errors, and then clears the error stack.
|
|
@@ -29,15 +25,16 @@ class ErrorReporter {
|
|
|
29
25
|
this.errors.push(...reporter.errors);
|
|
30
26
|
}
|
|
31
27
|
}
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
export class LinterErrorReporter extends ErrorReporter {
|
|
29
|
+
ruleName;
|
|
30
|
+
ruleSeverity;
|
|
34
31
|
constructor(ruleName, ruleSeverity) {
|
|
35
32
|
super();
|
|
36
33
|
this.ruleName = ruleName;
|
|
37
34
|
this.ruleSeverity = ruleSeverity;
|
|
38
35
|
}
|
|
39
36
|
lint(message, range, info, severityOverride) {
|
|
40
|
-
return this.report(
|
|
37
|
+
return this.report(localize('linter.diagnostic-message-wrapper', message, this.ruleName), range, severityOverride ?? this.ruleSeverity, info);
|
|
41
38
|
}
|
|
42
39
|
static fromErrorReporter(reporter, ruleName, ruleSeverity) {
|
|
43
40
|
const ans = new LinterErrorReporter(ruleName, ruleSeverity);
|
|
@@ -45,5 +42,4 @@ class LinterErrorReporter extends ErrorReporter {
|
|
|
45
42
|
return ans;
|
|
46
43
|
}
|
|
47
44
|
}
|
|
48
|
-
exports.LinterErrorReporter = LinterErrorReporter;
|
|
49
45
|
//# sourceMappingURL=ErrorReporter.js.map
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import type { Dependency } from './Dependency';
|
|
3
|
-
import type { RootUriString } from './fileUtil';
|
|
4
|
-
import type { Logger } from './Logger';
|
|
1
|
+
import type { Externals, Logger } from '../common/index.js';
|
|
2
|
+
import type { Dependency } from './Dependency.js';
|
|
3
|
+
import type { RootUriString } from './fileUtil.js';
|
|
5
4
|
export interface UriProtocolSupporter {
|
|
6
5
|
/**
|
|
7
6
|
* @throws
|
|
@@ -16,7 +15,7 @@ export interface UriProtocolSupporter {
|
|
|
16
15
|
* @returns The content of the file at `uri`.
|
|
17
16
|
* @throws If the URI doesn't exist in the file system.
|
|
18
17
|
*/
|
|
19
|
-
readFile(uri: string): Promise<
|
|
18
|
+
readFile(uri: string): Promise<Uint8Array>;
|
|
20
19
|
listFiles(): Iterable<string>;
|
|
21
20
|
/**
|
|
22
21
|
* Each URI in this array must end with a slash (`/`).
|
|
@@ -37,12 +36,29 @@ export interface FileService extends UriProtocolSupporter {
|
|
|
37
36
|
* Unregister the supported associated with `protocol`. Nothing happens if the `protocol` isn't supported.
|
|
38
37
|
*/
|
|
39
38
|
unregister(protocol: Protocol): void;
|
|
39
|
+
/**
|
|
40
|
+
* Map the item at `uri` to physical disk.
|
|
41
|
+
*
|
|
42
|
+
* @returns The `file:` URI of the mapped file, or `undefined` if it cannot be mapped.
|
|
43
|
+
*/
|
|
44
|
+
mapToDisk(uri: string): Promise<string | undefined>;
|
|
45
|
+
/**
|
|
46
|
+
* Map the item at `uri` from physical disk back to a (virtual) URI used by Spyglass internally.
|
|
47
|
+
*/
|
|
48
|
+
mapFromDisk(uri: string): string;
|
|
40
49
|
}
|
|
41
50
|
export declare namespace FileService {
|
|
42
|
-
function create(): FileService;
|
|
51
|
+
function create(externals: Externals, cacheRoot: RootUriString): FileService;
|
|
43
52
|
}
|
|
44
53
|
export declare class FileServiceImpl implements FileService {
|
|
54
|
+
private readonly externals;
|
|
55
|
+
private readonly virtualUrisRoot?;
|
|
45
56
|
private readonly supporters;
|
|
57
|
+
/**
|
|
58
|
+
* A two-way map from mapped physical URIs to virtual URIs.
|
|
59
|
+
*/
|
|
60
|
+
private readonly map;
|
|
61
|
+
constructor(externals: Externals, virtualUrisRoot?: `${string}/` | undefined);
|
|
46
62
|
register(protocol: Protocol, supporter: UriProtocolSupporter, force?: boolean): void;
|
|
47
63
|
unregister(protocol: Protocol): void;
|
|
48
64
|
/**
|
|
@@ -58,39 +74,49 @@ export declare class FileServiceImpl implements FileService {
|
|
|
58
74
|
/**
|
|
59
75
|
* @throws
|
|
60
76
|
*/
|
|
61
|
-
readFile(uri: string): Promise<
|
|
77
|
+
readFile(uri: string): Promise<Uint8Array>;
|
|
62
78
|
listFiles(): Generator<string, void, undefined>;
|
|
63
79
|
listRoots(): Generator<`${string}/`, void, undefined>;
|
|
80
|
+
mapToDisk(virtualUri: string): Promise<string | undefined>;
|
|
81
|
+
mapFromDisk(mappedUri: string): string;
|
|
64
82
|
}
|
|
65
83
|
export declare class FileUriSupporter implements UriProtocolSupporter {
|
|
84
|
+
private readonly externals;
|
|
66
85
|
private readonly roots;
|
|
67
86
|
private readonly files;
|
|
68
87
|
readonly protocol = "file:";
|
|
69
88
|
private constructor();
|
|
70
89
|
hash(uri: string): Promise<string>;
|
|
71
|
-
readFile(uri: string): Promise<
|
|
90
|
+
readFile(uri: string): Promise<Uint8Array>;
|
|
72
91
|
listFiles(): Generator<string, void, undefined>;
|
|
73
92
|
listRoots(): `${string}/`[];
|
|
74
|
-
|
|
75
|
-
static create(dependencies: readonly Dependency[], logger: Logger): Promise<FileUriSupporter>;
|
|
93
|
+
mapToDisk(uri: string): Promise<string | undefined>;
|
|
94
|
+
static create(dependencies: readonly Dependency[], externals: Externals, logger: Logger): Promise<FileUriSupporter>;
|
|
76
95
|
}
|
|
77
|
-
export declare class
|
|
96
|
+
export declare class ArchiveUriSupporter implements UriProtocolSupporter {
|
|
97
|
+
private readonly externals;
|
|
78
98
|
private readonly entries;
|
|
79
|
-
readonly
|
|
99
|
+
static readonly Protocol = "archive:";
|
|
80
100
|
private static readonly SupportedArchiveExtnames;
|
|
101
|
+
readonly protocol = "archive:";
|
|
81
102
|
/**
|
|
82
103
|
* @param entries A map from archive URIs to unzipped entries.
|
|
83
104
|
*/
|
|
84
105
|
private constructor();
|
|
85
106
|
hash(uri: string): Promise<string>;
|
|
86
|
-
readFile(uri: string): Promise<
|
|
107
|
+
readFile(uri: string): Promise<Uint8Array>;
|
|
87
108
|
/**
|
|
88
109
|
* @throws
|
|
89
110
|
*/
|
|
90
111
|
private getDataInArchive;
|
|
91
112
|
listFiles(): Generator<string, void, unknown>;
|
|
92
113
|
listRoots(): Generator<`${string}/`, void, unknown>;
|
|
93
|
-
static
|
|
114
|
+
private static getUri;
|
|
115
|
+
/**
|
|
116
|
+
* @throws When `uri` has the wrong protocol or hostname.
|
|
117
|
+
*/
|
|
118
|
+
private static decodeUri;
|
|
119
|
+
static create(dependencies: readonly Dependency[], externals: Externals, logger: Logger, checksums: Record<RootUriString, string>): Promise<ArchiveUriSupporter>;
|
|
94
120
|
}
|
|
95
121
|
export {};
|
|
96
122
|
//# sourceMappingURL=FileService.d.ts.map
|