use of com.android.tools.idea.experimental.codeanalysis.datastructs.PsiCFGClass in project android by JetBrains.
the class PsiCFGAnalysisUtil method setClassHierarchyForApplicationClass.
public void setClassHierarchyForApplicationClass(@NotNull PsiCFGClass clazz) {
if (clazz.getPsiClass() != null) {
PsiClass psiClassRef = clazz.getPsiClass();
PsiClass directSuperClass = psiClassRef.getSuperClass();
PsiClass[] implementedInterface = psiClassRef.getInterfaces();
if (directSuperClass == null && mLangOjectClass != null) {
PsiCFGDebugUtil.LOG.warning("Super class is null for class " + clazz.getQualifiedClassName());
directSuperClass = mLangOjectClass;
}
if (directSuperClass != null) {
PsiCFGClass directCFGSuperClass = mScene.getOrCreateCFGClass(directSuperClass);
//Set superClass
clazz.setSuperClass(directCFGSuperClass);
directCFGSuperClass.addSubClass(clazz);
}
for (PsiClass interfaze : implementedInterface) {
PsiCFGClass cfgInterfaze = mScene.getOrCreateCFGClass(interfaze);
clazz.addInterface(cfgInterfaze);
if (clazz.isInterface()) {
cfgInterfaze.addSubInterface(clazz);
} else {
cfgInterfaze.addSubClass(clazz);
}
}
}
}
use of com.android.tools.idea.experimental.codeanalysis.datastructs.PsiCFGClass in project android by JetBrains.
the class PsiCFGAnalysisUtil method setInterfacesIfInLibrary.
public void setInterfacesIfInLibrary(PsiCFGClass curLibraryClass, PsiClass[] interfazes, Set<PsiClass> interfaceSet) {
for (PsiClass curInterface : interfazes) {
if (interfaceSet.contains(curInterface)) {
PsiCFGClass curCFGInterface = mScene.getOrCreateCFGClass(curInterface);
curLibraryClass.setSuperClass(curCFGInterface);
curCFGInterface.addSubClass(curLibraryClass);
}
}
}
use of com.android.tools.idea.experimental.codeanalysis.datastructs.PsiCFGClass 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