Skip to content

Commit

Permalink
Fix circular dependencies from 'task' extension
Browse files Browse the repository at this point in the history
- fixed the circular dependencies from the `@theia/task` extension.

Signed-off-by: Vincent Fugnitto <[email protected]>
  • Loading branch information
vince-fugnitto committed Dec 17, 2019
1 parent 582ae9d commit 4c4a1f2
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 56 deletions.
51 changes: 48 additions & 3 deletions packages/task/src/browser/quick-open-task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
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<QuickOpenAction> {
return [this.configureTaskAction];
}
}

@injectable()
export class QuickOpenTask implements QuickOpenModel, QuickOpenHandler {
Expand Down
52 changes: 1 addition & 51 deletions packages/task/src/browser/task-action-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
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<QuickOpenAction> {
return [this.configureTaskAction];
}
}
export { ConfigureTaskAction, TaskActionProvider } from './quick-open-task';
3 changes: 1 addition & 2 deletions packages/task/src/browser/task-frontend-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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';
Expand Down

0 comments on commit 4c4a1f2

Please sign in to comment.