use of com.intellij.util.graph.DFSTBuilder in project intellij-community by JetBrains.
the class JarsBuilder method sortJars.
@Nullable
private JarInfo[] sortJars() {
final DFSTBuilder<JarInfo> builder = new DFSTBuilder<>(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() + "' 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;
}
use of com.intellij.util.graph.DFSTBuilder in project intellij-community by JetBrains.
the class LoopAnalyzer method calcInLoop.
static int[] calcInLoop(ControlFlow controlFlow) {
// loop[i] = loop number(strongly connected component number) of i-th instruction or 0 if outside loop
final int[] loop = new int[controlFlow.getInstructionCount()];
MyGraph graph = new MyGraph(controlFlow);
final DFSTBuilder<Instruction> builder = new DFSTBuilder<>(graph);
TIntArrayList sccs = builder.getSCCs();
sccs.forEach(new TIntProcedure() {
private int myTNumber;
private int component;
@Override
public boolean execute(int size) {
int value = size > 1 ? ++component : 0;
for (int i = 0; i < size; i++) {
Instruction instruction = builder.getNodeByTNumber(myTNumber + i);
loop[instruction.getIndex()] = value;
}
myTNumber += size;
return true;
}
});
return loop;
}
Aggregations