mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Cleanup (migrates graph usages to lighter API)
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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<>();
|
||||
|
||||
+7
-10
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
+5
-4
@@ -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();
|
||||
}
|
||||
}));
|
||||
|
||||
@@ -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;
|
||||
|
||||
+2
-5
@@ -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();
|
||||
|
||||
+4
-3
@@ -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)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
+3
-7
@@ -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) {
|
||||
|
||||
+3
-5
@@ -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<>();
|
||||
|
||||
Reference in New Issue
Block a user