@volar/language-server 1.4.0-alpha.2 → 1.4.0-alpha.3

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.
@@ -126,19 +126,6 @@ function register(connection, projects, initParams, initOptions, cancelHost, sem
126
126
  connection.onCodeLensResolve(async (codeLens, token) => {
127
127
  return await lastCodeLensLs?.doCodeLensResolve(codeLens, token) ?? codeLens;
128
128
  });
129
- connection.onExecuteCommand(async (params) => {
130
- if (params.command === embedded.showReferencesCommand
131
- && params.arguments) {
132
- const args = params.arguments;
133
- await connection.sendNotification(protocol_1.ShowReferencesNotification.type, {
134
- textDocument: {
135
- uri: args[0],
136
- },
137
- position: args[1],
138
- references: args[2],
139
- });
140
- }
141
- });
142
129
  connection.onCodeAction(async (params, token) => {
143
130
  return worker(params.textDocument.uri, token, async (service) => {
144
131
  lastCodeActionLs = service;
@@ -12,7 +12,7 @@ export interface ProjectContext {
12
12
  }
13
13
  export type Project = ReturnType<typeof createProject>;
14
14
  export declare function createProject(context: ProjectContext): Promise<{
15
- tsConfig: ts.CompilerOptions | path.PosixPath;
15
+ tsConfig: path.PosixPath | ts.CompilerOptions;
16
16
  scripts: {
17
17
  clear: () => void;
18
18
  values: () => IterableIterator<{
@@ -58,12 +58,13 @@ async function createProject(context) {
58
58
  const options = {
59
59
  uriToFileName,
60
60
  fileNameToUri,
61
+ locale: context.workspace.workspaces.initParams.locale,
61
62
  rootUri: context.rootUri,
63
+ capabilities: context.workspace.workspaces.initParams.capabilities,
62
64
  host: languageServiceHost,
63
65
  get config() {
64
66
  return config;
65
67
  },
66
- locale: context.workspace.workspaces.initParams.locale,
67
68
  configurationHost: context.workspace.workspaces.configurationHost,
68
69
  fileSystemProvider: context.workspace.workspaces.server.runtimeEnv.fileSystemProvide,
69
70
  documentContext: getDocumentContext(fileNameToUri, uriToFileName, context.workspace.workspaces.ts, languageServiceHost, context.rootUri.toString()),
@@ -42,6 +42,13 @@ function startCommonLanguageServer(connection, getCtx) {
42
42
  const result = {
43
43
  capabilities: {
44
44
  textDocumentSync: options.textDocumentSync ?? vscode.TextDocumentSyncKind.Incremental,
45
+ workspace: {
46
+ // #18
47
+ workspaceFolders: {
48
+ supported: true,
49
+ changeNotifications: true,
50
+ },
51
+ },
45
52
  },
46
53
  };
47
54
  configurationHost = initParams.capabilities.workspace?.configuration ? (0, configurationHost_1.createConfigurationHost)(initParams, connection) : undefined;
@@ -1,6 +1,5 @@
1
1
  Object.defineProperty(exports, "__esModule", { value: true });
2
2
  exports.setupCapabilities = void 0;
3
- const embedded = require("@volar/language-service");
4
3
  const types_1 = require("../../types");
5
4
  const vscode = require("vscode-languageserver");
6
5
  function setupCapabilities(server, initOptions, plugins, semanticTokensLegend, lsPlugins) {
@@ -52,8 +51,6 @@ function setupCapabilities(server, initOptions, plugins, semanticTokensLegend, l
52
51
  server.codeLensProvider = {
53
52
  resolveProvider: true,
54
53
  };
55
- server.executeCommandProvider ??= { commands: [] };
56
- server.executeCommandProvider.commands.push(embedded.showReferencesCommand);
57
54
  server.semanticTokensProvider = {
58
55
  range: true,
59
56
  full: false,
@@ -1,4 +1,4 @@
1
- import * as path from 'typesafe-path';
1
+ import * as path from 'typesafe-path/posix';
2
2
  import type * as ts from 'typescript/lib/tsserverlibrary';
3
3
  import * as vscode from 'vscode-languageserver';
4
4
  import { URI } from 'vscode-uri';
@@ -12,7 +12,7 @@ export declare function createWorkspace(context: WorkspaceContext): Promise<{
12
12
  projects: {
13
13
  clear: () => void;
14
14
  values: () => IterableIterator<Promise<{
15
- tsConfig: ts.CompilerOptions | path.PosixPath;
15
+ tsConfig: import("typesafe-path").PosixPath | ts.CompilerOptions;
16
16
  scripts: {
17
17
  clear: () => void;
18
18
  values: () => IterableIterator<{
@@ -154,7 +154,7 @@ export declare function createWorkspace(context: WorkspaceContext): Promise<{
154
154
  }>>;
155
155
  uriDelete: (_uri: string) => boolean;
156
156
  uriGet: (_uri: string) => Promise<{
157
- tsConfig: ts.CompilerOptions | path.PosixPath;
157
+ tsConfig: import("typesafe-path").PosixPath | ts.CompilerOptions;
158
158
  scripts: {
159
159
  clear: () => void;
160
160
  values: () => IterableIterator<{
@@ -296,7 +296,7 @@ export declare function createWorkspace(context: WorkspaceContext): Promise<{
296
296
  }> | undefined;
297
297
  uriHas: (_uri: string) => boolean;
298
298
  uriSet: (_uri: string, item: Promise<{
299
- tsConfig: ts.CompilerOptions | path.PosixPath;
299
+ tsConfig: import("typesafe-path").PosixPath | ts.CompilerOptions;
300
300
  scripts: {
301
301
  clear: () => void;
302
302
  values: () => IterableIterator<{
@@ -438,7 +438,7 @@ export declare function createWorkspace(context: WorkspaceContext): Promise<{
438
438
  }>) => void;
439
439
  pathDelete: (path: string) => boolean;
440
440
  pathGet: (path: string) => Promise<{
441
- tsConfig: ts.CompilerOptions | path.PosixPath;
441
+ tsConfig: import("typesafe-path").PosixPath | ts.CompilerOptions;
442
442
  scripts: {
443
443
  clear: () => void;
444
444
  values: () => IterableIterator<{
@@ -579,7 +579,7 @@ export declare function createWorkspace(context: WorkspaceContext): Promise<{
579
579
  dispose: () => void;
580
580
  }> | undefined;
581
581
  pathHas: (path: string) => Promise<{
582
- tsConfig: ts.CompilerOptions | path.PosixPath;
582
+ tsConfig: import("typesafe-path").PosixPath | ts.CompilerOptions;
583
583
  scripts: {
584
584
  clear: () => void;
585
585
  values: () => IterableIterator<{
@@ -720,7 +720,7 @@ export declare function createWorkspace(context: WorkspaceContext): Promise<{
720
720
  dispose: () => void;
721
721
  }> | undefined;
722
722
  pathSet: (path: string, item: Promise<{
723
- tsConfig: ts.CompilerOptions | path.PosixPath;
723
+ tsConfig: import("typesafe-path").PosixPath | ts.CompilerOptions;
724
724
  scripts: {
725
725
  clear: () => void;
726
726
  values: () => IterableIterator<{
@@ -865,7 +865,7 @@ export declare function createWorkspace(context: WorkspaceContext): Promise<{
865
865
  getProjectAndTsConfig: (uri: string) => Promise<{
866
866
  tsconfig: string;
867
867
  project: {
868
- tsConfig: ts.CompilerOptions | path.PosixPath;
868
+ tsConfig: import("typesafe-path").PosixPath | ts.CompilerOptions;
869
869
  scripts: {
870
870
  clear: () => void;
871
871
  values: () => IterableIterator<{
@@ -1007,7 +1007,7 @@ export declare function createWorkspace(context: WorkspaceContext): Promise<{
1007
1007
  } | undefined;
1008
1008
  } | undefined>;
1009
1009
  getInferredProject: () => Promise<{
1010
- tsConfig: ts.CompilerOptions | path.PosixPath;
1010
+ tsConfig: import("typesafe-path").PosixPath | ts.CompilerOptions;
1011
1011
  scripts: {
1012
1012
  clear: () => void;
1013
1013
  values: () => IterableIterator<{
@@ -1148,7 +1148,7 @@ export declare function createWorkspace(context: WorkspaceContext): Promise<{
1148
1148
  dispose: () => void;
1149
1149
  }>;
1150
1150
  getInferredProjectDontCreate: () => Promise<{
1151
- tsConfig: ts.CompilerOptions | path.PosixPath;
1151
+ tsConfig: import("typesafe-path").PosixPath | ts.CompilerOptions;
1152
1152
  scripts: {
1153
1153
  clear: () => void;
1154
1154
  values: () => IterableIterator<{
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, "__esModule", { value: true });
2
2
  exports.sortTsConfigs = exports.createWorkspace = exports.rootTsConfigNames = void 0;
3
- const path = require("typesafe-path");
3
+ const path = require("typesafe-path/posix");
4
4
  const vscode = require("vscode-languageserver");
5
5
  const vscode_uri_1 = require("vscode-uri");
6
6
  const project_1 = require("./project");
@@ -15,7 +15,8 @@ async function createWorkspace(context) {
15
15
  const sys = context.workspaces.fileSystemHost?.getWorkspaceFileSystem(context.rootUri);
16
16
  const documentRegistry = sys ? context.workspaces.ts?.createDocumentRegistry(sys.useCaseSensitiveFileNames, uriToFileName(context.rootUri.toString())) : undefined;
17
17
  const projects = (0, uriMap_1.createUriMap)(fileNameToUri);
18
- const rootTsConfigs = new Set(sys?.readDirectory(uriToFileName(context.rootUri.toString()), exports.rootTsConfigNames, undefined, ['**/*']).map(fileName => fileName.replace(/\\/g, '/')));
18
+ const rootTsConfigs = new Set();
19
+ const searchedDirs = new Set();
19
20
  const disposeTsConfigWatch = context.workspaces.fileSystemHost?.onDidChangeWatchedFiles(({ changes }) => {
20
21
  for (const change of changes) {
21
22
  if (exports.rootTsConfigNames.includes(change.uri.substring(change.uri.lastIndexOf('/') + 1))) {
@@ -83,6 +84,24 @@ async function createWorkspace(context) {
83
84
  return inferredProject;
84
85
  }
85
86
  async function findMatchConfigs(uri) {
87
+ const filePath = uriToFileName(uri.toString());
88
+ let dir = path.dirname(filePath);
89
+ while (true) {
90
+ if (searchedDirs.has(dir)) {
91
+ break;
92
+ }
93
+ searchedDirs.add(dir);
94
+ const tsconfigPaths = [
95
+ path.join(dir, 'tsconfig.json'),
96
+ path.join(dir, 'jsconfig.json'),
97
+ ];
98
+ for (const tsconfigPath of tsconfigPaths) {
99
+ if (sys?.fileExists(tsconfigPath)) {
100
+ rootTsConfigs.add(tsconfigPath);
101
+ }
102
+ }
103
+ dir = path.dirname(dir);
104
+ }
86
105
  await prepareClosestootParsedCommandLine();
87
106
  return await findDirectIncludeTsconfig() ?? await findIndirectReferenceTsconfig();
88
107
  async function prepareClosestootParsedCommandLine() {
@@ -142,7 +161,7 @@ async function createWorkspace(context) {
142
161
  if (parsedCommandLine.projectReferences?.length) {
143
162
  const newChains = [];
144
163
  for (const projectReference of parsedCommandLine.projectReferences) {
145
- let tsConfigPath = projectReference.path;
164
+ let tsConfigPath = projectReference.path.replace(/\\/g, '/');
146
165
  // fix https://github.com/johnsoncodehk/volar/issues/712
147
166
  if (sys && !sys.fileExists(tsConfigPath)) {
148
167
  const newTsConfigPath = path.join(tsConfigPath, 'tsconfig.json');
@@ -26,7 +26,7 @@ export declare function createWorkspaces(context: WorkspacesContext): {
26
26
  projects: {
27
27
  clear: () => void;
28
28
  values: () => IterableIterator<Promise<{
29
- tsConfig: ts.CompilerOptions | path.PosixPath;
29
+ tsConfig: path.PosixPath | ts.CompilerOptions;
30
30
  scripts: {
31
31
  clear: () => void;
32
32
  values: () => IterableIterator<{
@@ -168,7 +168,7 @@ export declare function createWorkspaces(context: WorkspacesContext): {
168
168
  }>>;
169
169
  uriDelete: (_uri: string) => boolean;
170
170
  uriGet: (_uri: string) => Promise<{
171
- tsConfig: ts.CompilerOptions | path.PosixPath;
171
+ tsConfig: path.PosixPath | ts.CompilerOptions;
172
172
  scripts: {
173
173
  clear: () => void;
174
174
  values: () => IterableIterator<{
@@ -310,7 +310,7 @@ export declare function createWorkspaces(context: WorkspacesContext): {
310
310
  }> | undefined;
311
311
  uriHas: (_uri: string) => boolean;
312
312
  uriSet: (_uri: string, item: Promise<{
313
- tsConfig: ts.CompilerOptions | path.PosixPath;
313
+ tsConfig: path.PosixPath | ts.CompilerOptions;
314
314
  scripts: {
315
315
  clear: () => void;
316
316
  values: () => IterableIterator<{
@@ -452,7 +452,7 @@ export declare function createWorkspaces(context: WorkspacesContext): {
452
452
  }>) => void;
453
453
  pathDelete: (path: string) => boolean;
454
454
  pathGet: (path: string) => Promise<{
455
- tsConfig: ts.CompilerOptions | path.PosixPath;
455
+ tsConfig: path.PosixPath | ts.CompilerOptions;
456
456
  scripts: {
457
457
  clear: () => void;
458
458
  values: () => IterableIterator<{
@@ -593,7 +593,7 @@ export declare function createWorkspaces(context: WorkspacesContext): {
593
593
  dispose: () => void;
594
594
  }> | undefined;
595
595
  pathHas: (path: string) => Promise<{
596
- tsConfig: ts.CompilerOptions | path.PosixPath;
596
+ tsConfig: path.PosixPath | ts.CompilerOptions;
597
597
  scripts: {
598
598
  clear: () => void;
599
599
  values: () => IterableIterator<{
@@ -734,7 +734,7 @@ export declare function createWorkspaces(context: WorkspacesContext): {
734
734
  dispose: () => void;
735
735
  }> | undefined;
736
736
  pathSet: (path: string, item: Promise<{
737
- tsConfig: ts.CompilerOptions | path.PosixPath;
737
+ tsConfig: path.PosixPath | ts.CompilerOptions;
738
738
  scripts: {
739
739
  clear: () => void;
740
740
  values: () => IterableIterator<{
@@ -879,7 +879,7 @@ export declare function createWorkspaces(context: WorkspacesContext): {
879
879
  getProjectAndTsConfig: (uri: string) => Promise<{
880
880
  tsconfig: string;
881
881
  project: {
882
- tsConfig: ts.CompilerOptions | path.PosixPath;
882
+ tsConfig: path.PosixPath | ts.CompilerOptions;
883
883
  scripts: {
884
884
  clear: () => void;
885
885
  values: () => IterableIterator<{
@@ -1021,7 +1021,7 @@ export declare function createWorkspaces(context: WorkspacesContext): {
1021
1021
  } | undefined;
1022
1022
  } | undefined>;
1023
1023
  getInferredProject: () => Promise<{
1024
- tsConfig: ts.CompilerOptions | path.PosixPath;
1024
+ tsConfig: path.PosixPath | ts.CompilerOptions;
1025
1025
  scripts: {
1026
1026
  clear: () => void;
1027
1027
  values: () => IterableIterator<{
@@ -1162,7 +1162,7 @@ export declare function createWorkspaces(context: WorkspacesContext): {
1162
1162
  dispose: () => void;
1163
1163
  }>;
1164
1164
  getInferredProjectDontCreate: () => Promise<{
1165
- tsConfig: ts.CompilerOptions | path.PosixPath;
1165
+ tsConfig: path.PosixPath | ts.CompilerOptions;
1166
1166
  scripts: {
1167
1167
  clear: () => void;
1168
1168
  values: () => IterableIterator<{
@@ -1308,7 +1308,7 @@ export declare function createWorkspaces(context: WorkspacesContext): {
1308
1308
  getProject: (uri: string) => Promise<{
1309
1309
  tsconfig: string;
1310
1310
  project: {
1311
- tsConfig: ts.CompilerOptions | path.PosixPath;
1311
+ tsConfig: path.PosixPath | ts.CompilerOptions;
1312
1312
  scripts: {
1313
1313
  clear: () => void;
1314
1314
  values: () => IterableIterator<{
@@ -1451,7 +1451,7 @@ export declare function createWorkspaces(context: WorkspacesContext): {
1451
1451
  } | {
1452
1452
  tsconfig: undefined;
1453
1453
  project: {
1454
- tsConfig: ts.CompilerOptions | path.PosixPath;
1454
+ tsConfig: path.PosixPath | ts.CompilerOptions;
1455
1455
  scripts: {
1456
1456
  clear: () => void;
1457
1457
  values: () => IterableIterator<{
package/out/protocol.d.ts CHANGED
@@ -4,12 +4,6 @@ import type { FileKind, FileRangeCapabilities } from '@volar/language-core';
4
4
  /**
5
5
  * Server request client
6
6
  */
7
- export declare namespace ShowReferencesNotification {
8
- type ResponseType = vscode.TextDocumentPositionParams & {
9
- references: vscode.Location[];
10
- };
11
- const type: vscode.NotificationType<ResponseType>;
12
- }
13
7
  export declare namespace FsReadFileRequest {
14
8
  const type: vscode.RequestType<string, Uint8Array | null | undefined, unknown>;
15
9
  }
package/out/protocol.js CHANGED
@@ -1,13 +1,9 @@
1
1
  Object.defineProperty(exports, "__esModule", { value: true });
2
- exports.ReportStats = exports.GetVirtualFileRequest = exports.GetVirtualFileNamesRequest = exports.ReloadProjectNotification = exports.WriteVirtualFilesNotification = exports.AutoInsertRequest = exports.GetMatchTsConfigRequest = exports.FindFileReferenceRequest = exports.FsReadDirectoryRequest = exports.FsReadFileRequest = exports.ShowReferencesNotification = void 0;
2
+ exports.ReportStats = exports.GetVirtualFileRequest = exports.GetVirtualFileNamesRequest = exports.ReloadProjectNotification = exports.WriteVirtualFilesNotification = exports.AutoInsertRequest = exports.GetMatchTsConfigRequest = exports.FindFileReferenceRequest = exports.FsReadDirectoryRequest = exports.FsReadFileRequest = void 0;
3
3
  const vscode = require("vscode-languageserver-protocol");
4
4
  /**
5
5
  * Server request client
6
6
  */
7
- var ShowReferencesNotification;
8
- (function (ShowReferencesNotification) {
9
- ShowReferencesNotification.type = new vscode.NotificationType('volar/server/showReferences');
10
- })(ShowReferencesNotification = exports.ShowReferencesNotification || (exports.ShowReferencesNotification = {}));
11
7
  var FsReadFileRequest;
12
8
  (function (FsReadFileRequest) {
13
9
  FsReadFileRequest.type = new vscode.RequestType('volar/server/fs/readFile');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volar/language-server",
3
- "version": "1.4.0-alpha.2",
3
+ "version": "1.4.0-alpha.3",
4
4
  "main": "out/index.js",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -17,8 +17,8 @@
17
17
  "directory": "packages/language-server"
18
18
  },
19
19
  "dependencies": {
20
- "@volar/language-core": "1.4.0-alpha.2",
21
- "@volar/language-service": "1.4.0-alpha.2",
20
+ "@volar/language-core": "1.4.0-alpha.3",
21
+ "@volar/language-service": "1.4.0-alpha.3",
22
22
  "@vscode/l10n": "^0.0.11",
23
23
  "request-light": "^0.7.0",
24
24
  "typesafe-path": "^0.2.2",
@@ -28,5 +28,5 @@
28
28
  "vscode-languageserver-textdocument": "^1.0.8",
29
29
  "vscode-uri": "^3.0.7"
30
30
  },
31
- "gitHead": "034b230da17794a6fcf5a0b07668710f98ff84e3"
31
+ "gitHead": "033129d71b355a0f5bbf514c6887ed3a6e083c21"
32
32
  }