better things extraction of constants 2
This commit is contained in:
@@ -321,32 +321,39 @@ public abstract class AbstractCallGraphEngine implements CallGraphEngine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (declaredType != null) {
|
if (declaredType != null) {
|
||||||
List<String> typesToInspect = new ArrayList<>();
|
List<String> enumValues = context.getEnumValues(declaredType);
|
||||||
if ("inline-instantiation".equals(sourceMethod)) {
|
if (enumValues != null && !enumValues.isEmpty()) {
|
||||||
typesToInspect.add(declaredType);
|
for (String ev : enumValues) {
|
||||||
} else {
|
polymorphicEvents.add(parseEnumSetElement(ev));
|
||||||
typesToInspect.add(declaredType);
|
|
||||||
typesToInspect.addAll(context.getImplementations(declaredType));
|
|
||||||
}
|
|
||||||
|
|
||||||
for (String type : typesToInspect) {
|
|
||||||
Set<String> visited = new HashSet<>();
|
|
||||||
TypeDeclaration baseTd = context.getTypeDeclaration(type);
|
|
||||||
CompilationUnit cuToUse = null;
|
|
||||||
if (baseTd != null && baseTd.getRoot() instanceof CompilationUnit) {
|
|
||||||
cuToUse = (CompilationUnit) baseTd.getRoot();
|
|
||||||
} else {
|
|
||||||
String firstPathMethod = path.get(0);
|
|
||||||
String entryClassName = firstPathMethod.substring(0, firstPathMethod.lastIndexOf('.'));
|
|
||||||
TypeDeclaration entryTd = context.getTypeDeclaration(entryClassName);
|
|
||||||
if (entryTd != null && entryTd.getRoot() instanceof CompilationUnit) {
|
|
||||||
cuToUse = (CompilationUnit) entryTd.getRoot();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
List<String> constants = resolveMethodReturnConstant(type, methodName, 0, visited, cuToUse);
|
} else {
|
||||||
for (String constant : constants) {
|
List<String> typesToInspect = new ArrayList<>();
|
||||||
if (!polymorphicEvents.contains(constant)) {
|
if ("inline-instantiation".equals(sourceMethod)) {
|
||||||
polymorphicEvents.add(constant);
|
typesToInspect.add(declaredType);
|
||||||
|
} else {
|
||||||
|
typesToInspect.add(declaredType);
|
||||||
|
typesToInspect.addAll(context.getImplementations(declaredType));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String type : typesToInspect) {
|
||||||
|
Set<String> visited = new HashSet<>();
|
||||||
|
TypeDeclaration baseTd = context.getTypeDeclaration(type);
|
||||||
|
CompilationUnit cuToUse = null;
|
||||||
|
if (baseTd != null && baseTd.getRoot() instanceof CompilationUnit) {
|
||||||
|
cuToUse = (CompilationUnit) baseTd.getRoot();
|
||||||
|
} else {
|
||||||
|
String firstPathMethod = path.get(0);
|
||||||
|
String entryClassName = firstPathMethod.substring(0, firstPathMethod.lastIndexOf('.'));
|
||||||
|
TypeDeclaration entryTd = context.getTypeDeclaration(entryClassName);
|
||||||
|
if (entryTd != null && entryTd.getRoot() instanceof CompilationUnit) {
|
||||||
|
cuToUse = (CompilationUnit) entryTd.getRoot();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
List<String> constants = resolveMethodReturnConstant(type, methodName, 0, visited, cuToUse);
|
||||||
|
for (String constant : constants) {
|
||||||
|
if (!polymorphicEvents.contains(constant)) {
|
||||||
|
polymorphicEvents.add(constant);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user