@volar/language-service 1.4.0 → 1.5.0-alpha.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/out/baseLanguageService.d.ts +8 -5
- package/out/baseLanguageService.js +72 -61
- package/out/documentFeatures/colorPresentations.d.ts +2 -2
- package/out/documentFeatures/documentColors.d.ts +2 -2
- package/out/documentFeatures/documentSymbols.d.ts +2 -2
- package/out/documentFeatures/foldingRanges.d.ts +2 -2
- package/out/documentFeatures/format.d.ts +2 -2
- package/out/documentFeatures/format.js +6 -6
- package/out/documentFeatures/linkedEditingRanges.d.ts +2 -2
- package/out/documentFeatures/selectionRanges.d.ts +2 -2
- package/out/documents.d.ts +3 -3
- package/out/documents.js +10 -10
- package/out/languageFeatures/autoInsert.d.ts +2 -2
- package/out/languageFeatures/callHierarchy.d.ts +2 -2
- package/out/languageFeatures/callHierarchy.js +1 -1
- package/out/languageFeatures/codeActionResolve.d.ts +2 -2
- package/out/languageFeatures/codeActions.d.ts +2 -2
- package/out/languageFeatures/codeLens.d.ts +2 -2
- package/out/languageFeatures/codeLensResolve.d.ts +2 -2
- package/out/languageFeatures/codeLensResolve.js +1 -1
- package/out/languageFeatures/complete.d.ts +2 -2
- package/out/languageFeatures/completeResolve.d.ts +2 -2
- package/out/languageFeatures/definition.d.ts +2 -2
- package/out/languageFeatures/documentHighlights.d.ts +2 -2
- package/out/languageFeatures/documentLinkResolve.d.ts +2 -2
- package/out/languageFeatures/documentLinks.d.ts +2 -2
- package/out/languageFeatures/documentSemanticTokens.d.ts +2 -2
- package/out/languageFeatures/fileReferences.d.ts +2 -2
- package/out/languageFeatures/fileRename.d.ts +2 -2
- package/out/languageFeatures/hover.d.ts +2 -2
- package/out/languageFeatures/inlayHintResolve.d.ts +2 -2
- package/out/languageFeatures/inlayHints.d.ts +2 -2
- package/out/languageFeatures/inlayHints.js +1 -1
- package/out/languageFeatures/references.d.ts +2 -2
- package/out/languageFeatures/rename.d.ts +2 -2
- package/out/languageFeatures/renamePrepare.d.ts +2 -2
- package/out/languageFeatures/signatureHelp.d.ts +2 -2
- package/out/languageFeatures/validation.d.ts +2 -2
- package/out/languageFeatures/validation.js +2 -2
- package/out/languageFeatures/workspaceSymbols.d.ts +2 -2
- package/out/types.d.ts +76 -111
- package/out/utils/featureWorkers.d.ts +4 -4
- package/out/utils/featureWorkers.js +2 -18
- package/package.json +4 -4
- package/out/languageFeatures/codeLensResolve copy.d.ts +0 -3
- package/out/languageFeatures/codeLensResolve copy.js +0 -31
- package/out/languageFeatures/documentLinkResolve copy.d.ts +0 -3
- package/out/languageFeatures/documentLinkResolve copy.js +0 -19
- package/out/languageFeatures/documentLinks copy.d.ts +0 -8
- package/out/languageFeatures/documentLinks copy.js +0 -62
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ServiceContext } from '../types';
|
|
3
3
|
export interface InlayHintData {
|
|
4
4
|
uri: string;
|
|
5
5
|
original: Pick<vscode.CodeAction, 'data' | 'edit'>;
|
|
6
6
|
pluginId: string;
|
|
7
7
|
}
|
|
8
|
-
export declare function register(context:
|
|
8
|
+
export declare function register(context: ServiceContext): (uri: string, range: vscode.Range, token?: vscode.CancellationToken) => Promise<vscode.InlayHint[] | undefined>;
|
|
@@ -54,7 +54,7 @@ function register(context) {
|
|
|
54
54
|
}, (inlayHints, map) => inlayHints.map((_inlayHint) => {
|
|
55
55
|
if (!map)
|
|
56
56
|
return _inlayHint;
|
|
57
|
-
const position = map.toSourcePosition(_inlayHint.position);
|
|
57
|
+
const position = map.toSourcePosition(_inlayHint.position, data => !!data.semanticTokens /* todo */);
|
|
58
58
|
const edits = _inlayHint.textEdits
|
|
59
59
|
?.map(textEdit => transformer.asTextEdit(textEdit, range => map.toSourceRange(range), map.virtualFileDocument))
|
|
60
60
|
.filter(common_1.notEmpty);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import type {
|
|
3
|
-
export declare function register(context:
|
|
2
|
+
import type { ServiceContext } from '../types';
|
|
3
|
+
export declare function register(context: ServiceContext): (uri: string, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.Location[] | undefined>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ServiceContext } from '../types';
|
|
3
3
|
import { DocumentsAndSourceMaps } from '../documents';
|
|
4
|
-
export declare function register(context:
|
|
4
|
+
export declare function register(context: ServiceContext): (uri: string, position: vscode.Position, newName: string, token?: vscode.CancellationToken) => Promise<vscode.WorkspaceEdit | undefined>;
|
|
5
5
|
export declare function mergeWorkspaceEdits(original: vscode.WorkspaceEdit, ...others: vscode.WorkspaceEdit[]): void;
|
|
6
6
|
export declare function embeddedEditToSourceEdit(tsResult: vscode.WorkspaceEdit, documents: DocumentsAndSourceMaps, mode: 'fileName' | 'rename' | 'codeAction' | 'format', versions?: Record<string, number>): vscode.WorkspaceEdit | undefined;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import type {
|
|
3
|
-
export declare function register(context:
|
|
2
|
+
import type { ServiceContext } from '../types';
|
|
3
|
+
export declare function register(context: ServiceContext): (uri: string, position: vscode.Position, token?: vscode.CancellationToken) => Promise<NonNullable<vscode.Range | vscode.ResponseError<void> | null | undefined> | undefined>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import type {
|
|
3
|
-
export declare function register(context:
|
|
2
|
+
import type { ServiceContext } from '../types';
|
|
3
|
+
export declare function register(context: ServiceContext): (uri: string, position: vscode.Position, signatureHelpContext?: vscode.SignatureHelpContext, token?: vscode.CancellationToken) => Promise<vscode.SignatureHelp | undefined>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ServiceContext } from '../types';
|
|
3
3
|
export declare function updateRange(range: vscode.Range, change: {
|
|
4
4
|
range: vscode.Range;
|
|
5
5
|
newEnd: vscode.Position;
|
|
@@ -18,4 +18,4 @@ export declare const errorMarkups: Record<string, {
|
|
|
18
18
|
error: vscode.Diagnostic;
|
|
19
19
|
markup: vscode.MarkupContent;
|
|
20
20
|
}[]>;
|
|
21
|
-
export declare function register(context:
|
|
21
|
+
export declare function register(context: ServiceContext): (uri: string, mode: 'all' | 'semantic' | 'syntactic', token?: vscode.CancellationToken, response?: ((result: vscode.Diagnostic[]) => void) | undefined) => Promise<vscode.Diagnostic[]>;
|
|
@@ -99,7 +99,7 @@ function register(context) {
|
|
|
99
99
|
syntax_rules: { errors: [] },
|
|
100
100
|
format_rules: { errors: [] },
|
|
101
101
|
}).get(uri);
|
|
102
|
-
const newSnapshot = context.host.getScriptSnapshot(context.uriToFileName(uri));
|
|
102
|
+
const newSnapshot = context.host.getScriptSnapshot(context.env.uriToFileName(uri));
|
|
103
103
|
let updateCacheRangeFailed = false;
|
|
104
104
|
let errorsUpdated = false;
|
|
105
105
|
let lastCheckCancelAt = 0;
|
|
@@ -130,7 +130,7 @@ function register(context) {
|
|
|
130
130
|
await doResponse();
|
|
131
131
|
await lintWorker('onSyntax', cacheMaps.syntax_rules, lastResponse.syntax_rules);
|
|
132
132
|
await doResponse();
|
|
133
|
-
await worker('
|
|
133
|
+
await worker('provideDiagnostics', cacheMaps.syntactic, lastResponse.syntactic);
|
|
134
134
|
await doResponse();
|
|
135
135
|
}
|
|
136
136
|
if (mode === 'all' || mode === 'semantic') {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import type {
|
|
3
|
-
export declare function register(context:
|
|
2
|
+
import type { ServiceContext } from '../types';
|
|
3
|
+
export declare function register(context: ServiceContext): (query: string, token?: vscode.CancellationToken) => Promise<vscode.WorkspaceSymbol[]>;
|
package/out/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LanguageContext,
|
|
1
|
+
import { LanguageContext, Language, LanguageServiceHost } from '@volar/language-core';
|
|
2
2
|
import type * as ts from 'typescript/lib/tsserverlibrary';
|
|
3
3
|
import type { DocumentContext, FileSystemProvider } from 'vscode-html-languageservice';
|
|
4
4
|
import type { SchemaRequestService } from 'vscode-json-languageservice';
|
|
@@ -7,45 +7,43 @@ import type { TextDocument } from 'vscode-languageserver-textdocument';
|
|
|
7
7
|
import { URI } from 'vscode-uri';
|
|
8
8
|
import { DocumentsAndSourceMaps } from './documents';
|
|
9
9
|
export * from 'vscode-languageserver-protocol';
|
|
10
|
-
export interface
|
|
11
|
-
modules: {
|
|
12
|
-
typescript?: typeof import('typescript/lib/tsserverlibrary');
|
|
13
|
-
};
|
|
10
|
+
export interface ServiceEnvironment {
|
|
14
11
|
locale?: string;
|
|
15
12
|
rootUri: URI;
|
|
16
|
-
|
|
17
|
-
host: LanguageServiceHost;
|
|
18
|
-
config: Config;
|
|
13
|
+
clientCapabilities?: vscode.ClientCapabilities;
|
|
19
14
|
uriToFileName(uri: string): string;
|
|
20
15
|
fileNameToUri(fileName: string): string;
|
|
21
|
-
|
|
16
|
+
getConfiguration?<T>(section: string, scopeUri?: string): Promise<T | undefined>;
|
|
17
|
+
onDidChangeConfiguration?(cb: () => void): void;
|
|
18
|
+
onDidChangeWatchedFiles?(cb: (params: vscode.DidChangeWatchedFilesParams) => void): () => void;
|
|
22
19
|
documentContext?: DocumentContext;
|
|
23
20
|
fileSystemProvider?: FileSystemProvider;
|
|
24
|
-
fileSystemHost?: FileSystemHost;
|
|
25
21
|
schemaRequestService?: SchemaRequestService;
|
|
26
22
|
}
|
|
27
|
-
interface
|
|
28
|
-
|
|
23
|
+
interface Command<T> {
|
|
24
|
+
create: T;
|
|
25
|
+
is(value: vscode.Command): boolean;
|
|
29
26
|
}
|
|
30
|
-
export interface
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
export interface LanguageServicePluginContext extends LanguageServiceOptions {
|
|
27
|
+
export interface ServiceContext {
|
|
28
|
+
env: ServiceEnvironment;
|
|
29
|
+
config: Config;
|
|
30
|
+
host: LanguageServiceHost;
|
|
36
31
|
typescript: {
|
|
37
|
-
module: typeof import('typescript/lib/tsserverlibrary');
|
|
38
32
|
languageServiceHost: ts.LanguageServiceHost;
|
|
39
33
|
languageService: ts.LanguageService;
|
|
40
34
|
} | undefined;
|
|
41
|
-
commands:
|
|
35
|
+
commands: {
|
|
36
|
+
showReferences: Command<(uri: string, position: vscode.Position, locations: vscode.Location[]) => vscode.Command | undefined>;
|
|
37
|
+
rename: Command<(uri: string, position: vscode.Position) => vscode.Command | undefined>;
|
|
38
|
+
setSelection: Command<(position: vscode.Position) => vscode.Command | undefined>;
|
|
39
|
+
};
|
|
42
40
|
/** @private */
|
|
43
41
|
core: LanguageContext;
|
|
44
42
|
/** @private */
|
|
45
43
|
documents: DocumentsAndSourceMaps;
|
|
46
44
|
/** @private */
|
|
47
45
|
plugins: {
|
|
48
|
-
[id: string]:
|
|
46
|
+
[id: string]: ReturnType<Service>;
|
|
49
47
|
};
|
|
50
48
|
/** @private */
|
|
51
49
|
getTextDocument(uri: string): TextDocument | undefined;
|
|
@@ -58,18 +56,62 @@ export interface LanguageServicePluginContext extends LanguageServiceOptions {
|
|
|
58
56
|
};
|
|
59
57
|
};
|
|
60
58
|
}
|
|
61
|
-
export interface ConfigurationHost {
|
|
62
|
-
getConfiguration: (<T>(section: string, scopeUri?: string) => Promise<T | undefined>);
|
|
63
|
-
onDidChangeConfiguration: (cb: () => void) => void;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* LanguageServicePlugin
|
|
67
|
-
*/
|
|
68
59
|
export type Result<T> = T | Thenable<T>;
|
|
69
60
|
export type NullableResult<T> = Result<T | undefined | null>;
|
|
70
61
|
export type SemanticToken = [number, number, number, number, number];
|
|
71
|
-
export interface
|
|
72
|
-
(context
|
|
62
|
+
export interface Service {
|
|
63
|
+
(context: ServiceContext | undefined, modules: {
|
|
64
|
+
typescript?: typeof import('typescript/lib/tsserverlibrary');
|
|
65
|
+
} | undefined): {
|
|
66
|
+
isAdditionalCompletion?: boolean;
|
|
67
|
+
triggerCharacters?: string[];
|
|
68
|
+
signatureHelpTriggerCharacters?: string[];
|
|
69
|
+
signatureHelpRetriggerCharacters?: string[];
|
|
70
|
+
autoFormatTriggerCharacters?: string[];
|
|
71
|
+
provideHover?(document: TextDocument, position: vscode.Position, token: vscode.CancellationToken): NullableResult<vscode.Hover>;
|
|
72
|
+
provideDocumentSymbols?(document: TextDocument, token: vscode.CancellationToken): NullableResult<vscode.DocumentSymbol[]>;
|
|
73
|
+
provideDocumentHighlights?(document: TextDocument, position: vscode.Position, token: vscode.CancellationToken): NullableResult<vscode.DocumentHighlight[]>;
|
|
74
|
+
provideLinkedEditingRanges?(document: TextDocument, position: vscode.Position, token: vscode.CancellationToken): NullableResult<vscode.LinkedEditingRanges>;
|
|
75
|
+
provideDefinition?(document: TextDocument, position: vscode.Position, token: vscode.CancellationToken): NullableResult<vscode.LocationLink[]>;
|
|
76
|
+
provideTypeDefinition?(document: TextDocument, position: vscode.Position, token: vscode.CancellationToken): NullableResult<vscode.LocationLink[]>;
|
|
77
|
+
provideImplementation?(document: TextDocument, position: vscode.Position, token: vscode.CancellationToken): NullableResult<vscode.LocationLink[]>;
|
|
78
|
+
provideCodeLenses?(document: TextDocument, token: vscode.CancellationToken): NullableResult<vscode.CodeLens[]>;
|
|
79
|
+
provideCodeActions?(document: TextDocument, range: vscode.Range, context: vscode.CodeActionContext, token: vscode.CancellationToken): NullableResult<vscode.CodeAction[]>;
|
|
80
|
+
provideDocumentFormattingEdits?(document: TextDocument, range: vscode.Range, options: vscode.FormattingOptions, token: vscode.CancellationToken): NullableResult<vscode.TextEdit[]>;
|
|
81
|
+
provideOnTypeFormattingEdits?(document: TextDocument, position: vscode.Position, key: string, options: vscode.FormattingOptions, token: vscode.CancellationToken): NullableResult<vscode.TextEdit[]>;
|
|
82
|
+
provideDocumentLinks?(document: TextDocument, token: vscode.CancellationToken): NullableResult<vscode.DocumentLink[]>;
|
|
83
|
+
provideCompletionItems?(document: TextDocument, position: vscode.Position, context: vscode.CompletionContext, token: vscode.CancellationToken): NullableResult<vscode.CompletionList>;
|
|
84
|
+
provideDocumentColors?(document: TextDocument, token: vscode.CancellationToken): NullableResult<vscode.ColorInformation[]>;
|
|
85
|
+
provideColorPresentations?(document: TextDocument, color: vscode.Color, range: vscode.Range, token: vscode.CancellationToken): NullableResult<vscode.ColorPresentation[]>;
|
|
86
|
+
provideFoldingRanges?(document: TextDocument, token: vscode.CancellationToken): NullableResult<vscode.FoldingRange[]>;
|
|
87
|
+
provideSignatureHelp?(document: TextDocument, position: vscode.Position, context: vscode.SignatureHelpContext, token: vscode.CancellationToken): NullableResult<vscode.SignatureHelp>;
|
|
88
|
+
provideRenameRange?(document: TextDocument, position: vscode.Position, token: vscode.CancellationToken): NullableResult<vscode.Range | vscode.ResponseError<void>>;
|
|
89
|
+
provideRenameEdits?(document: TextDocument, position: vscode.Position, newName: string, token: vscode.CancellationToken): NullableResult<vscode.WorkspaceEdit>;
|
|
90
|
+
provideReferences?(document: TextDocument, position: vscode.Position, token: vscode.CancellationToken): NullableResult<vscode.Location[]>;
|
|
91
|
+
provideSelectionRanges?(document: TextDocument, positions: vscode.Position[], token: vscode.CancellationToken): NullableResult<vscode.SelectionRange[]>;
|
|
92
|
+
provideInlayHints?(document: TextDocument, range: vscode.Range, token: vscode.CancellationToken): NullableResult<vscode.InlayHint[]>;
|
|
93
|
+
provideCallHierarchyItems?(document: TextDocument, position: vscode.Position, token: vscode.CancellationToken): NullableResult<vscode.CallHierarchyItem[]>;
|
|
94
|
+
provideCallHierarchyIncomingCalls?(item: vscode.CallHierarchyItem, token: vscode.CancellationToken): Result<vscode.CallHierarchyIncomingCall[]>;
|
|
95
|
+
provideCallHierarchyOutgoingCalls?(item: vscode.CallHierarchyItem, token: vscode.CancellationToken): Result<vscode.CallHierarchyOutgoingCall[]>;
|
|
96
|
+
provideDocumentSemanticTokens?(document: TextDocument, range: vscode.Range, legend: vscode.SemanticTokensLegend, token: vscode.CancellationToken): NullableResult<SemanticToken[]>;
|
|
97
|
+
provideWorkspaceSymbols?(query: string, token: vscode.CancellationToken): NullableResult<vscode.WorkspaceSymbol[]>;
|
|
98
|
+
provideDiagnostics?(document: TextDocument, token: vscode.CancellationToken): NullableResult<vscode.Diagnostic[]>;
|
|
99
|
+
provideSemanticDiagnostics?(document: TextDocument, token: vscode.CancellationToken): NullableResult<vscode.Diagnostic[]>;
|
|
100
|
+
provideDiagnosticMarkupContent?(diagnostic: vscode.Diagnostic, token: vscode.CancellationToken): NullableResult<vscode.MarkupContent>;
|
|
101
|
+
provideFileReferences?(document: TextDocument, token: vscode.CancellationToken): NullableResult<vscode.Location[]>;
|
|
102
|
+
provideReferencesCodeLensRanges?(document: TextDocument, token: vscode.CancellationToken): NullableResult<vscode.Range[]>;
|
|
103
|
+
provideAutoInsertionEdit?(document: TextDocument, position: vscode.Position, context: AutoInsertionContext, token: vscode.CancellationToken): NullableResult<string | vscode.TextEdit>;
|
|
104
|
+
provideFileRenameEdits?(oldUri: string, newUri: string, token: vscode.CancellationToken): NullableResult<vscode.WorkspaceEdit>;
|
|
105
|
+
provideFormattingIndentSensitiveLines?(document: TextDocument, token: vscode.CancellationToken): NullableResult<number[]>;
|
|
106
|
+
resolveCodeLens?(codeLens: vscode.CodeLens, token: vscode.CancellationToken): Result<vscode.CodeLens>;
|
|
107
|
+
resolveCodeAction?(codeAction: vscode.CodeAction, token: vscode.CancellationToken): Result<vscode.CodeAction>;
|
|
108
|
+
resolveCompletionItem?(item: vscode.CompletionItem, token: vscode.CancellationToken): Result<vscode.CompletionItem>;
|
|
109
|
+
resolveDocumentLink?(link: vscode.DocumentLink, token: vscode.CancellationToken): Result<vscode.DocumentLink>;
|
|
110
|
+
resolveInlayHint?(inlayHint: vscode.InlayHint, token: vscode.CancellationToken): Result<vscode.InlayHint>;
|
|
111
|
+
resolveReferencesCodeLensLocations?(document: TextDocument, range: vscode.Range, references: vscode.Location[], token: vscode.CancellationToken): Result<vscode.Location[]>;
|
|
112
|
+
resolveRuleContext?(context: RuleContext, ruleType: 'format' | 'syntax' | 'semantic'): Result<RuleContext>;
|
|
113
|
+
resolveEmbeddedRange?(range: vscode.Range): vscode.Range | undefined;
|
|
114
|
+
};
|
|
73
115
|
}
|
|
74
116
|
export interface AutoInsertionContext {
|
|
75
117
|
lastChange: {
|
|
@@ -79,90 +121,13 @@ export interface AutoInsertionContext {
|
|
|
79
121
|
text: string;
|
|
80
122
|
};
|
|
81
123
|
}
|
|
82
|
-
export interface LanguageServicePluginInstance {
|
|
83
|
-
isAdditionalCompletion?: boolean;
|
|
84
|
-
triggerCharacters?: string[];
|
|
85
|
-
signatureHelpTriggerCharacters?: string[];
|
|
86
|
-
signatureHelpRetriggerCharacters?: string[];
|
|
87
|
-
autoFormatTriggerCharacters?: string[];
|
|
88
|
-
provideHover?(document: TextDocument, position: vscode.Position, token: vscode.CancellationToken): NullableResult<vscode.Hover>;
|
|
89
|
-
provideDocumentSymbols?(document: TextDocument, token: vscode.CancellationToken): NullableResult<vscode.DocumentSymbol[]>;
|
|
90
|
-
provideDocumentHighlights?(document: TextDocument, position: vscode.Position, token: vscode.CancellationToken): NullableResult<vscode.DocumentHighlight[]>;
|
|
91
|
-
provideLinkedEditingRanges?(document: TextDocument, position: vscode.Position, token: vscode.CancellationToken): NullableResult<vscode.LinkedEditingRanges>;
|
|
92
|
-
provideDefinition?(document: TextDocument, position: vscode.Position, token: vscode.CancellationToken): NullableResult<vscode.LocationLink[]>;
|
|
93
|
-
provideTypeDefinition?(document: TextDocument, position: vscode.Position, token: vscode.CancellationToken): NullableResult<vscode.LocationLink[]>;
|
|
94
|
-
provideImplementation?(document: TextDocument, position: vscode.Position, token: vscode.CancellationToken): NullableResult<vscode.LocationLink[]>;
|
|
95
|
-
provideCodeLenses?(document: TextDocument, token: vscode.CancellationToken): NullableResult<vscode.CodeLens[]>;
|
|
96
|
-
provideCodeActions?(document: TextDocument, range: vscode.Range, context: vscode.CodeActionContext, token: vscode.CancellationToken): NullableResult<vscode.CodeAction[]>;
|
|
97
|
-
provideDocumentFormattingEdits?(document: TextDocument, range: vscode.Range, options: vscode.FormattingOptions, token: vscode.CancellationToken): NullableResult<vscode.TextEdit[]>;
|
|
98
|
-
provideOnTypeFormattingEdits?(document: TextDocument, position: vscode.Position, key: string, options: vscode.FormattingOptions, token: vscode.CancellationToken): NullableResult<vscode.TextEdit[]>;
|
|
99
|
-
provideDocumentLinks?(document: TextDocument, token: vscode.CancellationToken): NullableResult<vscode.DocumentLink[]>;
|
|
100
|
-
provideCompletionItems?(document: TextDocument, position: vscode.Position, context: vscode.CompletionContext, token: vscode.CancellationToken): NullableResult<vscode.CompletionList>;
|
|
101
|
-
provideDocumentColors?(document: TextDocument, token: vscode.CancellationToken): NullableResult<vscode.ColorInformation[]>;
|
|
102
|
-
provideColorPresentations?(document: TextDocument, color: vscode.Color, range: vscode.Range, token: vscode.CancellationToken): NullableResult<vscode.ColorPresentation[]>;
|
|
103
|
-
provideFoldingRanges?(document: TextDocument, token: vscode.CancellationToken): NullableResult<vscode.FoldingRange[]>;
|
|
104
|
-
provideSignatureHelp?(document: TextDocument, position: vscode.Position, context: vscode.SignatureHelpContext, token: vscode.CancellationToken): NullableResult<vscode.SignatureHelp>;
|
|
105
|
-
provideRenameRange?(document: TextDocument, position: vscode.Position, token: vscode.CancellationToken): NullableResult<vscode.Range | vscode.ResponseError<void>>;
|
|
106
|
-
provideRenameEdits?(document: TextDocument, position: vscode.Position, newName: string, token: vscode.CancellationToken): NullableResult<vscode.WorkspaceEdit>;
|
|
107
|
-
provideReferences?(document: TextDocument, position: vscode.Position, token: vscode.CancellationToken): NullableResult<vscode.Location[]>;
|
|
108
|
-
provideSelectionRanges?(document: TextDocument, positions: vscode.Position[], token: vscode.CancellationToken): NullableResult<vscode.SelectionRange[]>;
|
|
109
|
-
provideInlayHints?(document: TextDocument, range: vscode.Range, token: vscode.CancellationToken): NullableResult<vscode.InlayHint[]>;
|
|
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[]>;
|
|
113
|
-
provideDocumentSemanticTokens?(document: TextDocument, range: vscode.Range, legend: vscode.SemanticTokensLegend, token: vscode.CancellationToken): NullableResult<SemanticToken[]>;
|
|
114
|
-
provideWorkspaceSymbols?(query: string, token: vscode.CancellationToken): NullableResult<vscode.WorkspaceSymbol[]>;
|
|
115
|
-
provideSyntacticDiagnostics?(document: TextDocument, token: vscode.CancellationToken): NullableResult<vscode.Diagnostic[]>;
|
|
116
|
-
provideSemanticDiagnostics?(document: TextDocument, token: vscode.CancellationToken): NullableResult<vscode.Diagnostic[]>;
|
|
117
|
-
provideDiagnosticMarkupContent?(diagnostic: vscode.Diagnostic, token: vscode.CancellationToken): NullableResult<vscode.MarkupContent>;
|
|
118
|
-
provideFileReferences?(document: TextDocument, token: vscode.CancellationToken): NullableResult<vscode.Location[]>;
|
|
119
|
-
provideReferencesCodeLensRanges?(document: TextDocument, token: vscode.CancellationToken): NullableResult<vscode.Range[]>;
|
|
120
|
-
provideAutoInsertionEdit?(document: TextDocument, position: vscode.Position, context: AutoInsertionContext, token: vscode.CancellationToken): NullableResult<string | vscode.TextEdit>;
|
|
121
|
-
provideFileRenameEdits?(oldUri: string, newUri: string, token: vscode.CancellationToken): NullableResult<vscode.WorkspaceEdit>;
|
|
122
|
-
provideFormattingIndentSensitiveLines?(document: TextDocument, token: vscode.CancellationToken): NullableResult<number[]>;
|
|
123
|
-
resolveCodeLens?(codeLens: vscode.CodeLens, token: vscode.CancellationToken): Result<vscode.CodeLens>;
|
|
124
|
-
resolveCodeAction?(codeAction: vscode.CodeAction, token: vscode.CancellationToken): Result<vscode.CodeAction>;
|
|
125
|
-
resolveCompletionItem?(item: vscode.CompletionItem, token: vscode.CancellationToken): Result<vscode.CompletionItem>;
|
|
126
|
-
resolveDocumentLink?(link: vscode.DocumentLink, token: vscode.CancellationToken): Result<vscode.DocumentLink>;
|
|
127
|
-
resolveInlayHint?(inlayHint: vscode.InlayHint, token: vscode.CancellationToken): Result<vscode.InlayHint>;
|
|
128
|
-
resolveReferencesCodeLensLocations?(document: TextDocument, range: vscode.Range, references: vscode.Location[], token: vscode.CancellationToken): Result<vscode.Location[]>;
|
|
129
|
-
resolveRuleContext?(context: RuleContext, ruleType: 'format' | 'syntax' | 'semantic'): Result<RuleContext>;
|
|
130
|
-
resolveEmbeddedRange?(range: vscode.Range): vscode.Range | undefined;
|
|
131
|
-
}
|
|
132
124
|
export interface Rule {
|
|
133
125
|
onFormat?(ctx: RuleContext): void;
|
|
134
126
|
onSyntax?(ctx: RuleContext): void;
|
|
135
127
|
onSemantic?(ctx: RuleContext): void;
|
|
136
128
|
}
|
|
137
129
|
export interface RuleContext {
|
|
138
|
-
|
|
139
|
-
* Shared modules.
|
|
140
|
-
*/
|
|
141
|
-
modules: {
|
|
142
|
-
typescript?: typeof import('typescript/lib/tsserverlibrary');
|
|
143
|
-
};
|
|
144
|
-
/**
|
|
145
|
-
* IDE or user define locale.
|
|
146
|
-
* You can use it to localize your rule.
|
|
147
|
-
*/
|
|
148
|
-
locale?: string;
|
|
149
|
-
/**
|
|
150
|
-
* Project root path.
|
|
151
|
-
*/
|
|
152
|
-
rootUri: URI;
|
|
153
|
-
uriToFileName(uri: string): string;
|
|
154
|
-
fileNameToUri(fileName: string): string;
|
|
155
|
-
/**
|
|
156
|
-
* Get configuration from IDE.
|
|
157
|
-
*
|
|
158
|
-
* For VSCode, it's .vscode/settings.json
|
|
159
|
-
*/
|
|
160
|
-
getConfiguration?: <T>(section: string) => Promise<T | undefined>;
|
|
161
|
-
onDidChangeConfiguration?: (cb: () => void) => void;
|
|
162
|
-
/**
|
|
163
|
-
* Global settings from config.
|
|
164
|
-
*/
|
|
165
|
-
settings: any;
|
|
130
|
+
env: ServiceEnvironment;
|
|
166
131
|
ruleId: string;
|
|
167
132
|
document: TextDocument;
|
|
168
133
|
report(error: vscode.Diagnostic, ...fixes: RuleFix[]): void;
|
|
@@ -189,10 +154,10 @@ export interface RuleFix {
|
|
|
189
154
|
}
|
|
190
155
|
export interface Config {
|
|
191
156
|
languages?: {
|
|
192
|
-
[id: string]:
|
|
157
|
+
[id: string]: Language | undefined;
|
|
193
158
|
};
|
|
194
|
-
|
|
195
|
-
[id: string]:
|
|
159
|
+
services?: {
|
|
160
|
+
[id: string]: Service | undefined;
|
|
196
161
|
};
|
|
197
162
|
lint?: {
|
|
198
163
|
rules?: {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { TextDocument } from 'vscode-languageserver-textdocument';
|
|
2
|
-
import type {
|
|
2
|
+
import type { Service, ServiceContext, Rule, RuleContext } from '../types';
|
|
3
3
|
import { FileRangeCapabilities, VirtualFile } from '@volar/language-service';
|
|
4
4
|
import { SourceMapWithDocuments } from '../documents';
|
|
5
|
-
export declare function documentFeatureWorker<T>(context:
|
|
6
|
-
export declare function languageFeatureWorker<T, K>(context:
|
|
7
|
-
export declare function ruleWorker<T>(context:
|
|
5
|
+
export declare function documentFeatureWorker<T>(context: ServiceContext, uri: string, isValidSourceMap: (file: VirtualFile, sourceMap: SourceMapWithDocuments<FileRangeCapabilities>) => boolean, worker: (service: ReturnType<Service>, document: TextDocument) => T, transform: (result: NonNullable<Awaited<T>>, sourceMap: SourceMapWithDocuments<FileRangeCapabilities> | undefined) => Awaited<T> | undefined, combineResult?: (results: NonNullable<Awaited<T>>[]) => NonNullable<Awaited<T>>): Promise<NonNullable<Awaited<T>> | undefined>;
|
|
6
|
+
export declare function languageFeatureWorker<T, K>(context: ServiceContext, uri: string, arg: K, transformArg: (arg: K, sourceMap: SourceMapWithDocuments<FileRangeCapabilities>, file: VirtualFile) => Generator<K> | K[], worker: (service: ReturnType<Service>, document: TextDocument, arg: K, sourceMap: SourceMapWithDocuments<FileRangeCapabilities> | undefined, file: VirtualFile | undefined) => T, transform: (result: NonNullable<Awaited<T>>, sourceMap: SourceMapWithDocuments<FileRangeCapabilities> | undefined) => Awaited<T> | undefined, combineResult?: (results: NonNullable<Awaited<T>>[]) => NonNullable<Awaited<T>>, reportProgress?: (result: NonNullable<Awaited<T>>) => void): Promise<NonNullable<Awaited<T>> | undefined>;
|
|
7
|
+
export declare function ruleWorker<T>(context: ServiceContext, api: 'onSyntax' | 'onSemantic' | 'onFormat', uri: string, isValidSourceMap: (file: VirtualFile) => boolean, worker: (ruleName: string, rule: Rule, ruleCtx: RuleContext) => T, transform: (result: NonNullable<Awaited<T>>, sourceMap: SourceMapWithDocuments<FileRangeCapabilities> | undefined) => Awaited<T> | undefined, combineResult?: (results: NonNullable<Awaited<T>>[]) => NonNullable<Awaited<T>>, reportProgress?: (result: NonNullable<Awaited<T>>) => void): Promise<NonNullable<Awaited<T>> | undefined>;
|
|
8
8
|
export declare function safeCall<T>(cb: () => Promise<T> | T, errorMsg?: string): Promise<T | undefined>;
|
|
@@ -72,15 +72,7 @@ async function ruleWorker(context, api, uri, isValidSourceMap, worker, transform
|
|
|
72
72
|
return true;
|
|
73
73
|
}
|
|
74
74
|
let ruleCtx = {
|
|
75
|
-
|
|
76
|
-
modules: { typescript: context.typescript?.module },
|
|
77
|
-
uriToFileName: context.uriToFileName,
|
|
78
|
-
fileNameToUri: context.fileNameToUri,
|
|
79
|
-
rootUri: context.rootUri,
|
|
80
|
-
locale: context.locale,
|
|
81
|
-
getConfiguration: context.configurationHost?.getConfiguration,
|
|
82
|
-
onDidChangeConfiguration: context.configurationHost?.onDidChangeConfiguration,
|
|
83
|
-
settings: context.config.lint?.settings ?? {},
|
|
75
|
+
env: context.env,
|
|
84
76
|
// document context
|
|
85
77
|
ruleId: '',
|
|
86
78
|
document: map.virtualFileDocument,
|
|
@@ -121,15 +113,7 @@ async function ruleWorker(context, api, uri, isValidSourceMap, worker, transform
|
|
|
121
113
|
}
|
|
122
114
|
else if (document) {
|
|
123
115
|
let ruleCtx = {
|
|
124
|
-
|
|
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 ?? {},
|
|
116
|
+
env: context.env,
|
|
133
117
|
// document context
|
|
134
118
|
ruleId: '',
|
|
135
119
|
document,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/language-service",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0-alpha.0",
|
|
4
4
|
"main": "out/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"directory": "packages/language-service"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@volar/language-core": "1.
|
|
17
|
-
"@volar/source-map": "1.
|
|
16
|
+
"@volar/language-core": "1.5.0-alpha.0",
|
|
17
|
+
"@volar/source-map": "1.5.0-alpha.0",
|
|
18
18
|
"typescript-auto-import-cache": "^0.2.1",
|
|
19
19
|
"vscode-html-languageservice": "^5.0.4",
|
|
20
20
|
"vscode-json-languageservice": "^5.2.0",
|
|
@@ -22,5 +22,5 @@
|
|
|
22
22
|
"vscode-languageserver-textdocument": "^1.0.8",
|
|
23
23
|
"vscode-uri": "^3.0.7"
|
|
24
24
|
},
|
|
25
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "a4e1b3766ccb5affe1613cad7630513b9073d275"
|
|
26
26
|
}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import type { LanguageServicePluginContext } from '../types';
|
|
3
|
-
export declare function register(context: LanguageServicePluginContext): (item: vscode.CodeLens, token?: vscode.CancellationToken) => Promise<vscode.CodeLens>;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.register = void 0;
|
|
4
|
-
const vscode = require("vscode-languageserver-protocol");
|
|
5
|
-
const references = require("./references");
|
|
6
|
-
function register(context) {
|
|
7
|
-
const findReferences = references.register(context);
|
|
8
|
-
return async (item, token = vscode.CancellationToken.None) => {
|
|
9
|
-
const data = item.data;
|
|
10
|
-
if (data?.kind === 'normal') {
|
|
11
|
-
const plugin = context.plugins[data.pluginId];
|
|
12
|
-
if (!plugin.resolveCodeLens)
|
|
13
|
-
return item;
|
|
14
|
-
Object.assign(item, data.original);
|
|
15
|
-
item = await plugin.resolveCodeLens(item, token);
|
|
16
|
-
// item.range already transformed in codeLens request
|
|
17
|
-
}
|
|
18
|
-
if (data?.kind === 'references') {
|
|
19
|
-
let references = await findReferences(data.uri, item.range.start, token) ?? [];
|
|
20
|
-
const plugin = context.plugins[data.pluginId];
|
|
21
|
-
const document = context.getTextDocument(data.uri);
|
|
22
|
-
if (document && plugin.resolveReferencesCodeLensLocations) {
|
|
23
|
-
references = await plugin.resolveReferencesCodeLensLocations(document, data.range, references, token);
|
|
24
|
-
}
|
|
25
|
-
item.command = context.commands.createShowReferencesCommand(data.uri, data.range.start, references);
|
|
26
|
-
}
|
|
27
|
-
return item;
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
exports.register = register;
|
|
31
|
-
//# sourceMappingURL=codeLensResolve%20copy.js.map
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import type { LanguageServicePluginContext } from '../types';
|
|
3
|
-
export declare function register(context: LanguageServicePluginContext): (item: vscode.CodeLens, token?: vscode.CancellationToken) => Promise<vscode.CodeLens>;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.register = void 0;
|
|
4
|
-
const vscode = require("vscode-languageserver-protocol");
|
|
5
|
-
function register(context) {
|
|
6
|
-
return async (item, token = vscode.CancellationToken.None) => {
|
|
7
|
-
const data = item.data;
|
|
8
|
-
if (data) {
|
|
9
|
-
const plugin = context.plugins[data.pluginId];
|
|
10
|
-
if (!plugin.resolveDocumentLink)
|
|
11
|
-
return item;
|
|
12
|
-
Object.assign(item, data.original);
|
|
13
|
-
item = await plugin.resolveDocumentLink(item, token);
|
|
14
|
-
}
|
|
15
|
-
return item;
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
exports.register = register;
|
|
19
|
-
//# sourceMappingURL=documentLinkResolve%20copy.js.map
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import type { LanguageServicePluginContext } from '../types';
|
|
3
|
-
export interface DocumentLinkData {
|
|
4
|
-
uri: string;
|
|
5
|
-
original: Pick<vscode.DocumentLink, 'data'>;
|
|
6
|
-
pluginId: string;
|
|
7
|
-
}
|
|
8
|
-
export declare function register(context: LanguageServicePluginContext): (uri: string, token?: vscode.CancellationToken) => Promise<vscode.DocumentLink[]>;
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.register = void 0;
|
|
4
|
-
const vscode = require("vscode-languageserver-protocol");
|
|
5
|
-
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
6
|
-
const common_1 = require("../utils/common");
|
|
7
|
-
function register(context) {
|
|
8
|
-
return async (uri, token = vscode.CancellationToken.None) => {
|
|
9
|
-
const pluginLinks = await (0, featureWorkers_1.documentFeatureWorker)(context, uri, file => !!file.capabilities.documentSymbol, async (plugin, document) => {
|
|
10
|
-
if (token.isCancellationRequested)
|
|
11
|
-
return;
|
|
12
|
-
const links = await plugin.provideDocumentLinks?.(document, token);
|
|
13
|
-
links?.forEach(link => {
|
|
14
|
-
link.data = {
|
|
15
|
-
uri,
|
|
16
|
-
original: {
|
|
17
|
-
data: link.data,
|
|
18
|
-
},
|
|
19
|
-
pluginId: Object.keys(context.plugins).find(key => context.plugins[key] === plugin),
|
|
20
|
-
};
|
|
21
|
-
});
|
|
22
|
-
return links;
|
|
23
|
-
}, (links, map) => links.map(link => {
|
|
24
|
-
if (!map)
|
|
25
|
-
return link;
|
|
26
|
-
const range = map.toSourceRange(link.range);
|
|
27
|
-
if (range) {
|
|
28
|
-
return {
|
|
29
|
-
...link,
|
|
30
|
-
range,
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
}).filter(common_1.notEmpty), arr => arr.flat()) ?? [];
|
|
34
|
-
const maps = context.documents.getMapsBySourceFileUri(uri);
|
|
35
|
-
const fictitiousLinks = maps ? getFictitiousLinks(context.documents.getDocumentByUri(maps.snapshot, uri), maps.maps) : [];
|
|
36
|
-
return [
|
|
37
|
-
...pluginLinks,
|
|
38
|
-
...fictitiousLinks,
|
|
39
|
-
];
|
|
40
|
-
function getFictitiousLinks(document, maps) {
|
|
41
|
-
const result = [];
|
|
42
|
-
for (const [_, map] of maps) {
|
|
43
|
-
for (const mapped of map.map.mappings) {
|
|
44
|
-
if (!mapped.data.displayWithLink)
|
|
45
|
-
continue;
|
|
46
|
-
if (mapped.sourceRange[0] === mapped.sourceRange[1])
|
|
47
|
-
continue;
|
|
48
|
-
result.push({
|
|
49
|
-
range: {
|
|
50
|
-
start: document.positionAt(mapped.sourceRange[0]),
|
|
51
|
-
end: document.positionAt(mapped.sourceRange[1]),
|
|
52
|
-
},
|
|
53
|
-
target: uri, // TODO
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
return result;
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
exports.register = register;
|
|
62
|
-
//# sourceMappingURL=documentLinks%20copy.js.map
|