@spyglassmc/core 0.1.2 → 0.4.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.js +4 -10
- package/lib/common/externals/BrowserExternals.d.ts +3 -0
- package/lib/common/externals/BrowserExternals.js +191 -0
- package/lib/common/externals/NodeJsExternals.d.ts +3 -0
- package/lib/common/externals/NodeJsExternals.js +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 -17
- package/lib/common/util.d.ts +48 -20
- package/lib/common/util.js +71 -86
- package/lib/index.d.ts +7 -7
- package/lib/index.js +7 -23
- 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 +4 -4
- package/lib/node/LiteralNode.js +4 -7
- 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 +7 -7
- package/lib/node/ResourceLocationNode.js +9 -12
- package/lib/node/Sequence.d.ts +2 -2
- package/lib/node/Sequence.js +4 -7
- package/lib/node/StringNode.d.ts +5 -5
- package/lib/node/StringNode.js +9 -12
- package/lib/node/SymbolNode.d.ts +4 -4
- package/lib/node/SymbolNode.js +4 -7
- package/lib/node/index.d.ts +15 -15
- package/lib/node/index.js +15 -31
- package/lib/nodejs.d.ts +2 -0
- package/lib/nodejs.js +2 -0
- package/lib/parser/Parser.d.ts +3 -3
- package/lib/parser/Parser.js +1 -4
- package/lib/parser/boolean.d.ts +2 -2
- package/lib/parser/boolean.js +3 -6
- package/lib/parser/comment.d.ts +2 -2
- package/lib/parser/comment.js +5 -9
- package/lib/parser/empty.d.ts +1 -1
- package/lib/parser/empty.js +1 -5
- package/lib/parser/error.d.ts +2 -2
- package/lib/parser/error.js +5 -9
- package/lib/parser/file.d.ts +3 -3
- package/lib/parser/file.js +9 -13
- package/lib/parser/float.d.ts +4 -4
- package/lib/parser/float.js +12 -16
- package/lib/parser/index.d.ts +16 -16
- package/lib/parser/index.js +16 -38
- package/lib/parser/integer.d.ts +4 -4
- package/lib/parser/integer.js +10 -14
- package/lib/parser/list.d.ts +2 -2
- package/lib/parser/list.js +15 -19
- package/lib/parser/literal.d.ts +2 -2
- package/lib/parser/literal.js +5 -9
- package/lib/parser/long.d.ts +4 -4
- package/lib/parser/long.js +10 -14
- package/lib/parser/record.d.ts +3 -3
- package/lib/parser/record.js +20 -24
- package/lib/parser/resourceLocation.d.ts +2 -2
- package/lib/parser/resourceLocation.js +12 -24
- package/lib/parser/string.d.ts +7 -7
- package/lib/parser/string.js +36 -42
- package/lib/parser/symbol.d.ts +3 -3
- package/lib/parser/symbol.js +4 -14
- package/lib/parser/util.d.ts +6 -5
- package/lib/parser/util.js +40 -60
- 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 -31
- 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 +34 -46
- package/lib/processor/colorizer/index.d.ts +2 -2
- package/lib/processor/colorizer/index.js +2 -31
- package/lib/processor/completer/Completer.d.ts +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 +47 -63
- package/lib/processor/completer/index.d.ts +2 -2
- package/lib/processor/completer/index.js +2 -31
- 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 -31
- package/lib/processor/index.d.ts +10 -9
- package/lib/processor/index.js +10 -25
- 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 +20 -24
- 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 -31
- package/lib/processor/util.d.ts +4 -14
- package/lib/processor/util.js +1 -16
- package/lib/service/CacheService.d.ts +13 -8
- package/lib/service/CacheService.js +45 -57
- package/lib/service/Config.d.ts +11 -12
- package/lib/service/Config.js +50 -45
- package/lib/service/Context.d.ts +23 -20
- package/lib/service/Context.js +39 -36
- package/lib/service/Dependency.js +2 -5
- package/lib/service/Downloader.d.ts +9 -40
- package/lib/service/Downloader.js +37 -110
- package/lib/service/ErrorReporter.d.ts +2 -2
- package/lib/service/ErrorReporter.js +10 -14
- package/lib/service/FileService.d.ts +15 -14
- package/lib/service/FileService.js +55 -92
- package/lib/service/Hover.d.ts +2 -2
- package/lib/service/Hover.js +4 -7
- package/lib/service/MetaRegistry.d.ts +22 -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 +105 -76
- package/lib/service/Project.js +449 -370
- package/lib/service/Service.d.ts +17 -27
- package/lib/service/Service.js +37 -43
- package/lib/service/SymbolLocations.d.ts +3 -3
- package/lib/service/SymbolLocations.js +4 -7
- package/lib/service/SymbolRegistrar.d.ts +1 -1
- package/lib/service/SymbolRegistrar.js +1 -2
- package/lib/service/UriProcessor.d.ts +5 -0
- package/lib/service/UriProcessor.js +2 -0
- package/lib/service/fileUtil.d.ts +15 -45
- package/lib/service/fileUtil.js +38 -143
- package/lib/service/index.d.ts +16 -17
- package/lib/service/index.js +16 -35
- package/lib/source/IndexMap.d.ts +1 -1
- package/lib/source/IndexMap.js +7 -10
- package/lib/source/LanguageError.d.ts +20 -6
- package/lib/source/LanguageError.js +16 -9
- 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 +3 -3
- package/lib/source/PositionRange.js +17 -20
- package/lib/source/Range.d.ts +1 -1
- package/lib/source/Range.js +7 -10
- package/lib/source/Source.d.ts +5 -3
- package/lib/source/Source.js +34 -29
- package/lib/source/index.d.ts +8 -8
- package/lib/source/index.js +8 -24
- package/lib/symbol/Symbol.d.ts +5 -4
- package/lib/symbol/Symbol.js +49 -65
- package/lib/symbol/SymbolUtil.d.ts +29 -31
- package/lib/symbol/SymbolUtil.js +178 -157
- package/lib/symbol/index.d.ts +2 -3
- package/lib/symbol/index.js +2 -19
- 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/Service.d.ts
CHANGED
|
@@ -1,43 +1,33 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import EventEmitter from 'events';
|
|
3
1
|
import type { TextDocument } from 'vscode-languageserver-textdocument';
|
|
4
|
-
import type {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import
|
|
16
|
-
import { Project } from './Project';
|
|
17
|
-
import { SymbolLocations } from './SymbolLocations';
|
|
2
|
+
import type { Logger } from '../common/index.js';
|
|
3
|
+
import type { FileNode } from '../node/index.js';
|
|
4
|
+
import { AstNode } from '../node/index.js';
|
|
5
|
+
import type { Color, ColorInfo, ColorToken, InlayHint, SignatureHelp } from '../processor/index.js';
|
|
6
|
+
import { ColorPresentation } from '../processor/index.js';
|
|
7
|
+
import { Range } from '../source/index.js';
|
|
8
|
+
import type { SymbolUsageType } from '../symbol/index.js';
|
|
9
|
+
import { Hover } from './Hover.js';
|
|
10
|
+
import { ProfilerFactory } from './Profiler.js';
|
|
11
|
+
import type { ProjectOptions } from './Project.js';
|
|
12
|
+
import { Project } from './Project.js';
|
|
13
|
+
import { SymbolLocations } from './SymbolLocations.js';
|
|
18
14
|
interface Options {
|
|
19
|
-
cacheRoot: string;
|
|
20
|
-
downloader?: Downloader;
|
|
21
|
-
fs?: FileService;
|
|
22
|
-
initializers?: readonly ProjectInitializer[];
|
|
23
15
|
isDebugging?: boolean;
|
|
24
|
-
logger
|
|
16
|
+
logger: Logger;
|
|
25
17
|
profilers?: ProfilerFactory;
|
|
26
|
-
|
|
18
|
+
project: ProjectOptions;
|
|
27
19
|
}
|
|
28
|
-
export declare class Service
|
|
29
|
-
readonly downloader: Downloader;
|
|
30
|
-
readonly fs: FileService;
|
|
20
|
+
export declare class Service {
|
|
31
21
|
readonly isDebugging: boolean;
|
|
32
22
|
readonly logger: Logger;
|
|
33
23
|
readonly profilers: ProfilerFactory;
|
|
34
24
|
readonly project: Project;
|
|
35
|
-
constructor({
|
|
25
|
+
constructor({ isDebugging, logger, profilers, project, }: Options);
|
|
36
26
|
private debug;
|
|
37
27
|
colorize(node: FileNode<AstNode>, doc: TextDocument, range?: Range): readonly ColorToken[];
|
|
38
28
|
getColorInfo(node: FileNode<AstNode>, doc: TextDocument): ColorInfo[];
|
|
39
29
|
getColorPresentation(file: FileNode<AstNode>, doc: TextDocument, range: Range, color: Color): ColorPresentation[];
|
|
40
|
-
complete(node: FileNode<AstNode>, doc: TextDocument, offset: number, triggerCharacter?: string): import("../processor").CompletionItem[];
|
|
30
|
+
complete(node: FileNode<AstNode>, doc: TextDocument, offset: number, triggerCharacter?: string): import("../processor/index.js").CompletionItem[];
|
|
41
31
|
dataHackPubify(initialism: string): string;
|
|
42
32
|
format(node: FileNode<AstNode>, doc: TextDocument, tabSize: number, insertSpaces: boolean): string;
|
|
43
33
|
getHover(file: FileNode<AstNode>, doc: TextDocument, offset: number): Hover | undefined;
|
package/lib/service/Service.js
CHANGED
|
@@ -1,33 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const symbol_1 = require("../symbol");
|
|
12
|
-
const Context_1 = require("./Context");
|
|
13
|
-
const Downloader_1 = require("./Downloader");
|
|
14
|
-
const FileService_1 = require("./FileService");
|
|
15
|
-
const fileUtil_1 = require("./fileUtil");
|
|
16
|
-
const Hover_1 = require("./Hover");
|
|
17
|
-
const Logger_1 = require("./Logger");
|
|
18
|
-
const Profiler_1 = require("./Profiler");
|
|
19
|
-
const Project_1 = require("./Project");
|
|
20
|
-
const SymbolLocations_1 = require("./SymbolLocations");
|
|
1
|
+
import { AstNode } from '../node/index.js';
|
|
2
|
+
import { ColorPresentation, completer, traversePreOrder } from '../processor/index.js';
|
|
3
|
+
import { Range } from '../source/index.js';
|
|
4
|
+
import { SymbolUsageTypes } from '../symbol/index.js';
|
|
5
|
+
import { ColorizerContext, CompleterContext, FormatterContext, ProcessorContext, SignatureHelpProviderContext } from './Context.js';
|
|
6
|
+
import { fileUtil } from './fileUtil.js';
|
|
7
|
+
import { Hover } from './Hover.js';
|
|
8
|
+
import { ProfilerFactory } from './Profiler.js';
|
|
9
|
+
import { Project } from './Project.js';
|
|
10
|
+
import { SymbolLocations } from './SymbolLocations.js';
|
|
21
11
|
/* istanbul ignore next */
|
|
22
|
-
class Service
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
12
|
+
export class Service {
|
|
13
|
+
isDebugging;
|
|
14
|
+
logger;
|
|
15
|
+
profilers;
|
|
16
|
+
project;
|
|
17
|
+
constructor({ isDebugging = false, logger, profilers = ProfilerFactory.noop(), project, }) {
|
|
27
18
|
this.isDebugging = isDebugging;
|
|
28
19
|
this.logger = logger;
|
|
29
20
|
this.profilers = profilers;
|
|
30
|
-
this.project = new
|
|
21
|
+
this.project = new Project({
|
|
22
|
+
logger,
|
|
23
|
+
profilers,
|
|
24
|
+
...project,
|
|
25
|
+
});
|
|
31
26
|
}
|
|
32
27
|
debug(message) {
|
|
33
28
|
if (this.isDebugging) {
|
|
@@ -38,7 +33,7 @@ class Service extends events_1.default {
|
|
|
38
33
|
try {
|
|
39
34
|
this.debug(`Colorizing '${doc.uri}' # ${doc.version}`);
|
|
40
35
|
const colorizer = this.project.meta.getColorizer(node.type);
|
|
41
|
-
return colorizer(node,
|
|
36
|
+
return colorizer(node, ColorizerContext.create(this.project, { doc, range }));
|
|
42
37
|
}
|
|
43
38
|
catch (e) {
|
|
44
39
|
this.logger.error(`[Service] [colorize] Failed for “${doc.uri}” #${doc.version}`, e);
|
|
@@ -49,7 +44,7 @@ class Service extends events_1.default {
|
|
|
49
44
|
try {
|
|
50
45
|
this.debug(`Getting color info for '${doc.uri}' # ${doc.version}`);
|
|
51
46
|
const ans = [];
|
|
52
|
-
|
|
47
|
+
traversePreOrder(node, _ => true, node => node.color, node => ans.push({
|
|
53
48
|
color: Array.isArray(node.color) ? node.color : node.color.value,
|
|
54
49
|
range: Array.isArray(node.color) ? node.range : (node.color.range ?? node.range),
|
|
55
50
|
}));
|
|
@@ -62,13 +57,13 @@ class Service extends events_1.default {
|
|
|
62
57
|
}
|
|
63
58
|
getColorPresentation(file, doc, range, color) {
|
|
64
59
|
try {
|
|
65
|
-
this.debug(`Getting color presentation for '${doc.uri}' # ${doc.version} @ ${
|
|
66
|
-
let node =
|
|
60
|
+
this.debug(`Getting color presentation for '${doc.uri}' # ${doc.version} @ ${Range.toString(range)}`);
|
|
61
|
+
let node = AstNode.findDeepestChild({ node: file, needle: range.start });
|
|
67
62
|
while (node) {
|
|
68
63
|
const nodeColor = node.color;
|
|
69
64
|
if (nodeColor && !Array.isArray(nodeColor)) {
|
|
70
65
|
const colorRange = nodeColor.range ?? node.range;
|
|
71
|
-
return nodeColor.format.map(format =>
|
|
66
|
+
return nodeColor.format.map(format => ColorPresentation.fromColorFormat(format, color, colorRange));
|
|
72
67
|
}
|
|
73
68
|
node = node.parent;
|
|
74
69
|
}
|
|
@@ -83,7 +78,7 @@ class Service extends events_1.default {
|
|
|
83
78
|
this.debug(`Getting completion for '${doc.uri}' # ${doc.version} @ ${offset}`);
|
|
84
79
|
const shouldComplete = this.project.meta.shouldComplete(doc.languageId, triggerCharacter);
|
|
85
80
|
if (shouldComplete) {
|
|
86
|
-
return
|
|
81
|
+
return completer.file(node, CompleterContext.create(this.project, { doc, offset, triggerCharacter }));
|
|
87
82
|
}
|
|
88
83
|
}
|
|
89
84
|
catch (e) {
|
|
@@ -112,7 +107,7 @@ class Service extends events_1.default {
|
|
|
112
107
|
try {
|
|
113
108
|
this.debug(`Formatting '${doc.uri}' # ${doc.version}`);
|
|
114
109
|
const formatter = this.project.meta.getFormatter(node.type);
|
|
115
|
-
return formatter(node,
|
|
110
|
+
return formatter(node, FormatterContext.create(this.project, { doc, tabSize, insertSpaces }));
|
|
116
111
|
}
|
|
117
112
|
catch (e) {
|
|
118
113
|
this.logger.error(`[Service] [format] Failed for “${doc.uri}” #${doc.version}`, e);
|
|
@@ -122,15 +117,15 @@ class Service extends events_1.default {
|
|
|
122
117
|
getHover(file, doc, offset) {
|
|
123
118
|
try {
|
|
124
119
|
this.debug(`Getting hover for '${doc.uri}' # ${doc.version} @ ${offset}`);
|
|
125
|
-
let node =
|
|
120
|
+
let node = AstNode.findDeepestChild({ node: file, needle: offset });
|
|
126
121
|
while (node) {
|
|
127
122
|
const symbol = this.project.symbols.resolveAlias(node.symbol);
|
|
128
123
|
if (symbol) {
|
|
129
124
|
const hover = `\`\`\`typescript\n(${symbol.category}${symbol.subcategory ? `/${symbol.subcategory}` : ''}) ${symbol.identifier}\n\`\`\`` + (symbol.desc ? `\n******\n${symbol.desc}` : '');
|
|
130
|
-
return
|
|
125
|
+
return Hover.create(node.range, hover);
|
|
131
126
|
}
|
|
132
127
|
if (node.hover) {
|
|
133
|
-
return
|
|
128
|
+
return Hover.create(node.range, node.hover);
|
|
134
129
|
}
|
|
135
130
|
node = node.parent;
|
|
136
131
|
}
|
|
@@ -145,7 +140,7 @@ class Service extends events_1.default {
|
|
|
145
140
|
// TODO: `range` argument is not used.
|
|
146
141
|
this.debug(`Getting inlay hints for '${doc.uri}' # ${doc.version}`);
|
|
147
142
|
const ans = [];
|
|
148
|
-
const ctx =
|
|
143
|
+
const ctx = ProcessorContext.create(this.project, { doc });
|
|
149
144
|
for (const provider of this.project.meta.inlayHintProviders) {
|
|
150
145
|
ans.push(...provider(node, ctx));
|
|
151
146
|
}
|
|
@@ -159,7 +154,7 @@ class Service extends events_1.default {
|
|
|
159
154
|
getSignatureHelp(node, doc, offset) {
|
|
160
155
|
try {
|
|
161
156
|
this.debug(`Getting signature help for '${doc.uri}' # ${doc.version} @ ${offset}`);
|
|
162
|
-
const ctx =
|
|
157
|
+
const ctx = SignatureHelpProviderContext.create(this.project, { doc, offset });
|
|
163
158
|
for (const provider of this.project.meta.signatureHelpProviders) {
|
|
164
159
|
const result = provider(node, ctx);
|
|
165
160
|
if (result) {
|
|
@@ -178,10 +173,10 @@ class Service extends events_1.default {
|
|
|
178
173
|
*
|
|
179
174
|
* @returns Symbol locations of the selected symbol at `offset`, or `undefined` if there's no symbol at `offset`.
|
|
180
175
|
*/
|
|
181
|
-
async getSymbolLocations(file, doc, offset, searchedUsages =
|
|
176
|
+
async getSymbolLocations(file, doc, offset, searchedUsages = SymbolUsageTypes, currentFileOnly = false) {
|
|
182
177
|
try {
|
|
183
178
|
this.debug(`Getting symbol locations of usage '${searchedUsages.join(',')}' for '${doc.uri}' # ${doc.version} @ ${offset} with currentFileOnly=${currentFileOnly}`);
|
|
184
|
-
let node =
|
|
179
|
+
let node = AstNode.findDeepestChild({ node: file, needle: offset });
|
|
185
180
|
while (node) {
|
|
186
181
|
const symbol = this.project.symbols.resolveAlias(node.symbol);
|
|
187
182
|
if (symbol) {
|
|
@@ -195,14 +190,14 @@ class Service extends events_1.default {
|
|
|
195
190
|
}
|
|
196
191
|
const locations = [];
|
|
197
192
|
for (const loc of rawLocations) {
|
|
198
|
-
const mappedUri =
|
|
193
|
+
const mappedUri = fileUtil.isFileUri(loc.uri)
|
|
199
194
|
? loc.uri
|
|
200
195
|
: await this.project.fs.mapToDisk(loc.uri);
|
|
201
196
|
if (mappedUri) {
|
|
202
197
|
locations.push({ ...loc, uri: mappedUri });
|
|
203
198
|
}
|
|
204
199
|
}
|
|
205
|
-
return
|
|
200
|
+
return SymbolLocations.create(node.range, locations.length ? locations : undefined);
|
|
206
201
|
}
|
|
207
202
|
node = node.parent;
|
|
208
203
|
}
|
|
@@ -213,5 +208,4 @@ class Service extends events_1.default {
|
|
|
213
208
|
return undefined;
|
|
214
209
|
}
|
|
215
210
|
}
|
|
216
|
-
exports.Service = Service;
|
|
217
211
|
//# sourceMappingURL=Service.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { RangeLike } from '../source';
|
|
2
|
-
import { Range } from '../source';
|
|
3
|
-
import type { SymbolLocation } from '../symbol';
|
|
1
|
+
import type { RangeLike } from '../source/index.js';
|
|
2
|
+
import { Range } from '../source/index.js';
|
|
3
|
+
import type { SymbolLocation } from '../symbol/index.js';
|
|
4
4
|
export interface SymbolLocations {
|
|
5
5
|
/**
|
|
6
6
|
* The range of the currently selected symbol.
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.SymbolLocations = void 0;
|
|
4
|
-
const source_1 = require("../source");
|
|
5
|
-
var SymbolLocations;
|
|
1
|
+
import { Range } from '../source/index.js';
|
|
2
|
+
export var SymbolLocations;
|
|
6
3
|
(function (SymbolLocations) {
|
|
7
4
|
/* istanbul ignore next */
|
|
8
5
|
function create(range, locations) {
|
|
9
6
|
return {
|
|
10
|
-
range:
|
|
7
|
+
range: Range.get(range),
|
|
11
8
|
locations,
|
|
12
9
|
};
|
|
13
10
|
}
|
|
14
11
|
SymbolLocations.create = create;
|
|
15
|
-
})(SymbolLocations
|
|
12
|
+
})(SymbolLocations || (SymbolLocations = {}));
|
|
16
13
|
//# sourceMappingURL=SymbolLocations.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { UriBinderContext } from './Context.js';
|
|
2
|
+
export declare type UriBinder = (uris: readonly string[], ctx: UriBinderContext) => void;
|
|
3
|
+
export declare type UriSorterRegistration = (this: void, a: string, b: string, next: UriSorter) => number;
|
|
4
|
+
export declare type UriSorter = (this: void, a: string, b: string) => number;
|
|
5
|
+
//# sourceMappingURL=UriProcessor.d.ts.map
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
import { URL as Uri } from 'url';
|
|
1
|
+
import type { Externals, FsLocation } from '../common/index.js';
|
|
4
2
|
export declare type RootUriString = `${string}/`;
|
|
5
3
|
export declare type FileExtension = `.${string}`;
|
|
6
|
-
/**
|
|
7
|
-
* A string file path, string file URI, or a file URI object.
|
|
8
|
-
*/
|
|
9
|
-
export declare type PathLike = string | Uri;
|
|
10
4
|
export declare namespace fileUtil {
|
|
11
5
|
/**
|
|
12
6
|
* @param rootUris The root URIs. Each URI in this array must end with a slash (`/`).
|
|
@@ -45,25 +39,13 @@ export declare namespace fileUtil {
|
|
|
45
39
|
* @returns The part from the last `/` to the end of the URI.
|
|
46
40
|
*/
|
|
47
41
|
function basename(uri: string): string;
|
|
48
|
-
|
|
49
|
-
* @param fileUri A file URI.
|
|
50
|
-
* @returns The corresponding file path of the `fileUri` in platform-specific format.
|
|
51
|
-
* @throws If the URI is not a file schema URI.
|
|
52
|
-
*/
|
|
53
|
-
function fileUriToPath(fileUri: string): string;
|
|
54
|
-
/**
|
|
55
|
-
* @param path A file path.
|
|
56
|
-
* @returns The corresponding file URI of the `path`.
|
|
57
|
-
*/
|
|
58
|
-
function pathToFileUri(path: string): string;
|
|
59
|
-
function normalize(uri: string): string;
|
|
60
|
-
function getParentOfFile(path: PathLike): PathLike;
|
|
42
|
+
function getParentOfFile(externals: Externals, path: FsLocation): FsLocation;
|
|
61
43
|
/**
|
|
62
44
|
* @throws
|
|
63
45
|
*
|
|
64
46
|
* @param mode Default to `0o777` (`rwxrwxrwx`)
|
|
65
47
|
*/
|
|
66
|
-
function ensureDir(path:
|
|
48
|
+
function ensureDir(externals: Externals, path: FsLocation, mode?: number): Promise<void>;
|
|
67
49
|
/**
|
|
68
50
|
* @throws
|
|
69
51
|
*
|
|
@@ -71,11 +53,11 @@ export declare namespace fileUtil {
|
|
|
71
53
|
*
|
|
72
54
|
* @param mode Default to `0o777` (`rwxrwxrwx`)
|
|
73
55
|
*/
|
|
74
|
-
function ensureParentOfFile(path:
|
|
75
|
-
function chmod(path:
|
|
76
|
-
function ensureWritable(path:
|
|
77
|
-
function markReadOnly(path:
|
|
78
|
-
function readFile(path:
|
|
56
|
+
function ensureParentOfFile(externals: Externals, path: FsLocation, mode?: number): Promise<void>;
|
|
57
|
+
function chmod(externals: Externals, path: FsLocation, mode: number): Promise<void>;
|
|
58
|
+
function ensureWritable(externals: Externals, path: FsLocation): Promise<void>;
|
|
59
|
+
function markReadOnly(externals: Externals, path: FsLocation): Promise<void>;
|
|
60
|
+
function readFile(externals: Externals, path: FsLocation): Promise<Uint8Array>;
|
|
79
61
|
/**
|
|
80
62
|
* @throws
|
|
81
63
|
*
|
|
@@ -88,44 +70,32 @@ export declare namespace fileUtil {
|
|
|
88
70
|
* * Mode: `0o666` (`rw-rw-rw-`)
|
|
89
71
|
* * Flag: `w`
|
|
90
72
|
*/
|
|
91
|
-
function writeFile(path:
|
|
73
|
+
function writeFile(externals: Externals, path: FsLocation, data: Uint8Array | string, mode?: number): Promise<void>;
|
|
92
74
|
/**
|
|
93
75
|
* @throws
|
|
94
76
|
*/
|
|
95
|
-
function readJson
|
|
77
|
+
function readJson(externals: Externals, path: FsLocation): Promise<unknown>;
|
|
96
78
|
/**
|
|
97
79
|
* @throws
|
|
98
80
|
*
|
|
99
81
|
* @see {@link writeFile}
|
|
100
82
|
*/
|
|
101
|
-
function writeJson(path:
|
|
83
|
+
function writeJson(externals: Externals, path: FsLocation, data: any): Promise<void>;
|
|
102
84
|
/**
|
|
103
85
|
* @throws
|
|
104
86
|
*/
|
|
105
|
-
function readGzippedFile(path:
|
|
87
|
+
function readGzippedFile(externals: Externals, path: FsLocation): Promise<Uint8Array>;
|
|
106
88
|
/**
|
|
107
89
|
* @throws
|
|
108
90
|
*/
|
|
109
|
-
function writeGzippedFile(path:
|
|
91
|
+
function writeGzippedFile(externals: Externals, path: FsLocation, buffer: Uint8Array | string): Promise<void>;
|
|
110
92
|
/**
|
|
111
93
|
* @throws
|
|
112
94
|
*/
|
|
113
|
-
function readGzippedJson
|
|
95
|
+
function readGzippedJson(externals: Externals, path: FsLocation): Promise<unknown>;
|
|
114
96
|
/**
|
|
115
97
|
* @throws
|
|
116
98
|
*/
|
|
117
|
-
function writeGzippedJson(path:
|
|
118
|
-
/**
|
|
119
|
-
* Show the file/directory in the platform-specific explorer program.
|
|
120
|
-
*
|
|
121
|
-
* Should not be called with unsanitized user-input path due to the possibility of
|
|
122
|
-
* arbitrary code execution.
|
|
123
|
-
*
|
|
124
|
-
* @returns The `stdout` from the spawned child process.
|
|
125
|
-
*/
|
|
126
|
-
function showFile(path: string): Promise<{
|
|
127
|
-
stdout: string;
|
|
128
|
-
stderr: string;
|
|
129
|
-
}>;
|
|
99
|
+
function writeGzippedJson(externals: Externals, path: FsLocation, data: any): Promise<void>;
|
|
130
100
|
}
|
|
131
101
|
//# sourceMappingURL=fileUtil.d.ts.map
|