Skip to content

Commit

Permalink
fixed "applyTo" property in task problem matcher
Browse files Browse the repository at this point in the history
- With this change, "applyTo" can be used as a property to control if a problem reported on a text document is applied only to open, closed or all documents.
- fixed #7396

Signed-off-by: Liang Huang <[email protected]>
  • Loading branch information
elaihau committed Mar 25, 2020
1 parent 8152c55 commit 2e3e202
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 18 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ Breaking changes:
renamed to ScmHistoryWidget. GitNavigableListWidget has also moved.
CSS classes have been moved renamed accordingly. [6381](https://github.com/eclipse-theia/theia/pull/6381)
- [task] `TaskRestartRunningQuickOpenItem` class is renamed into `RunningTaskQuickOpenItem`. [7392](https://github.com/eclipse-theia/theia/pull/7392)
- [task] `TaskAttachQuickOpenItem` class is removed.
- [task] `TaskAttachQuickOpenItem` class is removed. [7392](https://github.com/eclipse-theia/theia/pull/7392)
- [task] `TaskService.taskProviderRegistry` is removed. [7418](https://github.com/eclipse-theia/theia/pull/7418)

## v0.16.0

Expand Down
42 changes: 25 additions & 17 deletions packages/task/src/browser/task-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,13 @@ import {
TaskServer,
TaskIdentifier,
DependsOrder,
RevealKind
RevealKind,
ApplyToKind
} from '../common';
import { TaskWatcher } from '../common/task-watcher';
import { ProvidedTaskConfigurations } from './provided-task-configurations';
import { TaskConfigurationClient, TaskConfigurations } from './task-configurations';
import { TaskProviderRegistry, TaskResolverRegistry } from './task-contribution';
import { TaskResolverRegistry } from './task-contribution';
import { TaskDefinitionRegistry } from './task-definition-registry';
import { TaskNameResolver } from './task-name-resolver';
import { TaskSourceResolver } from './task-source-resolver';
Expand All @@ -60,6 +61,7 @@ import { TaskSchemaUpdater } from './task-schema-updater';
import { TaskConfigurationManager } from './task-configuration-manager';
import { PROBLEMS_WIDGET_ID, ProblemWidget } from '@theia/markers/lib/browser/problem/problem-widget';
import { TaskNode } from './task-node';
import { MonacoWorkspace } from '@theia/monaco/lib/browser/monaco-workspace';

export interface QuickPickProblemMatcherItem {
problemMatchers: NamedProblemMatcher[] | undefined;
Expand Down Expand Up @@ -94,6 +96,8 @@ export class TaskService implements TaskConfigurationClient {
terminateSignal: Deferred<string | undefined>,
isBackgroundTaskEnded: Deferred<boolean | undefined>
}>();
// URIs of the opened documents
protected openedDocuments: Set<string> = new Set();

@inject(FrontendApplication)
protected readonly app: FrontendApplication;
Expand Down Expand Up @@ -169,11 +173,9 @@ export class TaskService implements TaskConfigurationClient {

@inject(LabelProvider)
protected readonly labelProvider: LabelProvider;
/**
* @deprecated To be removed in 0.5.0
*/
@inject(TaskProviderRegistry)
protected readonly taskProviderRegistry: TaskProviderRegistry;

@inject(MonacoWorkspace)
protected monacoWorkspace: MonacoWorkspace;

@postConstruct()
protected init(): void {
Expand Down Expand Up @@ -236,16 +238,22 @@ export class TaskService implements TaskConfigurationClient {
}
}
const uri = new URI(problem.resource.path).withScheme(problem.resource.scheme);
if (uris.has(uri.toString())) {
const newData = [
...existingMarkers
.filter(marker => marker.uri === uri.toString())
.map(markerData => markerData.data),
problem.marker
];
this.problemManager.setMarkers(uri, problem.description.owner, newData);
} else {
this.problemManager.setMarkers(uri, problem.description.owner, [problem.marker]);
const document = this.monacoWorkspace.getTextDocument(uri.toString());
if (problem.description.applyTo === ApplyToKind.openDocuments && !!document ||
problem.description.applyTo === ApplyToKind.closedDocuments && !document ||
problem.description.applyTo === ApplyToKind.allDocuments
) {
if (uris.has(uri.toString())) {
const newData = [
...existingMarkers
.filter(marker => marker.uri === uri.toString())
.map(markerData => markerData.data),
problem.marker
];
this.problemManager.setMarkers(uri, problem.description.owner, newData);
} else {
this.problemManager.setMarkers(uri, problem.description.owner, [problem.marker]);
}
}
} else { // should have received an event for finding the "background task begins" pattern
uris.forEach(uriString => this.problemManager.setMarkers(new URI(uriString), problem.description.owner, []));
Expand Down

0 comments on commit 2e3e202

Please sign in to comment.