Cleanup (migrates graph usages to lighter API)
authorRoman Shevchenko <roman.shevchenko@jetbrains.com>
Mon, 21 Nov 2016 11:35:00 +0000 (12:35 +0100)
committerRoman Shevchenko <roman.shevchenko@jetbrains.com>
Mon, 21 Nov 2016 11:35:00 +0000 (12:35 +0100)
20 files changed:
java/compiler/impl/src/com/intellij/compiler/ant/GenerationOptionsImpl.java
java/compiler/openapi/src/com/intellij/compiler/ModuleCompilerUtil.java
java/idea-ui/src/com/intellij/ide/util/frameworkSupport/FrameworkSupportUtil.java
java/java-impl/src/com/intellij/cyclicDependencies/CyclicDependenciesBuilder.java
java/java-impl/src/com/intellij/refactoring/typeMigration/TypeMigrationLabeler.java
jps/jps-builders/src/org/jetbrains/jps/incremental/artifacts/impl/ArtifactSorter.java
jps/jps-builders/src/org/jetbrains/jps/incremental/artifacts/impl/JarsBuilder.java
platform/core-impl/src/com/intellij/ide/plugins/PluginManagerCore.java
platform/extensions/src/com/intellij/openapi/extensions/LoadingOrder.java
platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/AbstractIdeModifiableModelsProvider.java
platform/platform-impl/src/com/intellij/util/graph/impl/GraphAlgorithmsImpl.java
platform/projectModel-impl/src/com/intellij/openapi/module/impl/ModuleManagerImpl.java
platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ModifiableModelCommitter.java
platform/util/src/com/intellij/util/graph/CachingSemiGraph.java
platform/util/src/com/intellij/util/graph/GraphGenerator.java
platform/util/testSrc/com/intellij/util/graph/DFSTBuilderTest.java
platform/util/testSrc/com/intellij/util/graph/GraphGeneratorTest.java
platform/vcs-impl/src/com/intellij/impl/ConversionServiceImpl.java
plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/performance/TailRecursionInspection.java
plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundlePropertiesUpdateManager.java

index ada7b733dfb185f364729359980db5b20149a6b1..a72e6e086e70ebadd505c27180df82ce0b5f786f 100644 (file)
@@ -33,6 +33,7 @@ import com.intellij.util.containers.ContainerUtil;
 import com.intellij.util.graph.CachingSemiGraph;
 import com.intellij.util.graph.Graph;
 import com.intellij.util.graph.GraphGenerator;
+import com.intellij.util.graph.InboundSemiGraph;
 
 import java.io.File;
 import java.util.*;
@@ -229,30 +230,29 @@ public class GenerationOptionsImpl extends GenerationOptions {
       reverseMap.put(moduleChunk, chunk);
     }
 
