diff --git a/CHANGELOG.md b/CHANGELOG.md index a24fd577b1988..b183f792fc7e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/packages/task/src/browser/task-service.ts b/packages/task/src/browser/task-service.ts index 8b81387706505..9bbf58e07f056 100644 --- a/packages/task/src/browser/task-service.ts +++ b/packages/task/src/browser/task-service.ts @@ -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'; @@ -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; @@ -94,6 +96,8 @@ export class TaskService implements TaskConfigurationClient { terminateSignal: Deferred, isBackgroundTaskEnded: Deferred }>(); + // URIs of the opened documents + protected openedDocuments: Set = new Set(); @inject(FrontendApplication) protected readonly app: FrontendApplication; @@ -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 { @@ -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, []));