Skip to content

Commit

Permalink
Make task definition, problem pattern, and problem matcher dynamic
Browse files Browse the repository at this point in the history
  • Loading branch information
alexr00 committed Jan 25, 2019
1 parent 7efcf23 commit 48d48a0
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 9 deletions.
30 changes: 24 additions & 6 deletions src/vs/workbench/parts/tasks/common/problemMatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1092,7 +1092,8 @@ const problemPatternExtPoint = ExtensionsRegistry.registerExtensionPoint<Config.
Schemas.NamedMultiLineProblemPattern
]
}
}
},
isDynamic: true
});

export interface IProblemPatternRegistry {
Expand All @@ -1110,10 +1111,18 @@ class ProblemPatternRegistryImpl implements IProblemPatternRegistry {
this.patterns = Object.create(null);
this.fillDefaults();
this.readyPromise = new Promise<void>((resolve, reject) => {
problemPatternExtPoint.setHandler((extensions) => {
problemPatternExtPoint.setHandler((extensions, delta) => {
// We get all statically know extension during startup in one batch
try {
extensions.forEach(extension => {
delta.removed.forEach(extension => {
let problemPatterns = extension.value as Config.NamedProblemPatterns;
for (let pattern of problemPatterns) {
if (this.patterns[pattern.name]) {
delete this.patterns[pattern.name];
}
}
});
delta.added.forEach(extension => {
let problemPatterns = extension.value as Config.NamedProblemPatterns;
let parser = new ProblemPatternParser(new ExtensionRegistryReporter(extension.collector));
for (let pattern of problemPatterns) {
Expand Down Expand Up @@ -1664,7 +1673,8 @@ const problemMatchersExtPoint = ExtensionsRegistry.registerExtensionPoint<Config
description: localize('ProblemMatcherExtPoint', 'Contributes problem matchers'),
type: 'array',
items: Schemas.NamedProblemMatcher
}
},
isDynamic: true
});

export interface IProblemMatcherRegistry {
Expand All @@ -1682,9 +1692,17 @@ class ProblemMatcherRegistryImpl implements IProblemMatcherRegistry {
this.matchers = Object.create(null);
this.fillDefaults();
this.readyPromise = new Promise<void>((resolve, reject) => {
problemMatchersExtPoint.setHandler((extensions) => {
problemMatchersExtPoint.setHandler((extensions, delta) => {
try {
extensions.forEach(extension => {
delta.removed.forEach(extension => {
let problemMatchers = extension.value;
for (let matcher of problemMatchers) {
if (this.matchers[matcher.name]) {
delete this.matchers[matcher.name];
}
}
});
delta.added.forEach(extension => {
let problemMatchers = extension.value;
let parser = new ProblemMatcherParser(new ExtensionRegistryReporter(extension.collector));
for (let matcher of problemMatchers) {
Expand Down
15 changes: 12 additions & 3 deletions src/vs/workbench/parts/tasks/common/taskDefinitionRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ const taskDefinitionsExtPoint = ExtensionsRegistry.registerExtensionPoint<Config
description: nls.localize('TaskDefinitionExtPoint', 'Contributes task kinds'),
type: 'array',
items: taskDefinitionSchema
}
},
isDynamic: true
});

export interface ITaskDefinitionRegistry {
Expand All @@ -94,9 +95,17 @@ class TaskDefinitionRegistryImpl implements ITaskDefinitionRegistry {
constructor() {
this.taskTypes = Object.create(null);
this.readyPromise = new Promise<void>((resolve, reject) => {
taskDefinitionsExtPoint.setHandler((extensions) => {
taskDefinitionsExtPoint.setHandler((extensions, delta) => {
try {
for (let extension of extensions) {
for (let extension of delta.removed) {
let taskTypes = extension.value;
for (let taskType of taskTypes) {
if (this.taskTypes && this.taskTypes[taskType.type]) {
delete this.taskTypes[taskType.type];
}
}
}
for (let extension of delta.added) {
let taskTypes = extension.value;
for (let taskType of taskTypes) {
let type = Configuration.from(taskType, extension.description.identifier, extension.collector);
Expand Down

0 comments on commit 48d48a0

Please sign in to comment.