@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/fileUtil.js
CHANGED
|
@@ -1,37 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
-
};
|
|
24
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.fileUtil = void 0;
|
|
26
|
-
const child_process_1 = __importDefault(require("child_process"));
|
|
27
|
-
const fs_1 = require("fs");
|
|
28
|
-
const path_1 = require("path");
|
|
29
|
-
const process_1 = __importDefault(require("process"));
|
|
30
|
-
const url_1 = __importStar(require("url"));
|
|
31
|
-
const util_1 = require("util");
|
|
32
|
-
const zlib_1 = __importDefault(require("zlib"));
|
|
33
|
-
const common_1 = require("../common");
|
|
34
|
-
var fileUtil;
|
|
1
|
+
import { bufferToString, Uri } from '../common/index.js';
|
|
2
|
+
export var fileUtil;
|
|
35
3
|
(function (fileUtil) {
|
|
36
4
|
/**
|
|
37
5
|
* @param rootUris The root URIs. Each URI in this array must end with a slash (`/`).
|
|
@@ -93,54 +61,17 @@ var fileUtil;
|
|
|
93
61
|
return i >= 0 ? value.slice(i) : undefined;
|
|
94
62
|
}
|
|
95
63
|
fileUtil.extname = extname;
|
|
96
|
-
/* istanbul ignore next */
|
|
97
|
-
/**
|
|
98
|
-
* @param fileUri A file URI.
|
|
99
|
-
* @returns The corresponding file path of the `fileUri` in platform-specific format.
|
|
100
|
-
* @throws If the URI is not a file schema URI.
|
|
101
|
-
*/
|
|
102
|
-
function fileUriToPath(fileUri) {
|
|
103
|
-
return url_1.default.fileURLToPath(new url_1.URL(fileUri));
|
|
104
|
-
}
|
|
105
|
-
fileUtil.fileUriToPath = fileUriToPath;
|
|
106
|
-
/* istanbul ignore next */
|
|
107
64
|
/**
|
|
108
|
-
* @
|
|
109
|
-
* @returns The corresponding file URI of the `path`.
|
|
65
|
+
* @returns The part from the last `/` to the end of the URI.
|
|
110
66
|
*/
|
|
111
|
-
function
|
|
112
|
-
|
|
67
|
+
function basename(uri) {
|
|
68
|
+
const i = uri.lastIndexOf('/');
|
|
69
|
+
return i >= 0 ? uri.slice(i + 1) : uri;
|
|
113
70
|
}
|
|
114
|
-
fileUtil.
|
|
71
|
+
fileUtil.basename = basename;
|
|
115
72
|
/* istanbul ignore next */
|
|
116
|
-
function
|
|
117
|
-
|
|
118
|
-
return isFileUri(uri) ? pathToFileUri(fileUriToPath(uri)) : new url_1.URL(uri).toString();
|
|
119
|
-
}
|
|
120
|
-
catch {
|
|
121
|
-
return uri;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
fileUtil.normalize = normalize;
|
|
125
|
-
/**
|
|
126
|
-
* @param path A string file path, string file URI, or a file URI object.
|
|
127
|
-
*
|
|
128
|
-
* @returns A {@link fs.PathLike}.
|
|
129
|
-
*/
|
|
130
|
-
function toFsPathLike(path) {
|
|
131
|
-
if (typeof path === 'string' && isFileUri(path)) {
|
|
132
|
-
return new url_1.URL(path);
|
|
133
|
-
}
|
|
134
|
-
return path;
|
|
135
|
-
}
|
|
136
|
-
/* istanbul ignore next */
|
|
137
|
-
function getParentOfFile(path) {
|
|
138
|
-
if (path instanceof url_1.URL || isFileUri(path)) {
|
|
139
|
-
return new url_1.URL('.', path);
|
|
140
|
-
}
|
|
141
|
-
else {
|
|
142
|
-
return (0, path_1.resolve)(path, '..');
|
|
143
|
-
}
|
|
73
|
+
function getParentOfFile(externals, path) {
|
|
74
|
+
return new Uri('.', path);
|
|
144
75
|
}
|
|
145
76
|
fileUtil.getParentOfFile = getParentOfFile;
|
|
146
77
|
/* istanbul ignore next */
|
|
@@ -149,12 +80,12 @@ var fileUtil;
|
|
|
149
80
|
*
|
|
150
81
|
* @param mode Default to `0o777` (`rwxrwxrwx`)
|
|
151
82
|
*/
|
|
152
|
-
async function ensureDir(path, mode = 0o777) {
|
|
83
|
+
async function ensureDir(externals, path, mode = 0o777) {
|
|
153
84
|
try {
|
|
154
|
-
await
|
|
85
|
+
await externals.fs.mkdir(path, { mode, recursive: true });
|
|
155
86
|
}
|
|
156
87
|
catch (e) {
|
|
157
|
-
if (!
|
|
88
|
+
if (!externals.error.isKind(e, 'EEXIST')) {
|
|
158
89
|
throw e;
|
|
159
90
|
}
|
|
160
91
|
}
|
|
@@ -168,35 +99,58 @@ var fileUtil;
|
|
|
168
99
|
*
|
|
169
100
|
* @param mode Default to `0o777` (`rwxrwxrwx`)
|
|
170
101
|
*/
|
|
171
|
-
async function ensureParentOfFile(path, mode = 0o777) {
|
|
172
|
-
return ensureDir(getParentOfFile(path), mode);
|
|
102
|
+
async function ensureParentOfFile(externals, path, mode = 0o777) {
|
|
103
|
+
return ensureDir(externals, getParentOfFile(externals, path), mode);
|
|
173
104
|
}
|
|
174
105
|
fileUtil.ensureParentOfFile = ensureParentOfFile;
|
|
175
|
-
async function
|
|
176
|
-
return
|
|
106
|
+
async function chmod(externals, path, mode) {
|
|
107
|
+
return externals.fs.chmod(path, mode);
|
|
108
|
+
}
|
|
109
|
+
fileUtil.chmod = chmod;
|
|
110
|
+
async function ensureWritable(externals, path) {
|
|
111
|
+
try {
|
|
112
|
+
await chmod(externals, path, 0o666);
|
|
113
|
+
}
|
|
114
|
+
catch (e) {
|
|
115
|
+
if (!externals.error.isKind(e, 'ENOENT')) {
|
|
116
|
+
throw e;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
fileUtil.ensureWritable = ensureWritable;
|
|
121
|
+
async function markReadOnly(externals, path) {
|
|
122
|
+
return chmod(externals, path, 0o444);
|
|
123
|
+
}
|
|
124
|
+
fileUtil.markReadOnly = markReadOnly;
|
|
125
|
+
async function readFile(externals, path) {
|
|
126
|
+
return externals.fs.readFile(path);
|
|
177
127
|
}
|
|
178
128
|
fileUtil.readFile = readFile;
|
|
179
129
|
/* istanbul ignore next */
|
|
180
130
|
/**
|
|
181
131
|
* @throws
|
|
182
132
|
*
|
|
183
|
-
* The directory of the file will be created recursively if it doesn'
|
|
133
|
+
* The directory of the file will be created recursively if it doesn't exist.
|
|
134
|
+
*
|
|
135
|
+
* The target file will be given permission `0o666` (`rw-rw-rw-`) before being written into, and changed back to the
|
|
136
|
+
* specified `mode`.
|
|
184
137
|
*
|
|
185
138
|
* * Encoding: `utf-8`
|
|
186
139
|
* * Mode: `0o666` (`rw-rw-rw-`)
|
|
187
140
|
* * Flag: `w`
|
|
188
141
|
*/
|
|
189
|
-
async function writeFile(path, data) {
|
|
190
|
-
await ensureParentOfFile(path);
|
|
191
|
-
|
|
142
|
+
async function writeFile(externals, path, data, mode = 0o666) {
|
|
143
|
+
await ensureParentOfFile(externals, path);
|
|
144
|
+
await ensureWritable(externals, path);
|
|
145
|
+
return externals.fs.writeFile(path, data, { mode });
|
|
192
146
|
}
|
|
193
147
|
fileUtil.writeFile = writeFile;
|
|
194
148
|
/* istanbul ignore next */
|
|
195
149
|
/**
|
|
196
150
|
* @throws
|
|
197
151
|
*/
|
|
198
|
-
async function readJson(path) {
|
|
199
|
-
return JSON.parse(
|
|
152
|
+
async function readJson(externals, path) {
|
|
153
|
+
return JSON.parse(bufferToString(await readFile(externals, path)));
|
|
200
154
|
}
|
|
201
155
|
fileUtil.readJson = readJson;
|
|
202
156
|
/* istanbul ignore next */
|
|
@@ -205,64 +159,40 @@ var fileUtil;
|
|
|
205
159
|
*
|
|
206
160
|
* @see {@link writeFile}
|
|
207
161
|
*/
|
|
208
|
-
async function writeJson(path, data) {
|
|
209
|
-
return writeFile(path, JSON.stringify(data));
|
|
162
|
+
async function writeJson(externals, path, data) {
|
|
163
|
+
return writeFile(externals, path, JSON.stringify(data));
|
|
210
164
|
}
|
|
211
165
|
fileUtil.writeJson = writeJson;
|
|
212
166
|
/**
|
|
213
167
|
* @throws
|
|
214
168
|
*/
|
|
215
|
-
async function readGzippedFile(path) {
|
|
216
|
-
|
|
217
|
-
return unzip(await readFile(path));
|
|
169
|
+
async function readGzippedFile(externals, path) {
|
|
170
|
+
return externals.archive.gunzip(await readFile(externals, path));
|
|
218
171
|
}
|
|
219
172
|
fileUtil.readGzippedFile = readGzippedFile;
|
|
220
173
|
/**
|
|
221
174
|
* @throws
|
|
222
175
|
*/
|
|
223
|
-
async function writeGzippedFile(path, buffer) {
|
|
224
|
-
|
|
225
|
-
|
|
176
|
+
async function writeGzippedFile(externals, path, buffer) {
|
|
177
|
+
if (typeof buffer === 'string') {
|
|
178
|
+
buffer = new TextEncoder().encode(buffer);
|
|
179
|
+
}
|
|
180
|
+
return writeFile(externals, path, await externals.archive.gzip(buffer));
|
|
226
181
|
}
|
|
227
182
|
fileUtil.writeGzippedFile = writeGzippedFile;
|
|
228
183
|
/**
|
|
229
184
|
* @throws
|
|
230
185
|
*/
|
|
231
|
-
async function readGzippedJson(path) {
|
|
232
|
-
return JSON.parse(
|
|
186
|
+
async function readGzippedJson(externals, path) {
|
|
187
|
+
return JSON.parse(bufferToString(await readGzippedFile(externals, path)));
|
|
233
188
|
}
|
|
234
189
|
fileUtil.readGzippedJson = readGzippedJson;
|
|
235
190
|
/**
|
|
236
191
|
* @throws
|
|
237
192
|
*/
|
|
238
|
-
async function writeGzippedJson(path, data) {
|
|
239
|
-
return writeGzippedFile(path, JSON.stringify(data));
|
|
193
|
+
async function writeGzippedJson(externals, path, data) {
|
|
194
|
+
return writeGzippedFile(externals, path, JSON.stringify(data));
|
|
240
195
|
}
|
|
241
196
|
fileUtil.writeGzippedJson = writeGzippedJson;
|
|
242
|
-
|
|
243
|
-
* Show the file/directory in the platform-specific explorer program.
|
|
244
|
-
*
|
|
245
|
-
* Should not be called with unsanitized user-input path due to the possibility of
|
|
246
|
-
* arbitrary code execution.
|
|
247
|
-
*
|
|
248
|
-
* @returns The `stdout` from the spawned child process.
|
|
249
|
-
*/
|
|
250
|
-
async function showFile(path) {
|
|
251
|
-
const execFile = (0, util_1.promisify)(child_process_1.default.execFile);
|
|
252
|
-
let command;
|
|
253
|
-
switch (process_1.default.platform) {
|
|
254
|
-
case 'darwin':
|
|
255
|
-
command = 'open';
|
|
256
|
-
break;
|
|
257
|
-
case 'win32':
|
|
258
|
-
command = 'explorer';
|
|
259
|
-
break;
|
|
260
|
-
default:
|
|
261
|
-
command = 'xdg-open';
|
|
262
|
-
break;
|
|
263
|
-
}
|
|
264
|
-
return execFile(command, [path]);
|
|
265
|
-
}
|
|
266
|
-
fileUtil.showFile = showFile;
|
|
267
|
-
})(fileUtil = exports.fileUtil || (exports.fileUtil = {}));
|
|
197
|
+
})(fileUtil || (fileUtil = {}));
|
|
268
198
|
//# sourceMappingURL=fileUtil.js.map
|
package/lib/service/index.d.ts
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
export * from './CacheService';
|
|
2
|
-
export * from './Config';
|
|
3
|
-
export * from './Context';
|
|
4
|
-
export * from './Dependency';
|
|
5
|
-
export * from './Downloader';
|
|
6
|
-
export * from './ErrorReporter';
|
|
7
|
-
export { FileService, UriProtocolSupporter } from './FileService';
|
|
8
|
-
export * from './fileUtil';
|
|
9
|
-
export * from './Hover';
|
|
10
|
-
export * from './
|
|
11
|
-
export * from './
|
|
12
|
-
export * from './
|
|
13
|
-
export * from './
|
|
14
|
-
export * from './
|
|
15
|
-
export * from './
|
|
16
|
-
export * from './
|
|
17
|
-
export * from './SymbolRegistrar';
|
|
1
|
+
export * from './CacheService.js';
|
|
2
|
+
export * from './Config.js';
|
|
3
|
+
export * from './Context.js';
|
|
4
|
+
export * from './Dependency.js';
|
|
5
|
+
export * from './Downloader.js';
|
|
6
|
+
export * from './ErrorReporter.js';
|
|
7
|
+
export { FileService, UriProtocolSupporter } from './FileService.js';
|
|
8
|
+
export * from './fileUtil.js';
|
|
9
|
+
export * from './Hover.js';
|
|
10
|
+
export * from './MetaRegistry.js';
|
|
11
|
+
export * from './Profiler.js';
|
|
12
|
+
export * from './Project.js';
|
|
13
|
+
export * from './Service.js';
|
|
14
|
+
export * from './SymbolLocations.js';
|
|
15
|
+
export * from './SymbolRegistrar.js';
|
|
16
|
+
export * from './UriProcessor.js';
|
|
18
17
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/service/index.js
CHANGED
|
@@ -1,33 +1,18 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/* istanbul ignore file */
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
__exportStar(require("./Downloader"), exports);
|
|
20
|
-
__exportStar(require("./ErrorReporter"), exports);
|
|
21
|
-
var FileService_1 = require("./FileService");
|
|
22
|
-
Object.defineProperty(exports, "FileService", { enumerable: true, get: function () { return FileService_1.FileService; } });
|
|
23
|
-
__exportStar(require("./fileUtil"), exports);
|
|
24
|
-
__exportStar(require("./Hover"), exports);
|
|
25
|
-
__exportStar(require("./Logger"), exports);
|
|
26
|
-
__exportStar(require("./MetaRegistry"), exports);
|
|
27
|
-
__exportStar(require("./Operations"), exports);
|
|
28
|
-
__exportStar(require("./Profiler"), exports);
|
|
29
|
-
__exportStar(require("./Project"), exports);
|
|
30
|
-
__exportStar(require("./Service"), exports);
|
|
31
|
-
__exportStar(require("./SymbolLocations"), exports);
|
|
32
|
-
__exportStar(require("./SymbolRegistrar"), exports);
|
|
2
|
+
export * from './CacheService.js';
|
|
3
|
+
export * from './Config.js';
|
|
4
|
+
export * from './Context.js';
|
|
5
|
+
export * from './Dependency.js';
|
|
6
|
+
export * from './Downloader.js';
|
|
7
|
+
export * from './ErrorReporter.js';
|
|
8
|
+
export { FileService } from './FileService.js';
|
|
9
|
+
export * from './fileUtil.js';
|
|
10
|
+
export * from './Hover.js';
|
|
11
|
+
export * from './MetaRegistry.js';
|
|
12
|
+
export * from './Profiler.js';
|
|
13
|
+
export * from './Project.js';
|
|
14
|
+
export * from './Service.js';
|
|
15
|
+
export * from './SymbolLocations.js';
|
|
16
|
+
export * from './SymbolRegistrar.js';
|
|
17
|
+
export * from './UriProcessor.js';
|
|
33
18
|
//# sourceMappingURL=index.js.map
|
package/lib/source/IndexMap.d.ts
CHANGED
package/lib/source/IndexMap.js
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.IndexMap = void 0;
|
|
4
|
-
const Range_1 = require("./Range");
|
|
5
|
-
var IndexMap;
|
|
1
|
+
import { Range } from './Range.js';
|
|
2
|
+
export var IndexMap;
|
|
6
3
|
(function (IndexMap) {
|
|
7
4
|
function convertOffset(map, offset, from, to, isEndOffset) {
|
|
8
5
|
let ans = offset;
|
|
9
6
|
for (const pair of map) {
|
|
10
|
-
if (
|
|
7
|
+
if (Range.contains(pair[from], offset, isEndOffset)) {
|
|
11
8
|
return isEndOffset ? pair[to].end : pair[to].start;
|
|
12
9
|
}
|
|
13
|
-
else if (
|
|
10
|
+
else if (Range.endsBefore(pair[from], offset)) {
|
|
14
11
|
ans = offset - pair[from].end + pair[to].end;
|
|
15
12
|
}
|
|
16
13
|
else {
|
|
@@ -24,7 +21,7 @@ var IndexMap;
|
|
|
24
21
|
}
|
|
25
22
|
IndexMap.toInnerOffset = toInnerOffset;
|
|
26
23
|
function toInnerRange(map, outer) {
|
|
27
|
-
return
|
|
24
|
+
return Range.create(toInnerOffset(map, outer.start), convertOffset(map, outer.end, 'outer', 'inner', true));
|
|
28
25
|
}
|
|
29
26
|
IndexMap.toInnerRange = toInnerRange;
|
|
30
27
|
function toOuterOffset(map, offset) {
|
|
@@ -32,7 +29,7 @@ var IndexMap;
|
|
|
32
29
|
}
|
|
33
30
|
IndexMap.toOuterOffset = toOuterOffset;
|
|
34
31
|
function toOuterRange(map, inner) {
|
|
35
|
-
return
|
|
32
|
+
return Range.create(toOuterOffset(map, inner.start), convertOffset(map, inner.end, 'inner', 'outer', true));
|
|
36
33
|
}
|
|
37
34
|
IndexMap.toOuterRange = toOuterRange;
|
|
38
35
|
function merge(outerMap, innerMap) {
|
|
@@ -42,5 +39,5 @@ var IndexMap;
|
|
|
42
39
|
}));
|
|
43
40
|
}
|
|
44
41
|
IndexMap.merge = merge;
|
|
45
|
-
})(IndexMap
|
|
42
|
+
})(IndexMap || (IndexMap = {}));
|
|
46
43
|
//# sourceMappingURL=IndexMap.js.map
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LanguageError = void 0;
|
|
4
|
-
var LanguageError;
|
|
1
|
+
export var LanguageError;
|
|
5
2
|
(function (LanguageError) {
|
|
6
|
-
function create(message, range, severity = 3 /* Error */, info) {
|
|
3
|
+
function create(message, range, severity = 3 /* ErrorSeverity.Error */, info) {
|
|
7
4
|
const ans = { range, message, severity };
|
|
8
5
|
if (info) {
|
|
9
6
|
ans.info = info;
|
|
@@ -11,5 +8,5 @@ var LanguageError;
|
|
|
11
8
|
return ans;
|
|
12
9
|
}
|
|
13
10
|
LanguageError.create = create;
|
|
14
|
-
})(LanguageError
|
|
11
|
+
})(LanguageError || (LanguageError = {}));
|
|
15
12
|
//# sourceMappingURL=LanguageError.js.map
|
package/lib/source/Location.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { TextDocument } from 'vscode-languageserver-textdocument';
|
|
2
|
-
import { PositionRange } from './PositionRange';
|
|
3
|
-
import type { RangeLike } from './Range';
|
|
4
|
-
import { Range } from './Range';
|
|
2
|
+
import { PositionRange } from './PositionRange.js';
|
|
3
|
+
import type { RangeLike } from './Range.js';
|
|
4
|
+
import { Range } from './Range.js';
|
|
5
5
|
export interface Location {
|
|
6
6
|
uri: string;
|
|
7
7
|
range: Range;
|
package/lib/source/Location.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const PositionRange_1 = require("./PositionRange");
|
|
5
|
-
const Range_1 = require("./Range");
|
|
6
|
-
var Location;
|
|
1
|
+
import { PositionRange } from './PositionRange.js';
|
|
2
|
+
import { Range } from './Range.js';
|
|
3
|
+
export var Location;
|
|
7
4
|
(function (Location) {
|
|
8
5
|
function get(partial) {
|
|
9
6
|
return {
|
|
10
7
|
uri: partial.uri ?? '',
|
|
11
|
-
range:
|
|
8
|
+
range: Range.get(partial.range ?? { start: 0, end: 0 }),
|
|
12
9
|
posRange: partial.posRange ?? { start: { line: 0, character: 0 }, end: { line: 0, character: 0 } },
|
|
13
10
|
};
|
|
14
11
|
}
|
|
@@ -17,9 +14,9 @@ var Location;
|
|
|
17
14
|
return Location.get({
|
|
18
15
|
uri: doc.uri,
|
|
19
16
|
range,
|
|
20
|
-
posRange:
|
|
17
|
+
posRange: PositionRange.from(range, doc),
|
|
21
18
|
});
|
|
22
19
|
}
|
|
23
20
|
Location.create = create;
|
|
24
|
-
})(Location
|
|
21
|
+
})(Location || (Location = {}));
|
|
25
22
|
//# sourceMappingURL=Location.js.map
|
package/lib/source/Offset.d.ts
CHANGED
package/lib/source/Offset.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.Offset = void 0;
|
|
4
|
-
const Source_1 = require("./Source");
|
|
5
|
-
var Offset;
|
|
1
|
+
import { ReadonlySource } from './Source.js';
|
|
2
|
+
export var Offset;
|
|
6
3
|
(function (Offset) {
|
|
7
4
|
/**
|
|
8
5
|
* Get an offset from a `OffsetLike`.
|
|
@@ -15,11 +12,11 @@ var Offset;
|
|
|
15
12
|
if (typeof offset === 'function') {
|
|
16
13
|
offset = offset();
|
|
17
14
|
}
|
|
18
|
-
if (offset instanceof
|
|
15
|
+
if (offset instanceof ReadonlySource) {
|
|
19
16
|
offset = offset.cursor;
|
|
20
17
|
}
|
|
21
18
|
return offset;
|
|
22
19
|
}
|
|
23
20
|
Offset.get = get;
|
|
24
|
-
})(Offset
|
|
21
|
+
})(Offset || (Offset = {}));
|
|
25
22
|
//# sourceMappingURL=Offset.js.map
|
package/lib/source/Position.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Position = void 0;
|
|
4
|
-
var Position;
|
|
1
|
+
export var Position;
|
|
5
2
|
(function (Position) {
|
|
6
3
|
function create(param1, param2) {
|
|
7
4
|
if (typeof param1 === 'object') {
|
|
@@ -39,5 +36,5 @@ var Position;
|
|
|
39
36
|
(pos1.line === pos2.line && pos1.character < pos2.character));
|
|
40
37
|
}
|
|
41
38
|
Position.isBefore = isBefore;
|
|
42
|
-
})(Position
|
|
39
|
+
})(Position || (Position = {}));
|
|
43
40
|
//# sourceMappingURL=Position.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { TextDocument } from 'vscode-languageserver-textdocument';
|
|
2
|
-
import { Position } from './Position';
|
|
3
|
-
import type { RangeLike } from './Range';
|
|
2
|
+
import { Position } from './Position.js';
|
|
3
|
+
import type { RangeLike } from './Range.js';
|
|
4
4
|
export interface PositionRange {
|
|
5
5
|
start: Position;
|
|
6
6
|
end: Position;
|
|
@@ -1,28 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const Position_1 = require("./Position");
|
|
5
|
-
const Range_1 = require("./Range");
|
|
6
|
-
var PositionRange;
|
|
1
|
+
import { Position } from './Position.js';
|
|
2
|
+
import { Range } from './Range.js';
|
|
3
|
+
export var PositionRange;
|
|
7
4
|
(function (PositionRange) {
|
|
8
5
|
function create(param1, param2, param3, param4) {
|
|
9
6
|
if (typeof param1 === 'number') {
|
|
10
7
|
return {
|
|
11
|
-
start:
|
|
12
|
-
end:
|
|
8
|
+
start: Position.create(param1, param2),
|
|
9
|
+
end: Position.create(param3, param4),
|
|
13
10
|
};
|
|
14
11
|
}
|
|
15
12
|
else if (param2 !== undefined) {
|
|
16
13
|
return {
|
|
17
|
-
start:
|
|
18
|
-
end:
|
|
14
|
+
start: Position.create(param1),
|
|
15
|
+
end: Position.create(param2),
|
|
19
16
|
};
|
|
20
17
|
}
|
|
21
18
|
else {
|
|
22
19
|
const partial = param1;
|
|
23
20
|
return {
|
|
24
|
-
start:
|
|
25
|
-
end:
|
|
21
|
+
start: Position.create(partial.start ?? {}),
|
|
22
|
+
end: Position.create(partial.end ?? {}),
|
|
26
23
|
};
|
|
27
24
|
}
|
|
28
25
|
}
|
|
@@ -31,7 +28,7 @@ var PositionRange;
|
|
|
31
28
|
* @returns A `PositionRange` converted from a `RangeLike`.
|
|
32
29
|
*/
|
|
33
30
|
function from(range, doc) {
|
|
34
|
-
const _range =
|
|
31
|
+
const _range = Range.get(range);
|
|
35
32
|
const ans = {
|
|
36
33
|
start: doc.positionAt(_range.start),
|
|
37
34
|
end: doc.positionAt(_range.end),
|
|
@@ -56,9 +53,9 @@ var PositionRange;
|
|
|
56
53
|
* }
|
|
57
54
|
* ```
|
|
58
55
|
*/
|
|
59
|
-
PositionRange.Full = Object.freeze(PositionRange.create(
|
|
56
|
+
PositionRange.Full = Object.freeze(PositionRange.create(Position.Beginning, Position.Infinity));
|
|
60
57
|
function toString(range) {
|
|
61
|
-
return `[${
|
|
58
|
+
return `[${Position.toString(range.start)}, ${Position.toString(range.end)})`;
|
|
62
59
|
}
|
|
63
60
|
PositionRange.toString = toString;
|
|
64
61
|
function contains(range, pos) {
|
|
@@ -76,8 +73,8 @@ var PositionRange;
|
|
|
76
73
|
}
|
|
77
74
|
PositionRange.contains = contains;
|
|
78
75
|
function endsBefore(range, pos) {
|
|
79
|
-
return
|
|
76
|
+
return Position.isBefore(Position.create(range.end.line, range.end.character - 1), pos);
|
|
80
77
|
}
|
|
81
78
|
PositionRange.endsBefore = endsBefore;
|
|
82
|
-
})(PositionRange
|
|
79
|
+
})(PositionRange || (PositionRange = {}));
|
|
83
80
|
//# sourceMappingURL=PositionRange.js.map
|
package/lib/source/Range.d.ts
CHANGED
package/lib/source/Range.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.RangeContainer = exports.Range = void 0;
|
|
4
|
-
const Offset_1 = require("./Offset");
|
|
5
|
-
var Range;
|
|
1
|
+
import { Offset } from './Offset.js';
|
|
2
|
+
export var Range;
|
|
6
3
|
(function (Range) {
|
|
7
4
|
/**
|
|
8
5
|
* Gets a range from `RangeLike`.
|
|
@@ -27,10 +24,10 @@ var Range;
|
|
|
27
24
|
* Creates a range from `OffsetLike`. If only `start` is passed in, `end` will be the same value as `start`.
|
|
28
25
|
*/
|
|
29
26
|
function create(start, end) {
|
|
30
|
-
start =
|
|
27
|
+
start = Offset.get(start);
|
|
31
28
|
return {
|
|
32
29
|
start,
|
|
33
|
-
end: end !== undefined ?
|
|
30
|
+
end: end !== undefined ? Offset.get(end) : start,
|
|
34
31
|
};
|
|
35
32
|
}
|
|
36
33
|
Range.create = create;
|
|
@@ -143,13 +140,13 @@ var Range;
|
|
|
143
140
|
};
|
|
144
141
|
}
|
|
145
142
|
Range.translate = translate;
|
|
146
|
-
})(Range
|
|
147
|
-
var RangeContainer;
|
|
143
|
+
})(Range || (Range = {}));
|
|
144
|
+
export var RangeContainer;
|
|
148
145
|
(function (RangeContainer) {
|
|
149
146
|
function is(obj) {
|
|
150
147
|
return (!!obj && typeof obj === 'object' &&
|
|
151
148
|
Range.is(obj.range));
|
|
152
149
|
}
|
|
153
150
|
RangeContainer.is = is;
|
|
154
|
-
})(RangeContainer
|
|
151
|
+
})(RangeContainer || (RangeContainer = {}));
|
|
155
152
|
//# sourceMappingURL=Range.js.map
|