diff --git a/src/main/java/de/dhbwstuttgart/inferWildcards/ReplaceTypeparamVisitor.java b/src/main/java/de/dhbwstuttgart/inferWildcards/ReplaceTypeparamVisitor.java index eb8ae531..74619e07 100644 --- a/src/main/java/de/dhbwstuttgart/inferWildcards/ReplaceTypeparamVisitor.java +++ b/src/main/java/de/dhbwstuttgart/inferWildcards/ReplaceTypeparamVisitor.java @@ -116,20 +116,14 @@ public class ReplaceTypeparamVisitor // parent TPH mapping this.visit(nextRefType); - // Generate TPH - TypePlaceholder tph = generateTypePlaceholder(nextRefType); - - // Replace in AST - listIterator.set(tph); + generateTphAndReplaceInTree(listIterator, next); } else if (next instanceof GenericRefType) { - GenericRefType nextGenericRefType = (GenericRefType) next; - // Generate TPH - TypePlaceholder tph = generateTypePlaceholder(nextGenericRefType); + // Visit of nested type arguments not necessary as Generic Types cannot contain + // type parameters - // Replace in AST - listIterator.set(tph); + generateTphAndReplaceInTree(listIterator, next); } } @@ -152,5 +146,26 @@ public class ReplaceTypeparamVisitor tphMap.put(tph, t); return tph; } + + /** + * Generate the TPH for a {@link RefTypeOrTPHOrWildcardOrGeneric}, saves the + * mapping and replaces the type by the type placeholder in the tree. + * + * @param listIterator {@link ListIterator} over + * {@link RefTypeOrTPHOrWildcardOrGeneric} representing the + * tree to replace in + * @param refType {@link RefTypeOrTPHOrWildcardOrGeneric} to generate type + * placeholder for and replace + */ + private void generateTphAndReplaceInTree (ListIterator listIterator, + RefTypeOrTPHOrWildcardOrGeneric refType) { + // Generate TPH + TypePlaceholder tph = generateTypePlaceholder(refType); + + // Replace in AST + listIterator.set(tph); + } + } + }