Use object parameter for services
This commit is contained in:
parent
feadf5183d
commit
0a7364f005
9 changed files with 67 additions and 39 deletions
|
@ -55,7 +55,14 @@ export function activate(
|
||||||
'/builtin-extension/typescript-language-features/dist/browser/typescript-web/tsserver.js',
|
'/builtin-extension/typescript-language-features/dist/browser/typescript-web/tsserver.js',
|
||||||
API.v400));
|
API.v400));
|
||||||
|
|
||||||
const lazyClientHost = createLazyClientHost(context, false, pluginManager, commandManager, noopLogDirectoryProvider, noopRequestCancellerFactory, versionProvider, WorkerServerProcess, item => {
|
const lazyClientHost = createLazyClientHost(context, false, {
|
||||||
|
pluginManager,
|
||||||
|
commandManager,
|
||||||
|
logDirectoryProvider: noopLogDirectoryProvider,
|
||||||
|
cancellerFactory: noopRequestCancellerFactory,
|
||||||
|
versionProvider,
|
||||||
|
processFactory: WorkerServerProcess
|
||||||
|
}, item => {
|
||||||
onCompletionAccepted.fire(item);
|
onCompletionAccepted.fire(item);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,14 @@ export function activate(
|
||||||
|
|
||||||
context.subscriptions.push(new LanguageConfigurationManager());
|
context.subscriptions.push(new LanguageConfigurationManager());
|
||||||
|
|
||||||
const lazyClientHost = createLazyClientHost(context, onCaseInsenitiveFileSystem(), pluginManager, commandManager, logDirectoryProvider, nodeRequestCancellerFactory, versionProvider, ChildServerProcess, item => {
|
const lazyClientHost = createLazyClientHost(context, onCaseInsenitiveFileSystem(), {
|
||||||
|
pluginManager,
|
||||||
|
commandManager,
|
||||||
|
logDirectoryProvider,
|
||||||
|
cancellerFactory: nodeRequestCancellerFactory,
|
||||||
|
versionProvider,
|
||||||
|
processFactory: ChildServerProcess,
|
||||||
|
}, item => {
|
||||||
onCompletionAccepted.fire(item);
|
onCompletionAccepted.fire(item);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -20,12 +20,14 @@ import { PluginManager } from './utils/plugins';
|
||||||
export function createLazyClientHost(
|
export function createLazyClientHost(
|
||||||
context: vscode.ExtensionContext,
|
context: vscode.ExtensionContext,
|
||||||
onCaseInsenitiveFileSystem: boolean,
|
onCaseInsenitiveFileSystem: boolean,
|
||||||
pluginManager: PluginManager,
|
services: {
|
||||||
commandManager: CommandManager,
|
pluginManager: PluginManager,
|
||||||
logDirectoryProvider: ILogDirectoryProvider,
|
commandManager: CommandManager,
|
||||||
cancellerFactory: OngoingRequestCancellerFactory,
|
logDirectoryProvider: ILogDirectoryProvider,
|
||||||
versionProvider: ITypeScriptVersionProvider,
|
cancellerFactory: OngoingRequestCancellerFactory,
|
||||||
processFactory: TsServerProcessFactory,
|
versionProvider: ITypeScriptVersionProvider,
|
||||||
|
processFactory: TsServerProcessFactory,
|
||||||
|
},
|
||||||
onCompletionAccepted: (item: vscode.CompletionItem) => void,
|
onCompletionAccepted: (item: vscode.CompletionItem) => void,
|
||||||
): Lazy<TypeScriptServiceClientHost> {
|
): Lazy<TypeScriptServiceClientHost> {
|
||||||
return lazy(() => {
|
return lazy(() => {
|
||||||
|
@ -33,12 +35,7 @@ export function createLazyClientHost(
|
||||||
standardLanguageDescriptions,
|
standardLanguageDescriptions,
|
||||||
context.workspaceState,
|
context.workspaceState,
|
||||||
onCaseInsenitiveFileSystem,
|
onCaseInsenitiveFileSystem,
|
||||||
pluginManager,
|
services,
|
||||||
commandManager,
|
|
||||||
logDirectoryProvider,
|
|
||||||
cancellerFactory,
|
|
||||||
versionProvider,
|
|
||||||
processFactory,
|
|
||||||
onCompletionAccepted);
|
onCompletionAccepted);
|
||||||
|
|
||||||
context.subscriptions.push(clientHost);
|
context.subscriptions.push(clientHost);
|
||||||
|
@ -57,7 +54,7 @@ export function createLazyClientHost(
|
||||||
export function lazilyActivateClient(
|
export function lazilyActivateClient(
|
||||||
lazyClientHost: Lazy<TypeScriptServiceClientHost>,
|
lazyClientHost: Lazy<TypeScriptServiceClientHost>,
|
||||||
pluginManager: PluginManager,
|
pluginManager: PluginManager,
|
||||||
) {
|
): vscode.Disposable {
|
||||||
const disposables: vscode.Disposable[] = [];
|
const disposables: vscode.Disposable[] = [];
|
||||||
|
|
||||||
const supportedLanguage = flatten([
|
const supportedLanguage = flatten([
|
||||||
|
|
|
@ -10,7 +10,7 @@ import type * as Proto from '../protocol';
|
||||||
import { NodeRequestCanceller } from '../tsServer/cancellation.electron';
|
import { NodeRequestCanceller } from '../tsServer/cancellation.electron';
|
||||||
import { ProcessBasedTsServer, TsServerProcess } from '../tsServer/server';
|
import { ProcessBasedTsServer, TsServerProcess } from '../tsServer/server';
|
||||||
import { nulToken } from '../utils/cancellation';
|
import { nulToken } from '../utils/cancellation';
|
||||||
import Logger from '../utils/logger';
|
import { Logger } from '../utils/logger';
|
||||||
import { TelemetryReporter } from '../utils/telemetry';
|
import { TelemetryReporter } from '../utils/telemetry';
|
||||||
import Tracer from '../utils/tracer';
|
import Tracer from '../utils/tracer';
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ import { OngoingRequestCancellerFactory } from '../tsServer/cancellation';
|
||||||
import { ClientCapabilities, ClientCapability } from '../typescriptService';
|
import { ClientCapabilities, ClientCapability } from '../typescriptService';
|
||||||
import API from '../utils/api';
|
import API from '../utils/api';
|
||||||
import { SeparateSyntaxServerConfiguration, TsServerLogLevel, TypeScriptServiceConfiguration } from '../utils/configuration';
|
import { SeparateSyntaxServerConfiguration, TsServerLogLevel, TypeScriptServiceConfiguration } from '../utils/configuration';
|
||||||
import Logger from '../utils/logger';
|
import { Logger } from '../utils/logger';
|
||||||
import { TypeScriptPluginPathsProvider } from '../utils/pluginPathsProvider';
|
import { TypeScriptPluginPathsProvider } from '../utils/pluginPathsProvider';
|
||||||
import { PluginManager } from '../utils/plugins';
|
import { PluginManager } from '../utils/plugins';
|
||||||
import { TelemetryReporter } from '../utils/telemetry';
|
import { TelemetryReporter } from '../utils/telemetry';
|
||||||
|
|
|
@ -58,29 +58,31 @@ export default class TypeScriptServiceClientHost extends Disposable {
|
||||||
|
|
||||||
private reportStyleCheckAsWarnings: boolean = true;
|
private reportStyleCheckAsWarnings: boolean = true;
|
||||||
|
|
||||||
|
private readonly commandManager: CommandManager;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
descriptions: LanguageDescription[],
|
descriptions: LanguageDescription[],
|
||||||
workspaceState: vscode.Memento,
|
workspaceState: vscode.Memento,
|
||||||
onCaseInsenitiveFileSystem: boolean,
|
onCaseInsenitiveFileSystem: boolean,
|
||||||
pluginManager: PluginManager,
|
services: {
|
||||||
private readonly commandManager: CommandManager,
|
pluginManager: PluginManager,
|
||||||
logDirectoryProvider: ILogDirectoryProvider,
|
commandManager: CommandManager,
|
||||||
cancellerFactory: OngoingRequestCancellerFactory,
|
logDirectoryProvider: ILogDirectoryProvider,
|
||||||
versionProvider: ITypeScriptVersionProvider,
|
cancellerFactory: OngoingRequestCancellerFactory,
|
||||||
processFactory: TsServerProcessFactory,
|
versionProvider: ITypeScriptVersionProvider,
|
||||||
|
processFactory: TsServerProcessFactory,
|
||||||
|
},
|
||||||
onCompletionAccepted: (item: vscode.CompletionItem) => void,
|
onCompletionAccepted: (item: vscode.CompletionItem) => void,
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
const allModeIds = this.getAllModeIds(descriptions, pluginManager);
|
this.commandManager = services.commandManager;
|
||||||
|
|
||||||
|
const allModeIds = this.getAllModeIds(descriptions, services.pluginManager);
|
||||||
this.client = this._register(new TypeScriptServiceClient(
|
this.client = this._register(new TypeScriptServiceClient(
|
||||||
workspaceState,
|
workspaceState,
|
||||||
onCaseInsenitiveFileSystem,
|
onCaseInsenitiveFileSystem,
|
||||||
pluginManager,
|
services,
|
||||||
logDirectoryProvider,
|
|
||||||
cancellerFactory,
|
|
||||||
versionProvider,
|
|
||||||
processFactory,
|
|
||||||
allModeIds));
|
allModeIds));
|
||||||
|
|
||||||
this.client.onDiagnosticsReceived(({ kind, resource, diagnostics }) => {
|
this.client.onDiagnosticsReceived(({ kind, resource, diagnostics }) => {
|
||||||
|
@ -90,7 +92,7 @@ export default class TypeScriptServiceClientHost extends Disposable {
|
||||||
this.client.onConfigDiagnosticsReceived(diag => this.configFileDiagnosticsReceived(diag), null, this._disposables);
|
this.client.onConfigDiagnosticsReceived(diag => this.configFileDiagnosticsReceived(diag), null, this._disposables);
|
||||||
this.client.onResendModelsRequested(() => this.populateService(), null, this._disposables);
|
this.client.onResendModelsRequested(() => this.populateService(), null, this._disposables);
|
||||||
|
|
||||||
this._register(new VersionStatus(this.client, commandManager));
|
this._register(new VersionStatus(this.client, services.commandManager));
|
||||||
this._register(new AtaProgressReporter(this.client));
|
this._register(new AtaProgressReporter(this.client));
|
||||||
this.typingsStatus = this._register(new TypingsStatus(this.client));
|
this.typingsStatus = this._register(new TypingsStatus(this.client));
|
||||||
this.fileConfigurationManager = this._register(new FileConfigurationManager(this.client, onCaseInsenitiveFileSystem));
|
this.fileConfigurationManager = this._register(new FileConfigurationManager(this.client, onCaseInsenitiveFileSystem));
|
||||||
|
@ -111,7 +113,7 @@ export default class TypeScriptServiceClientHost extends Disposable {
|
||||||
this.client.ensureServiceStarted();
|
this.client.ensureServiceStarted();
|
||||||
this.client.onReady(() => {
|
this.client.onReady(() => {
|
||||||
const languages = new Set<string>();
|
const languages = new Set<string>();
|
||||||
for (const plugin of pluginManager.plugins) {
|
for (const plugin of services.pluginManager.plugins) {
|
||||||
if (plugin.configNamespace && plugin.languages.length) {
|
if (plugin.configNamespace && plugin.languages.length) {
|
||||||
this.registerExtensionLanguageProvider({
|
this.registerExtensionLanguageProvider({
|
||||||
id: plugin.configNamespace,
|
id: plugin.configNamespace,
|
||||||
|
|
|
@ -22,7 +22,7 @@ import API from './utils/api';
|
||||||
import { TsServerLogLevel, TypeScriptServiceConfiguration } from './utils/configuration';
|
import { TsServerLogLevel, TypeScriptServiceConfiguration } from './utils/configuration';
|
||||||
import { Disposable } from './utils/dispose';
|
import { Disposable } from './utils/dispose';
|
||||||
import * as fileSchemes from './utils/fileSchemes';
|
import * as fileSchemes from './utils/fileSchemes';
|
||||||
import Logger from './utils/logger';
|
import { Logger } from './utils/logger';
|
||||||
import { isWeb } from './utils/platform';
|
import { isWeb } from './utils/platform';
|
||||||
import { TypeScriptPluginPathsProvider } from './utils/pluginPathsProvider';
|
import { TypeScriptPluginPathsProvider } from './utils/pluginPathsProvider';
|
||||||
import { PluginManager } from './utils/plugins';
|
import { PluginManager } from './utils/plugins';
|
||||||
|
@ -119,17 +119,32 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
||||||
public readonly bufferSyncSupport: BufferSyncSupport;
|
public readonly bufferSyncSupport: BufferSyncSupport;
|
||||||
public readonly diagnosticsManager: DiagnosticsManager;
|
public readonly diagnosticsManager: DiagnosticsManager;
|
||||||
|
|
||||||
|
public readonly pluginManager: PluginManager;
|
||||||
|
private readonly logDirectoryProvider: ILogDirectoryProvider;
|
||||||
|
private readonly cancellerFactory: OngoingRequestCancellerFactory;
|
||||||
|
private readonly versionProvider: ITypeScriptVersionProvider;
|
||||||
|
private readonly processFactory: TsServerProcessFactory;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly workspaceState: vscode.Memento,
|
private readonly workspaceState: vscode.Memento,
|
||||||
onCaseInsenitiveFileSystem: boolean,
|
onCaseInsenitiveFileSystem: boolean,
|
||||||
public readonly pluginManager: PluginManager,
|
services: {
|
||||||
private readonly logDirectoryProvider: ILogDirectoryProvider,
|
pluginManager: PluginManager,
|
||||||
private readonly cancellerFactory: OngoingRequestCancellerFactory,
|
logDirectoryProvider: ILogDirectoryProvider,
|
||||||
private readonly versionProvider: ITypeScriptVersionProvider,
|
cancellerFactory: OngoingRequestCancellerFactory,
|
||||||
private readonly processFactory: TsServerProcessFactory,
|
versionProvider: ITypeScriptVersionProvider,
|
||||||
|
processFactory: TsServerProcessFactory,
|
||||||
|
},
|
||||||
allModeIds: readonly string[]
|
allModeIds: readonly string[]
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
this.pluginManager = services.pluginManager;
|
||||||
|
this.logDirectoryProvider = services.logDirectoryProvider;
|
||||||
|
this.cancellerFactory = services.cancellerFactory;
|
||||||
|
this.versionProvider = services.versionProvider;
|
||||||
|
this.processFactory = services.processFactory;
|
||||||
|
|
||||||
this.pathSeparator = path.sep;
|
this.pathSeparator = path.sep;
|
||||||
this.lastStart = Date.now();
|
this.lastStart = Date.now();
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ const localize = nls.loadMessageBundle();
|
||||||
|
|
||||||
type LogLevel = 'Trace' | 'Info' | 'Error';
|
type LogLevel = 'Trace' | 'Info' | 'Error';
|
||||||
|
|
||||||
export default class Logger {
|
export class Logger {
|
||||||
|
|
||||||
@memoize
|
@memoize
|
||||||
private get output(): vscode.OutputChannel {
|
private get output(): vscode.OutputChannel {
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
import type * as Proto from '../protocol';
|
import type * as Proto from '../protocol';
|
||||||
import Logger from './logger';
|
import { Logger } from './logger';
|
||||||
|
|
||||||
enum Trace {
|
enum Trace {
|
||||||
Off,
|
Off,
|
||||||
|
|
Loading…
Reference in a new issue