@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/Service.d.ts
CHANGED
|
@@ -1,44 +1,35 @@
|
|
|
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;
|
|
32
|
+
format(node: FileNode<AstNode>, doc: TextDocument, tabSize: number, insertSpaces: boolean): string;
|
|
42
33
|
getHover(file: FileNode<AstNode>, doc: TextDocument, offset: number): Hover | undefined;
|
|
43
34
|
getInlayHints(node: FileNode<AstNode>, doc: TextDocument, range?: Range): InlayHint[];
|
|
44
35
|
getSignatureHelp(node: FileNode<AstNode>, doc: TextDocument, offset: number): SignatureHelp | undefined;
|
|
@@ -48,8 +39,7 @@ export declare class Service extends EventEmitter {
|
|
|
48
39
|
*
|
|
49
40
|
* @returns Symbol locations of the selected symbol at `offset`, or `undefined` if there's no symbol at `offset`.
|
|
50
41
|
*/
|
|
51
|
-
getSymbolLocations(file: FileNode<AstNode>, doc: TextDocument, offset: number, searchedUsages?: readonly SymbolUsageType[], currentFileOnly?: boolean): SymbolLocations | undefined
|
|
52
|
-
format(node: FileNode<AstNode>, doc: TextDocument, tabSize: number, insertSpaces: boolean): string;
|
|
42
|
+
getSymbolLocations(file: FileNode<AstNode>, doc: TextDocument, offset: number, searchedUsages?: readonly SymbolUsageType[], currentFileOnly?: boolean): Promise<SymbolLocations | undefined>;
|
|
53
43
|
}
|
|
54
44
|
export {};
|
|
55
45
|
//# sourceMappingURL=Service.d.ts.map
|
package/lib/service/Service.js
CHANGED
|
@@ -1,32 +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 Hover_1 = require("./Hover");
|
|
16
|
-
const Logger_1 = require("./Logger");
|
|
17
|
-
const Profiler_1 = require("./Profiler");
|
|
18
|
-
const Project_1 = require("./Project");
|
|
19
|
-
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';
|
|
20
11
|
/* istanbul ignore next */
|
|
21
|
-
class Service
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
12
|
+
export class Service {
|
|
13
|
+
isDebugging;
|
|
14
|
+
logger;
|
|
15
|
+
profilers;
|
|
16
|
+
project;
|
|
17
|
+
constructor({ isDebugging = false, logger, profilers = ProfilerFactory.noop(), project, }) {
|
|
26
18
|
this.isDebugging = isDebugging;
|
|
27
19
|
this.logger = logger;
|
|
28
20
|
this.profilers = profilers;
|
|
29
|
-
this.project = new
|
|
21
|
+
this.project = new Project({
|
|
22
|
+
logger,
|
|
23
|
+
profilers,
|
|
24
|
+
...project,
|
|
25
|
+
});
|
|
30
26
|
}
|
|
31
27
|
debug(message) {
|
|
32
28
|
if (this.isDebugging) {
|
|
@@ -37,7 +33,7 @@ class Service extends events_1.default {
|
|
|
37
33
|
try {
|
|
38
34
|
this.debug(`Colorizing '${doc.uri}' # ${doc.version}`);
|
|
39
35
|
const colorizer = this.project.meta.getColorizer(node.type);
|
|
40
|
-
return colorizer(node,
|
|
36
|
+
return colorizer(node, ColorizerContext.create(this.project, { doc, range }));
|
|
41
37
|
}
|
|
42
38
|
catch (e) {
|
|
43
39
|
this.logger.error(`[Service] [colorize] Failed for “${doc.uri}” #${doc.version}`, e);
|
|
@@ -48,7 +44,7 @@ class Service extends events_1.default {
|
|
|
48
44
|
try {
|
|
49
45
|
this.debug(`Getting color info for '${doc.uri}' # ${doc.version}`);
|
|
50
46
|
const ans = [];
|
|
51
|
-
|
|
47
|
+
traversePreOrder(node, _ => true, node => node.color, node => ans.push({
|
|
52
48
|
color: Array.isArray(node.color) ? node.color : node.color.value,
|
|
53
49
|
range: Array.isArray(node.color) ? node.range : (node.color.range ?? node.range),
|
|
54
50
|
}));
|
|
@@ -61,13 +57,13 @@ class Service extends events_1.default {
|
|
|
61
57
|
}
|
|
62
58
|
getColorPresentation(file, doc, range, color) {
|
|
63
59
|
try {
|
|
64
|
-
this.debug(`Getting color presentation for '${doc.uri}' # ${doc.version} @ ${
|
|
65
|
-
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 });
|
|
66
62
|
while (node) {
|
|
67
63
|
const nodeColor = node.color;
|
|
68
64
|
if (nodeColor && !Array.isArray(nodeColor)) {
|
|
69
65
|
const colorRange = nodeColor.range ?? node.range;
|
|
70
|
-
return nodeColor.format.map(format =>
|
|
66
|
+
return nodeColor.format.map(format => ColorPresentation.fromColorFormat(format, color, colorRange));
|
|
71
67
|
}
|
|
72
68
|
node = node.parent;
|
|
73
69
|
}
|
|
@@ -82,7 +78,7 @@ class Service extends events_1.default {
|
|
|
82
78
|
this.debug(`Getting completion for '${doc.uri}' # ${doc.version} @ ${offset}`);
|
|
83
79
|
const shouldComplete = this.project.meta.shouldComplete(doc.languageId, triggerCharacter);
|
|
84
80
|
if (shouldComplete) {
|
|
85
|
-
return
|
|
81
|
+
return completer.file(node, CompleterContext.create(this.project, { doc, offset, triggerCharacter }));
|
|
86
82
|
}
|
|
87
83
|
}
|
|
88
84
|
catch (e) {
|
|
@@ -107,18 +103,29 @@ class Service extends events_1.default {
|
|
|
107
103
|
.map((c, i) => `${c.toUpperCase()}${secrets[i % secrets.length]}`)
|
|
108
104
|
.join(' ');
|
|
109
105
|
}
|
|
106
|
+
format(node, doc, tabSize, insertSpaces) {
|
|
107
|
+
try {
|
|
108
|
+
this.debug(`Formatting '${doc.uri}' # ${doc.version}`);
|
|
109
|
+
const formatter = this.project.meta.getFormatter(node.type);
|
|
110
|
+
return formatter(node, FormatterContext.create(this.project, { doc, tabSize, insertSpaces }));
|
|
111
|
+
}
|
|
112
|
+
catch (e) {
|
|
113
|
+
this.logger.error(`[Service] [format] Failed for “${doc.uri}” #${doc.version}`, e);
|
|
114
|
+
throw e;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
110
117
|
getHover(file, doc, offset) {
|
|
111
118
|
try {
|
|
112
119
|
this.debug(`Getting hover for '${doc.uri}' # ${doc.version} @ ${offset}`);
|
|
113
|
-
let node =
|
|
120
|
+
let node = AstNode.findDeepestChild({ node: file, needle: offset });
|
|
114
121
|
while (node) {
|
|
115
122
|
const symbol = this.project.symbols.resolveAlias(node.symbol);
|
|
116
123
|
if (symbol) {
|
|
117
124
|
const hover = `\`\`\`typescript\n(${symbol.category}${symbol.subcategory ? `/${symbol.subcategory}` : ''}) ${symbol.identifier}\n\`\`\`` + (symbol.desc ? `\n******\n${symbol.desc}` : '');
|
|
118
|
-
return
|
|
125
|
+
return Hover.create(node.range, hover);
|
|
119
126
|
}
|
|
120
127
|
if (node.hover) {
|
|
121
|
-
return
|
|
128
|
+
return Hover.create(node.range, node.hover);
|
|
122
129
|
}
|
|
123
130
|
node = node.parent;
|
|
124
131
|
}
|
|
@@ -133,7 +140,7 @@ class Service extends events_1.default {
|
|
|
133
140
|
// TODO: `range` argument is not used.
|
|
134
141
|
this.debug(`Getting inlay hints for '${doc.uri}' # ${doc.version}`);
|
|
135
142
|
const ans = [];
|
|
136
|
-
const ctx =
|
|
143
|
+
const ctx = ProcessorContext.create(this.project, { doc });
|
|
137
144
|
for (const provider of this.project.meta.inlayHintProviders) {
|
|
138
145
|
ans.push(...provider(node, ctx));
|
|
139
146
|
}
|
|
@@ -147,7 +154,7 @@ class Service extends events_1.default {
|
|
|
147
154
|
getSignatureHelp(node, doc, offset) {
|
|
148
155
|
try {
|
|
149
156
|
this.debug(`Getting signature help for '${doc.uri}' # ${doc.version} @ ${offset}`);
|
|
150
|
-
const ctx =
|
|
157
|
+
const ctx = SignatureHelpProviderContext.create(this.project, { doc, offset });
|
|
151
158
|
for (const provider of this.project.meta.signatureHelpProviders) {
|
|
152
159
|
const result = provider(node, ctx);
|
|
153
160
|
if (result) {
|
|
@@ -166,22 +173,31 @@ class Service extends events_1.default {
|
|
|
166
173
|
*
|
|
167
174
|
* @returns Symbol locations of the selected symbol at `offset`, or `undefined` if there's no symbol at `offset`.
|
|
168
175
|
*/
|
|
169
|
-
getSymbolLocations(file, doc, offset, searchedUsages =
|
|
176
|
+
async getSymbolLocations(file, doc, offset, searchedUsages = SymbolUsageTypes, currentFileOnly = false) {
|
|
170
177
|
try {
|
|
171
178
|
this.debug(`Getting symbol locations of usage '${searchedUsages.join(',')}' for '${doc.uri}' # ${doc.version} @ ${offset} with currentFileOnly=${currentFileOnly}`);
|
|
172
|
-
let node =
|
|
179
|
+
let node = AstNode.findDeepestChild({ node: file, needle: offset });
|
|
173
180
|
while (node) {
|
|
174
181
|
const symbol = this.project.symbols.resolveAlias(node.symbol);
|
|
175
182
|
if (symbol) {
|
|
176
|
-
const
|
|
183
|
+
const rawLocations = [];
|
|
177
184
|
for (const usage of searchedUsages) {
|
|
178
185
|
let locs = symbol[usage] ?? [];
|
|
179
186
|
if (currentFileOnly) {
|
|
180
187
|
locs = locs.filter(l => l.uri === doc.uri);
|
|
181
188
|
}
|
|
182
|
-
|
|
189
|
+
rawLocations.push(...locs);
|
|
190
|
+
}
|
|
191
|
+
const locations = [];
|
|
192
|
+
for (const loc of rawLocations) {
|
|
193
|
+
const mappedUri = fileUtil.isFileUri(loc.uri)
|
|
194
|
+
? loc.uri
|
|
195
|
+
: await this.project.fs.mapToDisk(loc.uri);
|
|
196
|
+
if (mappedUri) {
|
|
197
|
+
locations.push({ ...loc, uri: mappedUri });
|
|
198
|
+
}
|
|
183
199
|
}
|
|
184
|
-
return
|
|
200
|
+
return SymbolLocations.create(node.range, locations.length ? locations : undefined);
|
|
185
201
|
}
|
|
186
202
|
node = node.parent;
|
|
187
203
|
}
|
|
@@ -191,17 +207,5 @@ class Service extends events_1.default {
|
|
|
191
207
|
}
|
|
192
208
|
return undefined;
|
|
193
209
|
}
|
|
194
|
-
format(node, doc, tabSize, insertSpaces) {
|
|
195
|
-
try {
|
|
196
|
-
this.debug(`Formatting '${doc.uri}' # ${doc.version}`);
|
|
197
|
-
const formatter = this.project.meta.getFormatter(node.type);
|
|
198
|
-
return formatter(node, Context_1.FormatterContext.create(this.project, { doc, tabSize, insertSpaces }));
|
|
199
|
-
}
|
|
200
|
-
catch (e) {
|
|
201
|
-
this.logger.error(`[Service] [format] Failed for “${doc.uri}” #${doc.version}`, e);
|
|
202
|
-
throw e;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
210
|
}
|
|
206
|
-
exports.Service = Service;
|
|
207
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
|
-
import type fs from 'fs';
|
|
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 (`/`).
|
|
@@ -42,24 +36,16 @@ export declare namespace fileUtil {
|
|
|
42
36
|
*/
|
|
43
37
|
function extname(value: string): FileExtension | undefined;
|
|
44
38
|
/**
|
|
45
|
-
* @
|
|
46
|
-
* @returns The corresponding file path of the `fileUri` in platform-specific format.
|
|
47
|
-
* @throws If the URI is not a file schema URI.
|
|
39
|
+
* @returns The part from the last `/` to the end of the URI.
|
|
48
40
|
*/
|
|
49
|
-
function
|
|
50
|
-
|
|
51
|
-
* @param path A file path.
|
|
52
|
-
* @returns The corresponding file URI of the `path`.
|
|
53
|
-
*/
|
|
54
|
-
function pathToFileUri(path: string): string;
|
|
55
|
-
function normalize(uri: string): string;
|
|
56
|
-
function getParentOfFile(path: PathLike): PathLike;
|
|
41
|
+
function basename(uri: string): string;
|
|
42
|
+
function getParentOfFile(externals: Externals, path: FsLocation): FsLocation;
|
|
57
43
|
/**
|
|
58
44
|
* @throws
|
|
59
45
|
*
|
|
60
46
|
* @param mode Default to `0o777` (`rwxrwxrwx`)
|
|
61
47
|
*/
|
|
62
|
-
function ensureDir(path:
|
|
48
|
+
function ensureDir(externals: Externals, path: FsLocation, mode?: number): Promise<void>;
|
|
63
49
|
/**
|
|
64
50
|
* @throws
|
|
65
51
|
*
|
|
@@ -67,55 +53,49 @@ export declare namespace fileUtil {
|
|
|
67
53
|
*
|
|
68
54
|
* @param mode Default to `0o777` (`rwxrwxrwx`)
|
|
69
55
|
*/
|
|
70
|
-
function ensureParentOfFile(path:
|
|
71
|
-
function
|
|
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>;
|
|
72
61
|
/**
|
|
73
62
|
* @throws
|
|
74
63
|
*
|
|
75
|
-
* The directory of the file will be created recursively if it doesn'
|
|
64
|
+
* The directory of the file will be created recursively if it doesn't exist.
|
|
65
|
+
*
|
|
66
|
+
* The target file will be given permission `0o666` (`rw-rw-rw-`) before being written into, and changed back to the
|
|
67
|
+
* specified `mode`.
|
|
76
68
|
*
|
|
77
69
|
* * Encoding: `utf-8`
|
|
78
70
|
* * Mode: `0o666` (`rw-rw-rw-`)
|
|
79
71
|
* * Flag: `w`
|
|
80
72
|
*/
|
|
81
|
-
function writeFile(path:
|
|
73
|
+
function writeFile(externals: Externals, path: FsLocation, data: Uint8Array | string, mode?: number): Promise<void>;
|
|
82
74
|
/**
|
|
83
75
|
* @throws
|
|
84
76
|
*/
|
|
85
|
-
function readJson
|
|
77
|
+
function readJson(externals: Externals, path: FsLocation): Promise<unknown>;
|
|
86
78
|
/**
|
|
87
79
|
* @throws
|
|
88
80
|
*
|
|
89
81
|
* @see {@link writeFile}
|
|
90
82
|
*/
|
|
91
|
-
function writeJson(path:
|
|
83
|
+
function writeJson(externals: Externals, path: FsLocation, data: any): Promise<void>;
|
|
92
84
|
/**
|
|
93
85
|
* @throws
|
|
94
86
|
*/
|
|
95
|
-
function readGzippedFile(path:
|
|
87
|
+
function readGzippedFile(externals: Externals, path: FsLocation): Promise<Uint8Array>;
|
|
96
88
|
/**
|
|
97
89
|
* @throws
|
|
98
90
|
*/
|
|
99
|
-
function writeGzippedFile(path:
|
|
91
|
+
function writeGzippedFile(externals: Externals, path: FsLocation, buffer: Uint8Array | string): Promise<void>;
|
|
100
92
|
/**
|
|
101
93
|
* @throws
|
|
102
94
|
*/
|
|
103
|
-
function readGzippedJson
|
|
95
|
+
function readGzippedJson(externals: Externals, path: FsLocation): Promise<unknown>;
|
|
104
96
|
/**
|
|
105
97
|
* @throws
|
|
106
98
|
*/
|
|
107
|
-
function writeGzippedJson(path:
|
|
108
|
-
/**
|
|
109
|
-
* Show the file/directory in the platform-specific explorer program.
|
|
110
|
-
*
|
|
111
|
-
* Should not be called with unsanitized user-input path due to the possibility of
|
|
112
|
-
* arbitrary code execution.
|
|
113
|
-
*
|
|
114
|
-
* @returns The `stdout` from the spawned child process.
|
|
115
|
-
*/
|
|
116
|
-
function showFile(path: string): Promise<{
|
|
117
|
-
stdout: string;
|
|
118
|
-
stderr: string;
|
|
119
|
-
}>;
|
|
99
|
+
function writeGzippedJson(externals: Externals, path: FsLocation, data: any): Promise<void>;
|
|
120
100
|
}
|
|
121
101
|
//# sourceMappingURL=fileUtil.d.ts.map
|