Java 类com.intellij.util.graph.GraphGenerator 实例源码

项目:intellij-ce-playground    文件:JarsBuilder.java   
@Nullable
private JarInfo[] sortJars() {
  final DFSTBuilder<JarInfo> builder = new DFSTBuilder<JarInfo>(GraphGenerator.create(CachingSemiGraph.create(new JarsGraph())));
  if (!builder.isAcyclic()) {
    final Pair<JarInfo, JarInfo> dependency = builder.getCircularDependency();
    String message = "Cannot build: circular dependency found between '" + dependency.getFirst().getPresentableDestination() +
                     "' and '" + dependency.getSecond().getPresentableDestination() + "'";
    myContext.processMessage(new CompilerMessage(IncArtifactBuilder.BUILDER_NAME, BuildMessage.Kind.ERROR, message));
    return null;
  }

  JarInfo[] jars = myJarsToBuild.toArray(new JarInfo[myJarsToBuild.size()]);
  Arrays.sort(jars, builder.comparator());
  jars = ArrayUtil.reverseArray(jars);
  return jars;
}
项目:intellij-ce-playground    文件:CyclicDependenciesBuilder.java   
private Graph<PsiPackage> buildGraph() {
  final Graph<PsiPackage> graph = GraphGenerator.create(CachingSemiGraph.create(new GraphGenerator.SemiGraph<PsiPackage>() {
    public Collection<PsiPackage> getNodes() {
      return getAllScopePackages().values();
    }

    public Iterator<PsiPackage> getIn(PsiPackage psiPack) {
      final Set<PsiPackage> psiPackages = myPackageDependencies.get(psiPack);
      if (psiPackages == null) {     //for packs without java classes
        return new HashSet<PsiPackage>().iterator();
      }
      return psiPackages.iterator();
    }
  }));
  return graph;
}
项目:intellij-ce-playground    文件:ConversionServiceImpl.java   
private static List<ConversionRunner> createConversionRunners(ConversionContextImpl context, final Set<String> performedConversionIds) {
  List<ConversionRunner> runners = new ArrayList<ConversionRunner>();
  final ConverterProvider[] providers = ConverterProvider.EP_NAME.getExtensions();
  for (ConverterProvider provider : providers) {
    if (!performedConversionIds.contains(provider.getId())) {
      runners.add(new ConversionRunner(provider, context));
    }
  }
  final CachingSemiGraph<ConverterProvider> graph = CachingSemiGraph.create(new ConverterProvidersGraph(providers));
  final DFSTBuilder<ConverterProvider> builder = new DFSTBuilder<ConverterProvider>(GraphGenerator.create(graph));
  if (!builder.isAcyclic()) {
    final Pair<ConverterProvider,ConverterProvider> pair = builder.getCircularDependency();
    LOG.error("cyclic dependencies between converters: " + pair.getFirst().getId() + " and " + pair.getSecond().getId());
  }
  final Comparator<ConverterProvider> comparator = builder.comparator();
  Collections.sort(runners, new Comparator<ConversionRunner>() {
    @Override
    public int compare(ConversionRunner o1, ConversionRunner o2) {
      return comparator.compare(o1.getProvider(), o2.getProvider());
    }
  });
  return runners;
}
项目:tools-idea    文件:JarsBuilder.java   
@Nullable
private JarInfo[] sortJars() {
  final DFSTBuilder<JarInfo> builder = new DFSTBuilder<JarInfo>(GraphGenerator.create(CachingSemiGraph.create(new JarsGraph())));
  if (!builder.isAcyclic()) {
    final Pair<JarInfo, JarInfo> dependency = builder.getCircularDependency();
    String message = "Cannot build: circular dependency found between '" + dependency.getFirst().getPresentableDestination() +
                     "' and '" + dependency.getSecond().getPresentableDestination() + "'";
    myContext.processMessage(new CompilerMessage(IncArtifactBuilder.BUILDER_NAME, BuildMessage.Kind.ERROR, message));
    return null;
  }

  JarInfo[] jars = myJarsToBuild.toArray(new JarInfo[myJarsToBuild.size()]);
  Arrays.sort(jars, builder.comparator());
  jars = ArrayUtil.reverseArray(jars);
  return jars;
}
项目:tools-idea    文件:CyclicDependenciesBuilder.java   
private Graph<PsiPackage> buildGraph() {
  final Graph<PsiPackage> graph = GraphGenerator.create(CachingSemiGraph.create(new GraphGenerator.SemiGraph<PsiPackage>() {
    public Collection<PsiPackage> getNodes() {
      return getAllScopePackages().values();
    }

    public Iterator<PsiPackage> getIn(PsiPackage psiPack) {
      final Set<PsiPackage> psiPackages = myPackageDependencies.get(psiPack);
      if (psiPackages == null) {     //for packs without java classes
        return new HashSet<PsiPackage>().iterator();
      }
      return psiPackages.iterator();
    }
  }));
  return graph;
}
项目:tools-idea    文件:CompilerManagerImpl.java   
private Graph<Compiler> createCompilerGraph(final List<Compiler> compilers) {
  return GraphGenerator.create(CachingSemiGraph.create(new GraphGenerator.SemiGraph<Compiler>() {
    public Collection<Compiler> getNodes() {
      return compilers;
    }

    public Iterator<Compiler> getIn(Compiler compiler) {
      final Set<FileType> compilerInput = myCompilerToInputTypes.get(compiler);
      if (compilerInput == null || compilerInput.isEmpty()) {
        return Collections.<Compiler>emptySet().iterator();
      }

      final Set<Compiler> inCompilers = new HashSet<Compiler>();

      for (Map.Entry<Compiler, Set<FileType>> entry : myCompilerToOutputTypes.entrySet()) {
        final Set<FileType> outputs = entry.getValue();
        Compiler comp = entry.getKey();
        if (outputs != null && ContainerUtil.intersects(compilerInput, outputs)) {
          inCompilers.add(comp);
        }
      }
      return inCompilers.iterator();
    }
  }));
}
项目:tools-idea    文件:JarsBuilder.java   
@Nullable
private JarInfo[] sortJars() {
  final DFSTBuilder<JarInfo> builder = new DFSTBuilder<JarInfo>(GraphGenerator.create(CachingSemiGraph.create(new JarsGraph())));
  if (!builder.isAcyclic()) {
    final Pair<JarInfo, JarInfo> dependency = builder.getCircularDependency();
    String message = CompilerBundle.message("packaging.compiler.error.cannot.build.circular.dependency.found.between.0.and.1",
                                            dependency.getFirst().getPresentableDestination(),
                                            dependency.getSecond().getPresentableDestination());
    myContext.addMessage(CompilerMessageCategory.ERROR, message, null, -1, -1);
    return null;
  }

  JarInfo[] jars = myJarsToBuild.toArray(new JarInfo[myJarsToBuild.size()]);
  Arrays.sort(jars, builder.comparator());
  jars = ArrayUtil.reverseArray(jars);
  return jars;
}
项目:tools-idea    文件:ConversionServiceImpl.java   
private static List<ConversionRunner> createConversionRunners(ConversionContextImpl context, final Set<String> performedConversionIds) {
  List<ConversionRunner> runners = new ArrayList<ConversionRunner>();
  final ConverterProvider[] providers = ConverterProvider.EP_NAME.getExtensions();
  for (ConverterProvider provider : providers) {
    if (!performedConversionIds.contains(provider.getId())) {
      runners.add(new ConversionRunner(provider, context));
    }
  }
  final CachingSemiGraph<ConverterProvider> graph = CachingSemiGraph.create(new ConverterProvidersGraph(providers));
  final DFSTBuilder<ConverterProvider> builder = new DFSTBuilder<ConverterProvider>(GraphGenerator.create(graph));
  if (!builder.isAcyclic()) {
    final Pair<ConverterProvider,ConverterProvider> pair = builder.getCircularDependency();
    LOG.error("cyclic dependencies between converters: " + pair.getFirst().getId() + " and " + pair.getSecond().getId());
  }
  final Comparator<ConverterProvider> comparator = builder.comparator();
  Collections.sort(runners, new Comparator<ConversionRunner>() {
    @Override
    public int compare(ConversionRunner o1, ConversionRunner o2) {
      return comparator.compare(o1.getProvider(), o2.getProvider());
    }
  });
  return runners;
}
项目:consulo    文件:ArchivesBuilder.java   
@Nullable
private ArchivePackageInfo[] sortArchives() {
  final DFSTBuilder<ArchivePackageInfo> builder = new DFSTBuilder<>(GraphGenerator.create(CachingSemiGraph.create(new ArchivesGraph())));
  if (!builder.isAcyclic()) {
    final Pair<ArchivePackageInfo, ArchivePackageInfo> dependency = builder.getCircularDependency();
    String message = CompilerBundle
            .message("packaging.compiler.error.cannot.build.circular.dependency.found.between.0.and.1", dependency.getFirst().getPresentableDestination(),
                     dependency.getSecond().getPresentableDestination());
    myContext.addMessage(CompilerMessageCategory.ERROR, message, null, -1, -1);
    return null;
  }

  ArchivePackageInfo[] archives = myArchivesToBuild.toArray(new ArchivePackageInfo[myArchivesToBuild.size()]);
  Arrays.sort(archives, builder.comparator());
  archives = ArrayUtil.reverseArray(archives);
  return archives;
}
项目:consulo-java    文件:CyclicDependenciesBuilder.java   
private Graph<PsiJavaPackage> buildGraph() {
  final Graph<PsiJavaPackage> graph = GraphGenerator.create(CachingSemiGraph.create(new GraphGenerator.SemiGraph<PsiJavaPackage>() {
    public Collection<PsiJavaPackage> getNodes() {
      return getAllScopePackages().values();
    }

    public Iterator<PsiJavaPackage> getIn(PsiJavaPackage psiPack) {
      final Set<PsiJavaPackage> psiPackages = myPackageDependencies.get(psiPack);
      if (psiPackages == null) {     //for packs without java classes
        return new HashSet<PsiJavaPackage>().iterator();
      }
      return psiPackages.iterator();
    }
  }));
  return graph;
}
项目:intellij-ce-playground    文件:ArtifactSorter.java   
private List<JpsArtifact> doGetSortedArtifacts() {
  GraphGenerator<JpsArtifact> graph = createArtifactsGraph();
  DFSTBuilder<JpsArtifact> builder = new DFSTBuilder<JpsArtifact>(graph);
  List<JpsArtifact> names = new ArrayList<JpsArtifact>();
  names.addAll(graph.getNodes());
  Collections.sort(names, builder.comparator());
  return names;
}
项目:intellij-ce-playground    文件:FrameworkSupportUtil.java   
public static Comparator<FrameworkSupportInModuleProvider> getFrameworkSupportProvidersComparator(final List<FrameworkSupportInModuleProvider> types) {
  DFSTBuilder<FrameworkSupportInModuleProvider>
    builder = new DFSTBuilder<FrameworkSupportInModuleProvider>(GraphGenerator.create(CachingSemiGraph.create(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.");
  }

  return builder.comparator();
}
项目:intellij-ce-playground    文件:ModuleManagerImpl.java   
private Graph<Module> moduleGraph(final boolean includeTests) {
  return GraphGenerator.create(CachingSemiGraph.create(new GraphGenerator.SemiGraph<Module>() {
    @Override
    public Collection<Module> getNodes() {
      return myModules.values();
    }

    @Override
    public Iterator<Module> getIn(Module m) {
      Module[] dependentModules = ModuleRootManager.getInstance(m).getDependencies(includeTests);
      return Arrays.asList(dependentModules).iterator();
    }
  }));
}
项目:intellij-ce-playground    文件:InspectionProfileImpl.java   
private boolean initialize(@Nullable Project project) {
  if (myBaseProfile != null) {
    myBaseProfile.initInspectionTools(project);
  }

  final List<InspectionToolWrapper> tools;
  try {
    tools = createTools(project);
  }
  catch (ProcessCanceledException ignored) {
    return false;
  }
  final Map<String, List<String>> dependencies = new HashMap<String, List<String>>();
  for (InspectionToolWrapper toolWrapper : tools) {
    addTool(project, toolWrapper, dependencies);
  }
  final GraphGenerator<String> graphGenerator = GraphGenerator.create(CachingSemiGraph.create(new GraphGenerator.SemiGraph<String>() {
    @Override
    public Collection<String> getNodes() {
      return dependencies.keySet();
    }

    @Override
    public Iterator<String> getIn(String n) {
      return dependencies.get(n).iterator();
    }
  }));

  DFSTBuilder<String> builder = new DFSTBuilder<String>(graphGenerator);
  if (builder.isAcyclic()) {
    final List<String> scopes = builder.getSortedNodes();
    myScopesOrder = ArrayUtil.toStringArray(scopes);
  }

  if (mySource != null) {
    copyToolsConfigurations(mySource, project);
  }
  return true;
}
项目:intellij-ce-playground    文件:AbstractIdeModifiableModelsProvider.java   
private Graph<Module> getModuleGraph(final boolean includeTests) {
  return GraphGenerator.create(CachingSemiGraph.create(new GraphGenerator.SemiGraph<Module>() {
    @Override
    public Collection<Module> getNodes() {
      return ContainerUtil.list(getModules());
    }

    @Override
    public Iterator<Module> getIn(Module m) {
      Module[] dependentModules = getModifiableRootModel(m).getModuleDependencies(includeTests);
      return Arrays.asList(dependentModules).iterator();
    }
  }));
}
项目:intellij-ce-playground    文件:PluginManagerCore.java   
@NotNull
private static Graph<PluginId> createPluginIdGraph(@NotNull final Map<PluginId, ? extends IdeaPluginDescriptor> idToDescriptorMap) {
  final List<PluginId> ids = new ArrayList<PluginId>(idToDescriptorMap.keySet());
  // this magic ensures that the dependent plugins always follow their dependencies in lexicographic order
  // needed to make sure that extensions are always in the same order
  Collections.sort(ids, new Comparator<PluginId>() {
    @Override
    public int compare(@NotNull PluginId o1, @NotNull PluginId o2) {
      return o2.getIdString().compareTo(o1.getIdString());
    }
  });
  return GraphGenerator.create(CachingSemiGraph.create(new GraphGenerator.SemiGraph<PluginId>() {
    @Override
    public Collection<PluginId> getNodes() {
      return ids;
    }

    @Override
    public Iterator<PluginId> getIn(PluginId pluginId) {
      final IdeaPluginDescriptor descriptor = idToDescriptorMap.get(pluginId);
      List<PluginId> plugins = new ArrayList<PluginId>();
      for (PluginId dependentPluginId : descriptor.getDependentPluginIds()) {
        // check for missing optional dependency
        IdeaPluginDescriptor dep = idToDescriptorMap.get(dependentPluginId);
        if (dep != null) {
          plugins.add(dep.getPluginId());
        }
      }
      return plugins.iterator();
    }
  }));
}
项目:tools-idea    文件:ArtifactSorter.java   
private List<JpsArtifact> doGetSortedArtifacts() {
  GraphGenerator<JpsArtifact> graph = createArtifactsGraph();
  DFSTBuilder<JpsArtifact> builder = new DFSTBuilder<JpsArtifact>(graph);
  builder.buildDFST();
  List<JpsArtifact> names = new ArrayList<JpsArtifact>();
  names.addAll(graph.getNodes());
  Collections.sort(names, builder.comparator());
  return names;
}
项目:tools-idea    文件:ModulesConfigurator.java   
public GraphGenerator<ModuleRootModel> createGraphGenerator() {
  final Map<Module, ModuleRootModel> models = new HashMap<Module, ModuleRootModel>();
  for (ModuleEditor moduleEditor : myModuleEditors) {
    models.put(moduleEditor.getModule(), moduleEditor.getRootModel());
  }
  return ModuleCompilerUtil.createGraphGenerator(models);
}
项目:tools-idea    文件:FrameworkSupportUtil.java   
public static Comparator<FrameworkSupportInModuleProvider> getFrameworkSupportProvidersComparator(final List<FrameworkSupportInModuleProvider> types) {
  DFSTBuilder<FrameworkSupportInModuleProvider>
    builder = new DFSTBuilder<FrameworkSupportInModuleProvider>(GraphGenerator.create(CachingSemiGraph.create(new ProvidersGraph(types))));
  if (!builder.isAcyclic()) {
    Pair<FrameworkSupportInModuleProvider, FrameworkSupportInModuleProvider> pair = builder.getCircularDependency();
    LOG.error("Circular dependency between types '" + pair.getFirst().getFrameworkType().getId() + "' and '" + pair.getSecond().getFrameworkType().getId() + "' was found.");
  }

  return builder.comparator();
}
项目:tools-idea    文件:ArtifactSortingUtilImpl.java   
private List<String> doGetSortedArtifacts() {
  GraphGenerator<String> graph = createArtifactsGraph();
  DFSTBuilder<String> builder = new DFSTBuilder<String>(graph);
  builder.buildDFST();
  List<String> names = new ArrayList<String>();
  names.addAll(graph.getNodes());
  Collections.sort(names, builder.comparator());
  return names;
}
项目:tools-idea    文件:ModuleManagerImpl.java   
private Graph<Module> moduleGraph(final boolean includeTests) {
  return GraphGenerator.create(CachingSemiGraph.create(new GraphGenerator.SemiGraph<Module>() {
    @Override
    public Collection<Module> getNodes() {
      return myPathToModule.values();
    }

    @Override
    public Iterator<Module> getIn(Module m) {
      Module[] dependentModules = ModuleRootManager.getInstance(m).getDependencies(includeTests);
      return Arrays.asList(dependentModules).iterator();
    }
  }));
}
项目:tools-idea    文件:PluginManagerCore.java   
private static Graph<PluginId> createPluginIdGraph(final Map<PluginId, IdeaPluginDescriptorImpl> idToDescriptorMap) {
  final List<PluginId> ids = new ArrayList<PluginId>(idToDescriptorMap.keySet());
  // this magic ensures that the dependent plugins always follow their dependencies in lexicographic order
  // needed to make sure that extensions are always in the same order
  Collections.sort(ids, new Comparator<PluginId>() {
    @Override
    public int compare(PluginId o1, PluginId o2) {
      return o2.getIdString().compareTo(o1.getIdString());
    }
  });
  return GraphGenerator.create(CachingSemiGraph.create(new GraphGenerator.SemiGraph<PluginId>() {
    @Override
    public Collection<PluginId> getNodes() {
      return ids;
    }

    @Override
    public Iterator<PluginId> getIn(PluginId pluginId) {
      final IdeaPluginDescriptor descriptor = idToDescriptorMap.get(pluginId);
      ArrayList<PluginId> plugins = new ArrayList<PluginId>();
      for (PluginId dependentPluginId : descriptor.getDependentPluginIds()) {
        // check for missing optional dependency
        if (idToDescriptorMap.containsKey(dependentPluginId)) {
          plugins.add(dependentPluginId);
        }
      }
      return plugins.iterator();
    }
  }));
}
项目:consulo    文件:CompilerManagerImpl.java   
private Graph<TranslatingCompiler> createCompilerGraph(final List<TranslatingCompiler> compilers) {
  return GraphGenerator.generate(new InboundSemiGraph<TranslatingCompiler>() {
    @Override
    public Collection<TranslatingCompiler> getNodes() {
      return compilers;
    }

    @Override
    public Iterator<TranslatingCompiler> getIn(TranslatingCompiler compiler) {
      final Collection<FileType> compilerInput = myTranslatingCompilerInputFileTypes.get(compiler);
      if (compilerInput == null || compilerInput.isEmpty()) {
        return Collections.<TranslatingCompiler>emptySet().iterator();
      }

      final Set<TranslatingCompiler> inCompilers = new HashSet<>();

      for (Map.Entry<TranslatingCompiler, Collection<FileType>> entry : myTranslatingCompilerOutputFileTypes.entrySet()) {
        final Collection<FileType> outputs = entry.getValue();
        TranslatingCompiler comp = entry.getKey();
        if (outputs != null && ContainerUtil.intersects(compilerInput, outputs)) {
          inCompilers.add(comp);
        }
      }
      return inCompilers.iterator();
    }
  });
}
项目:consulo    文件:ArtifactSortingUtilImpl.java   
private List<String> doGetSortedArtifacts() {
  GraphGenerator<String> graph = createArtifactsGraph();
  DFSTBuilder<String> builder = new DFSTBuilder<String>(graph);
  List<String> names = new ArrayList<String>();
  names.addAll(graph.getNodes());
  Collections.sort(names, builder.comparator());
  return names;
}
项目:consulo    文件:ModulesConfigurator.java   
public GraphGenerator<ModuleRootModel> createGraphGenerator() {
  final Map<Module, ModuleRootModel> models = new HashMap<Module, ModuleRootModel>();
  for (ModuleEditor moduleEditor : myModuleEditors) {
    models.put(moduleEditor.getModule(), moduleEditor.getRootModel());
  }
  return ModuleCompilerUtil.createGraphGenerator(models);
}
项目:consulo-java    文件:JavaModuleGraphUtil.java   
private static RequiresGraph buildRequiresGraph(Project project)
{
    MultiMap<PsiJavaModule, PsiJavaModule> relations = MultiMap.create();
    Set<String> transitiveEdges = ContainerUtil.newTroveSet();
    for(Module module : ModuleManager.getInstance(project).getModules())
    {
        Collection<VirtualFile> files = FilenameIndex.getVirtualFilesByName(project, MODULE_INFO_FILE, module.getModuleScope());
        Optional.ofNullable(ContainerUtil.getFirstItem(files)).map(PsiManager.getInstance(project)::findFile).map(f -> f instanceof PsiJavaFile ? ((PsiJavaFile) f).getModuleDeclaration() : null)
                .ifPresent(m -> visit(m, relations, transitiveEdges));
    }

    Graph<PsiJavaModule> graph = GraphGenerator.generate(new ChameleonGraph<>(relations, true));
    return new RequiresGraph(graph, transitiveEdges);
}
项目:intellij-ce-playground    文件:ArtifactSorter.java   
private GraphGenerator<JpsArtifact> createArtifactsGraph() {
  return GraphGenerator.create(CachingSemiGraph.create(new ArtifactsGraph(myModel)));
}
项目:tools-idea    文件:ArtifactSorter.java   
private GraphGenerator<JpsArtifact> createArtifactsGraph() {
  return GraphGenerator.create(CachingSemiGraph.create(new ArtifactsGraph(myModel)));
}
项目:tools-idea    文件:BuildTargetIndexImpl.java   
private synchronized void initializeChunks(@NotNull CompileContext context) {
  if (myTargetChunks != null) {
    return;
  }

  final List<? extends BuildTarget<?>> allTargets = getAllTargets();
  TargetOutputIndex outputIndex = new TargetOutputIndexImpl(allTargets, context);
  for (BuildTarget<?> target : allTargets) {
    myDependencies.put(target, target.computeDependencies(this, outputIndex));
  }

  GraphGenerator<BuildTarget<?>>
    graph = GraphGenerator.create(CachingSemiGraph.create(new GraphGenerator.SemiGraph<BuildTarget<?>>() {
    @Override
    public Collection<BuildTarget<?>> getNodes() {
      return myAllTargets;
    }

    @Override
    public Iterator<BuildTarget<?>> getIn(BuildTarget<?> n) {
      return myDependencies.get(n).iterator();
    }
  }));

  final DFSTBuilder<BuildTarget<?>> builder = new DFSTBuilder<BuildTarget<?>>(graph);
  final TIntArrayList sccs = builder.getSCCs();

  myTargetChunks = new ArrayList<BuildTargetChunk>(sccs.size());
  sccs.forEach(new TIntProcedure() {
    int myTNumber = 0;
    public boolean execute(int size) {
      final Set<BuildTarget<?>> chunkNodes = new LinkedHashSet<BuildTarget<?>>();
      for (int j = 0; j < size; j++) {
        final BuildTarget<?> node = builder.getNodeByTNumber(myTNumber + j);
        chunkNodes.add(node);
      }
      myTargetChunks.add(new BuildTargetChunk(chunkNodes));

      myTNumber += size;
      return true;
    }
  });
}
项目:tools-idea    文件:ArtifactSortingUtilImpl.java   
private GraphGenerator<String> createArtifactsGraph() {
  final ArtifactManager artifactManager = ArtifactManager.getInstance(myProject);
  return GraphGenerator.create(CachingSemiGraph.create(new ArtifactsGraph(artifactManager)));
}
项目:consulo    文件:ArtifactSortingUtilImpl.java   
private GraphGenerator<String> createArtifactsGraph() {
  final ArtifactManager artifactManager = ArtifactManager.getInstance(myProject);
  return GraphGenerator.create(CachingSemiGraph.create(new ArtifactsGraph(artifactManager)));
}
项目:consulo    文件:InspectionProfileImpl.java   
private boolean initialize(@Nullable Project project) {
  if (myBaseProfile != null) {
    myBaseProfile.initInspectionTools(project);
  }

  final List<InspectionToolWrapper> tools;
  try {
    tools = createTools(project);
  }
  catch (ProcessCanceledException ignored) {
    return false;
  }
  final Map<String, List<String>> dependencies = new HashMap<String, List<String>>();
  for (InspectionToolWrapper toolWrapper : tools) {
    final String shortName = toolWrapper.getShortName();
    HighlightDisplayKey key = HighlightDisplayKey.find(shortName);
    if (key == null) {
      final InspectionEP extension = toolWrapper.getExtension();
      Computable<String> computable = extension == null ? new Computable.PredefinedValueComputable<String>(toolWrapper.getDisplayName()) : new Computable<String>() {
        @Override
        public String compute() {
          return extension.getDisplayName();
        }
      };
      if (toolWrapper instanceof LocalInspectionToolWrapper) {
        key = HighlightDisplayKey.register(shortName, computable, ((LocalInspectionToolWrapper)toolWrapper).getID(),
                                           ((LocalInspectionToolWrapper)toolWrapper).getAlternativeID());
      }
      else {
        key = HighlightDisplayKey.register(shortName, computable);
      }
    }

    LOG.assertTrue(key != null, shortName + " ; number of initialized tools: " + myTools.size());
    HighlightDisplayLevel level = myBaseProfile != null ? myBaseProfile.getErrorLevel(key, project) : toolWrapper.getDefaultLevel();
    boolean enabled = myBaseProfile != null ? myBaseProfile.isToolEnabled(key) : toolWrapper.isEnabledByDefault();
    final ToolsImpl toolsList = new ToolsImpl(toolWrapper, level, !myLockedProfile && enabled, enabled);
    final Element element = myUninstalledInspectionsSettings.remove(shortName);
    try {
      if (element != null) {
        toolsList.readExternal(element, this, dependencies);
      }
      else if (!myUninstalledInspectionsSettings.containsKey(InspectionElementsMerger.getMergedMarkerName(shortName))) {
        final InspectionElementsMerger merger = getMergers().get(shortName);
        if (merger != null) {
          final Element merged = merger.merge(myUninstalledInspectionsSettings);
          if (merged != null) {
            toolsList.readExternal(merged, this, dependencies);
          }
        }
      }
    }
    catch (InvalidDataException e) {
      LOG.error("Can't read settings for " + toolWrapper, e);
    }
    myTools.put(toolWrapper.getShortName(), toolsList);
  }
  final GraphGenerator<String> graphGenerator = GraphGenerator.create(CachingSemiGraph.create(new GraphGenerator.SemiGraph<String>() {
    @Override
    public Collection<String> getNodes() {
      return dependencies.keySet();
    }

    @Override
    public Iterator<String> getIn(String n) {
      return dependencies.get(n).iterator();
    }
  }));

  DFSTBuilder<String> builder = new DFSTBuilder<String>(graphGenerator);
  if (builder.isAcyclic()) {
    final List<String> scopes = builder.getSortedNodes();
    myScopesOrder = ArrayUtil.toStringArray(scopes);
  }

  if (mySource != null) {
    copyToolsConfigurations(mySource, project);
  }
  return true;
}