@spyglassmc/core 0.4.0 → 0.4.2
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/lib/common/Dev.js +5 -2
- package/lib/common/Operations.js +7 -3
- package/lib/common/ReadonlyProxy.d.ts +2 -2
- package/lib/common/ReadonlyProxy.js +3 -1
- package/lib/common/StateProxy.d.ts +2 -2
- package/lib/common/StateProxy.js +18 -7
- package/lib/common/externals/BrowserExternals.js +2 -9
- package/lib/common/externals/NodeJsExternals.js +11 -18
- package/lib/common/externals/downloader.d.ts +2 -2
- package/lib/common/externals/index.d.ts +2 -5
- package/lib/common/util.d.ts +8 -7
- package/lib/common/util.js +16 -12
- package/lib/node/AstNode.d.ts +1 -1
- package/lib/node/AstNode.js +9 -5
- package/lib/node/CommentNode.d.ts +2 -2
- package/lib/node/FileNode.js +6 -1
- package/lib/node/ResourceLocationNode.d.ts +3 -3
- package/lib/node/ResourceLocationNode.js +9 -5
- package/lib/node/StringNode.d.ts +3 -3
- package/lib/node/StringNode.js +4 -1
- package/lib/parser/Parser.d.ts +5 -5
- package/lib/parser/boolean.js +1 -1
- package/lib/parser/comment.d.ts +1 -1
- package/lib/parser/comment.js +1 -1
- package/lib/parser/float.d.ts +1 -1
- package/lib/parser/float.js +2 -1
- package/lib/parser/integer.d.ts +1 -1
- package/lib/parser/integer.js +2 -1
- package/lib/parser/list.d.ts +1 -1
- package/lib/parser/list.js +3 -3
- package/lib/parser/long.d.ts +1 -1
- package/lib/parser/long.js +2 -1
- package/lib/parser/record.d.ts +1 -1
- package/lib/parser/record.js +18 -8
- package/lib/parser/resourceLocation.js +61 -8
- package/lib/parser/string.js +79 -8
- package/lib/parser/util.d.ts +7 -7
- package/lib/parser/util.js +14 -5
- package/lib/processor/ColorInfoProvider.d.ts +3 -3
- package/lib/processor/ColorInfoProvider.js +22 -7
- package/lib/processor/InlayHintProvider.d.ts +1 -1
- package/lib/processor/SignatureHelpProvider.d.ts +1 -1
- package/lib/processor/binder/Binder.d.ts +1 -1
- package/lib/processor/binder/builtin.d.ts +2 -2
- package/lib/processor/binder/builtin.js +30 -18
- package/lib/processor/binder/index.d.ts +1 -1
- package/lib/processor/binder/index.js +1 -1
- package/lib/processor/checker/Checker.d.ts +3 -3
- package/lib/processor/checker/builtin.d.ts +2 -3
- package/lib/processor/checker/builtin.js +12 -13
- package/lib/processor/colorizer/Colorizer.d.ts +3 -3
- package/lib/processor/colorizer/builtin.js +8 -7
- package/lib/processor/completer/Completer.d.ts +1 -1
- package/lib/processor/completer/Completer.js +4 -2
- package/lib/processor/completer/builtin.js +33 -26
- package/lib/processor/formatter/Formatter.d.ts +1 -1
- package/lib/processor/formatter/Formatter.js +3 -1
- package/lib/processor/formatter/builtin.js +14 -12
- package/lib/processor/linter/Linter.d.ts +1 -1
- package/lib/processor/linter/builtin/undeclaredSymbol.js +47 -24
- package/lib/processor/linter/builtin.js +7 -8
- package/lib/processor/util.d.ts +1 -1
- package/lib/service/CacheService.d.ts +1 -1
- package/lib/service/CacheService.js +9 -6
- package/lib/service/Config.d.ts +11 -11
- package/lib/service/Config.js +28 -21
- package/lib/service/Dependency.d.ts +3 -3
- package/lib/service/Downloader.js +12 -7
- package/lib/service/FileService.d.ts +1 -1
- package/lib/service/FileService.js +28 -10
- package/lib/service/MetaRegistry.js +7 -6
- package/lib/service/Profiler.js +10 -5
- package/lib/service/Project.d.ts +5 -5
- package/lib/service/Project.js +45 -34
- package/lib/service/Service.js +31 -12
- package/lib/service/SymbolRegistrar.d.ts +1 -1
- package/lib/service/UriProcessor.d.ts +3 -3
- package/lib/service/fileUtil.d.ts +2 -2
- package/lib/service/fileUtil.js +2 -1
- package/lib/source/IndexMap.d.ts +1 -1
- package/lib/source/IndexMap.js +1 -1
- package/lib/source/LanguageError.js +1 -1
- package/lib/source/Location.d.ts +1 -1
- package/lib/source/Location.js +4 -1
- package/lib/source/Offset.d.ts +1 -1
- package/lib/source/Range.d.ts +1 -1
- package/lib/source/Range.js +6 -3
- package/lib/source/Source.d.ts +4 -4
- package/lib/source/Source.js +3 -1
- package/lib/symbol/Symbol.d.ts +19 -19
- package/lib/symbol/Symbol.js +27 -12
- package/lib/symbol/SymbolUtil.d.ts +6 -6
- package/lib/symbol/SymbolUtil.js +76 -44
- package/package.json +2 -2
package/lib/service/Project.js
CHANGED
|
@@ -5,7 +5,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
7
|
import { TextDocument } from 'vscode-languageserver-textdocument';
|
|
8
|
-
import { bufferToString, Logger, SingletonPromise, StateProxy } from '../common/index.js';
|
|
8
|
+
import { bufferToString, Logger, normalizeUri, SingletonPromise, StateProxy, } from '../common/index.js';
|
|
9
9
|
import { FileNode } from '../node/index.js';
|
|
10
10
|
import { file } from '../parser/index.js';
|
|
11
11
|
import { traversePreOrder } from '../processor/index.js';
|
|
@@ -13,11 +13,11 @@ import { LanguageError, Source } from '../source/index.js';
|
|
|
13
13
|
import { SymbolUtil } from '../symbol/index.js';
|
|
14
14
|
import { CacheService } from './CacheService.js';
|
|
15
15
|
import { ConfigService, LinterConfigValue } from './Config.js';
|
|
16
|
-
import { BinderContext, CheckerContext, LinterContext, ParserContext, UriBinderContext } from './Context.js';
|
|
16
|
+
import { BinderContext, CheckerContext, LinterContext, ParserContext, UriBinderContext, } from './Context.js';
|
|
17
17
|
import { DependencyKey } from './Dependency.js';
|
|
18
18
|
import { Downloader } from './Downloader.js';
|
|
19
19
|
import { LinterErrorReporter } from './ErrorReporter.js';
|
|
20
|
-
import { ArchiveUriSupporter, FileService, FileUriSupporter } from './FileService.js';
|
|
20
|
+
import { ArchiveUriSupporter, FileService, FileUriSupporter, } from './FileService.js';
|
|
21
21
|
import { fileUtil } from './fileUtil.js';
|
|
22
22
|
import { MetaRegistry } from './MetaRegistry.js';
|
|
23
23
|
import { ProfilerFactory } from './Profiler.js';
|
|
@@ -60,7 +60,7 @@ const CacheAutoSaveInterval = 600000; // 10 Minutes.
|
|
|
60
60
|
*
|
|
61
61
|
* After the READY process is complete, editing text documents as signaled by the client or the file watcher results in the file being re-processed.
|
|
62
62
|
*/
|
|
63
|
-
|
|
63
|
+
class Project {
|
|
64
64
|
static RootSuffix = '/pack.mcmeta';
|
|
65
65
|
/** Prevent circular binding. */
|
|
66
66
|
#bindingInProgressUris = new Set();
|
|
@@ -125,7 +125,8 @@ export class Project {
|
|
|
125
125
|
const ans = new Set(rawRoots);
|
|
126
126
|
// Identify roots indicated by `pack.mcmeta`.
|
|
127
127
|
for (const file of this.getTrackedFiles()) {
|
|
128
|
-
if (file.endsWith(Project.RootSuffix) &&
|
|
128
|
+
if (file.endsWith(Project.RootSuffix) &&
|
|
129
|
+
rawRoots.some((r) => file.startsWith(r))) {
|
|
129
130
|
ans.add(file.slice(0, 1 - Project.RootSuffix.length));
|
|
130
131
|
}
|
|
131
132
|
}
|
|
@@ -151,8 +152,7 @@ export class Project {
|
|
|
151
152
|
*/
|
|
152
153
|
getTrackedFiles() {
|
|
153
154
|
const extensions = this.meta.getSupportedFileExtensions();
|
|
154
|
-
return [...this.#dependencyFiles, ...this.#watchedFiles]
|
|
155
|
-
.filter(file => extensions.includes(fileUtil.extname(file) ?? ''));
|
|
155
|
+
return [...this.#dependencyFiles, ...this.#watchedFiles].filter((file) => extensions.includes(fileUtil.extname(file) ?? ''));
|
|
156
156
|
}
|
|
157
157
|
constructor({ cacheRoot, defaultConfig, downloader, externals, fs = FileService.create(externals, cacheRoot), initializers = [], logger = Logger.create(), profilers = ProfilerFactory.noop(), projectRoot, }) {
|
|
158
158
|
this.#cacheRoot = cacheRoot;
|
|
@@ -165,7 +165,8 @@ export class Project {
|
|
|
165
165
|
this.projectRoot = projectRoot;
|
|
166
166
|
this.cacheService = new CacheService(cacheRoot, this);
|
|
167
167
|
this.#configService = new ConfigService(this, defaultConfig);
|
|
168
|
-
this.downloader = downloader ??
|
|
168
|
+
this.downloader = downloader ??
|
|
169
|
+
new Downloader(cacheRoot, externals, logger);
|
|
169
170
|
this.symbols = new SymbolUtil({}, externals.event.EventEmitter);
|
|
170
171
|
this.#ctx = {};
|
|
171
172
|
this.logger.info(`[Project] [init] cacheRoot = “${cacheRoot}”`);
|
|
@@ -178,13 +179,12 @@ export class Project {
|
|
|
178
179
|
this.setInitPromise();
|
|
179
180
|
this.setReadyPromise();
|
|
180
181
|
this.#cacheSaverIntervalId = setInterval(() => this.cacheService.save(), CacheAutoSaveInterval);
|
|
181
|
-
this
|
|
182
|
-
.on('documentUpdated', ({ doc, node }) => {
|
|
182
|
+
this.on('documentUpdated', ({ doc, node }) => {
|
|
183
183
|
// if (!this.#isReady) {
|
|
184
184
|
// return
|
|
185
185
|
// }
|
|
186
186
|
this.emit('documentErrored', {
|
|
187
|
-
errors: FileNode.getErrors(node).map(e => LanguageError.withPosRange(e, doc)),
|
|
187
|
+
errors: FileNode.getErrors(node).map((e) => LanguageError.withPosRange(e, doc)),
|
|
188
188
|
uri: doc.uri,
|
|
189
189
|
version: doc.version,
|
|
190
190
|
});
|
|
@@ -237,7 +237,7 @@ export class Project {
|
|
|
237
237
|
meta: this.meta,
|
|
238
238
|
projectRoot: this.projectRoot,
|
|
239
239
|
};
|
|
240
|
-
const results = await Promise.allSettled(this.#initializers.map(init => init(initCtx)));
|
|
240
|
+
const results = await Promise.allSettled(this.#initializers.map((init) => init(initCtx)));
|
|
241
241
|
let ctx = {};
|
|
242
242
|
results.forEach(async (r, i) => {
|
|
243
243
|
if (r.status === 'rejected') {
|
|
@@ -294,7 +294,7 @@ export class Project {
|
|
|
294
294
|
this.fs.register('file:', fileUriSupporter, true);
|
|
295
295
|
this.fs.register(ArchiveUriSupporter.Protocol, archiveUriSupporter, true);
|
|
296
296
|
};
|
|
297
|
-
const listProjectFiles = () => new Promise(resolve => {
|
|
297
|
+
const listProjectFiles = () => new Promise((resolve) => {
|
|
298
298
|
this.#watchedFiles.clear();
|
|
299
299
|
this.#watcherReady = false;
|
|
300
300
|
this.#watcher = this.externals.fs
|
|
@@ -303,34 +303,31 @@ export class Project {
|
|
|
303
303
|
this.#watcherReady = true;
|
|
304
304
|
resolve();
|
|
305
305
|
})
|
|
306
|
-
.on('add', uri => {
|
|
306
|
+
.on('add', (uri) => {
|
|
307
307
|
this.#watchedFiles.add(uri);
|
|
308
308
|
if (this.#watcherReady) {
|
|
309
309
|
this.emit('fileCreated', { uri });
|
|
310
310
|
}
|
|
311
311
|
})
|
|
312
|
-
.on('change', uri => {
|
|
312
|
+
.on('change', (uri) => {
|
|
313
313
|
if (this.#watcherReady) {
|
|
314
314
|
this.emit('fileModified', { uri });
|
|
315
315
|
}
|
|
316
316
|
})
|
|
317
|
-
.on('unlink', uri => {
|
|
317
|
+
.on('unlink', (uri) => {
|
|
318
318
|
this.#watchedFiles.delete(uri);
|
|
319
319
|
if (this.#watcherReady) {
|
|
320
320
|
this.emit('fileDeleted', { uri });
|
|
321
321
|
}
|
|
322
322
|
})
|
|
323
|
-
.on('error', e => {
|
|
323
|
+
.on('error', (e) => {
|
|
324
324
|
this.logger.error('[Project] [chokidar]', e);
|
|
325
325
|
});
|
|
326
326
|
});
|
|
327
327
|
const ready = async () => {
|
|
328
328
|
await this.init();
|
|
329
329
|
const __profiler = this.profilers.get('project#ready');
|
|
330
|
-
await Promise.all([
|
|
331
|
-
listDependencyFiles(),
|
|
332
|
-
listProjectFiles(),
|
|
333
|
-
]);
|
|
330
|
+
await Promise.all([listDependencyFiles(), listProjectFiles()]);
|
|
334
331
|
this.#dependencyFiles = new Set(this.fs.listFiles());
|
|
335
332
|
this.#dependencyRoots = new Set(this.fs.listRoots());
|
|
336
333
|
this.updateRoots();
|
|
@@ -353,7 +350,9 @@ export class Project {
|
|
|
353
350
|
this.emit('documentErrored', { errors: values, uri });
|
|
354
351
|
}
|
|
355
352
|
__profiler.task('Pop Errors');
|
|
356
|
-
const { addedFiles, changedFiles, removedFiles } = await this
|
|
353
|
+
const { addedFiles, changedFiles, removedFiles } = await this
|
|
354
|
+
.cacheService
|
|
355
|
+
.validate();
|
|
357
356
|
for (const uri of removedFiles) {
|
|
358
357
|
this.emit('fileDeleted', { uri });
|
|
359
358
|
}
|
|
@@ -424,7 +423,7 @@ export class Project {
|
|
|
424
423
|
return this.restart();
|
|
425
424
|
}
|
|
426
425
|
normalizeUri(uri) {
|
|
427
|
-
return this.fs.mapFromDisk(
|
|
426
|
+
return this.fs.mapFromDisk(normalizeUri(uri));
|
|
428
427
|
}
|
|
429
428
|
static TextDocumentCacheMaxLength = 268435456;
|
|
430
429
|
#textDocumentCache = new Map();
|
|
@@ -563,7 +562,8 @@ export class Project {
|
|
|
563
562
|
continue;
|
|
564
563
|
}
|
|
565
564
|
const { ruleSeverity, ruleValue } = result;
|
|
566
|
-
const { configValidator, linter, nodePredicate } = this.meta
|
|
565
|
+
const { configValidator, linter, nodePredicate } = this.meta
|
|
566
|
+
.getLinter(ruleName);
|
|
567
567
|
if (!configValidator(ruleName, ruleValue, this.logger)) {
|
|
568
568
|
// Config value is invalid.
|
|
569
569
|
continue;
|
|
@@ -574,7 +574,7 @@ export class Project {
|
|
|
574
574
|
ruleName,
|
|
575
575
|
ruleValue,
|
|
576
576
|
});
|
|
577
|
-
traversePreOrder(node, () => true, () => true, node => {
|
|
577
|
+
traversePreOrder(node, () => true, () => true, (node) => {
|
|
578
578
|
if (nodePredicate(node)) {
|
|
579
579
|
const proxy = StateProxy.create(node);
|
|
580
580
|
linter(proxy, ctx);
|
|
@@ -589,7 +589,9 @@ export class Project {
|
|
|
589
589
|
}
|
|
590
590
|
// @SingletonPromise()
|
|
591
591
|
async ensureBindingStarted(uri) {
|
|
592
|
-
|
|
592
|
+
uri = this.normalizeUri(uri);
|
|
593
|
+
if (this.#symbolUpToDateUris.has(uri) ||
|
|
594
|
+
this.#bindingInProgressUris.has(uri)) {
|
|
593
595
|
return;
|
|
594
596
|
}
|
|
595
597
|
this.#bindingInProgressUris.add(uri);
|
|
@@ -635,8 +637,8 @@ export class Project {
|
|
|
635
637
|
* @throws If there is no `TextDocument` corresponding to the URI.
|
|
636
638
|
*/
|
|
637
639
|
async onDidChange(uri, changes, version) {
|
|
638
|
-
this.#symbolUpToDateUris.delete(uri);
|
|
639
640
|
uri = this.normalizeUri(uri);
|
|
641
|
+
this.#symbolUpToDateUris.delete(uri);
|
|
640
642
|
if (!fileUtil.isFileUri(uri)) {
|
|
641
643
|
return; // We only accept `file:` scheme for client-managed URIs.
|
|
642
644
|
}
|
|
@@ -665,17 +667,21 @@ export class Project {
|
|
|
665
667
|
this.tryClearingCache(uri);
|
|
666
668
|
}
|
|
667
669
|
async ensureClientManagedChecked(uri) {
|
|
670
|
+
uri = this.normalizeUri(uri);
|
|
668
671
|
const result = this.#clientManagedDocAndNodes.get(uri);
|
|
669
|
-
if (result
|
|
672
|
+
if (result) {
|
|
670
673
|
const { doc, node } = result;
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
674
|
+
if (this.#isReady) {
|
|
675
|
+
await this.bind(doc, node);
|
|
676
|
+
await this.check(doc, node);
|
|
677
|
+
this.emit('documentUpdated', result);
|
|
678
|
+
}
|
|
679
|
+
return result;
|
|
675
680
|
}
|
|
676
681
|
return undefined;
|
|
677
682
|
}
|
|
678
683
|
getClientManaged(uri) {
|
|
684
|
+
uri = this.normalizeUri(uri);
|
|
679
685
|
return this.#clientManagedDocAndNodes.get(uri);
|
|
680
686
|
}
|
|
681
687
|
async showCacheRoot() {
|
|
@@ -696,10 +702,14 @@ export class Project {
|
|
|
696
702
|
}
|
|
697
703
|
}
|
|
698
704
|
shouldRemove(uri) {
|
|
699
|
-
return !this.#clientManagedUris.has(uri) &&
|
|
705
|
+
return (!this.#clientManagedUris.has(uri) &&
|
|
706
|
+
!this.#dependencyFiles.has(uri) &&
|
|
707
|
+
!this.#watchedFiles.has(uri));
|
|
700
708
|
}
|
|
701
709
|
isOnlyWatched(uri) {
|
|
702
|
-
return this.#watchedFiles.has(uri) &&
|
|
710
|
+
return (this.#watchedFiles.has(uri) &&
|
|
711
|
+
!this.#clientManagedUris.has(uri) &&
|
|
712
|
+
!this.#dependencyFiles.has(uri));
|
|
703
713
|
}
|
|
704
714
|
}
|
|
705
715
|
__decorate([
|
|
@@ -711,4 +721,5 @@ __decorate([
|
|
|
711
721
|
__decorate([
|
|
712
722
|
SingletonPromise()
|
|
713
723
|
], Project.prototype, "ensureClientManagedChecked", null);
|
|
724
|
+
export { Project };
|
|
714
725
|
//# sourceMappingURL=Project.js.map
|
package/lib/service/Service.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { AstNode } from '../node/index.js';
|
|
2
|
-
import { ColorPresentation, completer, traversePreOrder } from '../processor/index.js';
|
|
2
|
+
import { ColorPresentation, completer, traversePreOrder, } from '../processor/index.js';
|
|
3
3
|
import { Range } from '../source/index.js';
|
|
4
4
|
import { SymbolUsageTypes } from '../symbol/index.js';
|
|
5
|
-
import { ColorizerContext, CompleterContext, FormatterContext, ProcessorContext, SignatureHelpProviderContext } from './Context.js';
|
|
5
|
+
import { ColorizerContext, CompleterContext, FormatterContext, ProcessorContext, SignatureHelpProviderContext, } from './Context.js';
|
|
6
6
|
import { fileUtil } from './fileUtil.js';
|
|
7
7
|
import { Hover } from './Hover.js';
|
|
8
8
|
import { ProfilerFactory } from './Profiler.js';
|
|
@@ -44,9 +44,13 @@ export class Service {
|
|
|
44
44
|
try {
|
|
45
45
|
this.debug(`Getting color info for '${doc.uri}' # ${doc.version}`);
|
|
46
46
|
const ans = [];
|
|
47
|
-
traversePreOrder(node, _ => true, node => node.color, node => ans.push({
|
|
48
|
-
color: Array.isArray(node.color)
|
|
49
|
-
|
|
47
|
+
traversePreOrder(node, (_) => true, (node) => node.color, (node) => ans.push({
|
|
48
|
+
color: Array.isArray(node.color)
|
|
49
|
+
? node.color
|
|
50
|
+
: node.color.value,
|
|
51
|
+
range: Array.isArray(node.color)
|
|
52
|
+
? node.range
|
|
53
|
+
: node.color.range ?? node.range,
|
|
50
54
|
}));
|
|
51
55
|
return ans;
|
|
52
56
|
}
|
|
@@ -58,12 +62,15 @@ export class Service {
|
|
|
58
62
|
getColorPresentation(file, doc, range, color) {
|
|
59
63
|
try {
|
|
60
64
|
this.debug(`Getting color presentation for '${doc.uri}' # ${doc.version} @ ${Range.toString(range)}`);
|
|
61
|
-
let node = AstNode.findDeepestChild({
|
|
65
|
+
let node = AstNode.findDeepestChild({
|
|
66
|
+
node: file,
|
|
67
|
+
needle: range.start,
|
|
68
|
+
});
|
|
62
69
|
while (node) {
|
|
63
70
|
const nodeColor = node.color;
|
|
64
71
|
if (nodeColor && !Array.isArray(nodeColor)) {
|
|
65
72
|
const colorRange = nodeColor.range ?? node.range;
|
|
66
|
-
return nodeColor.format.map(format => ColorPresentation.fromColorFormat(format, color, colorRange));
|
|
73
|
+
return nodeColor.format.map((format) => ColorPresentation.fromColorFormat(format, color, colorRange));
|
|
67
74
|
}
|
|
68
75
|
node = node.parent;
|
|
69
76
|
}
|
|
@@ -78,7 +85,11 @@ export class Service {
|
|
|
78
85
|
this.debug(`Getting completion for '${doc.uri}' # ${doc.version} @ ${offset}`);
|
|
79
86
|
const shouldComplete = this.project.meta.shouldComplete(doc.languageId, triggerCharacter);
|
|
80
87
|
if (shouldComplete) {
|
|
81
|
-
return completer.file(node, CompleterContext.create(this.project, {
|
|
88
|
+
return completer.file(node, CompleterContext.create(this.project, {
|
|
89
|
+
doc,
|
|
90
|
+
offset,
|
|
91
|
+
triggerCharacter,
|
|
92
|
+
}));
|
|
82
93
|
}
|
|
83
94
|
}
|
|
84
95
|
catch (e) {
|
|
@@ -107,7 +118,11 @@ export class Service {
|
|
|
107
118
|
try {
|
|
108
119
|
this.debug(`Formatting '${doc.uri}' # ${doc.version}`);
|
|
109
120
|
const formatter = this.project.meta.getFormatter(node.type);
|
|
110
|
-
return formatter(node, FormatterContext.create(this.project, {
|
|
121
|
+
return formatter(node, FormatterContext.create(this.project, {
|
|
122
|
+
doc,
|
|
123
|
+
tabSize,
|
|
124
|
+
insertSpaces,
|
|
125
|
+
}));
|
|
111
126
|
}
|
|
112
127
|
catch (e) {
|
|
113
128
|
this.logger.error(`[Service] [format] Failed for “${doc.uri}” #${doc.version}`, e);
|
|
@@ -121,7 +136,8 @@ export class Service {
|
|
|
121
136
|
while (node) {
|
|
122
137
|
const symbol = this.project.symbols.resolveAlias(node.symbol);
|
|
123
138
|
if (symbol) {
|
|
124
|
-
const hover = `\`\`\`typescript\n(${symbol.category}${symbol.subcategory ? `/${symbol.subcategory}` : ''}) ${symbol.identifier}\n\`\`\`` +
|
|
139
|
+
const hover = `\`\`\`typescript\n(${symbol.category}${symbol.subcategory ? `/${symbol.subcategory}` : ''}) ${symbol.identifier}\n\`\`\`` +
|
|
140
|
+
(symbol.desc ? `\n******\n${symbol.desc}` : '');
|
|
125
141
|
return Hover.create(node.range, hover);
|
|
126
142
|
}
|
|
127
143
|
if (node.hover) {
|
|
@@ -154,7 +170,10 @@ export class Service {
|
|
|
154
170
|
getSignatureHelp(node, doc, offset) {
|
|
155
171
|
try {
|
|
156
172
|
this.debug(`Getting signature help for '${doc.uri}' # ${doc.version} @ ${offset}`);
|
|
157
|
-
const ctx = SignatureHelpProviderContext.create(this.project, {
|
|
173
|
+
const ctx = SignatureHelpProviderContext.create(this.project, {
|
|
174
|
+
doc,
|
|
175
|
+
offset,
|
|
176
|
+
});
|
|
158
177
|
for (const provider of this.project.meta.signatureHelpProviders) {
|
|
159
178
|
const result = provider(node, ctx);
|
|
160
179
|
if (result) {
|
|
@@ -184,7 +203,7 @@ export class Service {
|
|
|
184
203
|
for (const usage of searchedUsages) {
|
|
185
204
|
let locs = symbol[usage] ?? [];
|
|
186
205
|
if (currentFileOnly) {
|
|
187
|
-
locs = locs.filter(l => l.uri === doc.uri);
|
|
206
|
+
locs = locs.filter((l) => l.uri === doc.uri);
|
|
188
207
|
}
|
|
189
208
|
rawLocations.push(...locs);
|
|
190
209
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { SymbolUtil } from '../symbol/index.js';
|
|
2
|
-
export
|
|
2
|
+
export type SymbolRegistrar = (this: void, symbols: SymbolUtil, ctx: SymbolRegistrarContext) => void;
|
|
3
3
|
export interface SymbolRegistrarContext {
|
|
4
4
|
}
|
|
5
5
|
//# sourceMappingURL=SymbolRegistrar.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { UriBinderContext } from './Context.js';
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
2
|
+
export type UriBinder = (uris: readonly string[], ctx: UriBinderContext) => void;
|
|
3
|
+
export type UriSorterRegistration = (this: void, a: string, b: string, next: UriSorter) => number;
|
|
4
|
+
export type UriSorter = (this: void, a: string, b: string) => number;
|
|
5
5
|
//# sourceMappingURL=UriProcessor.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Externals, FsLocation } from '../common/index.js';
|
|
2
|
-
export
|
|
3
|
-
export
|
|
2
|
+
export type RootUriString = `${string}/`;
|
|
3
|
+
export type FileExtension = `.${string}`;
|
|
4
4
|
export declare namespace fileUtil {
|
|
5
5
|
/**
|
|
6
6
|
* @param rootUris The root URIs. Each URI in this array must end with a slash (`/`).
|
package/lib/service/fileUtil.js
CHANGED
|
@@ -43,7 +43,8 @@ export var fileUtil;
|
|
|
43
43
|
}
|
|
44
44
|
fileUtil.ensureEndingSlash = ensureEndingSlash;
|
|
45
45
|
function join(fromUri, toUri) {
|
|
46
|
-
return ensureEndingSlash(fromUri) +
|
|
46
|
+
return (ensureEndingSlash(fromUri) +
|
|
47
|
+
(toUri.startsWith('/') ? toUri.slice(1) : toUri));
|
|
47
48
|
}
|
|
48
49
|
fileUtil.join = join;
|
|
49
50
|
/**
|
package/lib/source/IndexMap.d.ts
CHANGED
package/lib/source/IndexMap.js
CHANGED
package/lib/source/Location.d.ts
CHANGED
package/lib/source/Location.js
CHANGED
|
@@ -6,7 +6,10 @@ export var Location;
|
|
|
6
6
|
return {
|
|
7
7
|
uri: partial.uri ?? '',
|
|
8
8
|
range: Range.get(partial.range ?? { start: 0, end: 0 }),
|
|
9
|
-
posRange: partial.posRange ?? {
|
|
9
|
+
posRange: partial.posRange ?? {
|
|
10
|
+
start: { line: 0, character: 0 },
|
|
11
|
+
end: { line: 0, character: 0 },
|
|
12
|
+
},
|
|
10
13
|
};
|
|
11
14
|
}
|
|
12
15
|
Location.get = get;
|
package/lib/source/Offset.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReadonlySource } from './Source.js';
|
|
2
|
-
export
|
|
2
|
+
export type OffsetLike = number | ReadonlySource | ((this: void) => number | ReadonlySource);
|
|
3
3
|
export declare namespace Offset {
|
|
4
4
|
/**
|
|
5
5
|
* Get an offset from a `OffsetLike`.
|
package/lib/source/Range.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { OffsetLike } from './Offset.js';
|
|
2
|
-
export
|
|
2
|
+
export type RangeLike = Range | RangeContainer | OffsetLike | ((this: void) => Range | RangeContainer | OffsetLike);
|
|
3
3
|
export interface Range {
|
|
4
4
|
start: number;
|
|
5
5
|
end: number;
|
package/lib/source/Range.js
CHANGED
|
@@ -42,7 +42,8 @@ export var Range;
|
|
|
42
42
|
}
|
|
43
43
|
Range.span = span;
|
|
44
44
|
function is(obj) {
|
|
45
|
-
return (!!obj &&
|
|
45
|
+
return (!!obj &&
|
|
46
|
+
typeof obj === 'object' &&
|
|
46
47
|
typeof obj.start === 'number' &&
|
|
47
48
|
typeof obj.end === 'number');
|
|
48
49
|
}
|
|
@@ -65,7 +66,8 @@ export var Range;
|
|
|
65
66
|
Range.toString = toString;
|
|
66
67
|
function contains(range, offset, endInclusive = false) {
|
|
67
68
|
range = get(range);
|
|
68
|
-
return range.start <= offset &&
|
|
69
|
+
return (range.start <= offset &&
|
|
70
|
+
(endInclusive ? offset <= range.end : offset < range.end));
|
|
69
71
|
}
|
|
70
72
|
Range.contains = contains;
|
|
71
73
|
function containsRange(a, b, endInclusive = false) {
|
|
@@ -144,7 +146,8 @@ export var Range;
|
|
|
144
146
|
export var RangeContainer;
|
|
145
147
|
(function (RangeContainer) {
|
|
146
148
|
function is(obj) {
|
|
147
|
-
return (!!obj &&
|
|
149
|
+
return (!!obj &&
|
|
150
|
+
typeof obj === 'object' &&
|
|
148
151
|
Range.is(obj.range));
|
|
149
152
|
}
|
|
150
153
|
RangeContainer.is = is;
|
package/lib/source/Source.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { IndexMap } from './IndexMap.js';
|
|
2
2
|
import type { RangeContainer } from './Range.js';
|
|
3
3
|
import { Range } from './Range.js';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
type Digit = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9';
|
|
5
|
+
type Space = ' ' | '\t';
|
|
6
|
+
type Newline = '\r\n' | '\r' | '\n';
|
|
7
|
+
type Whitespace = Space | Newline;
|
|
8
8
|
export declare const CRLF = "\r\n";
|
|
9
9
|
export declare const CR = "\r";
|
|
10
10
|
export declare const LF = "\n";
|
package/lib/source/Source.js
CHANGED
|
@@ -91,7 +91,9 @@ export class ReadonlySource {
|
|
|
91
91
|
slice(param0, end) {
|
|
92
92
|
if (typeof param0 === 'number') {
|
|
93
93
|
const innerStart = IndexMap.toInnerOffset(this.indexMap, param0);
|
|
94
|
-
const innerEnd = end !== undefined
|
|
94
|
+
const innerEnd = end !== undefined
|
|
95
|
+
? IndexMap.toInnerOffset(this.indexMap, end)
|
|
96
|
+
: undefined;
|
|
95
97
|
return this.string.slice(innerStart, innerEnd);
|
|
96
98
|
}
|
|
97
99
|
const range = IndexMap.toInnerRange(this.indexMap, Range.get(param0));
|