@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,593 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
9
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
10
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
11
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
12
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
13
|
+
};
|
|
14
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
15
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
16
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
17
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
18
|
+
};
|
|
19
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
20
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
21
|
+
};
|
|
22
|
+
var _Project_cacheSaverIntervalId, _Project_clientManagedUris, _Project_configService, _Project_docAndNodes, _Project_initializers, _Project_initPromise, _Project_readyPromise, _Project_watchedFiles, _Project_watcher, _Project_watcherReady, _Project_dependencyRoots, _Project_dependencyFiles, _Project_roots, _Project_ctx, _Project_cacheRoot;
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.Project = exports.ProjectData = void 0;
|
|
25
|
+
const chokidar_1 = __importDefault(require("chokidar"));
|
|
26
|
+
const events_1 = __importDefault(require("events"));
|
|
27
|
+
const p_limit_1 = __importDefault(require("p-limit"));
|
|
28
|
+
const vscode_languageserver_textdocument_1 = require("vscode-languageserver-textdocument");
|
|
29
|
+
const _1 = require(".");
|
|
30
|
+
const common_1 = require("../common");
|
|
31
|
+
const node_1 = require("../node");
|
|
32
|
+
const parser_1 = require("../parser");
|
|
33
|
+
const processor_1 = require("../processor");
|
|
34
|
+
const source_1 = require("../source");
|
|
35
|
+
const symbol_1 = require("../symbol");
|
|
36
|
+
const CacheService_1 = require("./CacheService");
|
|
37
|
+
const Config_1 = require("./Config");
|
|
38
|
+
const Context_1 = require("./Context");
|
|
39
|
+
const Dependency_1 = require("./Dependency");
|
|
40
|
+
const Downloader_1 = require("./Downloader");
|
|
41
|
+
const ErrorReporter_1 = require("./ErrorReporter");
|
|
42
|
+
const FileService_1 = require("./FileService");
|
|
43
|
+
const fileUtil_1 = require("./fileUtil");
|
|
44
|
+
const Logger_1 = require("./Logger");
|
|
45
|
+
const MetaRegistry_1 = require("./MetaRegistry");
|
|
46
|
+
const Profiler_1 = require("./Profiler");
|
|
47
|
+
const CacheAutoSaveInterval = 600000; // 10 Minutes.
|
|
48
|
+
var ProjectData;
|
|
49
|
+
(function (ProjectData) {
|
|
50
|
+
function mock(data = {}) {
|
|
51
|
+
const cacheRoot = data.cacheRoot ?? '/some/random/garbage/path/that/definitely/does/not/exist';
|
|
52
|
+
const logger = data.logger ?? Logger_1.Logger.create();
|
|
53
|
+
const downloader = data.downloader ?? new Downloader_1.Downloader(cacheRoot, logger, _1.LowLevelDownloader.mock({ fixtures: {} }));
|
|
54
|
+
return {
|
|
55
|
+
cacheRoot,
|
|
56
|
+
config: data.config ?? Config_1.VanillaConfig,
|
|
57
|
+
ctx: data.ctx ?? {},
|
|
58
|
+
downloader,
|
|
59
|
+
ensureParsedAndChecked: data.ensureParsedAndChecked,
|
|
60
|
+
fs: data.fs ?? FileService_1.FileService.create(),
|
|
61
|
+
get: data.get ?? (() => undefined),
|
|
62
|
+
logger,
|
|
63
|
+
meta: data.meta ?? new MetaRegistry_1.MetaRegistry(),
|
|
64
|
+
profilers: data.profilers ?? Profiler_1.ProfilerFactory.noop(),
|
|
65
|
+
projectRoot: data.projectRoot ?? 'file:///',
|
|
66
|
+
roots: data.roots ?? [],
|
|
67
|
+
symbols: data.symbols ?? new symbol_1.SymbolUtil({}),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
ProjectData.mock = mock;
|
|
71
|
+
})(ProjectData = exports.ProjectData || (exports.ProjectData = {}));
|
|
72
|
+
/* istanbul ignore next */
|
|
73
|
+
/**
|
|
74
|
+
* Manage all tracked documents and errors.
|
|
75
|
+
*/
|
|
76
|
+
class Project extends events_1.default {
|
|
77
|
+
constructor({ cacheRoot, downloader, fs = FileService_1.FileService.create(), initializers = [], logger = Logger_1.Logger.create(), profilers = Profiler_1.ProfilerFactory.noop(), projectPath, }) {
|
|
78
|
+
super();
|
|
79
|
+
_Project_cacheSaverIntervalId.set(this, void 0);
|
|
80
|
+
/**
|
|
81
|
+
* URI of files that are currently managed by the language client.
|
|
82
|
+
*/
|
|
83
|
+
_Project_clientManagedUris.set(this, new Set());
|
|
84
|
+
_Project_configService.set(this, void 0);
|
|
85
|
+
_Project_docAndNodes.set(this, new Map());
|
|
86
|
+
_Project_initializers.set(this, void 0);
|
|
87
|
+
_Project_initPromise.set(this, void 0);
|
|
88
|
+
_Project_readyPromise.set(this, void 0);
|
|
89
|
+
_Project_watchedFiles.set(this, new Set());
|
|
90
|
+
_Project_watcher.set(this, void 0);
|
|
91
|
+
_Project_watcherReady.set(this, false);
|
|
92
|
+
this.meta = new MetaRegistry_1.MetaRegistry();
|
|
93
|
+
_Project_dependencyRoots.set(this, void 0);
|
|
94
|
+
_Project_dependencyFiles.set(this, void 0);
|
|
95
|
+
_Project_roots.set(this, []
|
|
96
|
+
/**
|
|
97
|
+
* All tracked root URIs. Each URI in this array is guaranteed to end with a slash (`/`).
|
|
98
|
+
*
|
|
99
|
+
* Includes the roots of all dependencies, the project root, and all data pack roots identified
|
|
100
|
+
* by `pack.mcmeta` files.
|
|
101
|
+
*
|
|
102
|
+
* Some URIs in the array may overlap with each other. In such cases, the deeper ones are guaranteed to come
|
|
103
|
+
* before the shallower ones (e.g. `file:///foo/bar/` will come before `file:///foo/`).
|
|
104
|
+
*/
|
|
105
|
+
);
|
|
106
|
+
_Project_ctx.set(this, void 0);
|
|
107
|
+
_Project_cacheRoot.set(this, void 0);
|
|
108
|
+
__classPrivateFieldSet(this, _Project_cacheRoot, cacheRoot, "f");
|
|
109
|
+
this.cacheService = new CacheService_1.CacheService(cacheRoot, this);
|
|
110
|
+
__classPrivateFieldSet(this, _Project_configService, new Config_1.ConfigService(this), "f");
|
|
111
|
+
this.downloader = downloader ?? new Downloader_1.Downloader(cacheRoot, logger);
|
|
112
|
+
this.fs = fs;
|
|
113
|
+
__classPrivateFieldSet(this, _Project_initializers, initializers, "f");
|
|
114
|
+
this.logger = logger;
|
|
115
|
+
this.profilers = profilers;
|
|
116
|
+
this.projectPath = projectPath;
|
|
117
|
+
this.projectRoot = fileUtil_1.fileUtil.ensureEndingSlash(fileUtil_1.fileUtil.pathToFileUri(projectPath));
|
|
118
|
+
this.symbols = new symbol_1.SymbolUtil({});
|
|
119
|
+
__classPrivateFieldSet(this, _Project_ctx, {}, "f");
|
|
120
|
+
this.logger.info(`[Project] [init] cacheRoot = “${cacheRoot}”`);
|
|
121
|
+
__classPrivateFieldGet(this, _Project_configService, "f")
|
|
122
|
+
.on('changed', ({ config }) => {
|
|
123
|
+
this.config = config;
|
|
124
|
+
this.logger.info('[Project] [Config] Changed');
|
|
125
|
+
})
|
|
126
|
+
.on('error', ({ error, uri }) => this.logger.error(`[Project] [Config] Failed loading “${uri}”`, error));
|
|
127
|
+
this.setInitPromise();
|
|
128
|
+
this.setReadyPromise();
|
|
129
|
+
__classPrivateFieldSet(this, _Project_cacheSaverIntervalId, setInterval(() => this.cacheService.save(), CacheAutoSaveInterval), "f");
|
|
130
|
+
this
|
|
131
|
+
.on('documentUpdated', ({ doc, node }) => {
|
|
132
|
+
this.emit('documentErrorred', {
|
|
133
|
+
doc,
|
|
134
|
+
errors: node_1.FileNode.getErrors(node),
|
|
135
|
+
node,
|
|
136
|
+
});
|
|
137
|
+
})
|
|
138
|
+
.on('fileCreated', async ({ uri }) => {
|
|
139
|
+
__classPrivateFieldGet(this, _Project_watchedFiles, "f").add(uri);
|
|
140
|
+
if (uri.endsWith(Project.RootSuffix)) {
|
|
141
|
+
this.updateRoots();
|
|
142
|
+
}
|
|
143
|
+
this.bind(uri);
|
|
144
|
+
return this.ensureParsedAndChecked(uri);
|
|
145
|
+
})
|
|
146
|
+
.on('fileModified', async ({ uri }) => {
|
|
147
|
+
if (this.isOnlyWatched(uri)) {
|
|
148
|
+
__classPrivateFieldGet(this, _Project_docAndNodes, "f").delete(uri);
|
|
149
|
+
await this.ensureParsedAndChecked(uri);
|
|
150
|
+
}
|
|
151
|
+
})
|
|
152
|
+
.on('fileDeleted', ({ uri }) => {
|
|
153
|
+
__classPrivateFieldGet(this, _Project_watchedFiles, "f").delete(uri);
|
|
154
|
+
if (uri.endsWith(Project.RootSuffix)) {
|
|
155
|
+
this.updateRoots();
|
|
156
|
+
}
|
|
157
|
+
this.symbols.clear({ uri });
|
|
158
|
+
this.tryClearingCache(uri);
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* All tracked root URIs. Each URI in this array is guaranteed to end with a slash (`/`).
|
|
163
|
+
*
|
|
164
|
+
* Includes the roots of all dependencies, the project root, and all data pack roots identified
|
|
165
|
+
* by `pack.mcmeta` files.
|
|
166
|
+
*
|
|
167
|
+
* Some URIs in the array may overlap with each other. In such cases, the deeper ones are guaranteed to come
|
|
168
|
+
* before the shallower ones (e.g. `file:///foo/bar/` will come before `file:///foo/`).
|
|
169
|
+
*/
|
|
170
|
+
get roots() {
|
|
171
|
+
return __classPrivateFieldGet(this, _Project_roots, "f");
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Arbitrary information that will be included in the `project` property of all `Context`s.
|
|
175
|
+
*/
|
|
176
|
+
get ctx() {
|
|
177
|
+
return __classPrivateFieldGet(this, _Project_ctx, "f");
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* File path to a directory where all cache files of Spyglass should be stored.
|
|
181
|
+
*/
|
|
182
|
+
get cacheRoot() {
|
|
183
|
+
return __classPrivateFieldGet(this, _Project_cacheRoot, "f");
|
|
184
|
+
}
|
|
185
|
+
updateRoots() {
|
|
186
|
+
const rawRoots = [...__classPrivateFieldGet(this, _Project_dependencyRoots, "f"), this.projectRoot];
|
|
187
|
+
const ans = new Set(rawRoots);
|
|
188
|
+
// Identify roots indicated by `pack.mcmeta`.
|
|
189
|
+
for (const file of this.getTrackedFiles()) {
|
|
190
|
+
if (file.endsWith(Project.RootSuffix) && rawRoots.some(r => file.startsWith(r))) {
|
|
191
|
+
ans.add(file.slice(0, 1 - Project.RootSuffix.length));
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
__classPrivateFieldSet(this, _Project_roots, [...ans].sort((a, b) => b.length - a.length), "f");
|
|
195
|
+
this.emit('rootsUpdated', { roots: __classPrivateFieldGet(this, _Project_roots, "f") });
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Get all files that are tracked and supported.
|
|
199
|
+
*
|
|
200
|
+
* Files in cached archives may not show up in the result as those files
|
|
201
|
+
* are not loaded into the memory.
|
|
202
|
+
*/
|
|
203
|
+
getTrackedFiles() {
|
|
204
|
+
const extensions = this.meta.getSupportedFileExtensions();
|
|
205
|
+
return [...__classPrivateFieldGet(this, _Project_dependencyFiles, "f"), ...__classPrivateFieldGet(this, _Project_watchedFiles, "f")]
|
|
206
|
+
.filter(file => extensions.includes(fileUtil_1.fileUtil.extname(file) ?? ''));
|
|
207
|
+
}
|
|
208
|
+
setInitPromise() {
|
|
209
|
+
const loadConfig = async () => {
|
|
210
|
+
this.config = await __classPrivateFieldGet(this, _Project_configService, "f").load();
|
|
211
|
+
};
|
|
212
|
+
const callIntializers = async () => {
|
|
213
|
+
const initCtx = {
|
|
214
|
+
cacheRoot: this.cacheRoot,
|
|
215
|
+
config: this.config,
|
|
216
|
+
downloader: this.downloader,
|
|
217
|
+
logger: this.logger,
|
|
218
|
+
meta: this.meta,
|
|
219
|
+
projectRoot: this.projectRoot,
|
|
220
|
+
};
|
|
221
|
+
const results = await Promise.allSettled(__classPrivateFieldGet(this, _Project_initializers, "f").map(init => init(initCtx)));
|
|
222
|
+
let ctx = {};
|
|
223
|
+
results.forEach(async (r, i) => {
|
|
224
|
+
if (r.status === 'rejected') {
|
|
225
|
+
this.logger.error(`[Project] [callInitializers] [${i}] “${__classPrivateFieldGet(this, _Project_initializers, "f")[i].name}”`, r.reason);
|
|
226
|
+
}
|
|
227
|
+
else if (r.value) {
|
|
228
|
+
ctx = { ...ctx, ...r.value };
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
__classPrivateFieldSet(this, _Project_ctx, ctx, "f");
|
|
232
|
+
};
|
|
233
|
+
const init = async () => {
|
|
234
|
+
const __profiler = this.profilers.get('project#init');
|
|
235
|
+
const { symbols } = await this.cacheService.load();
|
|
236
|
+
this.symbols = new symbol_1.SymbolUtil(symbols);
|
|
237
|
+
this.symbols.buildCache();
|
|
238
|
+
__profiler.task('Load Cache');
|
|
239
|
+
await loadConfig();
|
|
240
|
+
__profiler.task('Load Config');
|
|
241
|
+
await callIntializers();
|
|
242
|
+
__profiler.task('Initialize').finalize();
|
|
243
|
+
};
|
|
244
|
+
__classPrivateFieldSet(this, _Project_initPromise, init(), "f");
|
|
245
|
+
}
|
|
246
|
+
setReadyPromise() {
|
|
247
|
+
const getDependencies = async () => {
|
|
248
|
+
const ans = [];
|
|
249
|
+
for (const dependency of this.config.env.dependencies) {
|
|
250
|
+
if (Dependency_1.DependencyKey.is(dependency)) {
|
|
251
|
+
const provider = this.meta.getDependencyProvider(dependency);
|
|
252
|
+
if (provider) {
|
|
253
|
+
try {
|
|
254
|
+
ans.push(await provider());
|
|
255
|
+
this.logger.info(`[Project] [getDependencies] Executed provider “${dependency}”`);
|
|
256
|
+
}
|
|
257
|
+
catch (e) {
|
|
258
|
+
this.logger.error(`[Project] [getDependencies] Bad provider “${dependency}”`, e);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
else {
|
|
262
|
+
this.logger.error(`[Project] [getDependencies] Bad dependency “${dependency}”: no associated provider`);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
ans.push({ uri: dependency });
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
return ans;
|
|
270
|
+
};
|
|
271
|
+
const listDependencyFiles = async () => {
|
|
272
|
+
const dependencies = await getDependencies();
|
|
273
|
+
const fileUriSupporter = await FileService_1.FileUriSupporter.create(dependencies, this.logger);
|
|
274
|
+
const spyglassUriSupporter = await FileService_1.SpyglassUriSupporter.create(dependencies, this.logger, this.cacheService.checksums.roots);
|
|
275
|
+
this.fs.register('file:', fileUriSupporter, true);
|
|
276
|
+
this.fs.register(common_1.SpyglassUri.Protocol, spyglassUriSupporter, true);
|
|
277
|
+
};
|
|
278
|
+
const listProjectFiles = () => new Promise(resolve => {
|
|
279
|
+
__classPrivateFieldSet(this, _Project_watcherReady, false, "f");
|
|
280
|
+
__classPrivateFieldSet(this, _Project_watcher, chokidar_1.default
|
|
281
|
+
.watch(this.projectPath, { ignoreInitial: false })
|
|
282
|
+
.once('ready', () => {
|
|
283
|
+
__classPrivateFieldSet(this, _Project_watcherReady, true, "f");
|
|
284
|
+
resolve();
|
|
285
|
+
})
|
|
286
|
+
.on('add', path => {
|
|
287
|
+
const uri = fileUtil_1.fileUtil.pathToFileUri(path);
|
|
288
|
+
__classPrivateFieldGet(this, _Project_watchedFiles, "f").add(uri);
|
|
289
|
+
if (__classPrivateFieldGet(this, _Project_watcherReady, "f")) {
|
|
290
|
+
this.emit('fileCreated', { uri });
|
|
291
|
+
}
|
|
292
|
+
})
|
|
293
|
+
.on('change', path => {
|
|
294
|
+
const uri = fileUtil_1.fileUtil.pathToFileUri(path);
|
|
295
|
+
if (__classPrivateFieldGet(this, _Project_watcherReady, "f")) {
|
|
296
|
+
this.emit('fileModified', { uri });
|
|
297
|
+
}
|
|
298
|
+
})
|
|
299
|
+
.on('unlink', path => {
|
|
300
|
+
const uri = fileUtil_1.fileUtil.pathToFileUri(path);
|
|
301
|
+
__classPrivateFieldGet(this, _Project_watchedFiles, "f").delete(uri);
|
|
302
|
+
if (__classPrivateFieldGet(this, _Project_watcherReady, "f")) {
|
|
303
|
+
this.emit('fileDeleted', { uri });
|
|
304
|
+
}
|
|
305
|
+
})
|
|
306
|
+
.on('error', e => {
|
|
307
|
+
this.logger.error('[Project] [chokidar]', e);
|
|
308
|
+
}), "f");
|
|
309
|
+
});
|
|
310
|
+
const ready = async () => {
|
|
311
|
+
await this.init();
|
|
312
|
+
const __profiler = this.profilers.get('project#ready');
|
|
313
|
+
const limit = (0, p_limit_1.default)(8);
|
|
314
|
+
const ensureParsed = this.ensureParsed.bind(this);
|
|
315
|
+
const ensureChecked = this.ensureChecked.bind(this);
|
|
316
|
+
await Promise.all([
|
|
317
|
+
listDependencyFiles(),
|
|
318
|
+
listProjectFiles(),
|
|
319
|
+
]);
|
|
320
|
+
__classPrivateFieldSet(this, _Project_dependencyFiles, new Set(this.fs.listFiles()), "f");
|
|
321
|
+
__classPrivateFieldSet(this, _Project_dependencyRoots, new Set(this.fs.listRoots()), "f");
|
|
322
|
+
this.updateRoots();
|
|
323
|
+
__profiler.task('List Files');
|
|
324
|
+
for (const [id, { checksum, registrar }] of this.meta.symbolRegistrars) {
|
|
325
|
+
const cacheChecksum = this.cacheService.checksums.symbolRegistrars[id];
|
|
326
|
+
if (cacheChecksum === undefined || checksum !== cacheChecksum) {
|
|
327
|
+
this.symbols.clear({ contributor: `symbol_registrar/${id}` });
|
|
328
|
+
this.symbols.contributeAs(`symbol_registrar/${id}`, () => {
|
|
329
|
+
registrar(this.symbols, { logger: this.logger });
|
|
330
|
+
});
|
|
331
|
+
this.emit('symbolRegistrarExecuted', { id, checksum });
|
|
332
|
+
}
|
|
333
|
+
else {
|
|
334
|
+
this.logger.info(`[SymbolRegistrar] Skipped “${id}” thanks to cache ${checksum}`);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
__profiler.task('Register Symbols');
|
|
338
|
+
const { addedFiles, changedFiles, removedFiles } = await this.cacheService.validate();
|
|
339
|
+
for (const uri of removedFiles) {
|
|
340
|
+
this.symbols.clear({ uri });
|
|
341
|
+
}
|
|
342
|
+
__profiler.task('Validate Cache');
|
|
343
|
+
if (addedFiles.length > 0) {
|
|
344
|
+
this.bind(addedFiles);
|
|
345
|
+
}
|
|
346
|
+
__profiler.task('Bind URIs');
|
|
347
|
+
const files = [...addedFiles, ...changedFiles]; // FIXME: nbtdoc files might need to be parsed and checked before others.
|
|
348
|
+
// const docAndNodes = (await Promise.all(files.map(uri => limit(ensureParsed, uri)))).filter((r): r is DocAndNode => !!r)
|
|
349
|
+
const docAndNodes = (await Promise.all(files.map(uri => ensureParsed(uri)))).filter((r) => !!r);
|
|
350
|
+
__profiler.task('Parse Files');
|
|
351
|
+
// await Promise.all(docAndNodes.map(({ doc, node }) => limit(ensureChecked, doc, node)))
|
|
352
|
+
await Promise.all(docAndNodes.map(({ doc, node }) => ensureChecked(doc, node)));
|
|
353
|
+
__profiler.task('Check Files').finalize();
|
|
354
|
+
this.emit('ready', {});
|
|
355
|
+
};
|
|
356
|
+
__classPrivateFieldSet(this, _Project_readyPromise, ready(), "f");
|
|
357
|
+
}
|
|
358
|
+
async init() {
|
|
359
|
+
await __classPrivateFieldGet(this, _Project_initPromise, "f");
|
|
360
|
+
return this;
|
|
361
|
+
}
|
|
362
|
+
async ready() {
|
|
363
|
+
await __classPrivateFieldGet(this, _Project_initPromise, "f");
|
|
364
|
+
await __classPrivateFieldGet(this, _Project_readyPromise, "f");
|
|
365
|
+
return this;
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Behavior of the `Project` instance is undefined after this function has settled.
|
|
369
|
+
*/
|
|
370
|
+
async close() {
|
|
371
|
+
clearInterval(__classPrivateFieldGet(this, _Project_cacheSaverIntervalId, "f"));
|
|
372
|
+
await __classPrivateFieldGet(this, _Project_watcher, "f").close();
|
|
373
|
+
await this.cacheService.save();
|
|
374
|
+
}
|
|
375
|
+
async restart() {
|
|
376
|
+
try {
|
|
377
|
+
await __classPrivateFieldGet(this, _Project_watcher, "f").close();
|
|
378
|
+
this.setReadyPromise();
|
|
379
|
+
await this.ready();
|
|
380
|
+
}
|
|
381
|
+
catch (e) {
|
|
382
|
+
this.logger.error('[Project#reset]', e);
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
resetCache() {
|
|
386
|
+
return this.cacheService.reset();
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* @returns The language ID of the file, or the file extension without the leading dot.
|
|
390
|
+
*/
|
|
391
|
+
getLanguageID(uri) {
|
|
392
|
+
uri = fileUtil_1.fileUtil.normalize(uri);
|
|
393
|
+
const ext = fileUtil_1.fileUtil.extname(uri) ?? '.plaintext';
|
|
394
|
+
return this.meta.getLanguageID(ext) ?? ext.slice(1);
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* @returns The cached `TextDocument` and `AstNode` for the URI, or `undefined` when such data isn't available in cache.
|
|
398
|
+
*/
|
|
399
|
+
get(uri) {
|
|
400
|
+
uri = fileUtil_1.fileUtil.normalize(uri);
|
|
401
|
+
return __classPrivateFieldGet(this, _Project_docAndNodes, "f").get(uri);
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* @throws FS-related errors
|
|
405
|
+
*/
|
|
406
|
+
async ensureParsed(uri) {
|
|
407
|
+
uri = fileUtil_1.fileUtil.normalize(uri);
|
|
408
|
+
if (__classPrivateFieldGet(this, _Project_docAndNodes, "f").has(uri)) {
|
|
409
|
+
return __classPrivateFieldGet(this, _Project_docAndNodes, "f").get(uri);
|
|
410
|
+
}
|
|
411
|
+
const languageID = this.getLanguageID(uri);
|
|
412
|
+
if (!this.meta.isSupportedLanguage(languageID)) {
|
|
413
|
+
return undefined;
|
|
414
|
+
}
|
|
415
|
+
try {
|
|
416
|
+
const content = (0, common_1.bufferToString)(await this.fs.readFile(uri));
|
|
417
|
+
const doc = vscode_languageserver_textdocument_1.TextDocument.create(uri, languageID, -1, content);
|
|
418
|
+
return this.parseAndCache(doc);
|
|
419
|
+
}
|
|
420
|
+
catch (e) {
|
|
421
|
+
this.logger.warn(`[Project] [ensureParsed] Failed for “${uri}”`, e);
|
|
422
|
+
return undefined;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
parseAndCache(doc) {
|
|
426
|
+
const node = this.parse(doc);
|
|
427
|
+
return this.cache(doc, node);
|
|
428
|
+
}
|
|
429
|
+
parse(doc) {
|
|
430
|
+
const ctx = Context_1.ParserContext.create(this, { doc });
|
|
431
|
+
const src = new source_1.Source(doc.getText());
|
|
432
|
+
let ans;
|
|
433
|
+
ctx.symbols.clear({ contributor: 'parser', uri: doc.uri });
|
|
434
|
+
ctx.symbols.contributeAs('parser', () => ans = (0, parser_1.file)()(src, ctx));
|
|
435
|
+
return ans;
|
|
436
|
+
}
|
|
437
|
+
cache(doc, node) {
|
|
438
|
+
const data = { doc, node };
|
|
439
|
+
__classPrivateFieldGet(this, _Project_docAndNodes, "f").set(doc.uri, data);
|
|
440
|
+
this.emit('documentUpdated', data);
|
|
441
|
+
return data;
|
|
442
|
+
}
|
|
443
|
+
async check(doc, node) {
|
|
444
|
+
const checker = this.meta.getChecker(node.type);
|
|
445
|
+
const ctx = Context_1.CheckerContext.create(this, { doc });
|
|
446
|
+
ctx.symbols.clear({ contributor: 'checker', uri: doc.uri });
|
|
447
|
+
await ctx.symbols.contributeAsAsync('checker', async () => {
|
|
448
|
+
await checker(node, ctx);
|
|
449
|
+
node.checkerErrors = ctx.err.dump();
|
|
450
|
+
this.cache(doc, node);
|
|
451
|
+
this.ensureLinted(doc, node);
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
async ensureChecked(doc, node) {
|
|
455
|
+
if (!node.checkerErrors) {
|
|
456
|
+
try {
|
|
457
|
+
return this.check(doc, node);
|
|
458
|
+
}
|
|
459
|
+
catch (e) {
|
|
460
|
+
this.logger.error(`[Project] [ensuredChecked] Failed for “${doc.uri}” #${doc.version}`, e);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
lint(doc, node) {
|
|
465
|
+
node.linterErrors = [];
|
|
466
|
+
for (const [ruleName, rawValue] of Object.entries(this.config.lint)) {
|
|
467
|
+
const result = Config_1.LinterConfigValue.destruct(rawValue);
|
|
468
|
+
if (!result) {
|
|
469
|
+
// Rule is disabled (i.e. set to `null`) in the config.
|
|
470
|
+
continue;
|
|
471
|
+
}
|
|
472
|
+
const { ruleSeverity, ruleValue } = result;
|
|
473
|
+
const { configValidator, linter, nodePredicate } = this.meta.getLinter(ruleName);
|
|
474
|
+
if (!configValidator(ruleName, ruleValue, this.logger)) {
|
|
475
|
+
// Config value is invalid.
|
|
476
|
+
continue;
|
|
477
|
+
}
|
|
478
|
+
const ctx = Context_1.LinterContext.create(this, {
|
|
479
|
+
doc,
|
|
480
|
+
err: new ErrorReporter_1.LinterErrorReporter(ruleName, ruleSeverity),
|
|
481
|
+
ruleName,
|
|
482
|
+
ruleValue,
|
|
483
|
+
});
|
|
484
|
+
(0, processor_1.traversePreOrder)(node, () => true, () => true, node => {
|
|
485
|
+
if (nodePredicate(node)) {
|
|
486
|
+
linter(node, ctx);
|
|
487
|
+
}
|
|
488
|
+
});
|
|
489
|
+
node.linterErrors.push(...ctx.err.dump());
|
|
490
|
+
}
|
|
491
|
+
this.cache(doc, node);
|
|
492
|
+
}
|
|
493
|
+
ensureLinted(doc, node) {
|
|
494
|
+
if (!node.linterErrors) {
|
|
495
|
+
try {
|
|
496
|
+
this.lint(doc, node);
|
|
497
|
+
}
|
|
498
|
+
catch (e) {
|
|
499
|
+
this.logger.error(`[Project] [ensureLinted] Failed for “${doc.uri}” #${doc.version}`, e);
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
async ensureParsedAndChecked(uri) {
|
|
504
|
+
const result = await this.ensureParsed(uri);
|
|
505
|
+
if (result) {
|
|
506
|
+
await this.ensureChecked(result.doc, result.node);
|
|
507
|
+
}
|
|
508
|
+
return result;
|
|
509
|
+
}
|
|
510
|
+
bind(param) {
|
|
511
|
+
const ctx = Context_1.UriBinderContext.create(this);
|
|
512
|
+
// Remove all symbol locations contributed by URI binders if the parameter is an array.
|
|
513
|
+
// Otherwise only remove the ones associated with the specified URI.
|
|
514
|
+
ctx.symbols.clear({ contributor: 'uri_binder', uri: Array.isArray(param) ? undefined : param });
|
|
515
|
+
ctx.symbols.contributeAs('uri_binder', () => {
|
|
516
|
+
const uris = Array.isArray(param) ? param : [param];
|
|
517
|
+
for (const binder of this.meta.uriBinders) {
|
|
518
|
+
binder(uris, ctx);
|
|
519
|
+
}
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
/**
|
|
523
|
+
* Notify that a new document was opened in the editor.
|
|
524
|
+
*/
|
|
525
|
+
onDidOpen(uri, languageID, version, content) {
|
|
526
|
+
uri = fileUtil_1.fileUtil.normalize(uri);
|
|
527
|
+
__classPrivateFieldGet(this, _Project_clientManagedUris, "f").add(uri);
|
|
528
|
+
const doc = vscode_languageserver_textdocument_1.TextDocument.create(uri, languageID, version, content);
|
|
529
|
+
const { node } = this.parseAndCache(doc);
|
|
530
|
+
this.check(doc, node);
|
|
531
|
+
}
|
|
532
|
+
/**
|
|
533
|
+
* Notify that an existing document was changed in the editor.
|
|
534
|
+
* @throws If there is no `TextDocument` corresponding to the URI.
|
|
535
|
+
*/
|
|
536
|
+
onDidChange(uri, changes, version) {
|
|
537
|
+
uri = fileUtil_1.fileUtil.normalize(uri);
|
|
538
|
+
const result = this.get(uri);
|
|
539
|
+
if (!result) {
|
|
540
|
+
throw new Error(`Document for “${uri}” is not cached. This should not happen. Did the language client send a didChange notification without sending a didOpen one?`);
|
|
541
|
+
}
|
|
542
|
+
vscode_languageserver_textdocument_1.TextDocument.update(result.doc, changes, version);
|
|
543
|
+
const { node } = this.parseAndCache(result.doc);
|
|
544
|
+
this.check(result.doc, node);
|
|
545
|
+
}
|
|
546
|
+
/**
|
|
547
|
+
* Notify that an existing document was closed in the editor.
|
|
548
|
+
*/
|
|
549
|
+
onDidClose(uri) {
|
|
550
|
+
uri = fileUtil_1.fileUtil.normalize(uri);
|
|
551
|
+
__classPrivateFieldGet(this, _Project_clientManagedUris, "f").delete(uri);
|
|
552
|
+
this.tryClearingCache(uri);
|
|
553
|
+
}
|
|
554
|
+
async showCacheRoot() {
|
|
555
|
+
if (!__classPrivateFieldGet(this, _Project_cacheRoot, "f")) {
|
|
556
|
+
return;
|
|
557
|
+
}
|
|
558
|
+
try {
|
|
559
|
+
await fileUtil_1.fileUtil.showFile(__classPrivateFieldGet(this, _Project_cacheRoot, "f"));
|
|
560
|
+
}
|
|
561
|
+
catch (e) {
|
|
562
|
+
this.logger.error('[Service#showCacheRoot]', e);
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
tryClearingCache(uri) {
|
|
566
|
+
if (this.shouldRemove(uri)) {
|
|
567
|
+
__classPrivateFieldGet(this, _Project_docAndNodes, "f").delete(uri);
|
|
568
|
+
this.emit('documentRemoved', { uri });
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
shouldRemove(uri) {
|
|
572
|
+
return !__classPrivateFieldGet(this, _Project_clientManagedUris, "f").has(uri) && !__classPrivateFieldGet(this, _Project_dependencyFiles, "f").has(uri) && !__classPrivateFieldGet(this, _Project_watchedFiles, "f").has(uri);
|
|
573
|
+
}
|
|
574
|
+
isOnlyWatched(uri) {
|
|
575
|
+
return __classPrivateFieldGet(this, _Project_watchedFiles, "f").has(uri) && !__classPrivateFieldGet(this, _Project_clientManagedUris, "f").has(uri) && !__classPrivateFieldGet(this, _Project_dependencyFiles, "f").has(uri);
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
_Project_cacheSaverIntervalId = new WeakMap(), _Project_clientManagedUris = new WeakMap(), _Project_configService = new WeakMap(), _Project_docAndNodes = new WeakMap(), _Project_initializers = new WeakMap(), _Project_initPromise = new WeakMap(), _Project_readyPromise = new WeakMap(), _Project_watchedFiles = new WeakMap(), _Project_watcher = new WeakMap(), _Project_watcherReady = new WeakMap(), _Project_dependencyRoots = new WeakMap(), _Project_dependencyFiles = new WeakMap(), _Project_roots = new WeakMap(), _Project_ctx = new WeakMap(), _Project_cacheRoot = new WeakMap();
|
|
579
|
+
Project.RootSuffix = '/pack.mcmeta';
|
|
580
|
+
__decorate([
|
|
581
|
+
(0, common_1.CachePromise)()
|
|
582
|
+
], Project.prototype, "ensureParsed", null);
|
|
583
|
+
__decorate([
|
|
584
|
+
(0, common_1.CachePromise)()
|
|
585
|
+
], Project.prototype, "check", null);
|
|
586
|
+
__decorate([
|
|
587
|
+
(0, common_1.CachePromise)()
|
|
588
|
+
], Project.prototype, "ensureChecked", null);
|
|
589
|
+
__decorate([
|
|
590
|
+
(0, common_1.CachePromise)()
|
|
591
|
+
], Project.prototype, "ensureParsedAndChecked", null);
|
|
592
|
+
exports.Project = Project;
|
|
593
|
+
//# sourceMappingURL=Project.js.map
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import EventEmitter from 'events';
|
|
3
|
+
import type { TextDocument } from 'vscode-languageserver-textdocument';
|
|
4
|
+
import type { FileNode } from '../node';
|
|
5
|
+
import { AstNode } from '../node';
|
|
6
|
+
import type { Color, ColorInfo, ColorToken, InlayHint, SignatureHelp } from '../processor';
|
|
7
|
+
import { ColorPresentation } from '../processor';
|
|
8
|
+
import { Range } from '../source';
|
|
9
|
+
import type { SymbolUsageType } from '../symbol';
|
|
10
|
+
import { Downloader } from './Downloader';
|
|
11
|
+
import { FileService } from './FileService';
|
|
12
|
+
import { Hover } from './Hover';
|
|
13
|
+
import { Logger } from './Logger';
|
|
14
|
+
import { ProfilerFactory } from './Profiler';
|
|
15
|
+
import type { ProjectInitializer } from './Project';
|
|
16
|
+
import { Project } from './Project';
|
|
17
|
+
import { SymbolLocations } from './SymbolLocations';
|
|
18
|
+
interface Options {
|
|
19
|
+
cacheRoot: string;
|
|
20
|
+
downloader?: Downloader;
|
|
21
|
+
fs?: FileService;
|
|
22
|
+
initializers?: readonly ProjectInitializer[];
|
|
23
|
+
isDebugging?: boolean;
|
|
24
|
+
logger?: Logger;
|
|
25
|
+
profilers?: ProfilerFactory;
|
|
26
|
+
projectPath: string;
|
|
27
|
+
}
|
|
28
|
+
export declare class Service extends EventEmitter {
|
|
29
|
+
readonly downloader: Downloader;
|
|
30
|
+
readonly fs: FileService;
|
|
31
|
+
readonly isDebugging: boolean;
|
|
32
|
+
readonly logger: Logger;
|
|
33
|
+
readonly profilers: ProfilerFactory;
|
|
34
|
+
readonly project: Project;
|
|
35
|
+
constructor({ cacheRoot, downloader, fs, initializers, isDebugging, logger, profilers, projectPath, }: Options);
|
|
36
|
+
private debug;
|
|
37
|
+
colorize(node: FileNode<AstNode>, doc: TextDocument, range?: Range): readonly ColorToken[];
|
|
38
|
+
getColorInfo(node: FileNode<AstNode>, doc: TextDocument): ColorInfo[];
|
|
39
|
+
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[];
|
|
41
|
+
dataHackPubify(initialism: string): string;
|
|
42
|
+
getHover(file: FileNode<AstNode>, doc: TextDocument, offset: number): Hover | undefined;
|
|
43
|
+
getInlayHints(node: FileNode<AstNode>, doc: TextDocument, range?: Range): InlayHint[];
|
|
44
|
+
getSignatureHelp(node: FileNode<AstNode>, doc: TextDocument, offset: number): SignatureHelp | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* @param searchedUsages Type of symbol usages that should be included in the result. Defaults to all usages.
|
|
47
|
+
* @param currentFileOnly Whether only symbol locations in the current file should be returned.
|
|
48
|
+
*
|
|
49
|
+
* @returns Symbol locations of the selected symbol at `offset`, or `undefined` if there's no symbol at `offset`.
|
|
50
|
+
*/
|
|
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;
|
|
53
|
+
}
|
|
54
|
+
export {};
|
|
55
|
+
//# sourceMappingURL=Service.d.ts.map
|