treeMaker.removeClassTypeParameter(modifiedClazz,index) doesn't work correctly
"mexer" <[email protected]>
| Newsgroups | gmane.comp.java.netbeans.modules.openide.devel |
|---|---|
| Message-ID | <[email protected]> |
I want to modify a class
Code:
public abstract class AbstractFacade<T> {
private Class<T> entityClass;
public AbstractFacade(Class<T> entityClass) {
this.entityClass = entityClass;
}
...
}
to
Code:
public abstract class AbstractFacade<T extends MyEntity> {
private Class<T> entityClass;
public AbstractFacade(Class<T> entityClass) {
this.entityClass = entityClass;
}
First I tried to delete the current type parameter with
Code:
modifiedClazz=maker.removeClassTypeParameter(modifiedClazz,0);
and got
Code:
public abstract class AbstractFacade> {// the > was not deleted
...
}
Then I tried
Code:
TypeElement element = workingCopy.getElements().getTypeElement(entitiesPkg+".MyEntity");
ExpressionTree implementsClause = maker.QualIdent(element);
List<ExpressionTree> bounds=new ArrayList<ExpressionTree>();
TypeParameterTree tp=maker.TypeParameter("T", bounds);
tp=maker.addTypeParameterBound(tp, implementsClause);
modifiedClazz=maker.addClassTypeParameter(modifiedClazz, tp);
//without the following line i got
//public abstract class AbstractFacade<T, T extends MyEntity>{
modifiedClazz=maker.removeClassTypeParameter(modifiedClazz,0);
It doesn't matter the index I use in removeClassTypeParameter (0 or 1) at the end the result is
Code:
public abstract class AbstractFacade<T> {
is there any workaround? am I doing something wrong?
References:
http://bits.netbeans.org/dev/javadoc/org-netbeans-modules-java-source-base/allclasses-frame.html
http://wiki.netbeans.org/JavaHT_TreeMaker