@spyglassmc/core 0.1.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 +10 -0
- package/lib/common/Heap.d.ts +1 -0
- package/lib/common/Heap.js +2 -0
- package/lib/common/index.d.ts +2 -0
- package/lib/common/index.js +14 -0
- package/lib/common/util.d.ts +120 -0
- package/lib/common/util.js +292 -0
- package/lib/index.d.ts +8 -0
- package/lib/index.js +20 -0
- package/lib/node/AstNode.d.ts +64 -0
- package/lib/node/AstNode.js +108 -0
- package/lib/node/BooleanNode.d.ts +13 -0
- package/lib/node/BooleanNode.js +20 -0
- package/lib/node/CommentNode.d.ts +12 -0
- package/lib/node/CommentNode.js +11 -0
- package/lib/node/ErrorNode.d.ts +8 -0
- package/lib/node/ErrorNode.js +12 -0
- package/lib/node/FileNode.d.ts +21 -0
- package/lib/node/FileNode.js +11 -0
- package/lib/node/FloatNode.d.ts +13 -0
- package/lib/node/FloatNode.js +21 -0
- package/lib/node/IntegerNode.d.ts +13 -0
- package/lib/node/IntegerNode.js +20 -0
- package/lib/node/ListNode.d.ts +15 -0
- package/lib/node/ListNode.js +11 -0
- package/lib/node/LiteralNode.d.ts +19 -0
- package/lib/node/LiteralNode.js +22 -0
- package/lib/node/LongNode.d.ts +13 -0
- package/lib/node/LongNode.js +20 -0
- package/lib/node/RecordNode.d.ts +20 -0
- package/lib/node/RecordNode.js +11 -0
- package/lib/node/ResourceLocationNode.d.ts +41 -0
- package/lib/node/ResourceLocationNode.js +65 -0
- package/lib/node/Sequence.d.ts +22 -0
- package/lib/node/Sequence.js +11 -0
- package/lib/node/StringNode.d.ts +63 -0
- package/lib/node/StringNode.js +43 -0
- package/lib/node/SymbolNode.d.ts +21 -0
- package/lib/node/SymbolNode.js +22 -0
- package/lib/node/TableNode.d.ts +17 -0
- package/lib/node/TableNode.js +11 -0
- package/lib/node/index.d.ts +16 -0
- package/lib/node/index.js +28 -0
- package/lib/parser/Parser.d.ts +16 -0
- package/lib/parser/Parser.js +5 -0
- package/lib/parser/boolean.d.ts +4 -0
- package/lib/parser/boolean.js +11 -0
- package/lib/parser/comment.d.ts +12 -0
- package/lib/parser/comment.js +34 -0
- package/lib/parser/empty.d.ts +3 -0
- package/lib/parser/empty.js +7 -0
- package/lib/parser/error.d.ts +8 -0
- package/lib/parser/error.js +22 -0
- package/lib/parser/file.d.ts +9 -0
- package/lib/parser/file.js +37 -0
- package/lib/parser/float.d.ts +33 -0
- package/lib/parser/float.js +57 -0
- package/lib/parser/index.d.ts +17 -0
- package/lib/parser/index.js +36 -0
- package/lib/parser/integer.d.ts +33 -0
- package/lib/parser/integer.js +46 -0
- package/lib/parser/list.d.ts +12 -0
- package/lib/parser/list.js +70 -0
- package/lib/parser/literal.d.ts +5 -0
- package/lib/parser/literal.js +41 -0
- package/lib/parser/long.d.ts +33 -0
- package/lib/parser/long.js +50 -0
- package/lib/parser/record.d.ts +22 -0
- package/lib/parser/record.js +97 -0
- package/lib/parser/resourceLocation.d.ts +4 -0
- package/lib/parser/resourceLocation.js +67 -0
- package/lib/parser/string.d.ts +18 -0
- package/lib/parser/string.js +129 -0
- package/lib/parser/symbol.d.ts +12 -0
- package/lib/parser/symbol.js +33 -0
- package/lib/parser/table.d.ts +22 -0
- package/lib/parser/table.js +97 -0
- package/lib/parser/util.d.ts +134 -0
- package/lib/parser/util.js +224 -0
- package/lib/processor/ColorInfoProvider.d.ts +87 -0
- package/lib/processor/ColorInfoProvider.js +141 -0
- package/lib/processor/InlayHintProvider.d.ts +8 -0
- package/lib/processor/InlayHintProvider.js +3 -0
- package/lib/processor/SignatureHelpProvider.d.ts +18 -0
- package/lib/processor/SignatureHelpProvider.js +3 -0
- package/lib/processor/checker/Checker.d.ts +7 -0
- package/lib/processor/checker/Checker.js +7 -0
- package/lib/processor/checker/builtin.d.ts +23 -0
- package/lib/processor/checker/builtin.js +83 -0
- package/lib/processor/checker/index.d.ts +3 -0
- package/lib/processor/checker/index.js +28 -0
- package/lib/processor/colorizer/Colorizer.d.ts +23 -0
- package/lib/processor/colorizer/Colorizer.js +70 -0
- package/lib/processor/colorizer/builtin.d.ts +17 -0
- package/lib/processor/colorizer/builtin.js +84 -0
- package/lib/processor/colorizer/index.d.ts +3 -0
- package/lib/processor/colorizer/index.js +28 -0
- package/lib/processor/completer/Completer.d.ts +75 -0
- package/lib/processor/completer/Completer.js +92 -0
- package/lib/processor/completer/builtin.d.ts +30 -0
- package/lib/processor/completer/builtin.js +172 -0
- package/lib/processor/completer/index.d.ts +3 -0
- package/lib/processor/completer/index.js +28 -0
- package/lib/processor/formatter/Formatter.d.ts +6 -0
- package/lib/processor/formatter/Formatter.js +19 -0
- package/lib/processor/formatter/builtin.d.ts +15 -0
- package/lib/processor/formatter/builtin.js +60 -0
- package/lib/processor/formatter/index.d.ts +3 -0
- package/lib/processor/formatter/index.js +28 -0
- package/lib/processor/index.d.ts +10 -0
- package/lib/processor/index.js +22 -0
- package/lib/processor/linter/Linter.d.ts +4 -0
- package/lib/processor/linter/Linter.js +3 -0
- package/lib/processor/linter/builtin/undeclaredSymbol.d.ts +4 -0
- package/lib/processor/linter/builtin/undeclaredSymbol.js +73 -0
- package/lib/processor/linter/builtin.d.ts +15 -0
- package/lib/processor/linter/builtin.js +120 -0
- package/lib/processor/linter/index.d.ts +3 -0
- package/lib/processor/linter/index.js +28 -0
- package/lib/processor/util.d.ts +17 -0
- package/lib/processor/util.js +32 -0
- package/lib/service/CacheService.d.ts +54 -0
- package/lib/service/CacheService.js +195 -0
- package/lib/service/CommandExecutor.d.ts +3 -0
- package/lib/service/CommandExecutor.js +7 -0
- package/lib/service/Config.d.ts +218 -0
- package/lib/service/Config.js +264 -0
- package/lib/service/Context.d.ts +143 -0
- package/lib/service/Context.js +143 -0
- package/lib/service/Dependency.d.ts +10 -0
- package/lib/service/Dependency.js +11 -0
- package/lib/service/Downloader.d.ts +67 -0
- package/lib/service/Downloader.js +185 -0
- package/lib/service/ErrorReporter.d.ts +27 -0
- package/lib/service/ErrorReporter.js +49 -0
- package/lib/service/FileService.d.ts +96 -0
- package/lib/service/FileService.js +224 -0
- package/lib/service/Hover.d.ts +10 -0
- package/lib/service/Hover.js +16 -0
- package/lib/service/Logger.d.ts +31 -0
- package/lib/service/Logger.js +30 -0
- package/lib/service/MetaRegistry.d.ts +106 -0
- package/lib/service/MetaRegistry.js +192 -0
- package/lib/service/Operations.d.ts +8 -0
- package/lib/service/Operations.js +26 -0
- package/lib/service/Profiler.d.ts +33 -0
- package/lib/service/Profiler.js +76 -0
- package/lib/service/Project.d.ts +173 -0
- package/lib/service/Project.js +593 -0
- package/lib/service/Service.d.ts +55 -0
- package/lib/service/Service.js +207 -0
- package/lib/service/SymbolLocations.d.ts +17 -0
- package/lib/service/SymbolLocations.js +16 -0
- package/lib/service/SymbolRegistrar.d.ts +5 -0
- package/lib/service/SymbolRegistrar.js +3 -0
- package/lib/service/fileUtil.d.ts +121 -0
- package/lib/service/fileUtil.js +268 -0
- package/lib/service/index.d.ts +18 -0
- package/lib/service/index.js +33 -0
- package/lib/source/IndexMap.d.ts +16 -0
- package/lib/source/IndexMap.js +46 -0
- package/lib/source/LanguageError.d.ts +27 -0
- package/lib/source/LanguageError.js +15 -0
- package/lib/source/Location.d.ts +19 -0
- package/lib/source/Location.js +25 -0
- package/lib/source/Offset.d.ts +13 -0
- package/lib/source/Offset.js +25 -0
- package/lib/source/Position.d.ts +23 -0
- package/lib/source/Position.js +43 -0
- package/lib/source/PositionRange.d.ts +38 -0
- package/lib/source/PositionRange.js +83 -0
- package/lib/source/Range.d.ts +68 -0
- package/lib/source/Range.js +155 -0
- package/lib/source/Source.d.ts +110 -0
- package/lib/source/Source.js +222 -0
- package/lib/source/index.d.ts +9 -0
- package/lib/source/index.js +21 -0
- package/lib/symbol/Symbol.d.ts +219 -0
- package/lib/symbol/Symbol.js +324 -0
- package/lib/symbol/SymbolUtil.d.ts +407 -0
- package/lib/symbol/SymbolUtil.js +880 -0
- package/lib/symbol/UriBinder.d.ts +3 -0
- package/lib/symbol/UriBinder.js +3 -0
- package/lib/symbol/index.d.ts +4 -0
- package/lib/symbol/index.js +16 -0
- package/package.json +41 -0
|
@@ -0,0 +1,407 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import EventEmitter from 'events';
|
|
3
|
+
import { TextDocument } from 'vscode-languageserver-textdocument';
|
|
4
|
+
import type { AstNode } from '../node';
|
|
5
|
+
import type { RangeLike } from '../source';
|
|
6
|
+
import type { AllCategory, Symbol, SymbolLocationBuiltInContributor, SymbolLocationMetadata, SymbolMap, SymbolMetadata, SymbolTable, SymbolUsageType } from './Symbol';
|
|
7
|
+
import { SymbolLocation, SymbolVisibility } from './Symbol';
|
|
8
|
+
export interface LookupResult {
|
|
9
|
+
/**
|
|
10
|
+
* The {@link SymbolMap} that contains the symbol. If `symbol` is `undefined`, this property will be the map that could
|
|
11
|
+
* potentially store the symbol if it's ever created. `undefined` if no such map exists.
|
|
12
|
+
*/
|
|
13
|
+
parentMap: SymbolMap | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* The {@link Symbol} of which `symbol` is a member. If `symbol` is `undefined`, this property will be the symbol that could
|
|
16
|
+
* potentially store the symbol as a member if it's ever created. `undefined` if no such symbol exists.
|
|
17
|
+
*/
|
|
18
|
+
parentSymbol: Symbol | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* The {@link Symbol} corresponding to the `path`. `undefined` if no such symbol exists.
|
|
21
|
+
*/
|
|
22
|
+
symbol: Symbol | undefined;
|
|
23
|
+
}
|
|
24
|
+
interface SymbolEvent {
|
|
25
|
+
symbol: Symbol;
|
|
26
|
+
}
|
|
27
|
+
interface SymbolLocationEvent extends SymbolEvent {
|
|
28
|
+
type: SymbolUsageType;
|
|
29
|
+
location: SymbolLocation;
|
|
30
|
+
}
|
|
31
|
+
export interface SymbolUtil {
|
|
32
|
+
on(event: 'symbolCreated', callbackFn: (data: SymbolEvent) => void): this;
|
|
33
|
+
on(event: 'symbolAmended', callbackFn: (data: SymbolEvent) => void): this;
|
|
34
|
+
on(event: 'symbolRemoved', callbackFn: (data: SymbolEvent) => void): this;
|
|
35
|
+
on(event: 'symbolLocationCreated', callbackFn: (data: SymbolLocationEvent) => void): this;
|
|
36
|
+
on(event: 'symbolLocationRemoved', callbackFn: (data: SymbolLocationEvent) => void): this;
|
|
37
|
+
once(event: 'symbolCreated', callbackFn: (data: SymbolEvent) => void): this;
|
|
38
|
+
once(event: 'symbolAmended', callbackFn: (data: SymbolEvent) => void): this;
|
|
39
|
+
once(event: 'symbolRemoved', callbackFn: (data: SymbolEvent) => void): this;
|
|
40
|
+
once(event: 'symbolLocationCreated', callbackFn: (data: SymbolLocationEvent) => void): this;
|
|
41
|
+
once(event: 'symbolLocationRemoved', callbackFn: (data: SymbolLocationEvent) => void): this;
|
|
42
|
+
emit(event: 'symbolCreated', data: SymbolEvent): boolean;
|
|
43
|
+
emit(event: 'symbolAmended', data: SymbolEvent): boolean;
|
|
44
|
+
emit(event: 'symbolRemoved', data: SymbolEvent): boolean;
|
|
45
|
+
emit(event: 'symbolLocationCreated', data: SymbolLocationEvent): boolean;
|
|
46
|
+
emit(event: 'symbolLocationRemoved', data: SymbolLocationEvent): boolean;
|
|
47
|
+
}
|
|
48
|
+
interface DocAndNode {
|
|
49
|
+
doc: TextDocument;
|
|
50
|
+
node: AstNode;
|
|
51
|
+
}
|
|
52
|
+
export declare class SymbolUtil extends EventEmitter {
|
|
53
|
+
#private;
|
|
54
|
+
/**
|
|
55
|
+
* @internal
|
|
56
|
+
*/
|
|
57
|
+
_delayedOps: ((this: void) => unknown)[];
|
|
58
|
+
/**
|
|
59
|
+
* @internal
|
|
60
|
+
*/
|
|
61
|
+
_inDelayMode: boolean;
|
|
62
|
+
get global(): SymbolTable;
|
|
63
|
+
constructor(global: SymbolTable,
|
|
64
|
+
/** @internal */
|
|
65
|
+
_currentContributor?: string,
|
|
66
|
+
/** @internal */
|
|
67
|
+
_inDelayMode?: boolean);
|
|
68
|
+
/**
|
|
69
|
+
* Build the internal cache of the SymbolUtil according to the current global symbol table.
|
|
70
|
+
*/
|
|
71
|
+
buildCache(): void;
|
|
72
|
+
/**
|
|
73
|
+
* @returns A clone of this SymbolUtil that is in delay mode: changes to the symbol table happened in the clone will
|
|
74
|
+
* not take effect until the {@link SymbolUtil.applyDelayedEdits} method is called on that clone.
|
|
75
|
+
*
|
|
76
|
+
* The clone shares the same reference of the global symbol table and symbol stacks, meaning that after
|
|
77
|
+
* `applyDelayedEdits` is called, the original SymbolUtil will also be modified.
|
|
78
|
+
*/
|
|
79
|
+
clone(): SymbolUtil;
|
|
80
|
+
/**
|
|
81
|
+
* Apply edits done during the delay mode.
|
|
82
|
+
*/
|
|
83
|
+
applyDelayedEdits(): void;
|
|
84
|
+
/**
|
|
85
|
+
* All symbol locations added in `fn` are associated with the specified `contributor`.
|
|
86
|
+
*
|
|
87
|
+
* @param contributor The name of the contributor which will add symbols to the symbol table. See {@link SymbolLocation.contributor}
|
|
88
|
+
* @param fn All symbols added in this function will be considered as URI bound.
|
|
89
|
+
* @param keepExisting Default to `false`, indicating existing symbols contributed by the specified contributor will be removed first. Set to `true` to keep them instead.
|
|
90
|
+
*/
|
|
91
|
+
contributeAs(contributor: SymbolLocationBuiltInContributor, fn: () => unknown): this;
|
|
92
|
+
contributeAs(contributor: string, fn: () => unknown): this;
|
|
93
|
+
/**
|
|
94
|
+
* This is an asynchronous version of {@link contributeAs}.
|
|
95
|
+
*/
|
|
96
|
+
contributeAsAsync(contributor: SymbolLocationBuiltInContributor, fn: () => PromiseLike<unknown>): Promise<this>;
|
|
97
|
+
contributeAsAsync(contributor: string, fn: () => PromiseLike<unknown>): Promise<this>;
|
|
98
|
+
/**
|
|
99
|
+
* @param
|
|
100
|
+
* - `contributor` - clear symbol locations contributed by this contributor. Pass in `undefined`
|
|
101
|
+
* to select all symbol locations that don't have a contributor.
|
|
102
|
+
* - `uri` - clear symbol locations associated with this URI.
|
|
103
|
+
* - `predicate` - clear symbol locations matching this predicate
|
|
104
|
+
*/
|
|
105
|
+
clear({ uri, contributor, predicate }: {
|
|
106
|
+
contributor?: string;
|
|
107
|
+
uri?: string;
|
|
108
|
+
predicate?: (this: void, data: SymbolLocationEvent) => boolean;
|
|
109
|
+
}): void;
|
|
110
|
+
/**
|
|
111
|
+
* @param uri Optional. The corresponding {@link SymbolStack} of the file will also be looked up if this is specified.
|
|
112
|
+
*
|
|
113
|
+
* @returns A {@link LookupResult}
|
|
114
|
+
*/
|
|
115
|
+
lookup(category: AllCategory, path: readonly string[], node?: AstNode): LookupResult;
|
|
116
|
+
lookup(category: string, path: readonly string[], node?: AstNode): LookupResult;
|
|
117
|
+
/**
|
|
118
|
+
* @param doc A {@link TextDocument} or a string URI. It is used to both check the visibility of symbols and serve as
|
|
119
|
+
* the location of future entered symbol usages. If a string URI is provided, all `range`s specified while entering
|
|
120
|
+
* symbol usages latter will be ignored and seen as `[0, 0)`.
|
|
121
|
+
*
|
|
122
|
+
* @throws When the queried symbol belongs to another non-existent symbol, or when no contributor is specified.
|
|
123
|
+
*/
|
|
124
|
+
query(doc: DocAndNode | TextDocument | string, category: AllCategory, ...path: string[]): SymbolQuery;
|
|
125
|
+
query(doc: DocAndNode | TextDocument | string, category: string, ...path: string[]): SymbolQuery;
|
|
126
|
+
getVisibleSymbols(category: AllCategory, uri?: string): SymbolMap;
|
|
127
|
+
getVisibleSymbols(category: string, uri?: string): SymbolMap;
|
|
128
|
+
static toUri(uri: DocAndNode | TextDocument | string): string;
|
|
129
|
+
/**
|
|
130
|
+
* @see {@link SymbolUtil.trimMap}
|
|
131
|
+
*/
|
|
132
|
+
trim(table: SymbolTable): void;
|
|
133
|
+
removeLocationsFromSymbol(symbol: Symbol, predicate: (this: void, data: SymbolLocationEvent) => boolean): void;
|
|
134
|
+
/**
|
|
135
|
+
* Enters a symbol into a symbol map. If there is already a symbol with the specified identifier under the map,
|
|
136
|
+
* it will be amended with the information provided in `addition`. Otherwise, a new symbol with that identifier
|
|
137
|
+
* will be created.
|
|
138
|
+
*
|
|
139
|
+
* @param map The map where this symbol will be entered into.
|
|
140
|
+
* @param category The category of this symbol.
|
|
141
|
+
* @param identifier The identifier of this symbol.
|
|
142
|
+
* @param addition The metadata and usage that will be amended onto this symbol if it already exists, or
|
|
143
|
+
* to create the symbol if it doesn't exist yet.
|
|
144
|
+
* @param doc The `TextDocument` where this symbol belongs to.
|
|
145
|
+
* @param isUriBinding Whether this entering is done by a URI binder or not.
|
|
146
|
+
*
|
|
147
|
+
* @returns The created/amended symbol.
|
|
148
|
+
*/
|
|
149
|
+
enterMap(parentSymbol: Symbol | undefined, map: SymbolMap, category: AllCategory, path: readonly string[], identifier: string, addition: SymbolAddition, doc: TextDocument, contributor: string | undefined): Symbol;
|
|
150
|
+
enterMap(parentSymbol: Symbol | undefined, map: SymbolMap, category: string, path: readonly string[], identifier: string, addition: SymbolAddition, doc: TextDocument, contributor: string | undefined): Symbol;
|
|
151
|
+
/**
|
|
152
|
+
* @returns A {@link LookupResult}
|
|
153
|
+
*/
|
|
154
|
+
static lookupTable(table: SymbolTable, category: AllCategory, path: readonly string[]): LookupResult;
|
|
155
|
+
static lookupTable(table: SymbolTable, category: string, path: readonly string[]): LookupResult;
|
|
156
|
+
/**
|
|
157
|
+
* @param tables Should be ordered from global to the toppest block.
|
|
158
|
+
*
|
|
159
|
+
* @returns A {@link LookupResult}
|
|
160
|
+
*/
|
|
161
|
+
static lookupTables(tables: SymbolTable[], category: AllCategory, path: readonly string[]): LookupResult;
|
|
162
|
+
static lookupTables(tables: SymbolTable[], category: string, path: readonly string[]): LookupResult;
|
|
163
|
+
createSymbol(category: string, parentSymbol: Symbol | undefined, parentMap: SymbolMap, path: readonly string[], identifier: string, addition: SymbolAddition, doc: TextDocument, contributor: string | undefined): Symbol;
|
|
164
|
+
amendSymbol(symbol: Symbol, addition: SymbolAddition, doc: TextDocument, contributor: string | undefined): void;
|
|
165
|
+
private amendSymbolMetadata;
|
|
166
|
+
private amendSymbolUsage;
|
|
167
|
+
/**
|
|
168
|
+
* @returns The ultimate symbol being pointed by the passed-in `symbol`'s alias.
|
|
169
|
+
*/
|
|
170
|
+
resolveAlias(symbol: Symbol | undefined): Symbol | undefined;
|
|
171
|
+
static filterVisibleSymbols(uri: string | undefined, map?: SymbolMap): SymbolMap;
|
|
172
|
+
static isTrimmable(symbol: Symbol): boolean;
|
|
173
|
+
/**
|
|
174
|
+
* @returns
|
|
175
|
+
* - For `Block` and `File` visibilities, always `true` as `Symbol`s of these visibilities are validated at the
|
|
176
|
+
* `SymbolStack` level, instead of here.
|
|
177
|
+
* - For `Public` visibility, also always `true`, obviously.
|
|
178
|
+
* - For `Restricted` visibility, // TODO: roots.
|
|
179
|
+
*/
|
|
180
|
+
static isVisible(symbol: Symbol, uri: string): boolean;
|
|
181
|
+
static isVisible(symbol: Symbol, uri: string | undefined): boolean | undefined;
|
|
182
|
+
/**
|
|
183
|
+
* @returns If the symbol has declarations or definitions.
|
|
184
|
+
*/
|
|
185
|
+
static isDeclared(symbol: Symbol | undefined): boolean;
|
|
186
|
+
/**
|
|
187
|
+
* @returns If the symbol has definitions, or declarations and implementations.
|
|
188
|
+
*/
|
|
189
|
+
static isDefined(symbol: Symbol | undefined): symbol is Symbol;
|
|
190
|
+
/**
|
|
191
|
+
* @returns If the symbol has implementations or definitions.
|
|
192
|
+
*/
|
|
193
|
+
static isImplemented(symbol: Symbol | undefined): symbol is Symbol;
|
|
194
|
+
/**
|
|
195
|
+
* @returns If the symbol has references.
|
|
196
|
+
*/
|
|
197
|
+
static isReferenced(symbol: Symbol | undefined): symbol is Symbol;
|
|
198
|
+
/**
|
|
199
|
+
* @returns If the symbol has type definitions.
|
|
200
|
+
*/
|
|
201
|
+
static isTypeDefined(symbol: Symbol | undefined): symbol is Symbol;
|
|
202
|
+
/**
|
|
203
|
+
* @throws If the symbol does not have any declarations or definitions.
|
|
204
|
+
*/
|
|
205
|
+
static getDeclaredLocation(symbol: Symbol): SymbolLocation;
|
|
206
|
+
static forEachSymbolInMap(map: SymbolMap, fn: (symbol: Symbol) => unknown): void;
|
|
207
|
+
static forEachSymbol(table: SymbolTable, fn: (symbol: Symbol) => unknown): void;
|
|
208
|
+
static forEachLocationOfSymbol(symbol: Symbol, fn: (data: {
|
|
209
|
+
type: SymbolUsageType;
|
|
210
|
+
location: SymbolLocation;
|
|
211
|
+
}) => unknown): void;
|
|
212
|
+
static isVisibilityInGlobal(v: SymbolVisibility | undefined): boolean;
|
|
213
|
+
static areVisibilitiesCompatible(v1: SymbolVisibility | undefined, v2: SymbolVisibility | undefined): boolean;
|
|
214
|
+
}
|
|
215
|
+
interface SymbolAddition {
|
|
216
|
+
data?: SymbolMetadata;
|
|
217
|
+
usage?: SymbolAdditionUsage;
|
|
218
|
+
}
|
|
219
|
+
declare type SymbolAdditionUsage = SymbolAdditionUsageWithRange | SymbolAdditionUsageWithNode;
|
|
220
|
+
interface SymbolAdditionUsageBase extends SymbolLocationMetadata {
|
|
221
|
+
/**
|
|
222
|
+
* The type of this usage. Use `definition` when the usage consists both a `declaration` and an `implementation`.
|
|
223
|
+
*/
|
|
224
|
+
type?: SymbolUsageType;
|
|
225
|
+
/**
|
|
226
|
+
* The range of the full declaration/implementation of this {@link Symbol}. For example, for the following piece of
|
|
227
|
+
* nbtdoc code,
|
|
228
|
+
* ```nbtdoc
|
|
229
|
+
* 0123456789012345
|
|
230
|
+
* compound Foo {}
|
|
231
|
+
* ```
|
|
232
|
+
*
|
|
233
|
+
* The `range` for the Symbol `Foo` is `[9, 12)`, while the `fullRange` for it is `[0, 15)`.
|
|
234
|
+
*/
|
|
235
|
+
fullRange?: RangeLike;
|
|
236
|
+
}
|
|
237
|
+
interface SymbolAdditionUsageWithRange extends SymbolAdditionUsageBase {
|
|
238
|
+
/**
|
|
239
|
+
* The range of this symbol usage. It should contain exactly the symbol identifier itself, with no
|
|
240
|
+
* whitespaces whatsoever included.
|
|
241
|
+
*
|
|
242
|
+
* This property is ignored when the specified document's URI is not of `file:` schema. It is also ignored and
|
|
243
|
+
* set to `[0, 0)` if only a file URI, instead of a {@link TextDocument}, is provided.
|
|
244
|
+
*
|
|
245
|
+
* Please use `node` instead of this property whenever it makes sense. Learn more at the documentation
|
|
246
|
+
* for that property.
|
|
247
|
+
*
|
|
248
|
+
* If neither `node` nor `range` is provided, the range falls back to `[0, 0)`.
|
|
249
|
+
*/
|
|
250
|
+
range?: RangeLike;
|
|
251
|
+
node?: undefined;
|
|
252
|
+
}
|
|
253
|
+
declare namespace SymbolAdditionUsageWithRange {
|
|
254
|
+
function is(usage: SymbolAdditionUsage | undefined): usage is SymbolAdditionUsageWithRange;
|
|
255
|
+
}
|
|
256
|
+
interface SymbolAdditionUsageWithNode extends SymbolAdditionUsageBase {
|
|
257
|
+
/**
|
|
258
|
+
* The node associated with this symbol usage. It should contain exactly the symbol identifier itself, with no
|
|
259
|
+
* wrapper nodes whatsoever included.
|
|
260
|
+
*
|
|
261
|
+
* This property is ignored when the specified document's URI is not of `file:` schema. It is also ignored and
|
|
262
|
+
* treated as `range: [0, 0)` if only a file URI, instead of a {@link TextDocument}, is provided.
|
|
263
|
+
*
|
|
264
|
+
* Either this property or `range` could be used to represent the range of this usage.
|
|
265
|
+
*
|
|
266
|
+
* However, using `node` also have the benefit of auto setting `node.symbol` to the queried symbol.
|
|
267
|
+
* It is recommended to use `node` whenever applicable.
|
|
268
|
+
*
|
|
269
|
+
* If neither `node` nor `range` is provided, the range falls back to `[0, 0)`.
|
|
270
|
+
*/
|
|
271
|
+
node?: AstNode;
|
|
272
|
+
range?: undefined;
|
|
273
|
+
}
|
|
274
|
+
declare namespace SymbolAdditionUsageWithNode {
|
|
275
|
+
function is(usage: SymbolAdditionUsage | undefined): usage is SymbolAdditionUsageWithNode;
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* A stack of {@link SymbolTable}s. The first element represents the `File` visibility scope,
|
|
279
|
+
* which is accessible by any later elements but not saved to the global `SymbolTable`.
|
|
280
|
+
* Later elements represent different levels of `Block` visibility scopes.
|
|
281
|
+
*/
|
|
282
|
+
export declare type SymbolStack = [SymbolTable, ...SymbolTable[]];
|
|
283
|
+
declare type QueryCallback<S extends Symbol | undefined = Symbol | undefined> = (this: SymbolQuery, symbol: S, query: SymbolQuery) => unknown;
|
|
284
|
+
declare type QueryMemberCallback = (this: void, query: SymbolQuery) => unknown;
|
|
285
|
+
export declare class SymbolQuery {
|
|
286
|
+
#private;
|
|
287
|
+
readonly category: string;
|
|
288
|
+
readonly path: readonly string[];
|
|
289
|
+
/**
|
|
290
|
+
* The {@link SymbolUtil} where this query was created.
|
|
291
|
+
*/
|
|
292
|
+
util: SymbolUtil;
|
|
293
|
+
get symbol(): Symbol | undefined;
|
|
294
|
+
get visibleMembers(): SymbolMap;
|
|
295
|
+
constructor({ category, contributor, doc, map, parentSymbol, path, symbol, util }: {
|
|
296
|
+
category: string;
|
|
297
|
+
contributor: string | undefined;
|
|
298
|
+
doc: DocAndNode | TextDocument | string;
|
|
299
|
+
map: SymbolMap | undefined;
|
|
300
|
+
parentSymbol: Symbol | undefined;
|
|
301
|
+
path: readonly string[];
|
|
302
|
+
symbol: Symbol | undefined;
|
|
303
|
+
util: SymbolUtil;
|
|
304
|
+
});
|
|
305
|
+
heyGimmeDaSymbol(): Symbol | undefined;
|
|
306
|
+
with(fn: QueryMemberCallback): this;
|
|
307
|
+
if(predicate: (this: void, symbol: Symbol | undefined) => symbol is undefined, fn: QueryCallback<undefined>): this;
|
|
308
|
+
if(predicate: (this: void, symbol: Symbol | undefined) => symbol is Symbol, fn: QueryCallback<Symbol>): this;
|
|
309
|
+
if(predicate: QueryCallback, fn: QueryCallback): this;
|
|
310
|
+
/**
|
|
311
|
+
* Calls `fn` if the queried symbol does not exist.
|
|
312
|
+
*/
|
|
313
|
+
ifUnknown(fn: QueryCallback<undefined>): this;
|
|
314
|
+
/**
|
|
315
|
+
* Calls `fn` if the queried symbol exists (i.e. has any of declarations/definitions/implementations/references/typeDefinitions).
|
|
316
|
+
*/
|
|
317
|
+
ifKnown(fn: QueryCallback<Symbol>): this;
|
|
318
|
+
/**
|
|
319
|
+
* Calls `fn` if the queried symbol has declarations or definitions.
|
|
320
|
+
*/
|
|
321
|
+
ifDeclared(fn: QueryCallback<Symbol>): this;
|
|
322
|
+
/**
|
|
323
|
+
* Calls `fn` if the queried symbol has definitions, or both declarations and implementations.
|
|
324
|
+
*/
|
|
325
|
+
ifDefined(fn: QueryCallback<Symbol>): this;
|
|
326
|
+
/**
|
|
327
|
+
* Calls `fn` if the queried symbol has implementations or definitions.
|
|
328
|
+
*/
|
|
329
|
+
ifImplemented(fn: QueryCallback<Symbol>): this;
|
|
330
|
+
/**
|
|
331
|
+
* Calls `fn` if the queried symbol has references.
|
|
332
|
+
*/
|
|
333
|
+
ifReferenced(fn: QueryCallback<Symbol>): this;
|
|
334
|
+
/**
|
|
335
|
+
* Calls `fn` if the queried symbol has type definitions.
|
|
336
|
+
*/
|
|
337
|
+
ifTypeDefined(fn: QueryCallback<Symbol>): this;
|
|
338
|
+
/**
|
|
339
|
+
* Calls `fn` if none of the former `if` conditions are met.
|
|
340
|
+
*/
|
|
341
|
+
else(fn: QueryCallback): this;
|
|
342
|
+
/**
|
|
343
|
+
* Enters the queried symbol if none of the former `if` conditions are met.
|
|
344
|
+
*/
|
|
345
|
+
elseEnter(symbol: SymbolAddition): this;
|
|
346
|
+
/**
|
|
347
|
+
* Resolves the queried symbol if it is an alias and if none of the former `if` conditions are met.
|
|
348
|
+
*
|
|
349
|
+
* @throws If the current symbol points to an non-existent symbol.
|
|
350
|
+
*/
|
|
351
|
+
elseResolveAlias(): this;
|
|
352
|
+
private _enter;
|
|
353
|
+
/**
|
|
354
|
+
* Enters the queried symbol.
|
|
355
|
+
*
|
|
356
|
+
* @throws If the parent of this symbol doesn't exist either.
|
|
357
|
+
*/
|
|
358
|
+
enter(addition: SymbolAddition): this;
|
|
359
|
+
/**
|
|
360
|
+
* Amends the queried symbol if the queried symbol exists (i.e. has any of declarations/definitions/implementations/references/typeDefinitions) and is visible at the current scope.
|
|
361
|
+
*
|
|
362
|
+
* This is equivalent to calling
|
|
363
|
+
* ```typescript
|
|
364
|
+
* query.ifKnown(function () {
|
|
365
|
+
* this.enter(symbol)
|
|
366
|
+
* })
|
|
367
|
+
* ```
|
|
368
|
+
*
|
|
369
|
+
* Therefore, if the symbol is successfully amended, `elseX` methods afterwards will **not** be executed.
|
|
370
|
+
*/
|
|
371
|
+
amend(symbol: SymbolAddition): this;
|
|
372
|
+
/**
|
|
373
|
+
* Resolves this symbol if it exists and is an alias.
|
|
374
|
+
*
|
|
375
|
+
* @throws If the current symbol points to an non-existent symbol. The state of this object will not be changed
|
|
376
|
+
* after the error is thrown.
|
|
377
|
+
*/
|
|
378
|
+
resolveAlias(): this;
|
|
379
|
+
/**
|
|
380
|
+
* @param identifier The identifier of the member symbol.
|
|
381
|
+
* @param fn A callback function where `this` is the member symbol's query result.
|
|
382
|
+
*
|
|
383
|
+
* @throws If the current queried symbol doesn't exist.
|
|
384
|
+
*/
|
|
385
|
+
member(identifier: string, fn: QueryMemberCallback): this;
|
|
386
|
+
member(doc: TextDocument | string, identifier: string, fn: QueryMemberCallback): this;
|
|
387
|
+
/**
|
|
388
|
+
* Do something with this query on each value in a given iterable. The query itself will be included
|
|
389
|
+
* in the callback function as the second parameter.
|
|
390
|
+
*/
|
|
391
|
+
onEach<T>(values: Iterable<T>, fn: (this: this, value: T, query: this) => unknown): this;
|
|
392
|
+
forEachMember(fn: (this: void, identifier: string, query: SymbolQuery) => unknown): this;
|
|
393
|
+
private getPath;
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* A series of methods for converting symbol structures to human-readable outputs. Mostly for debug purposes.
|
|
397
|
+
*/
|
|
398
|
+
export declare namespace SymbolFormatter {
|
|
399
|
+
function stringifySymbolStack(stack: SymbolStack): string;
|
|
400
|
+
function stringifySymbolTable(table: SymbolTable, indent?: string): string;
|
|
401
|
+
function stringifySymbolMap(map: SymbolMap | undefined, indent?: string): string;
|
|
402
|
+
function stringifySymbol(symbol: Symbol | undefined, indent?: string): string;
|
|
403
|
+
function stringifyVisibility(visibility: SymbolVisibility | undefined, visibilityRestriction?: string[]): string;
|
|
404
|
+
function stringifyLookupResult(result: LookupResult): string;
|
|
405
|
+
}
|
|
406
|
+
export {};
|
|
407
|
+
//# sourceMappingURL=SymbolUtil.d.ts.map
|