volar-service-typescript 0.0.1 → 0.0.2
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/index.d.ts +7 -6
- package/out/index.js +46 -31
- package/out/utils/typeConverters.d.ts +1 -1
- package/package.json +2 -2
package/out/index.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { InjectionKey, Service } from '@volar/language-service';
|
|
2
2
|
import type * as ts from 'typescript/lib/tsserverlibrary';
|
|
3
3
|
import type { TextDocument } from 'vscode-languageserver-textdocument';
|
|
4
|
-
export declare const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
export declare const injectionKeys: {
|
|
5
|
+
typescript: InjectionKey<[], typeof import('typescript/lib/tsserverlibrary')>;
|
|
6
|
+
sourceFile: InjectionKey<[TextDocument], ts.SourceFile>;
|
|
7
|
+
languageService: InjectionKey<[TextDocument], ts.LanguageService>;
|
|
8
|
+
languageServiceHost: InjectionKey<[TextDocument], ts.LanguageServiceHost>;
|
|
9
|
+
textDocument: InjectionKey<[uri: string], TextDocument>;
|
|
10
|
+
};
|
|
10
11
|
declare const _default: () => Service;
|
|
11
12
|
export default _default;
|
package/out/index.js
CHANGED
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
26
|
+
exports.injectionKeys = void 0;
|
|
27
27
|
const language_service_1 = require("@volar/language-service");
|
|
28
28
|
const semver = __importStar(require("semver"));
|
|
29
29
|
const vscode = __importStar(require("vscode-languageserver-protocol"));
|
|
@@ -55,7 +55,13 @@ const signatureHelp = __importStar(require("./services/signatureHelp"));
|
|
|
55
55
|
const typeDefinitions = __importStar(require("./services/typeDefinition"));
|
|
56
56
|
const workspaceSymbols = __importStar(require("./services/workspaceSymbol"));
|
|
57
57
|
const tsconfig = __importStar(require("./services/tsconfig"));
|
|
58
|
-
exports.
|
|
58
|
+
exports.injectionKeys = {
|
|
59
|
+
typescript: 'typescript/typescript',
|
|
60
|
+
sourceFile: 'typescript/sourceFile',
|
|
61
|
+
languageService: 'typescript/languageService',
|
|
62
|
+
languageServiceHost: 'typescript/languageServiceHost',
|
|
63
|
+
textDocument: 'typescript/textDocument',
|
|
64
|
+
};
|
|
59
65
|
exports.default = () => (contextOrNull, modules) => {
|
|
60
66
|
const jsDocTriggerCharacter = '*';
|
|
61
67
|
const directiveCommentTriggerCharacter = '@';
|
|
@@ -116,6 +122,7 @@ exports.default = () => (contextOrNull, modules) => {
|
|
|
116
122
|
const callHierarchy = _callHierarchy.register(semanticCtx);
|
|
117
123
|
const tsconfigRequests = tsconfig.register(semanticCtx);
|
|
118
124
|
let syntacticHostCtx = {
|
|
125
|
+
document: undefined,
|
|
119
126
|
fileName: '',
|
|
120
127
|
fileVersion: 0,
|
|
121
128
|
snapshot: ts.ScriptSnapshot.fromString(''),
|
|
@@ -143,36 +150,35 @@ exports.default = () => (contextOrNull, modules) => {
|
|
|
143
150
|
const doFormatting = formatting.register(syntacticCtx);
|
|
144
151
|
const getFoldingRanges = foldingRanges.register(syntacticCtx);
|
|
145
152
|
return {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
if (sourceFile) {
|
|
154
|
-
return {
|
|
155
|
-
sourceFile,
|
|
156
|
-
languageService: syntacticCtx.typescript.languageService,
|
|
157
|
-
languageServiceHost: syntacticCtx.typescript.languageServiceHost,
|
|
158
|
-
getTextDocument: syntacticCtx.getTextDocument,
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
else {
|
|
163
|
-
const sourceFile = semanticCtx.typescript.languageService.getProgram()?.getSourceFile(context.env.uriToFileName(document.uri));
|
|
164
|
-
if (sourceFile) {
|
|
165
|
-
return {
|
|
166
|
-
sourceFile,
|
|
167
|
-
languageService: semanticCtx.typescript.languageService,
|
|
168
|
-
languageServiceHost: semanticCtx.typescript.languageServiceHost,
|
|
169
|
-
getTextDocument: semanticCtx.getTextDocument,
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
}
|
|
153
|
+
provide: {
|
|
154
|
+
...(0, language_service_1.defineProvide)(exports.injectionKeys.typescript, () => ts),
|
|
155
|
+
...(0, language_service_1.defineProvide)(exports.injectionKeys.sourceFile, document => {
|
|
156
|
+
if ((0, shared_1.isTsDocument)(document)) {
|
|
157
|
+
const sourceFile = getSemanticServiceSourceFile(document.uri);
|
|
158
|
+
if (sourceFile) {
|
|
159
|
+
return sourceFile;
|
|
173
160
|
}
|
|
174
|
-
|
|
175
|
-
|
|
161
|
+
prepareSyntacticService(document);
|
|
162
|
+
return syntacticCtx.typescript.languageService.getProgram()?.getSourceFile(syntacticHostCtx.fileName);
|
|
163
|
+
}
|
|
164
|
+
}),
|
|
165
|
+
...(0, language_service_1.defineProvide)(exports.injectionKeys.languageService, document => {
|
|
166
|
+
const sourceFile = getSemanticServiceSourceFile(document.uri);
|
|
167
|
+
if (sourceFile) {
|
|
168
|
+
return semanticCtx.typescript.languageService;
|
|
169
|
+
}
|
|
170
|
+
prepareSyntacticService(document);
|
|
171
|
+
return syntacticCtx.typescript.languageService;
|
|
172
|
+
}),
|
|
173
|
+
...(0, language_service_1.defineProvide)(exports.injectionKeys.languageServiceHost, document => {
|
|
174
|
+
const sourceFile = getSemanticServiceSourceFile(document.uri);
|
|
175
|
+
if (sourceFile) {
|
|
176
|
+
return semanticCtx.typescript.languageServiceHost;
|
|
177
|
+
}
|
|
178
|
+
prepareSyntacticService(document);
|
|
179
|
+
return syntacticCtx.typescript.languageServiceHost;
|
|
180
|
+
}),
|
|
181
|
+
...(0, language_service_1.defineProvide)(exports.injectionKeys.textDocument, semanticCtx.getTextDocument),
|
|
176
182
|
},
|
|
177
183
|
...triggerCharacters,
|
|
178
184
|
triggerCharacters: [
|
|
@@ -392,7 +398,16 @@ exports.default = () => (contextOrNull, modules) => {
|
|
|
392
398
|
return tsconfigRequests.resolve(link, token);
|
|
393
399
|
},
|
|
394
400
|
};
|
|
401
|
+
function getSemanticServiceSourceFile(uri) {
|
|
402
|
+
const sourceFile = semanticCtx.typescript.languageService.getProgram()?.getSourceFile(context.env.uriToFileName(uri));
|
|
403
|
+
if (sourceFile) {
|
|
404
|
+
return sourceFile;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
395
407
|
function prepareSyntacticService(document) {
|
|
408
|
+
if (syntacticHostCtx.document === document && syntacticHostCtx.fileVersion === document.version) {
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
396
411
|
syntacticHostCtx.fileName = context.env.uriToFileName(document.uri);
|
|
397
412
|
syntacticHostCtx.fileVersion = document.version;
|
|
398
413
|
if (context.documents.isVirtualFileUri(document.uri)) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type * as ts from 'typescript/lib/tsserverlibrary';
|
|
2
2
|
export declare namespace SymbolKind {
|
|
3
|
-
function fromProtocolScriptElementKind(kind: ts.ScriptElementKind): 2 | 5 |
|
|
3
|
+
function fromProtocolScriptElementKind(kind: ts.ScriptElementKind): 2 | 5 | 10 | 22 | 11 | 6 | 7 | 13 | 12 | 9 | 26 | 15;
|
|
4
4
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "volar-service-typescript",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"main": "out/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -27,5 +27,5 @@
|
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"@volar/language-service": "*"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "19482084693c7349f461dc75ec52ee6917739c51"
|
|
31
31
|
}
|