Platform:

CacheInvalidator api improved
'invalidator' word added to the dictionary
This commit is contained in:
Anton Makeev
2014-12-02 22:55:47 +01:00
parent bbeae5cd2e
commit 729a0f33d4
4 changed files with 49 additions and 11 deletions
@@ -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<CachesInvalidator> EP_NAME = ExtensionPointName.create("com.intellij.cachesInvalidator");
public interface CachesInvalidater {
ExtensionPointName<CachesInvalidater> 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();
}
@@ -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<String> descriptions = new SmartList<String>();
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<String, String>() {
@Override
public String fun(String s) {
return " " + s;
}
}, "\n");
}
String message = "<html>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();
}
@@ -238,6 +238,6 @@
<extensionPoint name="actionFromOptionDescriptorProvider" interface="com.intellij.ide.ui.search.ActionFromOptionDescriptorProvider"/>
<extensionPoint name="cachesInvalidater" interface="com.intellij.ide.caches.CachesInvalidater"/>
<extensionPoint name="cachesInvalidator" interface="com.intellij.ide.caches.CachesInvalidator"/>
</extensionPoints>
</idea-plugin>
@@ -79703,6 +79703,7 @@ invalidates
invalidating
invalidation
invalidation's
invalidator
invalided
invaliding
invalidism