more sane API for avoiding leaks in tests

This commit is contained in:
Alexey Kudravtsev
2015-04-21 14:25:35 +03:00
parent 780bd19447
commit 52c3ce11e5
3 changed files with 31 additions and 5 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,6 +15,7 @@
*/
package com.intellij.tasks;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vcs.AbstractVcs;
@@ -136,8 +137,12 @@ public abstract class TaskManager {
public abstract void removeTask(LocalTask task);
@Deprecated // use {@code com.intellij.tasks.TaskManager.addTaskListener(com.intellij.tasks.TaskListener, com.intellij.openapi.Disposable)}
public abstract void addTaskListener(TaskListener listener);
public abstract void addTaskListener(@NotNull TaskListener listener, @NotNull Disposable parentDisposable);
@Deprecated // use {@code com.intellij.tasks.TaskManager.addTaskListener(com.intellij.tasks.TaskListener, com.intellij.openapi.Disposable)}
public abstract void removeTaskListener(TaskListener listener);
// repositories management
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
package com.intellij.tasks.impl;
import com.intellij.notification.*;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.*;
import com.intellij.openapi.diagnostic.Logger;
@@ -224,6 +225,11 @@ public class TaskManagerImpl extends TaskManager implements ProjectComponent, Pe
myDispatcher.addListener(listener);
}
@Override
public void addTaskListener(@NotNull TaskListener listener, @NotNull Disposable parentDisposable) {
myDispatcher.addListener(listener, parentDisposable);
}
@Override
public void removeTaskListener(TaskListener listener) {
myDispatcher.removeListener(listener);
@@ -1,3 +1,18 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.tasks;
import com.intellij.tasks.impl.TaskManagerImpl;
@@ -16,19 +31,19 @@ public abstract class TaskManagerTestCase extends LightCodeInsightFixtureTestCas
IdeaTestCase.initPlatformPrefix();
}
protected TaskManagerImpl myTaskManager;
protected TaskManager myTaskManager;
@Override
protected void setUp() throws Exception {
super.setUp();
myTaskManager = (TaskManagerImpl)TaskManager.getManager(getProject());
myTaskManager = TaskManager.getManager(getProject());
removeAllTasks();
}
@Override
protected void tearDown() throws Exception {
try {
myTaskManager.setRepositories(Collections.<TaskRepository>emptyList());
((TaskManagerImpl)myTaskManager).setRepositories(Collections.<TaskRepository>emptyList());
removeAllTasks();
}
finally {