@volar/language-service 1.2.0-alpha.16 → 1.2.0-alpha.18
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/out/baseLanguageService.d.ts +3 -2
- package/out/baseLanguageService.js +1 -0
- package/out/documentFeatures/documentSymbols.d.ts +1 -1
- package/out/documentFeatures/documentSymbols.js +26 -5
- package/out/languageFeatures/workspaceSymbols.d.ts +1 -1
- package/out/languageFeatures/workspaceSymbols.js +3 -2
- package/out/transformer/documentSymbol.d.ts +2 -0
- package/out/transformer/documentSymbol.js +16 -0
- package/out/transformer/index.d.ts +2 -2
- package/out/transformer/index.js +5 -5
- package/out/transformer/workspaceSymbol.d.ts +2 -0
- package/out/transformer/workspaceSymbol.js +15 -0
- package/out/types.d.ts +3 -3
- package/package.json +6 -6
|
@@ -4,6 +4,7 @@ import type * as ts from 'typescript/lib/tsserverlibrary';
|
|
|
4
4
|
import type * as _ from 'vscode-languageserver-protocol';
|
|
5
5
|
export type LanguageService = ReturnType<typeof createLanguageService>;
|
|
6
6
|
export declare function createLanguageService(host: LanguageServiceHost, config: Config, env: LanguageServicePluginContext['env'], documentRegistry?: ts.DocumentRegistry): {
|
|
7
|
+
triggerCharacters: string[];
|
|
7
8
|
format: (uri: string, options: _.FormattingOptions, range?: _.Range | undefined, onTypeParams?: {
|
|
8
9
|
ch: string;
|
|
9
10
|
position: _.Position;
|
|
@@ -11,7 +12,7 @@ export declare function createLanguageService(host: LanguageServiceHost, config:
|
|
|
11
12
|
getFoldingRanges: (uri: string) => Promise<_.FoldingRange[] | undefined>;
|
|
12
13
|
getSelectionRanges: (uri: string, positions: _.Position[]) => Promise<_.SelectionRange[] | undefined>;
|
|
13
14
|
findLinkedEditingRanges: (uri: string, position: _.Position) => Promise<_.LinkedEditingRanges | undefined>;
|
|
14
|
-
findDocumentSymbols: (uri: string) => Promise<_.
|
|
15
|
+
findDocumentSymbols: (uri: string) => Promise<_.DocumentSymbol[] | undefined>;
|
|
15
16
|
findDocumentColors: (uri: string) => Promise<_.ColorInformation[] | undefined>;
|
|
16
17
|
getColorPresentations: (uri: string, color: _.Color, range: _.Range) => Promise<_.ColorPresentation[] | undefined>;
|
|
17
18
|
doValidation: (uri: string, token?: _.CancellationToken | undefined, response?: ((result: _.Diagnostic[]) => void) | undefined) => Promise<_.Diagnostic[]>;
|
|
@@ -34,7 +35,7 @@ export declare function createLanguageService(host: LanguageServiceHost, config:
|
|
|
34
35
|
doCodeLensResolve: (item: _.CodeLens) => Promise<_.CodeLens>;
|
|
35
36
|
findDocumentHighlights: (uri: string, position: _.Position) => Promise<_.DocumentHighlight[] | undefined>;
|
|
36
37
|
findDocumentLinks: (uri: string) => Promise<_.DocumentLink[]>;
|
|
37
|
-
findWorkspaceSymbols: (query: string) => Promise<_.
|
|
38
|
+
findWorkspaceSymbols: (query: string) => Promise<_.WorkspaceSymbol[]>;
|
|
38
39
|
doAutoInsert: (uri: string, position: _.Position, autoInsertContext: {
|
|
39
40
|
lastChange: {
|
|
40
41
|
range: _.Range;
|
|
@@ -103,6 +103,7 @@ function createLanguageServiceContext(host, languageContext, config, env, docume
|
|
|
103
103
|
}
|
|
104
104
|
function createLanguageServiceBase(context) {
|
|
105
105
|
return {
|
|
106
|
+
triggerCharacters: Object.values(context.plugins).map(plugin => { var _a, _b; return (_b = (_a = plugin.complete) === null || _a === void 0 ? void 0 : _a.triggerCharacters) !== null && _b !== void 0 ? _b : []; }).flat(),
|
|
106
107
|
format: format.register(context),
|
|
107
108
|
getFoldingRanges: foldingRanges.register(context),
|
|
108
109
|
getSelectionRanges: selectionRanges.register(context),
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { LanguageServicePluginContext } from '../types';
|
|
2
2
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
3
|
-
export declare function register(context: LanguageServicePluginContext): (uri: string) => Promise<vscode.
|
|
3
|
+
export declare function register(context: LanguageServicePluginContext): (uri: string) => Promise<vscode.DocumentSymbol[] | undefined>;
|
|
@@ -1,16 +1,37 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
1
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
11
|
exports.register = void 0;
|
|
3
12
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
4
13
|
const transformer = require("../transformer");
|
|
14
|
+
const shared = require("@volar/shared");
|
|
5
15
|
const vscode = require("vscode-languageserver-protocol");
|
|
6
16
|
function register(context) {
|
|
7
17
|
return (uri) => {
|
|
8
|
-
return (0, featureWorkers_1.documentFeatureWorker)(context, uri, file => !!file.capabilities.documentSymbol, (plugin, document) =>
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
18
|
+
return (0, featureWorkers_1.documentFeatureWorker)(context, uri, file => !!file.capabilities.documentSymbol, (plugin, document) => __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
var _a;
|
|
20
|
+
const symbols = yield ((_a = plugin.findDocumentSymbols) === null || _a === void 0 ? void 0 : _a.call(plugin, document));
|
|
21
|
+
if (!(symbols === null || symbols === void 0 ? void 0 : symbols.length)) {
|
|
22
|
+
return symbols;
|
|
12
23
|
}
|
|
13
|
-
|
|
24
|
+
if (vscode.DocumentSymbol.is(symbols[0])) {
|
|
25
|
+
return symbols;
|
|
26
|
+
}
|
|
27
|
+
return symbols.map(symbol => {
|
|
28
|
+
return vscode.DocumentSymbol.create(symbol.name, undefined, symbol.kind, symbol.location.range, symbol.location.range);
|
|
29
|
+
});
|
|
30
|
+
}), (data, map) => map
|
|
31
|
+
? data
|
|
32
|
+
.map(symbol => transformer.asDocumentSymbol(symbol, range => map.toSourceRange(range)))
|
|
33
|
+
.filter(shared.notEmpty)
|
|
34
|
+
: data, arr => arr.flat());
|
|
14
35
|
};
|
|
15
36
|
}
|
|
16
37
|
exports.register = register;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
2
|
import type { LanguageServicePluginContext } from '../types';
|
|
3
|
-
export declare function register(context: LanguageServicePluginContext): (query: string) => Promise<vscode.
|
|
3
|
+
export declare function register(context: LanguageServicePluginContext): (query: string) => Promise<vscode.WorkspaceSymbol[]>;
|
|
@@ -11,6 +11,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
11
11
|
exports.register = void 0;
|
|
12
12
|
const transformer = require("../transformer");
|
|
13
13
|
const vscode = require("vscode-languageserver-protocol");
|
|
14
|
+
const shared = require("@volar/shared");
|
|
14
15
|
function register(context) {
|
|
15
16
|
return (query) => __awaiter(this, void 0, void 0, function* () {
|
|
16
17
|
const symbolsList = [];
|
|
@@ -20,7 +21,7 @@ function register(context) {
|
|
|
20
21
|
const embeddedSymbols = yield plugin.findWorkspaceSymbols(query);
|
|
21
22
|
if (!embeddedSymbols)
|
|
22
23
|
continue;
|
|
23
|
-
const symbols = transformer.
|
|
24
|
+
const symbols = embeddedSymbols.map(symbol => transformer.asWorkspaceSymbol(symbol, loc => {
|
|
24
25
|
if (context.documents.hasVirtualFileByUri(loc.uri)) {
|
|
25
26
|
for (const [_, map] of context.documents.getMapsByVirtualFileUri(loc.uri)) {
|
|
26
27
|
const range = map.toSourceRange(loc.range);
|
|
@@ -32,7 +33,7 @@ function register(context) {
|
|
|
32
33
|
else {
|
|
33
34
|
return loc;
|
|
34
35
|
}
|
|
35
|
-
});
|
|
36
|
+
})).filter(shared.notEmpty);
|
|
36
37
|
symbolsList.push(symbols);
|
|
37
38
|
}
|
|
38
39
|
return symbolsList.flat();
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
+
exports.transform = void 0;
|
|
3
|
+
function transform(symbol, getOtherRange) {
|
|
4
|
+
const range = getOtherRange(symbol.range);
|
|
5
|
+
if (!range) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
const selectionRange = getOtherRange(symbol.selectionRange);
|
|
9
|
+
if (!selectionRange) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
return Object.assign(Object.assign({}, symbol), { range,
|
|
13
|
+
selectionRange });
|
|
14
|
+
}
|
|
15
|
+
exports.transform = transform;
|
|
16
|
+
//# sourceMappingURL=documentSymbol.js.map
|
|
@@ -6,6 +6,6 @@ export { transform as asLocation } from './locationLike';
|
|
|
6
6
|
export { transform as asLocations } from './locationsLike';
|
|
7
7
|
export { transform as asSelectionRange } from './selectionRange';
|
|
8
8
|
export { transform as asSelectionRanges } from './selectionRanges';
|
|
9
|
-
export { transform as asSymbolInformation } from './symbolInformation';
|
|
10
|
-
export { transform as asSymbolInformations } from './symbolInformations';
|
|
11
9
|
export { transform as asTextEdit } from './textEdit';
|
|
10
|
+
export { transform as asDocumentSymbol } from './documentSymbol';
|
|
11
|
+
export { transform as asWorkspaceSymbol } from './workspaceSymbol';
|
package/out/transformer/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
-
exports.
|
|
2
|
+
exports.asWorkspaceSymbol = exports.asDocumentSymbol = exports.asTextEdit = exports.asSelectionRanges = exports.asSelectionRange = exports.asLocations = exports.asLocation = exports.asHover = exports.asFoldingRanges = exports.asCompletionList = exports.asCompletionItem = void 0;
|
|
3
3
|
var completionItem_1 = require("./completionItem");
|
|
4
4
|
Object.defineProperty(exports, "asCompletionItem", { enumerable: true, get: function () { return completionItem_1.transform; } });
|
|
5
5
|
var completionList_1 = require("./completionList");
|
|
@@ -16,10 +16,10 @@ var selectionRange_1 = require("./selectionRange");
|
|
|
16
16
|
Object.defineProperty(exports, "asSelectionRange", { enumerable: true, get: function () { return selectionRange_1.transform; } });
|
|
17
17
|
var selectionRanges_1 = require("./selectionRanges");
|
|
18
18
|
Object.defineProperty(exports, "asSelectionRanges", { enumerable: true, get: function () { return selectionRanges_1.transform; } });
|
|
19
|
-
var symbolInformation_1 = require("./symbolInformation");
|
|
20
|
-
Object.defineProperty(exports, "asSymbolInformation", { enumerable: true, get: function () { return symbolInformation_1.transform; } });
|
|
21
|
-
var symbolInformations_1 = require("./symbolInformations");
|
|
22
|
-
Object.defineProperty(exports, "asSymbolInformations", { enumerable: true, get: function () { return symbolInformations_1.transform; } });
|
|
23
19
|
var textEdit_1 = require("./textEdit");
|
|
24
20
|
Object.defineProperty(exports, "asTextEdit", { enumerable: true, get: function () { return textEdit_1.transform; } });
|
|
21
|
+
var documentSymbol_1 = require("./documentSymbol");
|
|
22
|
+
Object.defineProperty(exports, "asDocumentSymbol", { enumerable: true, get: function () { return documentSymbol_1.transform; } });
|
|
23
|
+
var workspaceSymbol_1 = require("./workspaceSymbol");
|
|
24
|
+
Object.defineProperty(exports, "asWorkspaceSymbol", { enumerable: true, get: function () { return workspaceSymbol_1.transform; } });
|
|
25
25
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
+
exports.transform = void 0;
|
|
3
|
+
const vscode = require("vscode-languageserver-protocol");
|
|
4
|
+
function transform(symbol, getOtherLocation) {
|
|
5
|
+
if (!vscode.Location.is(symbol.location)) {
|
|
6
|
+
return symbol;
|
|
7
|
+
}
|
|
8
|
+
const loc = getOtherLocation(symbol.location);
|
|
9
|
+
if (!loc) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
return Object.assign(Object.assign({}, symbol), { location: loc });
|
|
13
|
+
}
|
|
14
|
+
exports.transform = transform;
|
|
15
|
+
//# sourceMappingURL=workspaceSymbol.js.map
|
package/out/types.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export interface LanguageServicePluginContext {
|
|
|
18
18
|
rootUri: URI;
|
|
19
19
|
locale?: string;
|
|
20
20
|
configurationHost?: ConfigurationHost;
|
|
21
|
-
documentContext
|
|
21
|
+
documentContext?: DocumentContext;
|
|
22
22
|
fileSystemProvider?: FileSystemProvider;
|
|
23
23
|
schemaRequestService?: SchemaRequestService;
|
|
24
24
|
};
|
|
@@ -77,9 +77,9 @@ export interface LanguageServicePluginInstance {
|
|
|
77
77
|
findFileReferences?(document: TextDocument): NullableResult<vscode.Location[]>;
|
|
78
78
|
findDocumentHighlights?(document: TextDocument, position: vscode.Position): NullableResult<vscode.DocumentHighlight[]>;
|
|
79
79
|
findDocumentLinks?(document: TextDocument): NullableResult<vscode.DocumentLink[]>;
|
|
80
|
-
findDocumentSymbols?(document: TextDocument): NullableResult<vscode.SymbolInformation[]>;
|
|
80
|
+
findDocumentSymbols?(document: TextDocument): NullableResult<vscode.DocumentSymbol[] | vscode.SymbolInformation[]>;
|
|
81
81
|
findDocumentSemanticTokens?(document: TextDocument, range: vscode.Range, legend: vscode.SemanticTokensLegend): NullableResult<SemanticToken[]>;
|
|
82
|
-
findWorkspaceSymbols?(query: string): NullableResult<vscode.
|
|
82
|
+
findWorkspaceSymbols?(query: string): NullableResult<vscode.WorkspaceSymbol[]>;
|
|
83
83
|
findDocumentColors?(document: TextDocument): NullableResult<vscode.ColorInformation[]>;
|
|
84
84
|
getColorPresentations?(document: TextDocument, color: vscode.Color, range: vscode.Range): NullableResult<vscode.ColorPresentation[]>;
|
|
85
85
|
doFileRename?(oldUri: string, newUri: string): NullableResult<vscode.WorkspaceEdit>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/language-service",
|
|
3
|
-
"version": "1.2.0-alpha.
|
|
3
|
+
"version": "1.2.0-alpha.18",
|
|
4
4
|
"main": "out/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -13,15 +13,15 @@
|
|
|
13
13
|
"directory": "packages/language-service"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@volar/language-core": "1.2.0-alpha.
|
|
17
|
-
"@volar/shared": "1.2.0-alpha.
|
|
18
|
-
"@volar/source-map": "1.2.0-alpha.
|
|
19
|
-
"@volar/typescript-faster": "1.2.0-alpha.
|
|
16
|
+
"@volar/language-core": "1.2.0-alpha.18",
|
|
17
|
+
"@volar/shared": "1.2.0-alpha.18",
|
|
18
|
+
"@volar/source-map": "1.2.0-alpha.18",
|
|
19
|
+
"@volar/typescript-faster": "1.2.0-alpha.18",
|
|
20
20
|
"vscode-html-languageservice": "^5.0.4",
|
|
21
21
|
"vscode-json-languageservice": "^5.2.0",
|
|
22
22
|
"vscode-languageserver-protocol": "^3.17.3",
|
|
23
23
|
"vscode-languageserver-textdocument": "^1.0.8",
|
|
24
24
|
"vscode-uri": "^3.0.7"
|
|
25
25
|
},
|
|
26
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "7f63794bb8ed5a20f7b8838d46ff8da243cb9dec"
|
|
27
27
|
}
|