mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-08 09:08:48 +01:00
Move standard TS commands to own file
This commit is contained in:
@@ -0,0 +1,99 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
import { TypeScriptServiceClientHost } from './typescriptMain';
|
||||
import { Command } from './utils/commandManager';
|
||||
|
||||
export class ReloadTypeScriptProjectsCommand implements Command {
|
||||
public readonly id = 'typescript.reloadProjects';
|
||||
|
||||
public constructor(
|
||||
private readonly lazyClientHost: () => TypeScriptServiceClientHost
|
||||
) { }
|
||||
|
||||
public execute() {
|
||||
this.lazyClientHost().reloadProjects();
|
||||
}
|
||||
}
|
||||
|
||||
export class ReloadJavaScriptProjectsCommand implements Command {
|
||||
public readonly id = 'javascript.reloadProjects';
|
||||
|
||||
public constructor(
|
||||
private readonly lazyClientHost: () => TypeScriptServiceClientHost
|
||||
) { }
|
||||
|
||||
public execute() {
|
||||
this.lazyClientHost().reloadProjects();
|
||||
}
|
||||
}
|
||||
|
||||
export class SelectTypeScriptVersionCommand implements Command {
|
||||
public readonly id = 'typescript.selectTypeScriptVersion';
|
||||
|
||||
public constructor(
|
||||
private readonly lazyClientHost: () => TypeScriptServiceClientHost
|
||||
) { }
|
||||
|
||||
public execute() {
|
||||
this.lazyClientHost().serviceClient.onVersionStatusClicked();
|
||||
}
|
||||
}
|
||||
|
||||
export class OpenTsServerLogCommand implements Command {
|
||||
public readonly id = 'typescript.openTsServerLog';
|
||||
|
||||
public constructor(
|
||||
private readonly lazyClientHost: () => TypeScriptServiceClientHost
|
||||
) { }
|
||||
|
||||
public execute() {
|
||||
this.lazyClientHost().serviceClient.openTsServerLogFile();
|
||||
}
|
||||
}
|
||||
|
||||
export class RestartTsServerCommand implements Command {
|
||||
public readonly id = 'typescript.restartTsServer';
|
||||
|
||||
public constructor(
|
||||
private readonly lazyClientHost: () => TypeScriptServiceClientHost
|
||||
) { }
|
||||
|
||||
public execute() {
|
||||
this.lazyClientHost().serviceClient.restartTsServer();
|
||||
}
|
||||
}
|
||||
|
||||
export class TypeScriptGoToProjectConfigCommand implements Command {
|
||||
public readonly id = 'typescript.goToProjectConfig';
|
||||
|
||||
public constructor(
|
||||
private readonly lazyClientHost: () => TypeScriptServiceClientHost,
|
||||
) { }
|
||||
|
||||
public execute() {
|
||||
const editor = vscode.window.activeTextEditor;
|
||||
if (editor) {
|
||||
this.lazyClientHost().goToProjectConfig(true, editor.document.uri);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class JavaScriptGoToProjectConfigCommand implements Command {
|
||||
public readonly id = 'javascript.goToProjectConfig';
|
||||
|
||||
public constructor(
|
||||
private readonly lazyClientHost: () => TypeScriptServiceClientHost,
|
||||
) { }
|
||||
|
||||
public execute() {
|
||||
const editor = vscode.window.activeTextEditor;
|
||||
if (editor) {
|
||||
this.lazyClientHost().goToProjectConfig(false, editor.document.uri);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,9 @@
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
import { CommandManager } from './utils/commandManager';
|
||||
import { ReloadTypeScriptProjectsCommand, SelectTypeScriptVersionCommand, ReloadJavaScriptProjectsCommand, RestartTsServerCommand, OpenTsServerLogCommand, TypeScriptGoToProjectConfigCommand, JavaScriptGoToProjectConfigCommand, TypeScriptServiceClientHost } from './typescriptMain';
|
||||
import { TypeScriptServiceClientHost } from './typescriptMain';
|
||||
import * as commands from './commands';
|
||||
|
||||
import TypeScriptTaskProviderManager from './features/taskProvider';
|
||||
import { getContributedTypeScriptServerPlugins, TypeScriptServerPlugin } from './utils/plugins';
|
||||
import * as ProjectStatus from './utils/projectStatus';
|
||||
@@ -70,11 +72,11 @@ function registerCommands(
|
||||
commandManager: CommandManager,
|
||||
lazyClientHost: () => TypeScriptServiceClientHost
|
||||
) {
|
||||
commandManager.register(new ReloadTypeScriptProjectsCommand(lazyClientHost));
|
||||
commandManager.register(new ReloadJavaScriptProjectsCommand(lazyClientHost));
|
||||
commandManager.register(new SelectTypeScriptVersionCommand(lazyClientHost));
|
||||
commandManager.register(new OpenTsServerLogCommand(lazyClientHost));
|
||||
commandManager.register(new RestartTsServerCommand(lazyClientHost));
|
||||
commandManager.register(new TypeScriptGoToProjectConfigCommand(lazyClientHost));
|
||||
commandManager.register(new JavaScriptGoToProjectConfigCommand(lazyClientHost));
|
||||
commandManager.register(new commands.ReloadTypeScriptProjectsCommand(lazyClientHost));
|
||||
commandManager.register(new commands.ReloadJavaScriptProjectsCommand(lazyClientHost));
|
||||
commandManager.register(new commands.SelectTypeScriptVersionCommand(lazyClientHost));
|
||||
commandManager.register(new commands.OpenTsServerLogCommand(lazyClientHost));
|
||||
commandManager.register(new commands.RestartTsServerCommand(lazyClientHost));
|
||||
commandManager.register(new commands.TypeScriptGoToProjectConfigCommand(lazyClientHost));
|
||||
commandManager.register(new commands.JavaScriptGoToProjectConfigCommand(lazyClientHost));
|
||||
}
|
||||
|
||||
@@ -33,100 +33,10 @@ import { openOrCreateConfigFile, isImplicitProjectConfigFile } from './utils/tsc
|
||||
import { tsLocationToVsPosition } from './utils/convert';
|
||||
import FormattingConfigurationManager from './features/formattingConfigurationManager';
|
||||
import * as languageConfigurations from './utils/languageConfigurations';
|
||||
import { CommandManager, Command } from './utils/commandManager';
|
||||
import { CommandManager } from './utils/commandManager';
|
||||
import DiagnosticsManager from './features/diagnostics';
|
||||
import { LanguageDescription } from './utils/languageDescription';
|
||||
|
||||
export class ReloadTypeScriptProjectsCommand implements Command {
|
||||
public readonly id = 'typescript.reloadProjects';
|
||||
|
||||
public constructor(
|
||||
private readonly lazyClientHost: () => TypeScriptServiceClientHost
|
||||
) { }
|
||||
|
||||
public execute() {
|
||||
this.lazyClientHost().reloadProjects();
|
||||
}
|
||||
}
|
||||
|
||||
export class ReloadJavaScriptProjectsCommand implements Command {
|
||||
public readonly id = 'javascript.reloadProjects';
|
||||
|
||||
public constructor(
|
||||
private readonly lazyClientHost: () => TypeScriptServiceClientHost
|
||||
) { }
|
||||
|
||||
public execute() {
|
||||
this.lazyClientHost().reloadProjects();
|
||||
}
|
||||
}
|
||||
|
||||
export class SelectTypeScriptVersionCommand implements Command {
|
||||
public readonly id = 'typescript.selectTypeScriptVersion';
|
||||
|
||||
public constructor(
|
||||
private readonly lazyClientHost: () => TypeScriptServiceClientHost
|
||||
) { }
|
||||
|
||||
public execute() {
|
||||
this.lazyClientHost().serviceClient.onVersionStatusClicked();
|
||||
}
|
||||
}
|
||||
|
||||
export class OpenTsServerLogCommand implements Command {
|
||||
public readonly id = 'typescript.openTsServerLog';
|
||||
|
||||
public constructor(
|
||||
private readonly lazyClientHost: () => TypeScriptServiceClientHost
|
||||
) { }
|
||||
|
||||
public execute() {
|
||||
this.lazyClientHost().serviceClient.openTsServerLogFile();
|
||||
}
|
||||
}
|
||||
|
||||
export class RestartTsServerCommand implements Command {
|
||||
public readonly id = 'typescript.restartTsServer';
|
||||
|
||||
public constructor(
|
||||
private readonly lazyClientHost: () => TypeScriptServiceClientHost
|
||||
) { }
|
||||
|
||||
public execute() {
|
||||
this.lazyClientHost().serviceClient.restartTsServer();
|
||||
}
|
||||
}
|
||||
|
||||
export class TypeScriptGoToProjectConfigCommand implements Command {
|
||||
public readonly id = 'typescript.goToProjectConfig';
|
||||
|
||||
public constructor(
|
||||
private readonly lazyClientHost: () => TypeScriptServiceClientHost,
|
||||
) { }
|
||||
|
||||
public execute() {
|
||||
const editor = window.activeTextEditor;
|
||||
if (editor) {
|
||||
this.lazyClientHost().goToProjectConfig(true, editor.document.uri);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class JavaScriptGoToProjectConfigCommand implements Command {
|
||||
public readonly id = 'javascript.goToProjectConfig';
|
||||
|
||||
public constructor(
|
||||
private readonly lazyClientHost: () => TypeScriptServiceClientHost,
|
||||
) { }
|
||||
|
||||
public execute() {
|
||||
const editor = window.activeTextEditor;
|
||||
if (editor) {
|
||||
this.lazyClientHost().goToProjectConfig(false, editor.document.uri);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const validateSetting = 'validate.enable';
|
||||
|
||||
class LanguageProvider {
|
||||
|
||||
Reference in New Issue
Block a user