@volar/language-service 1.4.0-alpha.0 → 1.4.0-alpha.10
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 +88 -37
- package/out/baseLanguageService.js +114 -21
- package/out/documentFeatures/colorPresentations.d.ts +1 -1
- package/out/documentFeatures/colorPresentations.js +4 -3
- package/out/documentFeatures/documentColors.d.ts +1 -1
- package/out/documentFeatures/documentColors.js +3 -3
- package/out/documentFeatures/documentSymbols.d.ts +1 -1
- package/out/documentFeatures/documentSymbols.js +7 -16
- package/out/documentFeatures/foldingRanges.d.ts +2 -2
- package/out/documentFeatures/foldingRanges.js +4 -3
- package/out/documentFeatures/format.d.ts +1 -1
- package/out/documentFeatures/format.js +38 -46
- package/out/documentFeatures/linkedEditingRanges.d.ts +1 -1
- package/out/documentFeatures/linkedEditingRanges.js +4 -3
- package/out/documentFeatures/selectionRanges.d.ts +1 -1
- package/out/documentFeatures/selectionRanges.js +31 -14
- package/out/documents.d.ts +1 -1
- package/out/documents.js +32 -18
- package/out/index.d.ts +0 -1
- package/out/index.js +2 -3
- package/out/languageFeatures/autoInsert.d.ts +1 -1
- package/out/languageFeatures/autoInsert.js +10 -7
- package/out/languageFeatures/callHierarchy.d.ts +3 -5
- package/out/languageFeatures/callHierarchy.js +68 -77
- package/out/languageFeatures/codeActionResolve.d.ts +2 -2
- package/out/languageFeatures/codeActionResolve.js +11 -19
- package/out/languageFeatures/codeActions.d.ts +1 -1
- package/out/languageFeatures/codeActions.js +31 -38
- package/out/languageFeatures/codeLens.d.ts +2 -2
- package/out/languageFeatures/codeLens.js +18 -25
- package/out/languageFeatures/codeLensResolve copy.d.ts +3 -0
- package/out/languageFeatures/codeLensResolve copy.js +31 -0
- package/out/languageFeatures/codeLensResolve.d.ts +1 -3
- package/out/languageFeatures/codeLensResolve.js +12 -25
- package/out/languageFeatures/complete.d.ts +2 -4
- package/out/languageFeatures/complete.js +27 -47
- package/out/languageFeatures/completeResolve.d.ts +1 -1
- package/out/languageFeatures/completeResolve.js +9 -17
- package/out/languageFeatures/definition.d.ts +1 -1
- package/out/languageFeatures/definition.js +39 -46
- package/out/languageFeatures/documentHighlights.d.ts +1 -1
- package/out/languageFeatures/documentHighlights.js +33 -40
- package/out/languageFeatures/documentLinkResolve copy.d.ts +3 -0
- package/out/languageFeatures/documentLinkResolve copy.js +19 -0
- package/out/languageFeatures/documentLinkResolve.d.ts +3 -0
- package/out/languageFeatures/documentLinkResolve.js +19 -0
- package/out/languageFeatures/documentLinks copy.d.ts +8 -0
- package/out/languageFeatures/documentLinks copy.js +62 -0
- package/out/languageFeatures/documentLinks.d.ts +6 -1
- package/out/languageFeatures/documentLinks.js +22 -18
- package/out/languageFeatures/documentSemanticTokens.d.ts +1 -1
- package/out/languageFeatures/documentSemanticTokens.js +8 -17
- package/out/languageFeatures/fileReferences.d.ts +1 -1
- package/out/languageFeatures/fileReferences.js +7 -15
- package/out/languageFeatures/fileRename.d.ts +1 -2
- package/out/languageFeatures/fileRename.js +8 -16
- package/out/languageFeatures/hover.d.ts +1 -1
- package/out/languageFeatures/hover.js +7 -10
- package/out/languageFeatures/inlayHintResolve.d.ts +3 -0
- package/out/languageFeatures/inlayHintResolve.js +19 -0
- package/out/languageFeatures/inlayHints.d.ts +6 -1
- package/out/languageFeatures/inlayHints.js +25 -20
- package/out/languageFeatures/references.d.ts +1 -1
- package/out/languageFeatures/references.js +30 -40
- package/out/languageFeatures/rename.d.ts +1 -1
- package/out/languageFeatures/rename.js +61 -74
- package/out/languageFeatures/renamePrepare.d.ts +1 -1
- package/out/languageFeatures/renamePrepare.js +3 -3
- package/out/languageFeatures/signatureHelp.d.ts +1 -1
- package/out/languageFeatures/signatureHelp.js +9 -10
- package/out/languageFeatures/validation.d.ts +1 -1
- package/out/languageFeatures/validation.js +141 -168
- package/out/languageFeatures/workspaceSymbols.d.ts +1 -1
- package/out/languageFeatures/workspaceSymbols.js +5 -13
- package/out/transformer/completionItem.js +9 -3
- package/out/transformer/completionList.js +7 -3
- package/out/transformer/documentSymbol.js +9 -3
- package/out/transformer/foldingRanges.js +3 -3
- package/out/transformer/hover.js +6 -2
- package/out/transformer/index.js +1 -0
- package/out/transformer/locationLike.js +5 -1
- package/out/transformer/locationsLike.js +1 -0
- package/out/transformer/selectionRange.js +1 -0
- package/out/transformer/selectionRanges.js +1 -0
- package/out/transformer/textEdit.js +21 -5
- package/out/transformer/workspaceSymbol.js +5 -1
- package/out/types.d.ts +24 -8
- package/out/types.js +1 -0
- package/out/utils/SemanticTokensBuilder.js +1 -0
- package/out/utils/common.d.ts +2 -1
- package/out/utils/common.js +7 -5
- package/out/utils/dedupe.js +1 -0
- package/out/utils/definePlugin.js +12 -23
- package/out/utils/featureWorkers.js +127 -146
- package/package.json +5 -5
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
3
|
exports.transform = void 0;
|
|
3
4
|
const vscode = require("vscode-languageserver-protocol");
|
|
@@ -9,7 +10,10 @@ function transform(symbol, getOtherLocation) {
|
|
|
9
10
|
if (!loc) {
|
|
10
11
|
return;
|
|
11
12
|
}
|
|
12
|
-
return
|
|
13
|
+
return {
|
|
14
|
+
...symbol,
|
|
15
|
+
location: loc,
|
|
16
|
+
};
|
|
13
17
|
}
|
|
14
18
|
exports.transform = transform;
|
|
15
19
|
//# sourceMappingURL=workspaceSymbol.js.map
|
package/out/types.d.ts
CHANGED
|
@@ -8,23 +8,37 @@ import { URI } from 'vscode-uri';
|
|
|
8
8
|
import { DocumentsAndSourceMaps } from './documents';
|
|
9
9
|
export * from 'vscode-languageserver-protocol';
|
|
10
10
|
export interface LanguageServiceOptions {
|
|
11
|
+
modules: {
|
|
12
|
+
typescript?: typeof import('typescript/lib/tsserverlibrary');
|
|
13
|
+
};
|
|
14
|
+
locale?: string;
|
|
15
|
+
rootUri: URI;
|
|
16
|
+
capabilities?: vscode.ClientCapabilities;
|
|
11
17
|
host: LanguageServiceHost;
|
|
12
18
|
config: Config;
|
|
13
19
|
uriToFileName(uri: string): string;
|
|
14
20
|
fileNameToUri(fileName: string): string;
|
|
15
|
-
rootUri: URI;
|
|
16
|
-
locale?: string;
|
|
17
21
|
configurationHost?: ConfigurationHost;
|
|
18
22
|
documentContext?: DocumentContext;
|
|
19
23
|
fileSystemProvider?: FileSystemProvider;
|
|
24
|
+
fileSystemHost?: FileSystemHost;
|
|
20
25
|
schemaRequestService?: SchemaRequestService;
|
|
21
26
|
}
|
|
27
|
+
interface FileSystemHost {
|
|
28
|
+
onDidChangeWatchedFiles(cb: (params: vscode.DidChangeWatchedFilesParams) => void): () => void;
|
|
29
|
+
}
|
|
30
|
+
export interface Commands {
|
|
31
|
+
createShowReferencesCommand(uri: string, position: vscode.Position, locations: vscode.Location[]): vscode.Command | undefined;
|
|
32
|
+
createRenameCommand(uri: string, position: vscode.Position): vscode.Command | undefined;
|
|
33
|
+
createSetSelectionCommand(position: vscode.Position): vscode.Command | undefined;
|
|
34
|
+
}
|
|
22
35
|
export interface LanguageServicePluginContext extends LanguageServiceOptions {
|
|
23
36
|
typescript: {
|
|
24
37
|
module: typeof import('typescript/lib/tsserverlibrary');
|
|
25
38
|
languageServiceHost: ts.LanguageServiceHost;
|
|
26
39
|
languageService: ts.LanguageService;
|
|
27
40
|
} | undefined;
|
|
41
|
+
commands: Commands;
|
|
28
42
|
/** @private */
|
|
29
43
|
core: LanguageContext;
|
|
30
44
|
/** @private */
|
|
@@ -82,7 +96,7 @@ export interface LanguageServicePluginInstance {
|
|
|
82
96
|
provideCodeActions?(document: TextDocument, range: vscode.Range, context: vscode.CodeActionContext, token: vscode.CancellationToken): NullableResult<vscode.CodeAction[]>;
|
|
83
97
|
provideDocumentFormattingEdits?(document: TextDocument, range: vscode.Range, options: vscode.FormattingOptions, token: vscode.CancellationToken): NullableResult<vscode.TextEdit[]>;
|
|
84
98
|
provideOnTypeFormattingEdits?(document: TextDocument, position: vscode.Position, key: string, options: vscode.FormattingOptions, token: vscode.CancellationToken): NullableResult<vscode.TextEdit[]>;
|
|
85
|
-
|
|
99
|
+
provideDocumentLinks?(document: TextDocument, token: vscode.CancellationToken): NullableResult<vscode.DocumentLink[]>;
|
|
86
100
|
provideCompletionItems?(document: TextDocument, position: vscode.Position, context: vscode.CompletionContext, token: vscode.CancellationToken): NullableResult<vscode.CompletionList>;
|
|
87
101
|
provideDocumentColors?(document: TextDocument, token: vscode.CancellationToken): NullableResult<vscode.ColorInformation[]>;
|
|
88
102
|
provideColorPresentations?(document: TextDocument, color: vscode.Color, range: vscode.Range, token: vscode.CancellationToken): NullableResult<vscode.ColorPresentation[]>;
|
|
@@ -93,22 +107,24 @@ export interface LanguageServicePluginInstance {
|
|
|
93
107
|
provideReferences?(document: TextDocument, position: vscode.Position, token: vscode.CancellationToken): NullableResult<vscode.Location[]>;
|
|
94
108
|
provideSelectionRanges?(document: TextDocument, positions: vscode.Position[], token: vscode.CancellationToken): NullableResult<vscode.SelectionRange[]>;
|
|
95
109
|
provideInlayHints?(document: TextDocument, range: vscode.Range, token: vscode.CancellationToken): NullableResult<vscode.InlayHint[]>;
|
|
96
|
-
provideCallHierarchyItems(document: TextDocument, position: vscode.Position, token: vscode.CancellationToken): NullableResult<vscode.CallHierarchyItem[]>;
|
|
97
|
-
provideCallHierarchyIncomingCalls(item: vscode.CallHierarchyItem, token: vscode.CancellationToken): Result<vscode.CallHierarchyIncomingCall[]>;
|
|
98
|
-
provideCallHierarchyOutgoingCalls(item: vscode.CallHierarchyItem, token: vscode.CancellationToken): Result<vscode.CallHierarchyOutgoingCall[]>;
|
|
110
|
+
provideCallHierarchyItems?(document: TextDocument, position: vscode.Position, token: vscode.CancellationToken): NullableResult<vscode.CallHierarchyItem[]>;
|
|
111
|
+
provideCallHierarchyIncomingCalls?(item: vscode.CallHierarchyItem, token: vscode.CancellationToken): Result<vscode.CallHierarchyIncomingCall[]>;
|
|
112
|
+
provideCallHierarchyOutgoingCalls?(item: vscode.CallHierarchyItem, token: vscode.CancellationToken): Result<vscode.CallHierarchyOutgoingCall[]>;
|
|
99
113
|
provideDocumentSemanticTokens?(document: TextDocument, range: vscode.Range, legend: vscode.SemanticTokensLegend, token: vscode.CancellationToken): NullableResult<SemanticToken[]>;
|
|
100
114
|
provideWorkspaceSymbols?(query: string, token: vscode.CancellationToken): NullableResult<vscode.WorkspaceSymbol[]>;
|
|
101
115
|
provideSyntacticDiagnostics?(document: TextDocument, token: vscode.CancellationToken): NullableResult<vscode.Diagnostic[]>;
|
|
102
116
|
provideSemanticDiagnostics?(document: TextDocument, token: vscode.CancellationToken): NullableResult<vscode.Diagnostic[]>;
|
|
103
117
|
provideFileReferences?(document: TextDocument, token: vscode.CancellationToken): NullableResult<vscode.Location[]>;
|
|
104
|
-
|
|
118
|
+
provideReferencesCodeLensRanges?(document: TextDocument, token: vscode.CancellationToken): NullableResult<vscode.Range[]>;
|
|
105
119
|
provideAutoInsertionEdit?(document: TextDocument, position: vscode.Position, context: AutoInsertionContext, token: vscode.CancellationToken): NullableResult<string | vscode.TextEdit>;
|
|
106
120
|
provideFileRenameEdits?(oldUri: string, newUri: string, token: vscode.CancellationToken): NullableResult<vscode.WorkspaceEdit>;
|
|
107
121
|
provideFormattingIndentSensitiveLines?(document: TextDocument, token: vscode.CancellationToken): NullableResult<number[]>;
|
|
108
122
|
resolveCodeLens?(codeLens: vscode.CodeLens, token: vscode.CancellationToken): Result<vscode.CodeLens>;
|
|
109
123
|
resolveCodeAction?(codeAction: vscode.CodeAction, token: vscode.CancellationToken): Result<vscode.CodeAction>;
|
|
110
124
|
resolveCompletionItem?(item: vscode.CompletionItem, token: vscode.CancellationToken): Result<vscode.CompletionItem>;
|
|
111
|
-
|
|
125
|
+
resolveDocumentLink?(link: vscode.DocumentLink, token: vscode.CancellationToken): Result<vscode.DocumentLink>;
|
|
126
|
+
resolveInlayHint?(inlayHint: vscode.InlayHint, token: vscode.CancellationToken): Result<vscode.InlayHint>;
|
|
127
|
+
resolveReferencesCodeLensLocations?(document: TextDocument, range: vscode.Range, references: vscode.Location[], token: vscode.CancellationToken): Result<vscode.Location[]>;
|
|
112
128
|
resolveRuleContext?(context: RuleContext, ruleType: 'format' | 'syntax' | 'semantic'): Result<RuleContext>;
|
|
113
129
|
resolveEmbeddedRange?(range: vscode.Range): vscode.Range | undefined;
|
|
114
130
|
}
|
package/out/types.js
CHANGED
package/out/utils/common.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type * as ts from 'typescript/lib/tsserverlibrary';
|
|
1
2
|
import type * as vscode from 'vscode-languageserver-protocol';
|
|
2
3
|
export declare function getOverlapRange(range1Start: number, range1End: number, range2Start: number, range2End: number): {
|
|
3
4
|
start: number;
|
|
@@ -5,6 +6,6 @@ export declare function getOverlapRange(range1Start: number, range1End: number,
|
|
|
5
6
|
} | undefined;
|
|
6
7
|
export declare function isInsideRange(parent: vscode.Range, child: vscode.Range): boolean;
|
|
7
8
|
export declare function stringToSnapshot(str: string): ts.IScriptSnapshot;
|
|
8
|
-
export declare function
|
|
9
|
+
export declare function resolveCommonLanguageId(uri: string): string;
|
|
9
10
|
export declare function sleep(ms: number): Promise<unknown>;
|
|
10
11
|
export declare function notEmpty<T>(value: T | null | undefined): value is T;
|
package/out/utils/common.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
-
exports.notEmpty = exports.sleep = exports.
|
|
3
|
+
exports.notEmpty = exports.sleep = exports.resolveCommonLanguageId = exports.stringToSnapshot = exports.isInsideRange = exports.getOverlapRange = void 0;
|
|
3
4
|
function getOverlapRange(range1Start, range1End, range2Start, range2End) {
|
|
4
5
|
const start = Math.max(range1Start, range2Start);
|
|
5
6
|
const end = Math.min(range1End, range2End);
|
|
@@ -31,8 +32,9 @@ function stringToSnapshot(str) {
|
|
|
31
32
|
};
|
|
32
33
|
}
|
|
33
34
|
exports.stringToSnapshot = stringToSnapshot;
|
|
34
|
-
function
|
|
35
|
-
|
|
35
|
+
function resolveCommonLanguageId(uri) {
|
|
36
|
+
const ext = uri.split('.').pop();
|
|
37
|
+
switch (ext) {
|
|
36
38
|
case 'js': return 'javascript';
|
|
37
39
|
case 'cjs': return 'javascript';
|
|
38
40
|
case 'mjs': return 'javascript';
|
|
@@ -44,9 +46,9 @@ function syntaxToLanguageId(syntax) {
|
|
|
44
46
|
case 'pug': return 'jade';
|
|
45
47
|
case 'md': return 'markdown';
|
|
46
48
|
}
|
|
47
|
-
return
|
|
49
|
+
return ext;
|
|
48
50
|
}
|
|
49
|
-
exports.
|
|
51
|
+
exports.resolveCommonLanguageId = resolveCommonLanguageId;
|
|
50
52
|
function sleep(ms) {
|
|
51
53
|
return new Promise(resolve => setTimeout(resolve, ms));
|
|
52
54
|
}
|
package/out/utils/dedupe.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
3
|
exports.withRanges = exports.withCallHierarchyOutgoingCalls = exports.withCallHierarchyIncomingCalls = exports.withLocationLinks = exports.withLocations = exports.withDiagnostics = exports.withDocumentChanges = exports.withTextEdits = exports.withCodeAction = exports.createLocationSet = void 0;
|
|
3
4
|
function createLocationSet() {
|
|
@@ -1,31 +1,20 @@
|
|
|
1
|
-
|
|
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
|
+
"use strict";
|
|
10
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
3
|
exports.visitEmbedded = void 0;
|
|
12
|
-
function visitEmbedded(documents, current, cb, rootFile = current) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
if (!(yield visitEmbedded(documents, embedded, cb, rootFile))) {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
4
|
+
async function visitEmbedded(documents, current, cb, rootFile = current) {
|
|
5
|
+
for (const embedded of current.embeddedFiles) {
|
|
6
|
+
if (!await visitEmbedded(documents, embedded, cb, rootFile)) {
|
|
7
|
+
return false;
|
|
19
8
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
9
|
+
}
|
|
10
|
+
for (const [_, map] of documents.getMapsByVirtualFileName(current.fileName)) {
|
|
11
|
+
if (documents.getSourceByUri(map.sourceFileDocument.uri)?.root === rootFile) {
|
|
12
|
+
if (!await cb(current, map)) {
|
|
13
|
+
return false;
|
|
25
14
|
}
|
|
26
15
|
}
|
|
27
|
-
|
|
28
|
-
|
|
16
|
+
}
|
|
17
|
+
return true;
|
|
29
18
|
}
|
|
30
19
|
exports.visitEmbedded = visitEmbedded;
|
|
31
20
|
//# sourceMappingURL=definePlugin.js.map
|
|
@@ -1,124 +1,25 @@
|
|
|
1
|
-
|
|
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
|
+
"use strict";
|
|
10
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
3
|
exports.safeCall = exports.ruleWorker = exports.languageFeatureWorker = exports.documentFeatureWorker = void 0;
|
|
12
4
|
const definePlugin_1 = require("./definePlugin");
|
|
13
|
-
function documentFeatureWorker(context, uri, isValidSourceMap, worker, transform, combineResult) {
|
|
14
|
-
return
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return [undefined];
|
|
18
|
-
}
|
|
19
|
-
return [];
|
|
20
|
-
}, worker, transform, combineResult);
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
exports.documentFeatureWorker = documentFeatureWorker;
|
|
24
|
-
function languageFeatureWorker(context, uri, arg, transformArg, worker, transform, combineResult, reportProgress) {
|
|
25
|
-
var _a;
|
|
26
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
-
const document = context.getTextDocument(uri);
|
|
28
|
-
const virtualFile = (_a = context.documents.getSourceByUri(uri)) === null || _a === void 0 ? void 0 : _a.root;
|
|
29
|
-
let results = [];
|
|
30
|
-
if (virtualFile) {
|
|
31
|
-
yield (0, definePlugin_1.visitEmbedded)(context.documents, virtualFile, (file, map) => __awaiter(this, void 0, void 0, function* () {
|
|
32
|
-
for (const mappedArg of transformArg(arg, map, file)) {
|
|
33
|
-
for (const [pluginId, plugin] of Object.entries(context.plugins)) {
|
|
34
|
-
const embeddedResult = yield safeCall(() => worker(plugin, map.virtualFileDocument, mappedArg, map, file), 'plugin ' + pluginId + ' crashed on ' + map.virtualFileDocument.uri);
|
|
35
|
-
if (!embeddedResult)
|
|
36
|
-
continue;
|
|
37
|
-
const result = transform(embeddedResult, map);
|
|
38
|
-
if (!result)
|
|
39
|
-
continue;
|
|
40
|
-
results.push(result);
|
|
41
|
-
if (!combineResult)
|
|
42
|
-
return false;
|
|
43
|
-
const isEmptyArray = Array.isArray(result) && result.length === 0;
|
|
44
|
-
if (reportProgress && !isEmptyArray) {
|
|
45
|
-
reportProgress(combineResult(results));
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return true;
|
|
50
|
-
}));
|
|
51
|
-
}
|
|
52
|
-
else if (document) {
|
|
53
|
-
for (const [pluginId, plugin] of Object.entries(context.plugins)) {
|
|
54
|
-
const embeddedResult = yield safeCall(() => worker(plugin, document, arg, undefined, undefined), 'plugin ' + pluginId + ' crashed on ' + uri);
|
|
55
|
-
if (!embeddedResult)
|
|
56
|
-
continue;
|
|
57
|
-
const result = transform(embeddedResult, undefined);
|
|
58
|
-
if (!result)
|
|
59
|
-
continue;
|
|
60
|
-
results.push(result);
|
|
61
|
-
if (!combineResult)
|
|
62
|
-
break;
|
|
63
|
-
const isEmptyArray = Array.isArray(result) && result.length === 0;
|
|
64
|
-
if (reportProgress && !isEmptyArray) {
|
|
65
|
-
reportProgress(combineResult(results));
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
if (combineResult && results.length > 0) {
|
|
70
|
-
return combineResult(results);
|
|
71
|
-
}
|
|
72
|
-
else if (results.length > 0) {
|
|
73
|
-
return results[0];
|
|
5
|
+
async function documentFeatureWorker(context, uri, isValidSourceMap, worker, transform, combineResult) {
|
|
6
|
+
return languageFeatureWorker(context, uri, undefined, (_, map, file) => {
|
|
7
|
+
if (isValidSourceMap(file, map)) {
|
|
8
|
+
return [undefined];
|
|
74
9
|
}
|
|
75
|
-
|
|
10
|
+
return [];
|
|
11
|
+
}, worker, transform, combineResult);
|
|
76
12
|
}
|
|
77
|
-
exports.
|
|
78
|
-
function
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
if (!isValidSourceMap(file)) {
|
|
88
|
-
return true;
|
|
89
|
-
}
|
|
90
|
-
let ruleCtx = {
|
|
91
|
-
// project context
|
|
92
|
-
modules: { typescript: (_j = context.typescript) === null || _j === void 0 ? void 0 : _j.module },
|
|
93
|
-
uriToFileName: context.uriToFileName,
|
|
94
|
-
fileNameToUri: context.fileNameToUri,
|
|
95
|
-
rootUri: context.rootUri,
|
|
96
|
-
locale: context.locale,
|
|
97
|
-
getConfiguration: (_k = context.configurationHost) === null || _k === void 0 ? void 0 : _k.getConfiguration,
|
|
98
|
-
onDidChangeConfiguration: (_l = context.configurationHost) === null || _l === void 0 ? void 0 : _l.onDidChangeConfiguration,
|
|
99
|
-
settings: (_o = (_m = context.config.lint) === null || _m === void 0 ? void 0 : _m.settings) !== null && _o !== void 0 ? _o : {},
|
|
100
|
-
// document context
|
|
101
|
-
ruleId: '',
|
|
102
|
-
document: map.virtualFileDocument,
|
|
103
|
-
report: () => { },
|
|
104
|
-
};
|
|
105
|
-
for (const plugin of Object.values(context.plugins)) {
|
|
106
|
-
try {
|
|
107
|
-
if (plugin.resolveRuleContext) {
|
|
108
|
-
ruleCtx = yield plugin.resolveRuleContext(ruleCtx, api === 'onFormat' ? 'format' : api === 'onSyntax' ? 'syntax' : 'semantic');
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
catch (err) {
|
|
112
|
-
console.warn('plugin rule context setup crashed on ' + map.virtualFileDocument.uri + ': ' + err);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
for (const ruleName in (_p = context.config.lint) === null || _p === void 0 ? void 0 : _p.rules) {
|
|
116
|
-
const rule = (_q = context.config.lint) === null || _q === void 0 ? void 0 : _q.rules[ruleName];
|
|
117
|
-
if (!rule) {
|
|
118
|
-
continue;
|
|
119
|
-
}
|
|
120
|
-
ruleCtx.ruleId = ruleName;
|
|
121
|
-
const embeddedResult = yield safeCall(() => worker(ruleName, rule, ruleCtx), 'rule ' + ruleName + ' crashed on ' + map.virtualFileDocument.uri);
|
|
13
|
+
exports.documentFeatureWorker = documentFeatureWorker;
|
|
14
|
+
async function languageFeatureWorker(context, uri, arg, transformArg, worker, transform, combineResult, reportProgress) {
|
|
15
|
+
const document = context.getTextDocument(uri);
|
|
16
|
+
const virtualFile = context.documents.getSourceByUri(uri)?.root;
|
|
17
|
+
let results = [];
|
|
18
|
+
if (virtualFile) {
|
|
19
|
+
await (0, definePlugin_1.visitEmbedded)(context.documents, virtualFile, async (file, map) => {
|
|
20
|
+
for (const mappedArg of transformArg(arg, map, file)) {
|
|
21
|
+
for (const [pluginId, plugin] of Object.entries(context.plugins)) {
|
|
22
|
+
const embeddedResult = await safeCall(() => worker(plugin, map.virtualFileDocument, mappedArg, map, file), 'plugin ' + pluginId + ' crashed on ' + map.virtualFileDocument.uri);
|
|
122
23
|
if (!embeddedResult)
|
|
123
24
|
continue;
|
|
124
25
|
const result = transform(embeddedResult, map);
|
|
@@ -132,74 +33,154 @@ function ruleWorker(context, api, uri, isValidSourceMap, worker, transform, comb
|
|
|
132
33
|
reportProgress(combineResult(results));
|
|
133
34
|
}
|
|
134
35
|
}
|
|
135
|
-
|
|
136
|
-
|
|
36
|
+
}
|
|
37
|
+
return true;
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
else if (document) {
|
|
41
|
+
for (const [pluginId, plugin] of Object.entries(context.plugins)) {
|
|
42
|
+
const embeddedResult = await safeCall(() => worker(plugin, document, arg, undefined, undefined), 'plugin ' + pluginId + ' crashed on ' + uri);
|
|
43
|
+
if (!embeddedResult)
|
|
44
|
+
continue;
|
|
45
|
+
const result = transform(embeddedResult, undefined);
|
|
46
|
+
if (!result)
|
|
47
|
+
continue;
|
|
48
|
+
results.push(result);
|
|
49
|
+
if (!combineResult)
|
|
50
|
+
break;
|
|
51
|
+
const isEmptyArray = Array.isArray(result) && result.length === 0;
|
|
52
|
+
if (reportProgress && !isEmptyArray) {
|
|
53
|
+
reportProgress(combineResult(results));
|
|
54
|
+
}
|
|
137
55
|
}
|
|
138
|
-
|
|
56
|
+
}
|
|
57
|
+
if (combineResult && results.length > 0) {
|
|
58
|
+
return combineResult(results);
|
|
59
|
+
}
|
|
60
|
+
else if (results.length > 0) {
|
|
61
|
+
return results[0];
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.languageFeatureWorker = languageFeatureWorker;
|
|
65
|
+
async function ruleWorker(context, api, uri, isValidSourceMap, worker, transform, combineResult, reportProgress) {
|
|
66
|
+
const document = context.getTextDocument(uri);
|
|
67
|
+
const virtualFile = context.documents.getSourceByUri(uri)?.root;
|
|
68
|
+
let results = [];
|
|
69
|
+
if (virtualFile) {
|
|
70
|
+
await (0, definePlugin_1.visitEmbedded)(context.documents, virtualFile, async (file, map) => {
|
|
71
|
+
if (!isValidSourceMap(file)) {
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
139
74
|
let ruleCtx = {
|
|
140
75
|
// project context
|
|
141
|
-
modules: { typescript:
|
|
76
|
+
modules: { typescript: context.typescript?.module },
|
|
142
77
|
uriToFileName: context.uriToFileName,
|
|
143
78
|
fileNameToUri: context.fileNameToUri,
|
|
144
79
|
rootUri: context.rootUri,
|
|
145
80
|
locale: context.locale,
|
|
146
|
-
getConfiguration:
|
|
147
|
-
onDidChangeConfiguration:
|
|
148
|
-
settings:
|
|
81
|
+
getConfiguration: context.configurationHost?.getConfiguration,
|
|
82
|
+
onDidChangeConfiguration: context.configurationHost?.onDidChangeConfiguration,
|
|
83
|
+
settings: context.config.lint?.settings ?? {},
|
|
149
84
|
// document context
|
|
150
85
|
ruleId: '',
|
|
151
|
-
document,
|
|
86
|
+
document: map.virtualFileDocument,
|
|
152
87
|
report: () => { },
|
|
153
88
|
};
|
|
154
89
|
for (const plugin of Object.values(context.plugins)) {
|
|
155
90
|
try {
|
|
156
91
|
if (plugin.resolveRuleContext) {
|
|
157
|
-
ruleCtx =
|
|
92
|
+
ruleCtx = await plugin.resolveRuleContext(ruleCtx, api === 'onFormat' ? 'format' : api === 'onSyntax' ? 'syntax' : 'semantic');
|
|
158
93
|
}
|
|
159
94
|
}
|
|
160
95
|
catch (err) {
|
|
161
|
-
console.warn('plugin rule context setup crashed on ' +
|
|
96
|
+
console.warn('plugin rule context setup crashed on ' + map.virtualFileDocument.uri + ': ' + err);
|
|
162
97
|
}
|
|
163
98
|
}
|
|
164
|
-
for (const ruleName in
|
|
165
|
-
const rule =
|
|
99
|
+
for (const ruleName in context.config.lint?.rules) {
|
|
100
|
+
const rule = context.config.lint?.rules[ruleName];
|
|
166
101
|
if (!rule) {
|
|
167
102
|
continue;
|
|
168
103
|
}
|
|
169
104
|
ruleCtx.ruleId = ruleName;
|
|
170
|
-
const embeddedResult =
|
|
105
|
+
const embeddedResult = await safeCall(() => worker(ruleName, rule, ruleCtx), 'rule ' + ruleName + ' crashed on ' + map.virtualFileDocument.uri);
|
|
171
106
|
if (!embeddedResult)
|
|
172
107
|
continue;
|
|
173
|
-
const result = transform(embeddedResult,
|
|
108
|
+
const result = transform(embeddedResult, map);
|
|
174
109
|
if (!result)
|
|
175
110
|
continue;
|
|
176
111
|
results.push(result);
|
|
177
112
|
if (!combineResult)
|
|
178
|
-
|
|
113
|
+
return false;
|
|
179
114
|
const isEmptyArray = Array.isArray(result) && result.length === 0;
|
|
180
115
|
if (reportProgress && !isEmptyArray) {
|
|
181
116
|
reportProgress(combineResult(results));
|
|
182
117
|
}
|
|
183
118
|
}
|
|
119
|
+
return true;
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
else if (document) {
|
|
123
|
+
let ruleCtx = {
|
|
124
|
+
// project context
|
|
125
|
+
modules: { typescript: context.typescript?.module },
|
|
126
|
+
uriToFileName: context.uriToFileName,
|
|
127
|
+
fileNameToUri: context.fileNameToUri,
|
|
128
|
+
rootUri: context.rootUri,
|
|
129
|
+
locale: context.locale,
|
|
130
|
+
getConfiguration: context.configurationHost?.getConfiguration,
|
|
131
|
+
onDidChangeConfiguration: context.configurationHost?.onDidChangeConfiguration,
|
|
132
|
+
settings: context.config.lint?.settings ?? {},
|
|
133
|
+
// document context
|
|
134
|
+
ruleId: '',
|
|
135
|
+
document,
|
|
136
|
+
report: () => { },
|
|
137
|
+
};
|
|
138
|
+
for (const plugin of Object.values(context.plugins)) {
|
|
139
|
+
try {
|
|
140
|
+
if (plugin.resolveRuleContext) {
|
|
141
|
+
ruleCtx = await plugin.resolveRuleContext(ruleCtx, api === 'onFormat' ? 'format' : api === 'onSyntax' ? 'syntax' : 'semantic');
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
catch (err) {
|
|
145
|
+
console.warn('plugin rule context setup crashed on ' + document.uri + ': ' + err);
|
|
146
|
+
}
|
|
184
147
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
148
|
+
for (const ruleName in context.config.lint?.rules) {
|
|
149
|
+
const rule = context.config.lint?.rules[ruleName];
|
|
150
|
+
if (!rule) {
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
ruleCtx.ruleId = ruleName;
|
|
154
|
+
const embeddedResult = await safeCall(() => worker(ruleName, rule, ruleCtx), 'rule ' + ruleName + ' crashed on ' + document.uri);
|
|
155
|
+
if (!embeddedResult)
|
|
156
|
+
continue;
|
|
157
|
+
const result = transform(embeddedResult, undefined);
|
|
158
|
+
if (!result)
|
|
159
|
+
continue;
|
|
160
|
+
results.push(result);
|
|
161
|
+
if (!combineResult)
|
|
162
|
+
break;
|
|
163
|
+
const isEmptyArray = Array.isArray(result) && result.length === 0;
|
|
164
|
+
if (reportProgress && !isEmptyArray) {
|
|
165
|
+
reportProgress(combineResult(results));
|
|
166
|
+
}
|
|
190
167
|
}
|
|
191
|
-
}
|
|
168
|
+
}
|
|
169
|
+
if (combineResult && results.length > 0) {
|
|
170
|
+
return combineResult(results);
|
|
171
|
+
}
|
|
172
|
+
else if (results.length > 0) {
|
|
173
|
+
return results[0];
|
|
174
|
+
}
|
|
192
175
|
}
|
|
193
176
|
exports.ruleWorker = ruleWorker;
|
|
194
|
-
function safeCall(cb, errorMsg) {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
}
|
|
202
|
-
});
|
|
177
|
+
async function safeCall(cb, errorMsg) {
|
|
178
|
+
try {
|
|
179
|
+
return await cb();
|
|
180
|
+
}
|
|
181
|
+
catch (err) {
|
|
182
|
+
console.warn(errorMsg, err);
|
|
183
|
+
}
|
|
203
184
|
}
|
|
204
185
|
exports.safeCall = safeCall;
|
|
205
186
|
//# sourceMappingURL=featureWorkers.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/language-service",
|
|
3
|
-
"version": "1.4.0-alpha.
|
|
3
|
+
"version": "1.4.0-alpha.10",
|
|
4
4
|
"main": "out/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -13,14 +13,14 @@
|
|
|
13
13
|
"directory": "packages/language-service"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@volar/language-core": "1.4.0-alpha.
|
|
17
|
-
"@volar/source-map": "1.4.0-alpha.
|
|
18
|
-
"typescript-auto-import-cache": "^0.
|
|
16
|
+
"@volar/language-core": "1.4.0-alpha.10",
|
|
17
|
+
"@volar/source-map": "1.4.0-alpha.10",
|
|
18
|
+
"typescript-auto-import-cache": "^0.2.1",
|
|
19
19
|
"vscode-html-languageservice": "^5.0.4",
|
|
20
20
|
"vscode-json-languageservice": "^5.2.0",
|
|
21
21
|
"vscode-languageserver-protocol": "^3.17.3",
|
|
22
22
|
"vscode-languageserver-textdocument": "^1.0.8",
|
|
23
23
|
"vscode-uri": "^3.0.7"
|
|
24
24
|
},
|
|
25
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "715bc5f17a0d1cadd4190712dcaff732989eb330"
|
|
26
26
|
}
|