Skip to content

Commit

Permalink
Merge pull request #52 from IBM/type-decl-model-update
Browse files Browse the repository at this point in the history
Lombok model update to remove subclasses of Type
  • Loading branch information
rangeetpan authored Oct 14, 2024
2 parents 4fe3f39 + 8b10301 commit c9b1400
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 37 deletions.
16 changes: 6 additions & 10 deletions src/main/java/com/ibm/northstar/SymbolTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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 {
Expand Down
15 changes: 0 additions & 15 deletions src/main/java/com/ibm/northstar/entities/ClassOrInterface.java

This file was deleted.

12 changes: 0 additions & 12 deletions src/main/java/com/ibm/northstar/entities/Enum.java

This file was deleted.

5 changes: 5 additions & 0 deletions src/main/java/com/ibm/northstar/entities/Type.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> extendsList;
private String comment;
private List<String> implementsList;
private List<String> modifiers;
Expand All @@ -20,4 +24,5 @@ public class Type {
private List<String> nestedTypeDeclarations;
private Map<String, Callable> callableDeclarations;
private List<Field> fieldDeclarations;
private List<EnumConstant> enumConstants;
}

0 comments on commit c9b1400

Please sign in to comment.