Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[task] fix circular dependencies from 'task' extension #6756

Merged
merged 1 commit into from
Dec 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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