提交 8c8f79dc 编写于 作者: M Matt Bierner

Auto restart when changing typescript.experimental.useSeparateSyntaxServer

上级 14bc8002
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
"typescript.problemMatchers.tsc.label": "TypeScript problems", "typescript.problemMatchers.tsc.label": "TypeScript problems",
"typescript.problemMatchers.tscWatch.label": "TypeScript problems (watch mode)", "typescript.problemMatchers.tscWatch.label": "TypeScript problems (watch mode)",
"configuration.suggest.paths": "Enable/disable suggestions for paths in import statements and require calls.", "configuration.suggest.paths": "Enable/disable suggestions for paths in import statements and require calls.",
"configuration.experimental.useSeparateSyntaxServer": "Enable/disable spawning a separate TypeScript server that can more quickly respond to syntax related operations, such as calculating folding or computing document symbols. Note that you must restart the TypeScript server after changing this setting. Requires using TypeScript 3.4.0 or newer in the workspace.", "configuration.experimental.useSeparateSyntaxServer": "Enable/disable spawning a separate TypeScript server that can more quickly respond to syntax related operations, such as calculating folding or computing document symbols. Requires using TypeScript 3.4.0 or newer in the workspace.",
"typescript.locale": "Sets the locale used to report JavaScript and TypeScript errors. Requires using TypeScript 2.6.0 or newer in the workspace. Default of `null` uses VS Code's locale.", "typescript.locale": "Sets the locale used to report JavaScript and TypeScript errors. Requires using TypeScript 2.6.0 or newer in the workspace. Default of `null` uses VS Code's locale.",
"javascript.implicitProjectConfig.experimentalDecorators": "Enable/disable `experimentalDecorators` for JavaScript files that are not part of a project. Existing jsconfig.json or tsconfig.json files override this setting. Requires using TypeScript 2.3.1 or newer in the workspace.", "javascript.implicitProjectConfig.experimentalDecorators": "Enable/disable `experimentalDecorators` for JavaScript files that are not part of a project. Existing jsconfig.json or tsconfig.json files override this setting. Requires using TypeScript 2.3.1 or newer in the workspace.",
"configuration.suggest.autoImports": "Enable/disable auto import suggestions. Requires using TypeScript 2.6.1 or newer in the workspace.", "configuration.suggest.autoImports": "Enable/disable auto import suggestions. Requires using TypeScript 2.6.1 or newer in the workspace.",
......
...@@ -37,7 +37,7 @@ export class TypeScriptServerSpawner { ...@@ -37,7 +37,7 @@ export class TypeScriptServerSpawner {
configuration: TypeScriptServiceConfiguration, configuration: TypeScriptServiceConfiguration,
pluginManager: PluginManager pluginManager: PluginManager
): ITypeScriptServer { ): ITypeScriptServer {
if (this.shouldUseSeparateSyntaxServer(version)) { if (this.shouldUseSeparateSyntaxServer(version, configuration)) {
const syntaxServer = this.spawnTsServer('syntax', version, configuration, pluginManager); const syntaxServer = this.spawnTsServer('syntax', version, configuration, pluginManager);
const semanticServer = this.spawnTsServer('semantic', version, configuration, pluginManager); const semanticServer = this.spawnTsServer('semantic', version, configuration, pluginManager);
return new SyntaxRoutingTsServer(syntaxServer, semanticServer); return new SyntaxRoutingTsServer(syntaxServer, semanticServer);
...@@ -46,12 +46,11 @@ export class TypeScriptServerSpawner { ...@@ -46,12 +46,11 @@ export class TypeScriptServerSpawner {
return this.spawnTsServer('main', version, configuration, pluginManager); return this.spawnTsServer('main', version, configuration, pluginManager);
} }
private shouldUseSeparateSyntaxServer(version: TypeScriptVersion): boolean { private shouldUseSeparateSyntaxServer(
if (!version.apiVersion || version.apiVersion.lt(API.v340)) { version: TypeScriptVersion,
return false; configuration: TypeScriptServiceConfiguration,
} ): boolean {
return vscode.workspace.getConfiguration('typescript') return configuration.useSeparateSyntaxServer && !!version.apiVersion && version.apiVersion.gte(API.v340);
.get<boolean>('experimental.useSeparateSyntaxServer', false);
} }
private spawnTsServer( private spawnTsServer(
......
...@@ -54,6 +54,7 @@ export class TypeScriptServiceConfiguration { ...@@ -54,6 +54,7 @@ export class TypeScriptServiceConfiguration {
public readonly checkJs: boolean; public readonly checkJs: boolean;
public readonly experimentalDecorators: boolean; public readonly experimentalDecorators: boolean;
public readonly disableAutomaticTypeAcquisition: boolean; public readonly disableAutomaticTypeAcquisition: boolean;
public readonly useSeparateSyntaxServer: boolean;
public static loadFromWorkspace(): TypeScriptServiceConfiguration { public static loadFromWorkspace(): TypeScriptServiceConfiguration {
return new TypeScriptServiceConfiguration(); return new TypeScriptServiceConfiguration();
...@@ -71,6 +72,7 @@ export class TypeScriptServiceConfiguration { ...@@ -71,6 +72,7 @@ export class TypeScriptServiceConfiguration {
this.checkJs = TypeScriptServiceConfiguration.readCheckJs(configuration); this.checkJs = TypeScriptServiceConfiguration.readCheckJs(configuration);
this.experimentalDecorators = TypeScriptServiceConfiguration.readExperimentalDecorators(configuration); this.experimentalDecorators = TypeScriptServiceConfiguration.readExperimentalDecorators(configuration);
this.disableAutomaticTypeAcquisition = TypeScriptServiceConfiguration.readDisableAutomaticTypeAcquisition(configuration); this.disableAutomaticTypeAcquisition = TypeScriptServiceConfiguration.readDisableAutomaticTypeAcquisition(configuration);
this.useSeparateSyntaxServer = TypeScriptServiceConfiguration.readUseSeparateSyntaxServer(configuration);
} }
public isEqualTo(other: TypeScriptServiceConfiguration): boolean { public isEqualTo(other: TypeScriptServiceConfiguration): boolean {
...@@ -82,7 +84,8 @@ export class TypeScriptServiceConfiguration { ...@@ -82,7 +84,8 @@ export class TypeScriptServiceConfiguration {
&& this.checkJs === other.checkJs && this.checkJs === other.checkJs
&& this.experimentalDecorators === other.experimentalDecorators && this.experimentalDecorators === other.experimentalDecorators
&& this.disableAutomaticTypeAcquisition === other.disableAutomaticTypeAcquisition && this.disableAutomaticTypeAcquisition === other.disableAutomaticTypeAcquisition
&& arrays.equals(this.tsServerPluginPaths, other.tsServerPluginPaths); && arrays.equals(this.tsServerPluginPaths, other.tsServerPluginPaths)
&& this.useSeparateSyntaxServer === other.useSeparateSyntaxServer;
} }
private static fixPathPrefixes(inspectValue: string): string { private static fixPathPrefixes(inspectValue: string): string {
...@@ -139,4 +142,8 @@ export class TypeScriptServiceConfiguration { ...@@ -139,4 +142,8 @@ export class TypeScriptServiceConfiguration {
private static extractLocale(configuration: vscode.WorkspaceConfiguration): string | null { private static extractLocale(configuration: vscode.WorkspaceConfiguration): string | null {
return configuration.get<string | null>('typescript.locale', null); return configuration.get<string | null>('typescript.locale', null);
} }
private static readUseSeparateSyntaxServer(configuration: vscode.WorkspaceConfiguration): boolean {
return configuration.get<boolean>('typescript.experimental.useSeparateSyntaxServer', false);
}
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册