diff --git a/platform/indexing-api/src/com/intellij/lang/findUsages/LanguageFindUsages.java b/platform/indexing-api/src/com/intellij/lang/findUsages/LanguageFindUsages.java index d34a35e743af..ee31ac8e006c 100644 --- a/platform/indexing-api/src/com/intellij/lang/findUsages/LanguageFindUsages.java +++ b/platform/indexing-api/src/com/intellij/lang/findUsages/LanguageFindUsages.java @@ -53,7 +53,7 @@ public class LanguageFindUsages extends LanguageExtension { * @return true iff could be found usages by some provider for this element */ public static boolean canFindUsagesFor(@NotNull PsiElement psiElement) { - return applyForProviders(p -> p.canFindUsagesFor(psiElement), psiElement, Boolean.FALSE); + return getFromProviders(psiElement, Boolean.FALSE, p -> p.canFindUsagesFor(psiElement)); } /** @@ -77,7 +77,7 @@ public class LanguageFindUsages extends LanguageExtension { */ @NotNull public static String getDescriptiveName(@NotNull PsiElement psiElement) { - return applyForProviders(p -> p.getDescriptiveName(psiElement), psiElement, ""); + return getFromProviders(psiElement, "", p -> p.getDescriptiveName(psiElement)); } /** @@ -86,7 +86,7 @@ public class LanguageFindUsages extends LanguageExtension { */ @NotNull public static String getType(@NotNull PsiElement psiElement) { - return applyForProviders(p -> p.getType(psiElement), psiElement, ""); + return getFromProviders(psiElement, "", p -> p.getType(psiElement)); } /** @@ -95,7 +95,7 @@ public class LanguageFindUsages extends LanguageExtension { */ @NotNull public static String getNodeText(@NotNull PsiElement psiElement, boolean useFullName) { - return applyForProviders(p -> p.getNodeText(psiElement, useFullName), psiElement, ""); + return getFromProviders(psiElement, "", p -> p.getNodeText(psiElement, useFullName)); } /** @@ -104,16 +104,17 @@ public class LanguageFindUsages extends LanguageExtension { */ @Nullable public static String getHelpId(@NotNull PsiElement psiElement) { - return applyForProviders(p -> p.getHelpId(psiElement), psiElement, null); + return getFromProviders(psiElement, null, p -> p.getHelpId(psiElement)); } - private static T applyForProviders(@NotNull Function method, @NotNull PsiElement psiElement, T defaultValue) { + private static T getFromProviders(@NotNull PsiElement psiElement, + T defaultValue, @NotNull Function getter) { Language language = psiElement.getLanguage(); List providers = INSTANCE.allForLanguage(language); assert !providers.isEmpty() : "Element: " + psiElement + ", language: " + language; for (FindUsagesProvider provider : providers) { - T res = method.apply(provider); + T res = getter.apply(provider); if (res != null && !res.equals(defaultValue)) { return res; } diff --git a/platform/lvcs-impl/src/com/intellij/history/integration/LocalHistoryEventDispatcher.java b/platform/lvcs-impl/src/com/intellij/history/integration/LocalHistoryEventDispatcher.java index dea55b127bf7..2fb167ec08bf 100644 --- a/platform/lvcs-impl/src/com/intellij/history/integration/LocalHistoryEventDispatcher.java +++ b/platform/lvcs-impl/src/com/intellij/history/integration/LocalHistoryEventDispatcher.java @@ -29,11 +29,10 @@ import com.intellij.openapi.vfs.newvfs.BulkFileListener; import com.intellij.openapi.vfs.newvfs.events.VFileEvent; import com.intellij.util.EventDispatcher; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import java.util.List; -public class LocalHistoryEventDispatcher implements VirtualFileManagerListener, CommandListener, +class LocalHistoryEventDispatcher implements VirtualFileManagerListener, CommandListener, BulkFileListener, VirtualFileListener { private static final Key WAS_VERSIONED_KEY = Key.create(LocalHistoryEventDispatcher.class.getSimpleName() + ".WAS_VERSIONED_KEY"); @@ -42,7 +41,7 @@ public class LocalHistoryEventDispatcher implements VirtualFileManagerListener, private final IdeaGateway myGateway; private final EventDispatcher myVfsEventsDispatcher = EventDispatcher.create(VirtualFileListener.class); - public LocalHistoryEventDispatcher(LocalHistoryFacade vcs, IdeaGateway gw) { + LocalHistoryEventDispatcher(LocalHistoryFacade vcs, IdeaGateway gw) { myVcs = vcs; myGateway = gw; myVfsEventsDispatcher.addListener(this); @@ -68,12 +67,12 @@ public class LocalHistoryEventDispatcher implements VirtualFileManagerListener, endChangeSet(e.getCommandName()); } - public void startAction() { + void startAction() { myGateway.registerUnsavedDocuments(myVcs); myVcs.forceBeginChangeSet(); } - public void finishAction(String name) { + void finishAction(String name) { myGateway.registerUnsavedDocuments(myVcs); endChangeSet(name); } @@ -103,7 +102,6 @@ public class LocalHistoryEventDispatcher implements VirtualFileManagerListener, return true; } - @Nullable @Override public Iterable getChildrenIterable(@NotNull VirtualFile f) { // For unversioned files we try to get cached children in hope that they are already generated by content root manager: @@ -213,7 +211,7 @@ public class LocalHistoryEventDispatcher implements VirtualFileManagerListener, }); } - public void addVirtualFileListener(VirtualFileListener virtualFileListener, Disposable disposable) { + void addVirtualFileListener(VirtualFileListener virtualFileListener, Disposable disposable) { myVfsEventsDispatcher.addListener(virtualFileListener, disposable); } } \ No newline at end of file