Add JavaDoc
This commit is contained in:
parent
e5d5376ce9
commit
6dd02a654b
@ -10,26 +10,43 @@ import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||
|
||||
/**
|
||||
* Visitor replace type parameter of the type RefType by Type Placeholder in a
|
||||
* AST.
|
||||
*
|
||||
* @author Till Schnell
|
||||
* @version 1.0
|
||||
*/
|
||||
public class ReplaceTypeparamVisitor
|
||||
extends AbstractASTWalker
|
||||
{
|
||||
|
||||
/**
|
||||
* Containing the replaced RefType and the mapping TPH
|
||||
*/
|
||||
private final Map<TypePlaceholder, RefType> tphMap;
|
||||
|
||||
/**
|
||||
* Constructor for a {@code ReplaceTypeparamVisitor}.
|
||||
*/
|
||||
public ReplaceTypeparamVisitor () {
|
||||
this.tphMap = new HashMap<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit (RefType refType) {
|
||||
|
||||
// check if RefType has Parameter Types
|
||||
if (!refType.getParaList().isEmpty()) {
|
||||
System.out.println("Type: " + refType);
|
||||
|
||||
// Iterate over all Parameter Types
|
||||
for (ListIterator<RefTypeOrTPHOrWildcardOrGeneric> listIterator = refType.getParaList()
|
||||
.listIterator(); listIterator
|
||||
.hasNext();) {
|
||||
RefTypeOrTPHOrWildcardOrGeneric next = listIterator.next();
|
||||
|
||||
// If Parameter type is RefType replace with TPH
|
||||
if (next instanceof RefType) {
|
||||
RefType nextRefType = (RefType) next;
|
||||
TypePlaceholder tph = generateTypePlaceholder(nextRefType);
|
||||
@ -40,12 +57,24 @@ public class ReplaceTypeparamVisitor
|
||||
super.visit(refType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the TPH for a {@link RefType} and saves the mapping.
|
||||
*
|
||||
* @param t {@link RefType}
|
||||
* @return {@link TypePlaceholder} generated
|
||||
*/
|
||||
private TypePlaceholder generateTypePlaceholder (RefType t) {
|
||||
TypePlaceholder tph = TypePlaceholder.fresh(new NullToken());
|
||||
tphMap.put(tph, t);
|
||||
return tph;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the mapping of the replaced {@link RefType} and the inserted
|
||||
* {@link TypePlaceholder}.
|
||||
*
|
||||
* @return {@link Map} of {@link TypePlaceholder} and {@link RefType}
|
||||
*/
|
||||
public Map<TypePlaceholder, RefType> getTphMap () {
|
||||
return tphMap;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user