From 4c4a1f2e03f0571635b39dafde09ef91029cdbb0 Mon Sep 17 00:00:00 2001 From: Vincent Fugnitto Date: Mon, 16 Dec 2019 07:14:35 -0500 Subject: [PATCH] Fix circular dependencies from 'task' extension - fixed the circular dependencies from the `@theia/task` extension. Signed-off-by: Vincent Fugnitto --- packages/task/src/browser/quick-open-task.ts | 51 ++++++++++++++++-- .../task/src/browser/task-action-provider.ts | 52 +------------------ .../task/src/browser/task-frontend-module.ts | 3 +- 3 files changed, 50 insertions(+), 56 deletions(-) diff --git a/packages/task/src/browser/quick-open-task.ts b/packages/task/src/browser/quick-open-task.ts index 6d42684fdf6db..46f14373d2ddf 100644 --- a/packages/task/src/browser/quick-open-task.ts +++ b/packages/task/src/browser/quick-open-task.ts @@ -19,16 +19,61 @@ import { TaskService } from './task-service'; import { TaskInfo, TaskConfiguration, TaskCustomization } from '../common/task-protocol'; import { TaskDefinitionRegistry } from './task-definition-registry'; import URI from '@theia/core/lib/common/uri'; -import { TaskActionProvider } from './task-action-provider'; -import { QuickOpenHandler, QuickOpenService, QuickOpenOptions } from '@theia/core/lib/browser'; +import { QuickOpenHandler, QuickOpenService, QuickOpenOptions, QuickOpenBaseAction } from '@theia/core/lib/browser'; import { WorkspaceService } from '@theia/workspace/lib/browser'; import { TerminalService } from '@theia/terminal/lib/browser/base/terminal-service'; import { FileSystem } from '@theia/filesystem/lib/common'; -import { QuickOpenModel, QuickOpenItem, QuickOpenActionProvider, QuickOpenMode, QuickOpenGroupItem, QuickOpenGroupItemOptions } from '@theia/core/lib/common/quick-open-model'; +import { QuickOpenModel, QuickOpenItem, QuickOpenActionProvider, QuickOpenMode, QuickOpenGroupItem, QuickOpenGroupItemOptions, QuickOpenAction } from '@theia/core/lib/common/quick-open-model'; import { PreferenceService } from '@theia/core/lib/browser'; import { TaskNameResolver } from './task-name-resolver'; import { TaskSourceResolver } from './task-source-resolver'; import { TaskConfigurationManager } from './task-configuration-manager'; +import { ThemeService } from '@theia/core/lib/browser/theming'; + +@injectable() +export class ConfigureTaskAction extends QuickOpenBaseAction { + + @inject(TaskService) + protected readonly taskService: TaskService; + + constructor() { + super({ id: 'configure:task' }); + + this.updateTheme(); + + ThemeService.get().onThemeChange(() => this.updateTheme()); + } + + async run(item?: QuickOpenItem): Promise { + if (item instanceof TaskRunQuickOpenItem) { + this.taskService.configure(item.getTask()); + } + } + + protected updateTheme(): void { + const theme = ThemeService.get().getCurrentTheme().id; + if (theme === 'dark') { + this.class = 'quick-open-task-configure-dark'; + } else if (theme === 'light') { + this.class = 'quick-open-task-configure-bright'; + } + } +} + +@injectable() +export class TaskActionProvider implements QuickOpenActionProvider { + + @inject(ConfigureTaskAction) + protected configureTaskAction: ConfigureTaskAction; + + hasActions(): boolean { + return true; + } + + getActions(): ReadonlyArray { + return [this.configureTaskAction]; + } +} @injectable() export class QuickOpenTask implements QuickOpenModel, QuickOpenHandler { diff --git a/packages/task/src/browser/task-action-provider.ts b/packages/task/src/browser/task-action-provider.ts index 514fc73f1a23b..8882a0f889259 100644 --- a/packages/task/src/browser/task-action-provider.ts +++ b/packages/task/src/browser/task-action-provider.ts @@ -14,54 +14,4 @@ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 ********************************************************************************/ -import { injectable, inject } from 'inversify'; -import { TaskService } from './task-service'; -import { TaskRunQuickOpenItem } from './quick-open-task'; -import { QuickOpenBaseAction, QuickOpenItem } from '@theia/core/lib/browser/quick-open'; -import { QuickOpenAction, QuickOpenActionProvider } from '@theia/core/lib/common/quick-open-model'; -import { ThemeService } from '@theia/core/lib/browser/theming'; - -@injectable() -export class ConfigureTaskAction extends QuickOpenBaseAction { - - @inject(TaskService) - protected readonly taskService: TaskService; - - constructor() { - super({ id: 'configure:task' }); - - this.updateTheme(); - - ThemeService.get().onThemeChange(() => this.updateTheme()); - } - - async run(item?: QuickOpenItem): Promise { - if (item instanceof TaskRunQuickOpenItem) { - this.taskService.configure(item.getTask()); - } - } - - protected updateTheme(): void { - const theme = ThemeService.get().getCurrentTheme().id; - if (theme === 'dark') { - this.class = 'quick-open-task-configure-dark'; - } else if (theme === 'light') { - this.class = 'quick-open-task-configure-bright'; - } - } -} - -@injectable() -export class TaskActionProvider implements QuickOpenActionProvider { - - @inject(ConfigureTaskAction) - protected configureTaskAction: ConfigureTaskAction; - - hasActions(): boolean { - return true; - } - - getActions(): ReadonlyArray { - return [this.configureTaskAction]; - } -} +export { ConfigureTaskAction, TaskActionProvider } from './quick-open-task'; diff --git a/packages/task/src/browser/task-frontend-module.ts b/packages/task/src/browser/task-frontend-module.ts index cc28be6be3965..38c99f291eab0 100644 --- a/packages/task/src/browser/task-frontend-module.ts +++ b/packages/task/src/browser/task-frontend-module.ts @@ -18,7 +18,7 @@ import { ContainerModule } from 'inversify'; import { FrontendApplicationContribution, QuickOpenContribution, KeybindingContribution } from '@theia/core/lib/browser'; import { CommandContribution, MenuContribution, bindContributionProvider } from '@theia/core/lib/common'; import { WebSocketConnectionProvider } from '@theia/core/lib/browser/messaging'; -import { QuickOpenTask, TaskTerminateQuickOpen, TaskRunningQuickOpen } from './quick-open-task'; +import { QuickOpenTask, TaskTerminateQuickOpen, TaskRunningQuickOpen, TaskActionProvider, ConfigureTaskAction } from './quick-open-task'; import { TaskContribution, TaskProviderRegistry, TaskResolverRegistry } from './task-contribution'; import { TaskService } from './task-service'; import { TaskConfigurations } from './task-configurations'; @@ -29,7 +29,6 @@ import { TaskServer, taskPath } from '../common/task-protocol'; import { TaskWatcher } from '../common/task-watcher'; import { bindProcessTaskModule } from './process/process-task-frontend-module'; import { TaskSchemaUpdater } from './task-schema-updater'; -import { TaskActionProvider, ConfigureTaskAction } from './task-action-provider'; import { TaskDefinitionRegistry } from './task-definition-registry'; import { ProblemMatcherRegistry } from './task-problem-matcher-registry'; import { ProblemPatternRegistry } from './task-problem-pattern-registry';