use of com.intellij.openapi.editor.impl.event.EditorEventMulticasterImpl in project intellij-community by JetBrains.
the class EditorListenerTracker method checkListenersLeak.
public void checkListenersLeak() throws AssertionError {
try {
// listeners may hang on default project
if (myDefaultProjectInitialized != ((ProjectManagerImpl) ProjectManager.getInstance()).isDefaultProjectInitialized())
return;
EditorEventMulticasterImpl multicaster = (EditorEventMulticasterImpl) EditorFactory.getInstance().getEventMulticaster();
Map<Class, List> after = multicaster.getListeners();
Map<Class, List> leaked = new LinkedHashMap<>();
for (Map.Entry<Class, List> entry : after.entrySet()) {
Class aClass = entry.getKey();
List beforeList = before.get(aClass);
List afterList = entry.getValue();
if (beforeList != null) {
afterList.removeAll(beforeList);
}
if (!afterList.isEmpty()) {
leaked.put(aClass, afterList);
}
}
for (Map.Entry<Class, List> entry : leaked.entrySet()) {
Class aClass = entry.getKey();
List list = entry.getValue();
Assert.fail("Listeners leaked for " + aClass + ":\n" + list);
}
} finally {
before.clear();
}
}
Aggregations