diff --git a/src/main/java/com/ibm/northstar/SymbolTable.java b/src/main/java/com/ibm/northstar/SymbolTable.java index 1182db5..7b43722 100644 --- a/src/main/java/com/ibm/northstar/SymbolTable.java +++ b/src/main/java/com/ibm/northstar/SymbolTable.java @@ -17,14 +17,12 @@ import com.github.javaparser.resolution.types.ResolvedType; import com.github.javaparser.symbolsolver.JavaSymbolSolver; import com.github.javaparser.symbolsolver.resolution.typesolvers.CombinedTypeSolver; -import com.github.javaparser.symbolsolver.resolution.typesolvers.JarTypeSolver; import com.github.javaparser.symbolsolver.resolution.typesolvers.ReflectionTypeSolver; import com.github.javaparser.symbolsolver.utils.SymbolSolverCollectionStrategy; import com.github.javaparser.utils.ProjectRoot; import com.github.javaparser.utils.SourceRoot; import com.google.common.collect.Table; import com.google.common.collect.Tables; -import com.ibm.northstar.entities.Enum; import com.ibm.northstar.entities.*; import com.ibm.northstar.utils.Log; import org.apache.commons.lang3.tuple.Pair; @@ -108,10 +106,9 @@ private static JavaCompilationUnit processCompilationUnit(CompilationUnit parseR .map(typeDecl -> { // get type name and initialize the type object String typeName = typeDecl.getFullyQualifiedName().get().toString(); - com.ibm.northstar.entities.Type typeNode = null; + com.ibm.northstar.entities.Type typeNode = new com.ibm.northstar.entities.Type(); if (typeDecl instanceof ClassOrInterfaceDeclaration) { - typeNode = new ClassOrInterface(); ClassOrInterfaceDeclaration classDecl = (ClassOrInterfaceDeclaration)typeDecl; // Add interfaces implemented by class @@ -127,17 +124,16 @@ private static JavaCompilationUnit processCompilationUnit(CompilationUnit parseR .collect(Collectors.toList())); // add booleans indicating interfaces and inner/local classes - ((ClassOrInterface)typeNode).setInterface(classDecl.isInterface()); - ((ClassOrInterface)typeNode).setInnerClass(classDecl.isInnerClass()); - ((ClassOrInterface)typeNode).setLocalClass(classDecl.isLocalClassDeclaration()); + typeNode.setInterface(classDecl.isInterface()); + typeNode.setInnerClass(classDecl.isInnerClass()); + typeNode.setLocalClass(classDecl.isLocalClassDeclaration()); // Add extends - ((ClassOrInterface)typeNode).setExtendsList(classDecl.getExtendedTypes().stream() + typeNode.setExtendsList(classDecl.getExtendedTypes().stream() .map(SymbolTable::resolveType) .collect(Collectors.toList())); } else if (typeDecl instanceof EnumDeclaration) { - typeNode = new Enum(); EnumDeclaration enumDecl = (EnumDeclaration)typeDecl; // Add interfaces implemented by enum @@ -153,7 +149,7 @@ private static JavaCompilationUnit processCompilationUnit(CompilationUnit parseR .collect(Collectors.toList())); // Add enum constants - ((Enum)typeNode).setEnumConstants(enumDecl.getEntries().stream() + typeNode.setEnumConstants(enumDecl.getEntries().stream() .map(SymbolTable::processEnumConstantDeclaration).collect(Collectors.toList())); } else { diff --git a/src/main/java/com/ibm/northstar/entities/ClassOrInterface.java b/src/main/java/com/ibm/northstar/entities/ClassOrInterface.java deleted file mode 100644 index d36fba8..0000000 --- a/src/main/java/com/ibm/northstar/entities/ClassOrInterface.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.ibm.northstar.entities; - -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.util.List; - -@Data -@EqualsAndHashCode(callSuper=false) -public class ClassOrInterface extends Type { - private boolean isInterface; - private boolean isInnerClass; - private boolean isLocalClass; - private List extendsList; -} \ No newline at end of file diff --git a/src/main/java/com/ibm/northstar/entities/Enum.java b/src/main/java/com/ibm/northstar/entities/Enum.java deleted file mode 100644 index 5eb397b..0000000 --- a/src/main/java/com/ibm/northstar/entities/Enum.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.ibm.northstar.entities; - -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.util.List; - -@Data -@EqualsAndHashCode(callSuper=false) -public class Enum extends Type { - private List enumConstants; -} \ No newline at end of file diff --git a/src/main/java/com/ibm/northstar/entities/Type.java b/src/main/java/com/ibm/northstar/entities/Type.java index 1f77347..3671771 100644 --- a/src/main/java/com/ibm/northstar/entities/Type.java +++ b/src/main/java/com/ibm/northstar/entities/Type.java @@ -12,6 +12,10 @@ public class Type { private boolean isEnumDeclaration; private boolean isAnnotationDeclaration; private boolean isRecordDeclaration; + private boolean isInterface; + private boolean isInnerClass; + private boolean isLocalClass; + private List extendsList; private String comment; private List implementsList; private List modifiers; @@ -20,4 +24,5 @@ public class Type { private List nestedTypeDeclarations; private Map callableDeclarations; private List fieldDeclarations; + private List enumConstants; } \ No newline at end of file