extract duplicate code to a separate method
This commit is contained in:
parent
cfce2f55ac
commit
c098a0a1b0
@ -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<RefTypeOrTPHOrWildcardOrGeneric> listIterator,
|
||||
RefTypeOrTPHOrWildcardOrGeneric refType) {
|
||||
// Generate TPH
|
||||
TypePlaceholder tph = generateTypePlaceholder(refType);
|
||||
|
||||
// Replace in AST
|
||||
listIterator.set(tph);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user