From 729a0f33d4de50a1a54bcd1ecfffd3b0782a135b Mon Sep 17 00:00:00 2001 From: Anton Makeev Date: Tue, 2 Dec 2014 22:55:47 +0100 Subject: [PATCH] Platform: CacheInvalidator api improved 'invalidator' word added to the dictionary --- ...nvalidater.java => CachesInvalidator.java} | 18 ++++++--- .../ide/actions/InvalidateCachesAction.java | 39 ++++++++++++++++--- .../src/META-INF/PlatformExtensionPoints.xml | 2 +- .../src/com/intellij/spellchecker/english.dic | 1 + 4 files changed, 49 insertions(+), 11 deletions(-) rename platform/platform-api/src/com/intellij/ide/caches/{CachesInvalidater.java => CachesInvalidator.java} (55%) diff --git a/platform/platform-api/src/com/intellij/ide/caches/CachesInvalidater.java b/platform/platform-api/src/com/intellij/ide/caches/CachesInvalidator.java similarity index 55% rename from platform/platform-api/src/com/intellij/ide/caches/CachesInvalidater.java rename to platform/platform-api/src/com/intellij/ide/caches/CachesInvalidator.java index 785fa59e488d..d5d133e33f31 100644 --- a/platform/platform-api/src/com/intellij/ide/caches/CachesInvalidater.java +++ b/platform/platform-api/src/com/intellij/ide/caches/CachesInvalidator.java @@ -16,13 +16,21 @@ package com.intellij.ide.caches; import com.intellij.openapi.extensions.ExtensionPointName; +import org.jetbrains.annotations.Nullable; + +public abstract class CachesInvalidator { + public static final ExtensionPointName EP_NAME = ExtensionPointName.create("com.intellij.cachesInvalidator"); -public interface CachesInvalidater { - ExtensionPointName EP_NAME = ExtensionPointName.create("com.intellij.cachesInvalidater"); /** - * The method should not consume significant time e.g. all the clearing operations should be executed next time the corresponding cache is - * required or checked for existing. + * @return description of the caches to be cleared, shown in the warning dialog to the user */ - void invalidateCaches(); + @Nullable + public String getDescription() { return null; } + + /** + * The method should not consume significant time. + * All the clearing operations should be executed after IDE relaunches. + */ + public abstract void invalidateCaches(); } diff --git a/platform/platform-impl/src/com/intellij/ide/actions/InvalidateCachesAction.java b/platform/platform-impl/src/com/intellij/ide/actions/InvalidateCachesAction.java index 74f84828212e..590e30c10e9a 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/InvalidateCachesAction.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/InvalidateCachesAction.java @@ -15,7 +15,7 @@ */ package com.intellij.ide.actions; -import com.intellij.ide.caches.CachesInvalidater; +import com.intellij.ide.caches.CachesInvalidator; import com.intellij.internal.statistic.UsageTrigger; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; @@ -25,9 +25,16 @@ import com.intellij.openapi.application.ex.ApplicationEx; import com.intellij.openapi.application.ex.ApplicationManagerEx; import com.intellij.openapi.project.DumbAware; import com.intellij.openapi.ui.Messages; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.newvfs.persistent.FSRecords; +import com.intellij.util.Function; +import com.intellij.util.SmartList; +import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; +import java.util.Collections; +import java.util.List; + public class InvalidateCachesAction extends AnAction implements DumbAware { @Override @@ -49,10 +56,32 @@ public class InvalidateCachesAction extends AnAction implements DumbAware { options[3] = "Just Restart"; } + List descriptions = new SmartList(); + descriptions.add("Local History"); + for (CachesInvalidator invalidater : CachesInvalidator.EP_NAME.getExtensions()) { + ContainerUtil.addIfNotNull(descriptions, invalidater.getDescription()); + } + Collections.sort(descriptions); + + String warnings = "WARNING: "; + if (descriptions.size() == 1) { + warnings += descriptions.get(0) + " will be also cleared."; + } + else { + warnings += "The following items will also be cleared:\n" + + StringUtil.join(descriptions, new Function() { + @Override + public String fun(String s) { + return " " + s; + } + }, "\n"); + } + + String message = "The caches will be invalidated and rebuilt on the next startup.\n\n" + + warnings + "\n\n" + + "Would you like to continue?\n"; int result = Messages.showDialog(e.getData(CommonDataKeys.PROJECT), - "The caches will be invalidated and rebuilt on the next startup.\n" + - "WARNING: Local History will be also cleared.\n\n" + - "Would you like to continue?\n\n", + message, "Invalidate Caches", options, 0, Messages.getWarningIcon()); @@ -69,7 +98,7 @@ public class InvalidateCachesAction extends AnAction implements DumbAware { UsageTrigger.trigger(ApplicationManagerEx.getApplicationEx().getName() + ".caches.invalidated"); FSRecords.invalidateCaches(); - for (CachesInvalidater invalidater : CachesInvalidater.EP_NAME.getExtensions()) { + for (CachesInvalidator invalidater : CachesInvalidator.EP_NAME.getExtensions()) { invalidater.invalidateCaches(); } diff --git a/platform/platform-resources/src/META-INF/PlatformExtensionPoints.xml b/platform/platform-resources/src/META-INF/PlatformExtensionPoints.xml index 55ebe6154f45..a26f4ca56cd5 100644 --- a/platform/platform-resources/src/META-INF/PlatformExtensionPoints.xml +++ b/platform/platform-resources/src/META-INF/PlatformExtensionPoints.xml @@ -238,6 +238,6 @@ - + diff --git a/spellchecker/src/com/intellij/spellchecker/english.dic b/spellchecker/src/com/intellij/spellchecker/english.dic index 1395ee7f3fb5..a5ae07c3ada7 100644 --- a/spellchecker/src/com/intellij/spellchecker/english.dic +++ b/spellchecker/src/com/intellij/spellchecker/english.dic @@ -79703,6 +79703,7 @@ invalidates invalidating invalidation invalidation's +invalidator invalided invaliding invalidism