Skip to content

Commit

Permalink
Fix handling of interfaces
Browse files Browse the repository at this point in the history
- Fixes #273
  • Loading branch information
gastaldi committed Nov 9, 2022
1 parent 894f32f commit b586795
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package org.jboss.forge.roaster.model.impl;

import org.apache.commons.lang3.StringUtils;
import org.eclipse.jdt.core.dom.AST;
import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.AbstractTypeDeclaration;
import org.eclipse.jdt.core.dom.BodyDeclaration;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.core.dom.MethodDeclaration;
import org.eclipse.jdt.core.dom.SimpleType;
import org.eclipse.jdt.core.dom.Type;
import org.eclipse.jface.text.Document;
import org.jboss.forge.roaster.Roaster;
import org.jboss.forge.roaster.model.JavaInterface;
import org.jboss.forge.roaster.model.Method;
import org.jboss.forge.roaster.model.ast.MethodFinderVisitor;
Expand Down Expand Up @@ -90,9 +90,10 @@ public O addInterface(final String type)
typeName = type;
}
AbstractTypeDeclaration declaration = getDeclaration();
AST ast = getDeclaration().getAST();
SimpleType simpleType = ast.newSimpleType(ast.newName(typeName));
JDTHelper.getInterfaces(declaration).add(simpleType);
Type interfaceType = JDTHelper.getInterfaces(Roaster.parse(JavaInterfaceImpl.class,
"public interface Mock extends " + typeName + " {}").getDeclaration()).get(0);
ASTNode node = ASTNode.copySubtree(unit.getAST(), interfaceType);
JDTHelper.getInterfaces(declaration).add((Type)node);
}
return (O) this;
}
Expand Down

0 comments on commit b586795

Please sign in to comment.