diff --git a/src/main/java/de/dhbwstuttgart/inferWildcards/InferWildcardsVisitor.java b/src/main/java/de/dhbwstuttgart/inferWildcards/InferWildcardsVisitor.java deleted file mode 100644 index ebd3be68..00000000 --- a/src/main/java/de/dhbwstuttgart/inferWildcards/InferWildcardsVisitor.java +++ /dev/null @@ -1,79 +0,0 @@ -package de.dhbwstuttgart.inferWildcards; - -import java.util.HashMap; -import java.util.Map; - -import com.sun.source.tree.ExpressionStatementTree; -import com.sun.source.tree.ExpressionTree; -import com.sun.source.tree.Tree; -import com.sun.source.tree.VariableTree; -import com.sun.source.util.TreeScanner; - -import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder; -import de.dhbwstuttgart.typeinference.constraints.ConstraintSet; - -public class InferWildcardsVisitor - extends TreeScanner -{ - - @SuppressWarnings("rawtypes") - private final ConstraintSet constraintsSet; - private final Map placeholderMapping; - - public InferWildcardsVisitor () { - super(); - this.constraintsSet = new ConstraintSet<>(); - this.placeholderMapping = new HashMap<>(); - } - - @Override - public Void visitOther (Tree node, Void p) { - // System.out.println("Other: " + node.toString()); - return super.visitOther(node, p); - } - - @Override - public Void visitExpressionStatement (ExpressionStatementTree node, Void p) { - System.out.println("Expression: " + node.toString()); - return super.visitExpressionStatement(node, p); - } - - @Override - public Void visitVariable (VariableTree node, Void p) { - System.out.println("Variable: " + node.toString()); - - // Get Type - System.out.println("Type: ============"); - - // generate visitor - TypeParamVisitor typeParamVisitor = new TypeParamVisitor(); - - // visit the nodes - node.getType().accept(typeParamVisitor, null); - - // consolidate results - constraintsSet.addAll(typeParamVisitor.getConstraintsSet()); - placeholderMapping.putAll(typeParamVisitor.getPlaceholderMapping()); - - System.out.println("=================="); - - // Initializer of the variable - ExpressionTree initializer = node.getInitializer(); - if (initializer != null) { - System.out.println("VariableInitializer: " + initializer.toString()); - - } - - return super.visitVariable(node, p); - } - - - @SuppressWarnings("rawtypes") - public ConstraintSet getConstraintSet() { - return constraintsSet; - } - - public Map getPlaceholderMapping () { - return placeholderMapping; - } -} diff --git a/src/main/java/de/dhbwstuttgart/inferWildcards/TypeParamVisitor.java b/src/main/java/de/dhbwstuttgart/inferWildcards/TypeParamVisitor.java deleted file mode 100644 index af51eb72..00000000 --- a/src/main/java/de/dhbwstuttgart/inferWildcards/TypeParamVisitor.java +++ /dev/null @@ -1,95 +0,0 @@ -package de.dhbwstuttgart.inferWildcards; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import com.sun.source.tree.IdentifierTree; -import com.sun.source.tree.ParameterizedTypeTree; -import com.sun.source.tree.Tree; -import com.sun.source.util.TreeScanner; - -import de.dhbwstuttgart.parser.NullToken; -import de.dhbwstuttgart.parser.scope.JavaClassName; -import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder; -import de.dhbwstuttgart.typeinference.constraints.ConstraintSet; - -public class TypeParamVisitor - extends TreeScanner, Void> -{ - - //1. List erstellen, welche Methoden gibt es alles. - //2. die Expressions auflösen und Typen aus 1. heraus abfragen. - - //Vistor für Expressions anlegen. - - @SuppressWarnings("rawtypes") - private final ConstraintSet constraintsSet; - private final Map placeholderMapping; - - public TypeParamVisitor () { - this.constraintsSet = new ConstraintSet<>(); - this.placeholderMapping = new HashMap<>(); - } - - private TypePlaceholder generateTypePlaceholder (Tree t) { - TypePlaceholder tph = TypePlaceholder.fresh(new NullToken()); - placeholderMapping.put(tph, t); - return tph; - } - - @SuppressWarnings("rawtypes") - @Override - public List visitParameterizedType (ParameterizedTypeTree node, Void p) { - System.out.println("ParameterizedType: " + node.toString()); - - List list = new ArrayList<>(); - - node.getTypeArguments().forEach(t -> { - System.out.println("Parameters: ---"); - - // generate Type Placeholder - TypePlaceholder tph = generateTypePlaceholder(t); - - // Search for the type parameter - List foundClassNames = t.accept(this, null); - foundClassNames.forEach(name -> { - ConstraintSet constraints = ConstraintsGenerationUtils.generateConstraints(name, tph); - constraintsSet.addAll(constraints); - }); - - // consolidate results - list.addAll(foundClassNames); - - System.out.println("---------------"); - }); - - return list; - } - - @Override - public List visitIdentifier (IdentifierTree node, Void p) { - System.out.println("Identifier: " + node.toString()); - - List list = new ArrayList<>(); - list.add(new JavaClassName(node.getName().toString())); - - return list; - } - - @Override - public List reduce (List r1, List r2) { - r1.addAll(r2); - return r1; - } - - @SuppressWarnings("rawtypes") - public ConstraintSet getConstraintsSet () { - return constraintsSet; - } - - public Map getPlaceholderMapping () { - return placeholderMapping; - } -}