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
|
// parent TPH mapping
|
||||||
this.visit(nextRefType);
|
this.visit(nextRefType);
|
||||||
|
|
||||||
// Generate TPH
|
generateTphAndReplaceInTree(listIterator, next);
|
||||||
TypePlaceholder tph = generateTypePlaceholder(nextRefType);
|
|
||||||
|
|
||||||
// Replace in AST
|
|
||||||
listIterator.set(tph);
|
|
||||||
}
|
}
|
||||||
else if (next instanceof GenericRefType) {
|
else if (next instanceof GenericRefType) {
|
||||||
GenericRefType nextGenericRefType = (GenericRefType) next;
|
|
||||||
|
|
||||||
// Generate TPH
|
// Visit of nested type arguments not necessary as Generic Types cannot contain
|
||||||
TypePlaceholder tph = generateTypePlaceholder(nextGenericRefType);
|
// type parameters
|
||||||
|
|
||||||
// Replace in AST
|
generateTphAndReplaceInTree(listIterator, next);
|
||||||
listIterator.set(tph);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,5 +146,26 @@ public class ReplaceTypeparamVisitor
|
|||||||
tphMap.put(tph, t);
|
tphMap.put(tph, t);
|
||||||
return tph;
|
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