From 2848a9492629e0d4e85da37760d3b5337e50c9e9 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Mon, 28 Jan 2019 03:22:09 +0300 Subject: [PATCH] cleanup: fix signatures --- .../library/DownloadableLibraryType.java | 2 +- .../libraries/LibraryPresentationManager.java | 6 ++-- .../impl/LibraryPresentationManagerImpl.java | 6 ++-- .../roots/libraries/LibrariesHelperImpl.java | 3 +- .../libraries/JarVersionDetectionUtil.java | 2 +- .../roots/libraries/LibrariesHelper.java | 3 +- .../openapi/roots/impl/LibraryScopeCache.java | 16 ++++----- .../filters/HyperlinkInfoFactory.java | 4 +-- .../impl/HyperlinkInfoFactoryImpl.java | 4 +-- .../LibraryDetectionManagerImpl.java | 12 +++---- .../libraries/LibraryDetectionManager.java | 4 +-- .../openapi/roots/OrderEnumerator.java | 31 ++++++++++++++--- .../roots/impl/ModifiableModelCommitter.java | 7 ++-- .../roots/impl/OrderEnumeratorBase.java | 27 +++++++++++---- .../roots/impl/ProjectOrderEnumerator.java | 4 +-- .../openapi/roots/impl/RootIndex.java | 34 +++++++++---------- 16 files changed, 102 insertions(+), 63 deletions(-) diff --git a/java/idea-ui/src/com/intellij/framework/library/DownloadableLibraryType.java b/java/idea-ui/src/com/intellij/framework/library/DownloadableLibraryType.java index 8ffb0d464890..9fa119a7ef79 100644 --- a/java/idea-ui/src/com/intellij/framework/library/DownloadableLibraryType.java +++ b/java/idea-ui/src/com/intellij/framework/library/DownloadableLibraryType.java @@ -74,7 +74,7 @@ public abstract class DownloadableLibraryType extends LibraryType classesRoots, String detectionClass) { + private static LibraryVersionProperties detectVersion(List classesRoots, String detectionClass) { if (!LibraryUtil.isClassAvailableInLibrary(classesRoots, detectionClass)) { return null; } diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/LibraryPresentationManager.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/LibraryPresentationManager.java index 67584fd34732..e51e1175b751 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/LibraryPresentationManager.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/LibraryPresentationManager.java @@ -50,11 +50,11 @@ public abstract class LibraryPresentationManager { public abstract List getDescriptions(@NotNull Library library, StructureConfigurableContext context); @NotNull - public abstract List getDescriptions(@NotNull VirtualFile[] classRoots, Set excludedKinds); + public abstract List getDescriptions(@NotNull VirtualFile[] classRoots, Set excludedKinds); - public abstract List getLibraries(@NotNull Set kinds, @NotNull Project project, @Nullable StructureConfigurableContext context); + public abstract List getLibraries(@NotNull Set kinds, @NotNull Project project, @Nullable StructureConfigurableContext context); - public abstract boolean isLibraryOfKind(@NotNull List files, @NotNull LibraryKind kind); + public abstract boolean isLibraryOfKind(@NotNull List files, @NotNull LibraryKind kind); public abstract boolean isLibraryOfKind(@NotNull Library library, @NotNull LibrariesContainer librariesContainer, @NotNull Set acceptedKinds); diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/impl/LibraryPresentationManagerImpl.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/impl/LibraryPresentationManagerImpl.java index ca56d853c0be..e0662dddfe0a 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/impl/LibraryPresentationManagerImpl.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/impl/LibraryPresentationManagerImpl.java @@ -118,7 +118,7 @@ public class LibraryPresentationManagerImpl extends LibraryPresentationManager { } @Override - public boolean isLibraryOfKind(@NotNull List files, @NotNull final LibraryKind kind) { + public boolean isLibraryOfKind(@NotNull List files, @NotNull final LibraryKind kind) { return !LibraryDetectionManager.getInstance().processProperties(files, new LibraryDetectionManager.LibraryPropertiesProcessor() { @Override public

boolean processProperties(@NotNull LibraryKind processedKind, @NotNull P properties) { @@ -152,7 +152,7 @@ public class LibraryPresentationManagerImpl extends LibraryPresentationManager { @NotNull @Override - public List getDescriptions(@NotNull VirtualFile[] classRoots, final Set excludedKinds) { + public List getDescriptions(@NotNull VirtualFile[] classRoots, final Set excludedKinds) { final SmartList result = new SmartList<>(); LibraryDetectionManager.getInstance().processProperties(Arrays.asList(classRoots), new LibraryDetectionManager.LibraryPropertiesProcessor() { @Override @@ -170,7 +170,7 @@ public class LibraryPresentationManagerImpl extends LibraryPresentationManager { } @Override - public List getLibraries(@NotNull Set kinds, @NotNull Project project, @Nullable StructureConfigurableContext context) { + public List getLibraries(@NotNull Set kinds, @NotNull Project project, @Nullable StructureConfigurableContext context) { List libraries = new ArrayList<>(); if (context != null) { Collections.addAll(libraries, context.getProjectLibrariesProvider().getModifiableModel().getLibraries()); diff --git a/java/java-impl/src/com/intellij/openapi/roots/libraries/LibrariesHelperImpl.java b/java/java-impl/src/com/intellij/openapi/roots/libraries/LibrariesHelperImpl.java index 6fa0e1e62416..d19a8946b0ad 100644 --- a/java/java-impl/src/com/intellij/openapi/roots/libraries/LibrariesHelperImpl.java +++ b/java/java-impl/src/com/intellij/openapi/roots/libraries/LibrariesHelperImpl.java @@ -21,6 +21,7 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFileManager; import com.intellij.util.text.StringTokenizer; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.Arrays; @@ -38,7 +39,7 @@ public class LibrariesHelperImpl extends LibrariesHelper { @Nullable @Override - public VirtualFile findRootByClass(List roots, String fqn) { + public VirtualFile findRootByClass(@NotNull List roots, String fqn) { for (VirtualFile file : roots) { if (findInFile(file, new StringTokenizer(fqn, "."))) return file; } diff --git a/java/openapi/src/com/intellij/openapi/roots/libraries/JarVersionDetectionUtil.java b/java/openapi/src/com/intellij/openapi/roots/libraries/JarVersionDetectionUtil.java index eaa9d18b1507..245ca3a459d5 100644 --- a/java/openapi/src/com/intellij/openapi/roots/libraries/JarVersionDetectionUtil.java +++ b/java/openapi/src/com/intellij/openapi/roots/libraries/JarVersionDetectionUtil.java @@ -52,7 +52,7 @@ public class JarVersionDetectionUtil { } @Nullable - public static String detectJarVersion(@NotNull String detectionClass, @NotNull List files) { + public static String detectJarVersion(@NotNull String detectionClass, @NotNull List files) { VirtualFile jarRoot = LibrariesHelper.getInstance().findRootByClass(files, detectionClass); return jarRoot != null && jarRoot.getFileSystem() instanceof JarFileSystem ? getMainAttribute(jarRoot, Attributes.Name.IMPLEMENTATION_VERSION) : null; diff --git a/java/openapi/src/com/intellij/openapi/roots/libraries/LibrariesHelper.java b/java/openapi/src/com/intellij/openapi/roots/libraries/LibrariesHelper.java index 3367f1147d2a..13ddb67cb948 100644 --- a/java/openapi/src/com/intellij/openapi/roots/libraries/LibrariesHelper.java +++ b/java/openapi/src/com/intellij/openapi/roots/libraries/LibrariesHelper.java @@ -18,6 +18,7 @@ package com.intellij.openapi.roots.libraries; import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.List; @@ -38,5 +39,5 @@ public abstract class LibrariesHelper { public abstract VirtualFile findJarByClass(final Library library, @NonNls String fqn); @Nullable - public abstract VirtualFile findRootByClass(List roots, String fqn); + public abstract VirtualFile findRootByClass(@NotNull List roots, String fqn); } diff --git a/platform/indexing-impl/src/com/intellij/openapi/roots/impl/LibraryScopeCache.java b/platform/indexing-impl/src/com/intellij/openapi/roots/impl/LibraryScopeCache.java index fa203d8c02e0..d424e4cf7e45 100644 --- a/platform/indexing-impl/src/com/intellij/openapi/roots/impl/LibraryScopeCache.java +++ b/platform/indexing-impl/src/com/intellij/openapi/roots/impl/LibraryScopeCache.java @@ -62,12 +62,10 @@ public class LibraryScopeCache { } }); private final ConcurrentMap mySdkScopes = ContainerUtil.newConcurrentMap(); - private final Map, GlobalSearchScope> myLibraryResolveScopeCache = - ConcurrentFactoryMap.createMap(key -> calcLibraryScope(key)); - private final Map, GlobalSearchScope> myLibraryUseScopeCache = - ConcurrentFactoryMap.createMap(key -> calcLibraryUseScope(key)); + private final Map, GlobalSearchScope> myLibraryResolveScopeCache = ConcurrentFactoryMap.createMap(key -> calcLibraryScope(key)); + private final Map, GlobalSearchScope> myLibraryUseScopeCache = ConcurrentFactoryMap.createMap(key -> calcLibraryUseScope(key)); - public LibraryScopeCache(Project project) { + public LibraryScopeCache(@NotNull Project project) { myProject = project; myLibrariesOnlyScope = new LibrariesOnlyScope(GlobalSearchScope.allScope(myProject), myProject); } @@ -85,7 +83,7 @@ public class LibraryScopeCache { } @NotNull - private GlobalSearchScope getScopeForLibraryUsedIn(@NotNull List modulesLibraryIsUsedIn) { + private GlobalSearchScope getScopeForLibraryUsedIn(@NotNull List modulesLibraryIsUsedIn) { Module[] array = modulesLibraryIsUsedIn.toArray(Module.EMPTY_ARRAY); GlobalSearchScope scope = myLibraryScopes.get(array); return scope != null ? scope : ConcurrencyUtil.cacheOrGet(myLibraryScopes, array, @@ -98,7 +96,7 @@ public class LibraryScopeCache { * @return a cached resolve scope */ @NotNull - public GlobalSearchScope getLibraryScope(@NotNull List orderEntries) { + public GlobalSearchScope getLibraryScope(@NotNull List orderEntries) { return myLibraryResolveScopeCache.get(orderEntries); } @@ -108,7 +106,7 @@ public class LibraryScopeCache { * @return a cached use scope */ @NotNull - public GlobalSearchScope getLibraryUseScope(@NotNull List orderEntries) { + public GlobalSearchScope getLibraryUseScope(@NotNull List orderEntries) { return myLibraryUseScopeCache.get(orderEntries); } @@ -131,7 +129,7 @@ public class LibraryScopeCache { } } - Comparator comparator = (o1, o2) -> o1.getName().compareTo(o2.getName()); + Comparator comparator = Comparator.comparing(Module::getName); Collections.sort(modulesLibraryUsedIn, comparator); List uniquesList = ContainerUtil.removeDuplicatesFromSorted(modulesLibraryUsedIn, comparator); diff --git a/platform/lang-api/src/com/intellij/execution/filters/HyperlinkInfoFactory.java b/platform/lang-api/src/com/intellij/execution/filters/HyperlinkInfoFactory.java index 49bd699391a5..2736fcda9244 100644 --- a/platform/lang-api/src/com/intellij/execution/filters/HyperlinkInfoFactory.java +++ b/platform/lang-api/src/com/intellij/execution/filters/HyperlinkInfoFactory.java @@ -34,7 +34,7 @@ public abstract class HyperlinkInfoFactory { } @NotNull - public abstract HyperlinkInfo createMultipleFilesHyperlinkInfo(@NotNull List files, + public abstract HyperlinkInfo createMultipleFilesHyperlinkInfo(@NotNull List files, int line, @NotNull Project project); /** @@ -46,7 +46,7 @@ public abstract class HyperlinkInfoFactory { * @return newly created HyperlinkInfo which navigates to given line and column */ @NotNull - public abstract HyperlinkInfo createMultipleFilesHyperlinkInfo(@NotNull List files, + public abstract HyperlinkInfo createMultipleFilesHyperlinkInfo(@NotNull List files, int line, @NotNull Project project, ToIntFunction columnFinder); diff --git a/platform/lang-impl/src/com/intellij/execution/filters/impl/HyperlinkInfoFactoryImpl.java b/platform/lang-impl/src/com/intellij/execution/filters/impl/HyperlinkInfoFactoryImpl.java index 2c9dc33f334f..0496db107dea 100644 --- a/platform/lang-impl/src/com/intellij/execution/filters/impl/HyperlinkInfoFactoryImpl.java +++ b/platform/lang-impl/src/com/intellij/execution/filters/impl/HyperlinkInfoFactoryImpl.java @@ -33,14 +33,14 @@ public class HyperlinkInfoFactoryImpl extends HyperlinkInfoFactory { @NotNull @Override - public HyperlinkInfo createMultipleFilesHyperlinkInfo(@NotNull List files, + public HyperlinkInfo createMultipleFilesHyperlinkInfo(@NotNull List files, int line, @NotNull Project project) { return new MultipleFilesHyperlinkInfo(files, line, project); } @NotNull @Override - public HyperlinkInfo createMultipleFilesHyperlinkInfo(@NotNull List files, + public HyperlinkInfo createMultipleFilesHyperlinkInfo(@NotNull List files, int line, @NotNull Project project, @Nullable ToIntFunction columnFinder) { diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryDetectionManagerImpl.java b/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryDetectionManagerImpl.java index fcf92bb1da26..9f3226393480 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryDetectionManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryDetectionManagerImpl.java @@ -32,10 +32,10 @@ import java.util.Map; * @author nik */ public class LibraryDetectionManagerImpl extends LibraryDetectionManager { - private final Map, List>> myCache = Collections.synchronizedMap(new HashMap, List>>()); + private final Map, List>> myCache = Collections.synchronizedMap(new HashMap<>()); @Override - public boolean processProperties(@NotNull List files, @NotNull LibraryPropertiesProcessor processor) { + public boolean processProperties(@NotNull List files, @NotNull LibraryPropertiesProcessor processor) { for (Pair pair : getOrComputeKinds(files)) { if (!processor.processProperties(pair.getFirst(), pair.getSecond())) { return false; @@ -46,10 +46,10 @@ public class LibraryDetectionManagerImpl extends LibraryDetectionManager { @Nullable @Override - public Pair, LibraryProperties> detectType(@NotNull List files) { + public Pair, LibraryProperties> detectType(@NotNull List files) { Pair, LibraryProperties> result = null; for (LibraryType type : LibraryType.EP_NAME.getExtensions()) { - final LibraryProperties properties = type.detect(files); + final LibraryProperties properties = type.detect((List)files); if (properties != null) { if (result != null) { return null; @@ -60,7 +60,7 @@ public class LibraryDetectionManagerImpl extends LibraryDetectionManager { return result; } - private List> getOrComputeKinds(List files) { + private List> getOrComputeKinds(List files) { List> result = myCache.get(files); if (result == null) { result = computeKinds(files); @@ -69,7 +69,7 @@ public class LibraryDetectionManagerImpl extends LibraryDetectionManager { return result; } - private static List> computeKinds(List files) { + private static List> computeKinds(List files) { final SmartList> result = new SmartList<>(); final LibraryType[] libraryTypes = LibraryType.EP_NAME.getExtensions(); final LibraryPresentationProvider[] presentationProviders = LibraryPresentationProvider.EP_NAME.getExtensions(); diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/libraries/LibraryDetectionManager.java b/platform/lang-impl/src/com/intellij/openapi/roots/libraries/LibraryDetectionManager.java index 51e72a2359e0..8d67c167b3a9 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/libraries/LibraryDetectionManager.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/libraries/LibraryDetectionManager.java @@ -31,10 +31,10 @@ public abstract class LibraryDetectionManager { return ServiceManager.getService(LibraryDetectionManager.class); } - public abstract boolean processProperties(@NotNull List files, @NotNull LibraryPropertiesProcessor processor); + public abstract boolean processProperties(@NotNull List files, @NotNull LibraryPropertiesProcessor processor); @Nullable - public abstract Pair, LibraryProperties> detectType(@NotNull List files); + public abstract Pair, LibraryProperties> detectType(@NotNull List files); public interface LibraryPropertiesProcessor {

boolean processProperties(@NotNull LibraryKind kind, @NotNull P properties); diff --git a/platform/projectModel-api/src/com/intellij/openapi/roots/OrderEnumerator.java b/platform/projectModel-api/src/com/intellij/openapi/roots/OrderEnumerator.java index 4da8777a8fed..a2e62062c90d 100644 --- a/platform/projectModel-api/src/com/intellij/openapi/roots/OrderEnumerator.java +++ b/platform/projectModel-api/src/com/intellij/openapi/roots/OrderEnumerator.java @@ -44,6 +44,7 @@ public abstract class OrderEnumerator { * * @return this instance */ + @NotNull public abstract OrderEnumerator productionOnly(); /** @@ -51,6 +52,7 @@ public abstract class OrderEnumerator { * * @return this instance */ + @NotNull public abstract OrderEnumerator compileOnly(); /** @@ -58,32 +60,41 @@ public abstract class OrderEnumerator { * * @return this instance */ + @NotNull public abstract OrderEnumerator runtimeOnly(); + @NotNull public abstract OrderEnumerator withoutSdk(); + @NotNull public abstract OrderEnumerator withoutLibraries(); + @NotNull public abstract OrderEnumerator withoutDepModules(); /** * Skip root module's entries * @return this */ + @NotNull public abstract OrderEnumerator withoutModuleSourceEntries(); + @NotNull public OrderEnumerator librariesOnly() { return withoutSdk().withoutDepModules().withoutModuleSourceEntries(); } + @NotNull public OrderEnumerator sdkOnly() { return withoutDepModules().withoutLibraries().withoutModuleSourceEntries(); } + @NotNull public VirtualFile[] getAllLibrariesAndSdkClassesRoots() { return withoutModuleSourceEntries().withoutDepModules().recursively().exportedOnly().classes().usingCache().getRoots(); } + @NotNull public VirtualFile[] getAllSourceRoots() { return recursively().exportedOnly().sources().usingCache().getRoots(); } @@ -94,6 +105,7 @@ public abstract class OrderEnumerator { * * @return this instance */ + @NotNull public abstract OrderEnumerator recursively(); /** @@ -101,6 +113,7 @@ public abstract class OrderEnumerator { * * @return this instance */ + @NotNull public abstract OrderEnumerator exportedOnly(); /** @@ -109,7 +122,8 @@ public abstract class OrderEnumerator { * @param condition filtering condition * @return this instance */ - public abstract OrderEnumerator satisfying(Condition condition); + @NotNull + public abstract OrderEnumerator satisfying(@NotNull Condition condition); /** * Use {@code provider.getRootModel()} to process module dependencies @@ -117,6 +131,7 @@ public abstract class OrderEnumerator { * @param provider provider * @return this instance */ + @NotNull public abstract OrderEnumerator using(@NotNull RootModelProvider provider); /** @@ -132,28 +147,33 @@ public abstract class OrderEnumerator { /** * @return {@link OrderRootsEnumerator} instance for processing classes roots */ + @NotNull public abstract OrderRootsEnumerator classes(); /** * @return {@link OrderRootsEnumerator} instance for processing source roots */ + @NotNull public abstract OrderRootsEnumerator sources(); /** * @param rootType root type * @return {@link OrderRootsEnumerator} instance for processing roots of the specified type */ + @NotNull public abstract OrderRootsEnumerator roots(@NotNull OrderRootType rootType); /** * @param rootTypeProvider custom root type provider * @return {@link OrderRootsEnumerator} instance for processing roots of the provided type */ + @NotNull public abstract OrderRootsEnumerator roots(@NotNull NotNullFunction rootTypeProvider); /** * @return classes roots for all entries processed by this enumerator */ + @NotNull public VirtualFile[] getClassesRoots() { return classes().getRoots(); } @@ -161,6 +181,7 @@ public abstract class OrderEnumerator { /** * @return source roots for all entries processed by this enumerator */ + @NotNull public VirtualFile[] getSourceRoots() { return sources().getRoots(); } @@ -168,6 +189,7 @@ public abstract class OrderEnumerator { /** * @return list containing classes roots for all entries processed by this enumerator */ + @NotNull public PathsList getPathsList() { return classes().getPathsList(); } @@ -175,6 +197,7 @@ public abstract class OrderEnumerator { /** * @return list containing source roots for all entries processed by this enumerator */ + @NotNull public PathsList getSourcePathsList() { return sources().getPathsList(); } @@ -184,21 +207,21 @@ public abstract class OrderEnumerator { * * @param processor processor */ - public abstract void forEach(@NotNull Processor processor); + public abstract void forEach(@NotNull Processor processor); /** * Runs {@code processor.process()} for each library processed by this enumerator. * * @param processor processor */ - public abstract void forEachLibrary(@NotNull Processor processor); + public abstract void forEachLibrary(@NotNull Processor processor); /** * Runs {@code processor.process()} for each module processed by this enumerator. * * @param processor processor */ - public abstract void forEachModule(@NotNull Processor processor); + public abstract void forEachModule(@NotNull Processor processor); /** * Passes order entries to the specified visitor. diff --git a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ModifiableModelCommitter.java b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ModifiableModelCommitter.java index 2ae10d040a25..4025272ce5f6 100644 --- a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ModifiableModelCommitter.java +++ b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ModifiableModelCommitter.java @@ -39,7 +39,7 @@ public class ModifiableModelCommitter { multiCommit(Arrays.asList(rootModels), moduleModel); } - public static void multiCommit(@NotNull Collection rootModels, @NotNull ModifiableModuleModel moduleModel) { + public static void multiCommit(@NotNull Collection rootModels, @NotNull ModifiableModuleModel moduleModel) { ApplicationManager.getApplication().assertWriteAccessAllowed(); final List modelsToCommit = getSortedChangedModels(rootModels, moduleModel); @@ -61,7 +61,7 @@ public class ModifiableModelCommitter { } @NotNull - private static List getSortedChangedModels(Collection rootModels, ModifiableModuleModel moduleModel) { + private static List getSortedChangedModels(@NotNull Collection rootModels, @NotNull ModifiableModuleModel moduleModel) { List result = null; for (ModifiableRootModel model : rootModels) { RootModelImpl rootModel = (RootModelImpl)model; @@ -82,7 +82,8 @@ public class ModifiableModelCommitter { return result; } - private static DFSTBuilder createDFSTBuilder(List rootModels, final ModifiableModuleModel moduleModel) { + @NotNull + private static DFSTBuilder createDFSTBuilder(@NotNull List rootModels, @NotNull ModifiableModuleModel moduleModel) { final Map nameToModel = ContainerUtil.newHashMap(); for (RootModelImpl rootModel : rootModels) { String name = rootModel.getModule().getName(); diff --git a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/OrderEnumeratorBase.java b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/OrderEnumeratorBase.java index 3e9b4a904c97..b293a44fdefc 100644 --- a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/OrderEnumeratorBase.java +++ b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/OrderEnumeratorBase.java @@ -47,7 +47,7 @@ abstract class OrderEnumeratorBase extends OrderEnumerator implements OrderEnume boolean myRecursively; boolean myRecursivelyExportedOnly; private boolean myExportedOnly; - private Condition myCondition; + private Condition myCondition; RootModelProvider myModulesProvider; private final OrderRootsCache myCache; @@ -69,54 +69,63 @@ abstract class OrderEnumeratorBase extends OrderEnumerator implements OrderEnume return customHandlers == null ? Collections.emptyList() : customHandlers; } + @NotNull @Override public OrderEnumerator productionOnly() { myProductionOnly = true; return this; } + @NotNull @Override public OrderEnumerator compileOnly() { myCompileOnly = true; return this; } + @NotNull @Override public OrderEnumerator runtimeOnly() { myRuntimeOnly = true; return this; } + @NotNull @Override public OrderEnumerator withoutSdk() { myWithoutJdk = true; return this; } + @NotNull @Override public OrderEnumerator withoutLibraries() { myWithoutLibraries = true; return this; } + @NotNull @Override public OrderEnumerator withoutDepModules() { myWithoutDepModules = true; return this; } + @NotNull @Override public OrderEnumerator withoutModuleSourceEntries() { myWithoutModuleSourceEntries = true; return this; } + @NotNull @Override public OrderEnumerator recursively() { myRecursively = true; return this; } + @NotNull @Override public OrderEnumerator exportedOnly() { if (myRecursively) { @@ -128,33 +137,39 @@ abstract class OrderEnumeratorBase extends OrderEnumerator implements OrderEnume return this; } + @NotNull @Override - public OrderEnumerator satisfying(Condition condition) { + public OrderEnumerator satisfying(@NotNull Condition condition) { myCondition = condition; return this; } + @NotNull @Override public OrderEnumerator using(@NotNull RootModelProvider provider) { myModulesProvider = provider; return this; } + @NotNull @Override public OrderRootsEnumerator classes() { return new OrderRootsEnumeratorImpl(this, OrderRootType.CLASSES); } + @NotNull @Override public OrderRootsEnumerator sources() { return new OrderRootsEnumeratorImpl(this, OrderRootType.SOURCES); } + @NotNull @Override public OrderRootsEnumerator roots(@NotNull OrderRootType rootType) { return new OrderRootsEnumeratorImpl(this, rootType); } + @NotNull @Override public OrderRootsEnumerator roots(@NotNull NotNullFunction rootTypeProvider) { return new OrderRootsEnumeratorImpl(this, rootTypeProvider); @@ -325,14 +340,14 @@ abstract class OrderEnumeratorBase extends OrderEnumerator implements OrderEnume } @Override - public void forEach(@NotNull final Processor processor) { + public void forEach(@NotNull final Processor processor) { forEach((entry, handlers) -> processor.process(entry)); } protected abstract void forEach(@NotNull PairProcessor> processor); @Override - public void forEachLibrary(@NotNull final Processor processor) { + public void forEachLibrary(@NotNull final Processor processor) { forEach((entry, handlers) -> { if (entry instanceof LibraryOrderEntry) { final Library library = ((LibraryOrderEntry)entry).getLibrary(); @@ -345,7 +360,7 @@ abstract class OrderEnumeratorBase extends OrderEnumerator implements OrderEnume } @Override - public void forEachModule(@NotNull final Processor processor) { + public void forEachModule(@NotNull final Processor processor) { forEach((orderEntry, customHandlers) -> { if (myRecursively && orderEntry instanceof ModuleSourceOrderEntry) { final Module module = ((ModuleSourceOrderEntry)orderEntry).getRootModel().getModule(); @@ -459,7 +474,7 @@ abstract class OrderEnumeratorBase extends OrderEnumerator implements OrderEnume private R myValue; private final RootPolicy myPolicy; - private OrderEntryProcessor(RootPolicy policy, R initialValue) { + private OrderEntryProcessor(@NotNull RootPolicy policy, R initialValue) { myPolicy = policy; myValue = initialValue; } diff --git a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ProjectOrderEnumerator.java b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ProjectOrderEnumerator.java index f201020f2cb5..e3a8190d1221 100644 --- a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ProjectOrderEnumerator.java +++ b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ProjectOrderEnumerator.java @@ -34,7 +34,7 @@ import java.util.List; public class ProjectOrderEnumerator extends OrderEnumeratorBase { private final Project myProject; - public ProjectOrderEnumerator(Project project, OrderRootsCache rootsCache) { + public ProjectOrderEnumerator(@NotNull Project project, @NotNull OrderRootsCache rootsCache) { super(rootsCache); myProject = project; } @@ -59,7 +59,7 @@ public class ProjectOrderEnumerator extends OrderEnumeratorBase { } @Override - public void forEachModule(@NotNull Processor processor) { + public void forEachModule(@NotNull Processor processor) { processRootModules(processor); } diff --git a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/RootIndex.java b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/RootIndex.java index 394081c63cda..899b60f4bf0a 100644 --- a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/RootIndex.java +++ b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/RootIndex.java @@ -460,8 +460,8 @@ public class RootIndex { } } - @Nullable Pair> libraryClassRootInfo = myRootInfo.findLibraryRootInfo(roots, false); - @Nullable Pair> librarySourceRootInfo = myRootInfo.findLibraryRootInfo(roots, true); + @Nullable Pair> libraryClassRootInfo = myRootInfo.findLibraryRootInfo(roots, false); + @Nullable Pair> librarySourceRootInfo = myRootInfo.findLibraryRootInfo(roots, true); result.addAll(myRootInfo.getLibraryOrderEntries(roots, Pair.getFirst(libraryClassRootInfo), Pair.getFirst(librarySourceRootInfo), @@ -582,7 +582,7 @@ public class RootIndex { } @Nullable("returns null only if dir is under ignored folder") - private static List getHierarchy(VirtualFile dir, @NotNull Set allRoots, @NotNull RootInfo info) { + private static List getHierarchy(VirtualFile dir, @NotNull Set allRoots, @NotNull RootInfo info) { List hierarchy = ContainerUtil.newArrayList(); boolean hasContentRoots = false; while (dir != null) { @@ -635,7 +635,7 @@ public class RootIndex { * root and there are no source roots on the path to the excluded root) returns {@code null}. */ @Nullable - private VirtualFile findNearestContentRoot(@NotNull List hierarchy) { + private VirtualFile findNearestContentRoot(@NotNull List hierarchy) { Collection sourceRootOwners = null; boolean underExcludedSourceRoot = false; for (VirtualFile root : hierarchy) { @@ -674,7 +674,7 @@ public class RootIndex { return null; } - private static boolean isExcludedByPattern(VirtualFile contentRoot, List hierarchy, FileTypeAssocTable table) { + private static boolean isExcludedByPattern(@NotNull VirtualFile contentRoot, List hierarchy, @NotNull FileTypeAssocTable table) { for (VirtualFile file : hierarchy) { if (table.findAssociatedFileType(file.getNameSequence()) != null) { return true; @@ -687,7 +687,7 @@ public class RootIndex { } @Nullable - private VirtualFile findNearestContentRootForExcluded(@NotNull List hierarchy) { + private VirtualFile findNearestContentRootForExcluded(@NotNull List hierarchy) { for (VirtualFile root : hierarchy) { if (contentRootOf.containsKey(root) || contentRootOfUnloaded.containsKey(root)) { return root; @@ -700,7 +700,7 @@ public class RootIndex { * @return root and set of libraries that provided it */ @Nullable - private Pair> findLibraryRootInfo(@NotNull List hierarchy, boolean source) { + private Pair> findLibraryRootInfo(@NotNull List hierarchy, boolean source) { Set librariesToIgnore = ContainerUtil.newHashSet(); for (VirtualFile root : hierarchy) { librariesToIgnore.addAll(excludedFromLibraries.get(root)); @@ -727,9 +727,9 @@ public class RootIndex { } @NotNull - private static Collection findLibraryRootProducers(@NotNull Collection producers, + private static Collection findLibraryRootProducers(@NotNull Collection producers, @NotNull VirtualFile root, - @NotNull Set librariesToIgnore) { + @NotNull Set librariesToIgnore) { Set libraries = ContainerUtil.newHashSet(); for (Object library : producers) { if (librariesToIgnore.contains(library)) continue; @@ -745,7 +745,7 @@ public class RootIndex { } private String calcPackagePrefix(@NotNull VirtualFile root, - @NotNull List hierarchy, + @NotNull List hierarchy, VirtualFile moduleContentRoot, VirtualFile libraryClassRoot, VirtualFile librarySourceRoot) { @@ -760,7 +760,7 @@ public class RootIndex { } @Nullable - private VirtualFile findPackageRootInfo(@NotNull List hierarchy, + private VirtualFile findPackageRootInfo(@NotNull List hierarchy, VirtualFile moduleContentRoot, VirtualFile libraryClassRoot, VirtualFile librarySourceRoot) { @@ -781,7 +781,7 @@ public class RootIndex { } @NotNull - private LinkedHashSet getLibraryOrderEntries(@NotNull List hierarchy, + private LinkedHashSet getLibraryOrderEntries(@NotNull List hierarchy, @Nullable VirtualFile libraryClassRoot, @Nullable VirtualFile librarySourceRoot, @NotNull MultiMap libClassRootEntries, @@ -803,7 +803,7 @@ public class RootIndex { @Nullable - private ModuleSourceOrderEntry getModuleSourceEntry(@NotNull List hierarchy, + private ModuleSourceOrderEntry getModuleSourceEntry(@NotNull List hierarchy, @NotNull VirtualFile moduleContentRoot, @NotNull MultiMap libClassRootEntries) { Module module = contentRootOf.get(moduleContentRoot); @@ -821,13 +821,13 @@ public class RootIndex { @NotNull private static Pair calcDirectoryInfo(@NotNull final VirtualFile root, - @NotNull final List hierarchy, + @NotNull final List hierarchy, @NotNull RootInfo info) { VirtualFile moduleContentRoot = info.findNearestContentRoot(hierarchy); - Pair> librarySourceRootInfo = info.findLibraryRootInfo(hierarchy, true); + Pair> librarySourceRootInfo = info.findLibraryRootInfo(hierarchy, true); VirtualFile librarySourceRoot = Pair.getFirst(librarySourceRootInfo); - Pair> libraryClassRootInfo = info.findLibraryRootInfo(hierarchy, false); + Pair> libraryClassRootInfo = info.findLibraryRootInfo(hierarchy, false); VirtualFile libraryClassRoot = Pair.getFirst(libraryClassRootInfo); boolean inProject = moduleContentRoot != null || @@ -871,7 +871,7 @@ public class RootIndex { } @Nullable - private static Condition getLibraryExclusionPredicate(@Nullable Pair> libraryRootInfo) { + private static Condition getLibraryExclusionPredicate(@Nullable Pair> libraryRootInfo) { Condition result = Conditions.alwaysFalse(); if (libraryRootInfo != null) { for (Object library : libraryRootInfo.second) {