Make extension point listeners API more robust

- explicit listener for extension point list change, which is called only once for bulk changes
- deduplication and cleanup of notification code

GitOrigin-RevId: e49d3bf23ad860d2aa129b7c1bb329d83080d47f
This commit is contained in:
Piotr Tomiak
2019-12-23 22:07:50 +01:00
committed by intellij-monorepo-bot
parent 81a2a874b5
commit 5dcee28701
22 changed files with 159 additions and 254 deletions

View File

@@ -12,9 +12,7 @@ import com.intellij.openapi.components.PersistentStateComponent;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.components.State;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.extensions.ExtensionPointListener;
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.openapi.extensions.PluginDescriptor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.JDOMExternalizableStringList;
@@ -79,25 +77,17 @@ public abstract class EntryPointsManagerBase extends EntryPointsManager implemen
myProject = project;
myTemporaryEntryPoints = new HashSet<>();
myPersistentEntryPoints = new LinkedHashMap<>(); // To keep the order between readExternal to writeExternal
DEAD_CODE_EP_NAME.addExtensionPointListener(new ExtensionPointListener<EntryPoint>() {
@Override
public void extensionAdded(@NotNull EntryPoint extension, @NotNull PluginDescriptor pluginDescriptor) {
extensionRemoved(extension, pluginDescriptor);
}
@Override
public void extensionRemoved(@NotNull EntryPoint extension, @NotNull PluginDescriptor pluginDescriptor) {
if (ADDITIONAL_ANNOS != null) {
ADDITIONAL_ANNOS = null;
UIUtil.invokeLaterIfNeeded(() -> {
if (!project.isDisposed()) {
ProjectInspectionProfileManager.getInstance(project).fireProfileChanged();
}
});
}
// annotations changed
DaemonCodeAnalyzer.getInstance(myProject).restart();
DEAD_CODE_EP_NAME.addExtensionPointListener(() -> {
if (ADDITIONAL_ANNOS != null) {
ADDITIONAL_ANNOS = null;
UIUtil.invokeLaterIfNeeded(() -> {
if (!project.isDisposed()) {
ProjectInspectionProfileManager.getInstance(project).fireProfileChanged();
}
});
}
// annotations changed
DaemonCodeAnalyzer.getInstance(myProject).restart();
}, this);
}