-    final Graph<ModuleChunk> moduleChunkGraph =
-      GraphGenerator.create(CachingSemiGraph.create(new GraphGenerator.SemiGraph<ModuleChunk>() {
-        public Collection<ModuleChunk> getNodes() {
-          return map.values();
-        }
+    final Graph<ModuleChunk> moduleChunkGraph = GraphGenerator.generate(CachingSemiGraph.cache(new InboundSemiGraph<ModuleChunk>() {
+      public Collection<ModuleChunk> getNodes() {
+        return map.values();
+      }
 
-        public Iterator<ModuleChunk> getIn(ModuleChunk n) {
-          final Chunk<Module> chunk = reverseMap.get(n);
-          final Iterator<Chunk<Module>> in = chunkGraph.getIn(chunk);
-          return new Iterator<ModuleChunk>() {
-            public boolean hasNext() {
-              return in.hasNext();
-            }
+      public Iterator<ModuleChunk> getIn(ModuleChunk n) {
+        final Chunk<Module> chunk = reverseMap.get(n);
+        final Iterator<Chunk<Module>> in = chunkGraph.getIn(chunk);
+        return new Iterator<ModuleChunk>() {
+          public boolean hasNext() {
+            return in.hasNext();
+          }
 
-            public ModuleChunk next() {
-              return map.get(in.next());
-            }
+          public ModuleChunk next() {
+            return map.get(in.next());
+          }
 
-            public void remove() {
-              throw new IncorrectOperationException("Method is not supported");
-            }
-          };
-        }
-      }));
+          public void remove() {
+            throw new IncorrectOperationException("Method is not supported");
+          }
+        };
+      }
+    }));
     final Collection<ModuleChunk> nodes = moduleChunkGraph.getNodes();
     final ModuleChunk[] moduleChunks = nodes.toArray(new ModuleChunk[nodes.size()]);
     for (ModuleChunk moduleChunk : moduleChunks) {
index 43ec173ad34b1b7dd3d01c66ef20ebbea51b3307..3e25ba278d01d291a5f90b55289b41aa51414dfe 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2014 JetBrains s.r.o.
+ * Copyright 2000-2016 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -13,7 +13,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package com.intellij.compiler;
 
 import com.intellij.openapi.application.Application;
@@ -25,10 +24,8 @@ import com.intellij.openapi.project.Project;
 import com.intellij.openapi.roots.*;
 import com.intellij.openapi.roots.ui.configuration.DefaultModulesProvider;
 import com.intellij.openapi.roots.ui.configuration.ModulesProvider;
-import com.intellij.openapi.util.Condition;
 import com.intellij.openapi.util.Couple;
 import com.intellij.util.Chunk;
-import com.intellij.util.Processor;
 import com.intellij.util.containers.ContainerUtil;
 import com.intellij.util.graph.*;
 import org.jetbrains.annotations.NotNull;
@@ -49,7 +46,7 @@ public final class ModuleCompilerUtil {
   }
 
   public static Graph<Module> createModuleGraph(final Module[] modules) {
-    return GraphGenerator.create(CachingSemiGraph.create(new GraphGenerator.SemiGraph<Module>() {
+    return GraphGenerator.generate(CachingSemiGraph.cache(new InboundSemiGraph<Module>() {
       public Collection<Module> getNodes() {
         return Arrays.asList(modules);
       }
@@ -109,9 +106,8 @@ public final class ModuleCompilerUtil {
     }
   }
 
-
-  public static <T extends ModuleRootModel> GraphGenerator<T> createGraphGenerator(final Map<Module, T> models) {
-    return GraphGenerator.create(CachingSemiGraph.create(new GraphGenerator.SemiGraph<T>() {
+  public static <T extends ModuleRootModel> Graph<T> createGraphGenerator(final Map<Module, T> models) {
+    return GraphGenerator.generate(CachingSemiGraph.cache(new InboundSemiGraph<T>() {
       public Collection<T> getNodes() {
         return models.values();
       }
@@ -187,7 +183,7 @@ public final class ModuleCompilerUtil {
   }
 
   private static Graph<ModuleSourceSet> createModuleSourceDependenciesGraph(final RootModelProvider provider) {
-    return GraphGenerator.create(new CachingSemiGraph<>(new GraphGenerator.SemiGraph<ModuleSourceSet>() {
+    return GraphGenerator.generate(CachingSemiGraph.cache(new InboundSemiGraph<ModuleSourceSet>() {
       @Override
       public Collection<ModuleSourceSet> getNodes() {
         Module[] modules = provider.getModules();
index d6171c151c16fe0f298c3e561938fc0007f9e51a..a1e0a7ce788a62c8905a7c388d1696416bfa6eec 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * Copyright 2000-2014 JetBrains s.r.o.
+ * Copyright 2000-2016 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -28,6 +28,7 @@ import com.intellij.openapi.util.Couple;
 import com.intellij.util.graph.CachingSemiGraph;
 import com.intellij.util.graph.DFSTBuilder;
 import com.intellij.util.graph.GraphGenerator;
+import com.intellij.util.graph.InboundSemiGraph;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
@@ -96,7 +97,7 @@ public class FrameworkSupportUtil {
 
   public static Comparator<FrameworkSupportInModuleProvider> getFrameworkSupportProvidersComparator(final List<FrameworkSupportInModuleProvider> types) {
     DFSTBuilder<FrameworkSupportInModuleProvider>
-      builder = new DFSTBuilder<>(GraphGenerator.create(CachingSemiGraph.create(new ProvidersGraph(types))));
+      builder = new DFSTBuilder<>(GraphGenerator.generate(CachingSemiGraph.cache(new ProvidersGraph(types))));
     if (!builder.isAcyclic()) {
       Couple<FrameworkSupportInModuleProvider> pair = builder.getCircularDependency();
       LOG.error("Circular dependency between types '" + pair.getFirst().getFrameworkType().getId() + "' and '" + pair.getSecond().getFrameworkType().getId() + "' was found.");
@@ -122,7 +123,7 @@ public class FrameworkSupportUtil {
     return null;
   }
 
-  private static class ProvidersGraph implements GraphGenerator.SemiGraph<FrameworkSupportInModuleProvider> {
+  private static class ProvidersGraph implements InboundSemiGraph<FrameworkSupportInModuleProvider> {
     private final List<FrameworkSupportInModuleProvider> myFrameworkSupportProviders;
 
     public ProvidersGraph(final List<FrameworkSupportInModuleProvider> frameworkSupportProviders) {
@@ -160,4 +161,4 @@ public class FrameworkSupportUtil {
       return dependencies.iterator();
     }
   }
-}
+}
\ No newline at end of file
index 8baaaa7b33374fd043f62ce39eeae9d00bdd8a01..03261b465a421564986ebfd83d080c998b4f1b88 100644 (file)
@@ -26,10 +26,7 @@ import com.intellij.openapi.roots.ProjectRootManager;
 import com.intellij.packageDependencies.DependenciesBuilder;
 import com.intellij.packageDependencies.ForwardDependenciesBuilder;
 import com.intellij.psi.*;
-import com.intellij.util.graph.CachingSemiGraph;
-import com.intellij.util.graph.Graph;
-import com.intellij.util.graph.GraphAlgorithms;
-import com.intellij.util.graph.GraphGenerator;
+import com.intellij.util.graph.*;
 
 import java.util.*;
 
@@ -241,9 +238,8 @@ public class CyclicDependenciesBuilder{
     return myPackages;
   }
 
-
   private Graph<PsiPackage> buildGraph() {
-    final Graph<PsiPackage> graph = GraphGenerator.create(CachingSemiGraph.create(new GraphGenerator.SemiGraph<PsiPackage>() {
+    return GraphGenerator.generate(CachingSemiGraph.cache(new InboundSemiGraph<PsiPackage>() {
       public Collection<PsiPackage> getNodes() {
         return getAllScopePackages().values();
       }
@@ -256,7 +252,6 @@ public class CyclicDependenciesBuilder{
         return psiPackages.iterator();
       }
     }));
-    return graph;
   }
 
   public Set<PsiPackage> getPackageHierarhy(String packageName) {
@@ -283,5 +278,4 @@ public class CyclicDependenciesBuilder{
     final PsiPackage psiPackage = getAllScopePackages().get(packName);
     return psiPackage;
   }
-
-}
+}
\ No newline at end of file
index 140e87fd1be0e0a4128de142ef02378c86235f6d..81c88f9d947b6fc693c60f2d97b2147864e80201 100644 (file)
@@ -49,6 +49,7 @@ import com.intellij.util.containers.ContainerUtil;
 import com.intellij.util.containers.MultiMap;
 import com.intellij.util.graph.DFSTBuilder;
 import com.intellij.util.graph.GraphGenerator;
+import com.intellij.util.graph.InboundSemiGraph;
 import gnu.trove.THashMap;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -204,8 +205,8 @@ public class TypeMigrationLabeler {
   }
 
   private TypeMigrationUsageInfo[] sortMigratedUsages(TypeMigrationUsageInfo[] infos) {
-    final DFSTBuilder<TypeMigrationUsageInfo> builder = new DFSTBuilder<>(GraphGenerator.create(
-      new GraphGenerator.SemiGraph<TypeMigrationUsageInfo>() {
+    final DFSTBuilder<TypeMigrationUsageInfo> builder = new DFSTBuilder<>(GraphGenerator.generate(
+      new InboundSemiGraph<TypeMigrationUsageInfo>() {
         @Override
         public Collection<TypeMigrationUsageInfo> getNodes() {
           final Set<TypeMigrationUsageInfo> infos = new HashSet<>();
index 7f49eb83520162891e53e8229ba54d709334445b..06fecaddce0cbc5dfe97ec9176ec6dfcbb6d6974 100644 (file)
@@ -18,9 +18,7 @@ package org.jetbrains.jps.incremental.artifacts.impl;
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.util.Consumer;
 import com.intellij.util.Processor;
-import com.intellij.util.graph.CachingSemiGraph;
-import com.intellij.util.graph.DFSTBuilder;
-import com.intellij.util.graph.GraphGenerator;
+import com.intellij.util.graph.*;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.jps.incremental.artifacts.JpsBuilderArtifactService;
 import org.jetbrains.jps.model.JpsModel;
@@ -57,7 +55,7 @@ public class ArtifactSorter {
   }
 
   private List<JpsArtifact> doGetSortedArtifacts() {
-    GraphGenerator<JpsArtifact> graph = createArtifactsGraph();
+    Graph<JpsArtifact> graph = createArtifactsGraph();
     DFSTBuilder<JpsArtifact> builder = new DFSTBuilder<JpsArtifact>(graph);
     List<JpsArtifact> names = new ArrayList<JpsArtifact>();
     names.addAll(graph.getNodes());
@@ -67,7 +65,7 @@ public class ArtifactSorter {
 
   private Map<JpsArtifact, JpsArtifact> computeArtifactToSelfIncludingNameMap() {
     final Map<JpsArtifact, JpsArtifact> result = new HashMap<JpsArtifact, JpsArtifact>();
-    final GraphGenerator<JpsArtifact> graph = createArtifactsGraph();
+    final Graph<JpsArtifact> graph = createArtifactsGraph();
     for (JpsArtifact artifact : graph.getNodes()) {
       final Iterator<JpsArtifact> in = graph.getIn(artifact);
       while (in.hasNext()) {
@@ -134,8 +132,8 @@ public class ArtifactSorter {
     });
   }
 
-  private GraphGenerator<JpsArtifact> createArtifactsGraph() {
-    return GraphGenerator.create(CachingSemiGraph.create(new ArtifactsGraph(myModel)));
+  private Graph<JpsArtifact> createArtifactsGraph() {
+    return GraphGenerator.generate(CachingSemiGraph.cache(new ArtifactsGraph(myModel)));
   }
 
   private static void processIncludedArtifacts(JpsArtifact artifact, final Consumer<JpsArtifact> consumer) {
@@ -154,7 +152,7 @@ public class ArtifactSorter {
     });
   }
 
-  private static class ArtifactsGraph implements GraphGenerator.SemiGraph<JpsArtifact> {
+  private static class ArtifactsGraph implements InboundSemiGraph<JpsArtifact> {
     private final Set<JpsArtifact> myArtifactNodes;
 
     public ArtifactsGraph(final JpsModel model) {
@@ -181,5 +179,4 @@ public class ArtifactSorter {
       return included.iterator();
     }
   }
-
-}
+}
\ No newline at end of file
index c5ce16567be490d24eb7fa7951c5edc76b080e9d..96a0da166c78bcfc4b3d0f0af1fedaf7d5ab16b3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2016 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -26,6 +26,7 @@ import com.intellij.util.ArrayUtil;
 import com.intellij.util.graph.CachingSemiGraph;
 import com.intellij.util.graph.DFSTBuilder;
 import com.intellij.util.graph.GraphGenerator;
+import com.intellij.util.graph.InboundSemiGraph;
 import com.intellij.util.io.ZipUtil;
 import gnu.trove.THashSet;
 import org.jetbrains.annotations.NonNls;
@@ -119,7 +120,7 @@ public class JarsBuilder {
 
   @Nullable
   private JarInfo[] sortJars() {
-    final DFSTBuilder<JarInfo> builder = new DFSTBuilder<JarInfo>(GraphGenerator.create(CachingSemiGraph.create(new JarsGraph())));
+    final DFSTBuilder<JarInfo> builder = new DFSTBuilder<JarInfo>(GraphGenerator.generate(CachingSemiGraph.cache(new JarsGraph())));
     if (!builder.isAcyclic()) {
       final Pair<JarInfo, JarInfo> dependency = builder.getCircularDependency();
       String message = "Cannot build: circular dependency found between '" + dependency.getFirst().getPresentableDestination() +
@@ -383,7 +384,7 @@ public class JarsBuilder {
     output.closeEntry();
   }
 
-  private class JarsGraph implements GraphGenerator.SemiGraph<JarInfo> {
+  private class JarsGraph implements InboundSemiGraph<JarInfo> {
     public Collection<JarInfo> getNodes() {
       return myJarsToBuild;
     }
@@ -397,4 +398,4 @@ public class JarsBuilder {
       return ins.iterator();
     }
   }
-}
+}
\ No newline at end of file
index f22e6c93913530d40c22322a960f247ad910b6fb..37321a30f824cae4895b5ef73a100bd8d2eb13df 100644 (file)
@@ -36,10 +36,7 @@ import com.intellij.util.*;
 import com.intellij.util.containers.ContainerUtil;
 import com.intellij.util.containers.MultiMap;
 import com.intellij.util.execution.ParametersListUtil;
-import com.intellij.util.graph.CachingSemiGraph;
-import com.intellij.util.graph.DFSTBuilder;
-import com.intellij.util.graph.Graph;
-import com.intellij.util.graph.GraphGenerator;
+import com.intellij.util.graph.*;
 import com.intellij.util.io.URLUtil;
 import com.intellij.util.lang.UrlClassLoader;
 import com.intellij.util.xmlb.JDOMXIncluder;
@@ -622,7 +619,7 @@ public class PluginManagerCore {
         return o2.getIdString().compareTo(o1.getIdString());
       }
     });
-    return GraphGenerator.create(CachingSemiGraph.create(new GraphGenerator.SemiGraph<PluginId>() {
+    return GraphGenerator.generate(CachingSemiGraph.cache(new InboundSemiGraph<PluginId>() {
       @Override
       public Collection<PluginId> getNodes() {
         return ids;
index 3af33eafd44414db2c8a9512bb8dcfb5ac63bb61..465fa6df289b7505f70305d0b02e1e010de47321 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2014 JetBrains s.r.o.
+ * Copyright 2000-2016 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,6 +21,7 @@ import com.intellij.util.containers.ContainerUtil;
 import com.intellij.util.graph.CachingSemiGraph;
 import com.intellij.util.graph.DFSTBuilder;
 import com.intellij.util.graph.GraphGenerator;
+import com.intellij.util.graph.InboundSemiGraph;
 import org.jdom.Element;
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
@@ -136,7 +137,7 @@ public class LoadingOrder {
       if (!order.myBefore.isEmpty()) hasBefore.add(o);
     }
 
-    GraphGenerator.SemiGraph<Orderable> graph = new GraphGenerator.SemiGraph<Orderable>() {
+    InboundSemiGraph<Orderable> graph = new InboundSemiGraph<Orderable>() {
       @Override
       public Collection<Orderable> getNodes() {
         List<Orderable> list = ContainerUtil.newArrayList(orderable);
@@ -183,7 +184,7 @@ public class LoadingOrder {
       }
     };
 
-    DFSTBuilder<Orderable> builder = new DFSTBuilder<Orderable>(new GraphGenerator<Orderable>(new CachingSemiGraph<Orderable>(graph)));
+    DFSTBuilder<Orderable> builder = new DFSTBuilder<Orderable>(GraphGenerator.generate(CachingSemiGraph.cache(graph)));
 
     if (!builder.isAcyclic()) {
       Couple<Orderable> p = builder.getCircularDependency();
index a035e0db496ef5027cc2a2b82b5aa3d5884e776e..45b171e20b67200d70d4167ba2ce8bb037f396f0 100644 (file)
@@ -47,6 +47,7 @@ import com.intellij.util.containers.ContainerUtil;
 import com.intellij.util.graph.CachingSemiGraph;
 import com.intellij.util.graph.Graph;
 import com.intellij.util.graph.GraphGenerator;
+import com.intellij.util.graph.InboundSemiGraph;
 import gnu.trove.THashMap;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -251,15 +252,15 @@ public abstract class AbstractIdeModifiableModelsProvider extends IdeModelsProvi
   @Override
   public List<Module> getAllDependentModules(@NotNull Module module) {
     final ArrayList<Module> list = new ArrayList<>();
-    final Graph<Module> graph = getModuleGraph(true);
+    final Graph<Module> graph = getModuleGraph();
     for (Iterator<Module> i = graph.getOut(module); i.hasNext();) {
       list.add(i.next());
     }
     return list;
   }
 
-  private Graph<Module> getModuleGraph(final boolean includeTests) {
-    return GraphGenerator.create(CachingSemiGraph.create(new GraphGenerator.SemiGraph<Module>() {
+  private Graph<Module> getModuleGraph() {
+    return GraphGenerator.generate(CachingSemiGraph.cache(new InboundSemiGraph<Module>() {
       @Override
       public Collection<Module> getNodes() {
         return ContainerUtil.list(getModules());
@@ -267,7 +268,7 @@ public abstract class AbstractIdeModifiableModelsProvider extends IdeModelsProvi
 
       @Override
       public Iterator<Module> getIn(Module m) {
-        Module[] dependentModules = getModifiableRootModel(m).getModuleDependencies(includeTests);
+        Module[] dependentModules = getModifiableRootModel(m).getModuleDependencies(true);
         return Arrays.asList(dependentModules).iterator();
       }
     }));
index f877fd2f579e8da6e87c173d5062c8308d32073e..c87852d22ded4c80125b2ed7962fd1be98cc9298 100644 (file)
@@ -81,7 +81,7 @@ public class GraphAlgorithmsImpl extends GraphAlgorithms {
       }
     }
 
-    return GraphGenerator.create(CachingSemiGraph.create(new GraphGenerator.SemiGraph<Chunk<Node>>() {
+    return GraphGenerator.generate(CachingSemiGraph.cache(new InboundSemiGraph<Chunk<Node>>() {
       @Override
       public Collection<Chunk<Node>> getNodes() {
         return chunks;
index c2b0a09c6897c2eaeb1327a9e79b3f7cb55d8ef4..aec869826e7127f98080835a55b5b6d2d1ad014a 100644 (file)
@@ -44,10 +44,7 @@ import com.intellij.util.containers.HashMap;
 import com.intellij.util.containers.StringInterner;
 import com.intellij.util.containers.hash.HashSet;
 import com.intellij.util.containers.hash.LinkedHashMap;
-import com.intellij.util.graph.CachingSemiGraph;
-import com.intellij.util.graph.DFSTBuilder;
-import com.intellij.util.graph.Graph;
-import com.intellij.util.graph.GraphGenerator;
+import com.intellij.util.graph.*;
 import com.intellij.util.io.URLUtil;
 import com.intellij.util.messages.MessageBus;
 import gnu.trove.THashMap;
@@ -782,7 +779,7 @@ public abstract class ModuleManagerImpl extends ModuleManager implements Project
     }
 
     private Graph<Module> moduleGraph(final boolean includeTests) {
-      return GraphGenerator.create(CachingSemiGraph.create(new GraphGenerator.SemiGraph<Module>() {
+      return GraphGenerator.generate(CachingSemiGraph.cache(new InboundSemiGraph<Module>() {
         @Override
         public Collection<Module> getNodes() {
           return myModules.values();
index 78dcd8c364335ffb691d365843ab8e98e9852b02..fccc6d2bbfbff8577fdb54d9648b1afe3cd8a081 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2015 JetBrains s.r.o.
+ * Copyright 2000-2016 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -26,6 +26,7 @@ import com.intellij.util.containers.ContainerUtil;
 import com.intellij.util.graph.CachingSemiGraph;
 import com.intellij.util.graph.DFSTBuilder;
 import com.intellij.util.graph.GraphGenerator;
+import com.intellij.util.graph.InboundSemiGraph;
 import org.jetbrains.annotations.NotNull;
 
 import java.util.*;
@@ -89,7 +90,7 @@ public class ModifiableModelCommitter {
     }
 
     final Collection<RootModelImpl> allRootModels = nameToModel.values();
-    GraphGenerator.SemiGraph<RootModelImpl> graph = new GraphGenerator.SemiGraph<RootModelImpl>() {
+    InboundSemiGraph<RootModelImpl> graph = new InboundSemiGraph<RootModelImpl>() {
       @Override
       public Collection<RootModelImpl> getNodes() {
         return allRootModels;
@@ -126,6 +127,6 @@ public class ModifiableModelCommitter {
         return result.iterator();
       }
     };
-    return new DFSTBuilder<>(new GraphGenerator<>(new CachingSemiGraph<>(graph)));
+    return new DFSTBuilder<>(GraphGenerator.generate(CachingSemiGraph.cache(graph)));
   }
 }
index a52f36094dda86e5866df5b33e41aa05c0f5cd59..30d78eddfe0db5c9e90e9e05b6fcb82e6bf7bebb 100644 (file)
@@ -51,10 +51,12 @@ public class CachingSemiGraph<Node> implements GraphGenerator.SemiGraph<Node> {
   }
 
   //<editor-fold desc="Deprecated stuff.">
+  /** @deprecated use {@link #cache(InboundSemiGraph)} (to be removed in IDEA 2018) */
   public static <T> CachingSemiGraph<T> create(GraphGenerator.SemiGraph<T> original) {
     return new CachingSemiGraph<T>((InboundSemiGraph<T>)original);
   }
 
+  /** @deprecated use {@link #cache(InboundSemiGraph)} (to be removed in IDEA 2018) */
   public CachingSemiGraph(GraphGenerator.SemiGraph<Node> original) {
     this((InboundSemiGraph<Node>)original);
   }
index 73a50dd29b96ecde8aef34a7d458999d43489b94..a7315975ebc9a18b8e32ce8caec30a669d2a46a7 100644 (file)
@@ -75,10 +75,12 @@ public class GraphGenerator<Node> implements Graph<Node> {
     Iterator<Node> getIn(Node n);
   }
 
+  /** @deprecated use {@link #generate(InboundSemiGraph)} (to be removed in IDEA 2018) */
   public GraphGenerator(SemiGraph<Node> graph) {
     this((InboundSemiGraph<Node>)graph);
   }
 
+  /** @deprecated use {@link #generate(InboundSemiGraph)} (to be removed in IDEA 2018) */
   public static <T> GraphGenerator<T> create(SemiGraph<T> graph) {
     return new GraphGenerator<T>((InboundSemiGraph<T>)graph);
   }
index fc367d2cfdd3ff217cbce56c06e962154894bc2b..eded63a17c45f650e52bdbcf147d4649979b2a3f 100644 (file)
@@ -24,7 +24,7 @@ import java.util.*;
 import static org.junit.Assert.*;
 
 /**
- *  @author dsl
+ * @author dsl
  */
 public class DFSTBuilderTest {
   @Test
@@ -44,7 +44,7 @@ public class DFSTBuilderTest {
     map.put(nE, new TestNode[]{nC});
     map.put(nF, new TestNode[]{nB});
 
-    GraphGenerator<TestNode> graph = graphByNodes(allNodes, map);
+    Graph<TestNode> graph = graphByNodes(allNodes, map);
     DFSTBuilder<TestNode> builder = new DFSTBuilder<>(graph);
     if (!builder.isAcyclic()) {
       fail("Acyclic graph expected");
@@ -60,8 +60,8 @@ public class DFSTBuilderTest {
     assertTrue(comparator.compare(nB, nF) < 0);
   }
 
-  private static GraphGenerator<TestNode> graphByNodes(TestNode[] allNodes, Map<TestNode, TestNode[]> mapIn) {
-    return new GraphGenerator<>(new GraphGenerator.SemiGraph<TestNode>() {
+  private static Graph<TestNode> graphByNodes(TestNode[] allNodes, Map<TestNode, TestNode[]> mapIn) {
+    return GraphGenerator.generate(new InboundSemiGraph<TestNode>() {
       @Override
       public Collection<TestNode> getNodes() {
         return Arrays.asList(allNodes);
@@ -90,9 +90,9 @@ public class DFSTBuilderTest {
   }
 
   private static void checkCircularDependencyDetected(TestNode[] allNodes, Map<TestNode, TestNode[]> map) {
-    GraphGenerator<TestNode> graph = graphByNodes(allNodes, map);
+    Graph<TestNode> graph = graphByNodes(allNodes, map);
     DFSTBuilder<TestNode> builder = new DFSTBuilder<>(graph);
-    assertTrue (builder.getCircularDependency() != null);
+    assertTrue(builder.getCircularDependency() != null);
   }
 
   @Test
@@ -131,7 +131,7 @@ public class DFSTBuilderTest {
     map.put(nB, new TestNode[]{nA});
     map.put(nC, new TestNode[]{nB});
     map.put(nD, new TestNode[]{nB});
-    GraphGenerator<TestNode> graph = graphByNodes(allNodes, map);
+    Graph<TestNode> graph = graphByNodes(allNodes, map);
     DFSTBuilder<TestNode> builder = new DFSTBuilder<>(graph);
     assertFalse(builder.isAcyclic());
     Comparator<TestNode> comparator = builder.comparator();
@@ -151,7 +151,7 @@ public class DFSTBuilderTest {
       }
     }
     map.put(allNodes[0], new TestNode[]{allNodes[allNodes.length - 1]});
-    GraphGenerator<TestNode> graph = graphByNodes(allNodes, map);
+    Graph<TestNode> graph = graphByNodes(allNodes, map);
     DFSTBuilder<TestNode> builder = new DFSTBuilder<>(graph);
     assertFalse(builder.isAcyclic());
   }
@@ -167,13 +167,13 @@ public class DFSTBuilderTest {
     TestNode[] allNodes = {main, dep, d, d2, resMain, resDep};
     Map<TestNode, TestNode[]> mapIn = new HashMap<>();
     mapIn.put(main, new TestNode[]{d, resMain});
-    mapIn.put(dep, new TestNode[]{main,resDep});
+    mapIn.put(dep, new TestNode[]{main, resDep});
     mapIn.put(d, new TestNode[]{d2});
     mapIn.put(d2, new TestNode[]{dep, d});
-    GraphGenerator<TestNode> graph = graphByNodes(allNodes, mapIn);
+    Graph<TestNode> graph = graphByNodes(allNodes, mapIn);
 
     DFSTBuilder<TestNode> builder = new DFSTBuilder<>(graph);
-    assertTrue (!builder.isAcyclic());
+    assertTrue(!builder.isAcyclic());
     Comparator<TestNode> comparator = builder.comparator();
     assertTrue(comparator.compare(resMain, main) < 0);
     assertTrue(comparator.compare(resMain, d) < 0);
@@ -188,20 +188,20 @@ public class DFSTBuilderTest {
     TestNode a = new TestNode("a");
     TestNode b = new TestNode("b");
     TestNode c = new TestNode("c");
-    for (int oIndex = 0; oIndex<4; oIndex++) {
+    for (int oIndex = 0; oIndex < 4; oIndex++) {
       List<TestNode> list = new ArrayList<>(Arrays.asList(a, b, c));
       list.add(oIndex, o);
       TestNode[] allNodes = list.toArray(new TestNode[list.size()]);
 
       Map<TestNode, TestNode[]> mapIn = new HashMap<>();
-      mapIn.put(o, new TestNode[]{a,b,c});
+      mapIn.put(o, new TestNode[]{a, b, c});
 
       DFSTBuilder<TestNode> builder = new DFSTBuilder<>(graphByNodes(allNodes, mapIn));
-      assertTrue (builder.isAcyclic());
+      assertTrue(builder.isAcyclic());
       Comparator<TestNode> comparator = builder.comparator();
       TestNode[] sorted = allNodes.clone();
       Arrays.sort(sorted, comparator);
-      assertEquals("All nodes: "+list, Arrays.asList(c,b,a,o), Arrays.asList(sorted));
+      assertEquals("All nodes: " + list, Arrays.asList(c, b, a, o), Arrays.asList(sorted));
     }
   }
 
@@ -212,28 +212,28 @@ public class DFSTBuilderTest {
     TestNode a = new TestNode("a");
     TestNode b = new TestNode("b");
     TestNode c = new TestNode("c");
-    for (int oIndex = 0; oIndex<4; oIndex++) {
+    for (int oIndex = 0; oIndex < 4; oIndex++) {
       List<TestNode> list = new ArrayList<>(Arrays.asList(a, b, c));
       list.add(oIndex, o1);
       list.add(oIndex, o2);
       TestNode[] allNodes = list.toArray(new TestNode[list.size()]);
 
       Map<TestNode, TestNode[]> mapIn = new HashMap<>();
-      mapIn.put(o1, new TestNode[]{a,b,c,o2});
+      mapIn.put(o1, new TestNode[]{a, b, c, o2});
       mapIn.put(o2, new TestNode[]{o1});
 
       DFSTBuilder<TestNode> builder = new DFSTBuilder<>(graphByNodes(allNodes, mapIn));
       assertFalse(builder.isAcyclic());
       Comparator<TestNode> comparator = builder.comparator();
-      assertTrue("All nodes: "+list,comparator.compare(b, a) < 0); //reversed loading order
-      assertTrue("All nodes: "+list,comparator.compare(c, a) < 0); //reversed loading order
-      assertTrue("All nodes: "+list,comparator.compare(c, b) < 0); //reversed loading order
-      assertTrue("All nodes: "+list,comparator.compare(a, o1) < 0);
-      assertTrue("All nodes: "+list,comparator.compare(a, o2) < 0);
-      assertTrue("All nodes: "+list,comparator.compare(b, o1) < 0);
-      assertTrue("All nodes: "+list,comparator.compare(b, o2) < 0);
-      assertTrue("All nodes: "+list,comparator.compare(c, o1) < 0);
-      assertTrue("All nodes: "+list,comparator.compare(c, o2) < 0);
+      assertTrue("All nodes: " + list, comparator.compare(b, a) < 0); //reversed loading order
+      assertTrue("All nodes: " + list, comparator.compare(c, a) < 0); //reversed loading order
+      assertTrue("All nodes: " + list, comparator.compare(c, b) < 0); //reversed loading order
+      assertTrue("All nodes: " + list, comparator.compare(a, o1) < 0);
+      assertTrue("All nodes: " + list, comparator.compare(a, o2) < 0);
+      assertTrue("All nodes: " + list, comparator.compare(b, o1) < 0);
+      assertTrue("All nodes: " + list, comparator.compare(b, o2) < 0);
+      assertTrue("All nodes: " + list, comparator.compare(c, o1) < 0);
+      assertTrue("All nodes: " + list, comparator.compare(c, o2) < 0);
     }
   }
 }
\ No newline at end of file
index d041524e60147347c6aa13f1e7c721b19f044b68..14e54c2bf3396bd644ac5574add1377aa31a12ce 100644 (file)
@@ -29,7 +29,7 @@ public class GraphGeneratorTest {
   @Test
   public void testEmptyGraph() {
     TestNode node = new TestNode("A");
-    GraphGenerator<TestNode> graphGenerator = new GraphGenerator<>(new GraphGenerator.SemiGraph<TestNode>() {
+    Graph<TestNode> graph = GraphGenerator.generate(new InboundSemiGraph<TestNode>() {
       @Override
       public Collection<TestNode> getNodes() {
         return Collections.singletonList(node);
@@ -41,7 +41,7 @@ public class GraphGeneratorTest {
       }
     });
 
-    assertFalse(graphGenerator.getOut(node).hasNext());
+    assertFalse(graph.getOut(node).hasNext());
   }
 
   @Test
@@ -52,7 +52,7 @@ public class GraphGeneratorTest {
     TestNode[] inA = {nodeB};
     TestNode[] inB = {nodeA};
 
-    GraphGenerator<TestNode> graph = new GraphGenerator<>(new GraphGenerator.SemiGraph<TestNode>() {
+    Graph<TestNode> graph = GraphGenerator.generate(new InboundSemiGraph<TestNode>() {
       @Override
       public Collection<TestNode> getNodes() {
         return Arrays.asList(nodes);
index dda507752c75cfa5a502d4bd5ca17647918f7fc2..a972f83e6bb007ca9f68ec78e133994340847d97 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2015 JetBrains s.r.o.
+ * Copyright 2000-2016 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -32,9 +32,7 @@ import com.intellij.openapi.util.Pair;
 import com.intellij.openapi.util.io.FileUtil;
 import com.intellij.util.PathUtil;
 import com.intellij.util.SystemProperties;
-import com.intellij.util.graph.CachingSemiGraph;
-import com.intellij.util.graph.DFSTBuilder;
-import com.intellij.util.graph.GraphGenerator;
+import com.intellij.util.graph.*;
 import com.intellij.util.xmlb.XmlSerializer;
 import com.intellij.util.xmlb.annotations.AbstractCollection;
 import com.intellij.util.xmlb.annotations.MapAnnotation;
@@ -242,8 +240,8 @@ public class ConversionServiceImpl extends ConversionService {
         runners.add(new ConversionRunner(provider, context));
       }
     }
-    final CachingSemiGraph<ConverterProvider> graph = CachingSemiGraph.create(new ConverterProvidersGraph(providers));
-    final DFSTBuilder<ConverterProvider> builder = new DFSTBuilder<>(GraphGenerator.create(graph));
+    final Graph<ConverterProvider> graph = GraphGenerator.generate(CachingSemiGraph.cache(new ConverterProvidersGraph(providers)));
+    final DFSTBuilder<ConverterProvider> builder = new DFSTBuilder<>(graph);
     if (!builder.isAcyclic()) {
       final Pair<ConverterProvider,ConverterProvider> pair = builder.getCircularDependency();
       LOG.error("cyclic dependencies between converters: " + pair.getFirst().getId() + " and " + pair.getSecond().getId());
@@ -384,7 +382,7 @@ public class ConversionServiceImpl extends ConversionService {
     public Map<String, Long> myProjectFilesTimestamps = new HashMap<>();
   }
 
-  private static class ConverterProvidersGraph implements GraphGenerator.SemiGraph<ConverterProvider> {
+  private static class ConverterProvidersGraph implements InboundSemiGraph<ConverterProvider> {
     private final ConverterProvider[] myProviders;
 
     public ConverterProvidersGraph(ConverterProvider[] providers) {
index 44f49d5834262d1a98eef1ec86ba81eb04fcb849..423176aaea01da33dd5e2710426fd17ac5a9bbf0 100644 (file)
@@ -21,10 +21,7 @@ import com.intellij.psi.*;
 import com.intellij.psi.codeStyle.CodeStyleManager;
 import com.intellij.psi.codeStyle.JavaCodeStyleManager;
 import com.intellij.psi.util.PsiTreeUtil;
-import com.intellij.util.graph.CachingSemiGraph;
-import com.intellij.util.graph.DFSTBuilder;
-import com.intellij.util.graph.Graph;
-import com.intellij.util.graph.GraphGenerator;
+import com.intellij.util.graph.*;
 import com.siyeh.InspectionGadgetsBundle;
 import com.siyeh.ig.BaseInspection;
 import com.siyeh.ig.BaseInspectionVisitor;
@@ -320,8 +317,7 @@ public class TailRecursionInspection extends BaseInspection {
     }
 
     private static Graph<Integer> buildGraph(PsiParameter[] parameters, PsiExpression[] arguments) {
-      final GraphGenerator.SemiGraph<Integer> graph = new GraphGenerator.SemiGraph<Integer>() {
-
+      final InboundSemiGraph<Integer> graph = new InboundSemiGraph<Integer>() {
         @Override
         public Collection<Integer> getNodes() {
           final List<Integer> result = new ArrayList<>();
@@ -344,7 +340,7 @@ public class TailRecursionInspection extends BaseInspection {
           return result.iterator();
         }
       };
-      return GraphGenerator.create(CachingSemiGraph.create(graph));
+      return GraphGenerator.generate(CachingSemiGraph.cache(graph));
     }
 
     private static boolean isImplicitCallOnThis(PsiElement element, PsiMethod containingMethod) {
index 2d34a3de9342cb0559389861d1e173786885b088..546de727e95306b97fcc4d04276afd2411734009 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2015 JetBrains s.r.o.
+ * Copyright 2000-2016 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -31,9 +31,7 @@ import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiWhiteSpace;
 import com.intellij.psi.codeStyle.CodeStyleManager;
 import com.intellij.util.IncorrectOperationException;
-import com.intellij.util.graph.CachingSemiGraph;
-import com.intellij.util.graph.DFSTBuilder;
-import com.intellij.util.graph.GraphGenerator;
+import com.intellij.util.graph.*;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
@@ -169,7 +167,7 @@ public class ResourceBundlePropertiesUpdateManager {
   @Nullable
   private static Pair<List<String>, Boolean> keysOrder(final ResourceBundle resourceBundle) {
     final boolean[] isAlphaSorted = new boolean[]{true};
-    final GraphGenerator<String> generator = GraphGenerator.create(CachingSemiGraph.create(new GraphGenerator.SemiGraph<String>() {
+    final Graph<String> generator = GraphGenerator.generate(CachingSemiGraph.cache(new InboundSemiGraph<String>() {
       @Override
       public Collection<String> getNodes() {
         final Set<String> nodes = new LinkedHashSet<>();