use of com.android.tools.idea.experimental.codeanalysis.datastructs.graph.MethodGraph in project android by JetBrains.
the class CFGBuilder method resolveParam.
/**
* Resolve the parameter at the current context.
* @param param The parameter
* @return The PsiCFG wrapper for the parameter
*/
@Nullable
private Param resolveParam(@NotNull PsiParameter param) {
Graph graph = this.mGraph;
if (graph instanceof BlockGraph) {
Param p = ((BlockGraph) graph).getParamFromPsiParameter(param);
if (p == null) {
if (graph instanceof MethodGraph) {
MethodGraph methodGraph = (MethodGraph) graph;
PsiCFGDebugUtil.LOG.warning("Parameter " + param.getName() + " does not exist in method " + methodGraph.getPsiCFGMethod().getName() + " in class " + this.containerClass.getQualifiedClassName());
} else {
PsiStatement psiStmt = ((BlockGraph) graph).getParentStmt();
PsiCFGDebugUtil.LOG.warning("Parameter " + param.getName() + " does not exist in context " + psiStmt.getText() + " in class " + this.containerClass.getQualifiedClassName());
}
}
return p;
}
PsiCFGDebugUtil.LOG.warning("Parameter " + param.getName() + " does not exist, the graph is not" + " a block graph");
return null;
}
use of com.android.tools.idea.experimental.codeanalysis.datastructs.graph.MethodGraph in project android by JetBrains.
the class PsiCFGAnalysisUtil method performStage3.
/**
* The purpose of the Stage3 is create IntraProcedural
* CFG for the methods and lambdas inside the app
* class, including the constructor and the init code
*/
public void performStage3() {
PsiCFGClass[] appClasses = mScene.getAllApplicationClasses();
mScene.workingList.clear();
mScene.workingList.addAll(Arrays.asList(appClasses));
while (!mScene.workingList.isEmpty()) {
//While the working list is not empty
//Process the working list
PsiCFGClass currentClass = mScene.workingList.removeFirst();
PsiCFGMethod[] allMethods = currentClass.getAllMethods();
for (PsiCFGMethod currentMethod : allMethods) {
//Lambda methods' CFG is created by the time it is decleared
if (currentMethod.isAbstract() || currentMethod.isLambda()) {
continue;
}
PsiMethod methodRef = currentMethod.getMethodRef();
if (methodRef != null) {
PsiCodeBlock codeBlock = methodRef.getBody();
if (codeBlock == null) {
PsiCFGDebugUtil.LOG.info("In " + currentClass.getQualifiedClassName() + "." + currentMethod.getName() + "Code block is null");
continue;
}
MethodGraph cfg = CFGUtil.constructMethodGraph(mScene, codeBlock, currentMethod);
currentMethod.setControlFlowGraph(cfg);
}
}
}
}
Aggregations