1 11 package org.eclipse.jdt.apt.core.internal.declaration; 12 13 import org.eclipse.core.resources.IFile; 14 import org.eclipse.jdt.apt.core.internal.env.BaseProcessorEnv; 15 import org.eclipse.jdt.apt.core.internal.util.Factory; 16 import org.eclipse.jdt.core.dom.ITypeBinding; 17 import org.eclipse.jdt.core.dom.Type; 18 19 import com.sun.mirror.declaration.MethodDeclaration; 20 import com.sun.mirror.type.TypeMirror; 21 import com.sun.mirror.util.DeclarationVisitor; 22 23 public class ASTBasedMethodDeclarationImpl 24 extends ASTBasedExecutableDeclarationImpl 25 implements MethodDeclaration{ 26 27 public ASTBasedMethodDeclarationImpl( 28 final org.eclipse.jdt.core.dom.BodyDeclaration astNode, 29 final IFile file, 30 final BaseProcessorEnv env) 31 { 32 super(astNode, file, env); 33 } 34 35 public void accept(DeclarationVisitor visitor) 36 { 37 visitor.visitMethodDeclaration(this); 38 } 39 40 public TypeMirror getReturnType() 41 { 42 final org.eclipse.jdt.core.dom.MethodDeclaration methodAstNode = getMethodAstNode(); 43 final Type retType = methodAstNode.getReturnType2(); 44 if( retType == null ) 46 return Factory.createErrorClassType(EMPTY_STRING); 47 final ITypeBinding typeBinding = retType.resolveBinding(); 48 if( typeBinding == null ){ 50 return Factory.createErrorClassType(retType.toString()); 51 } 52 else{ 53 final TypeMirror type = Factory.createTypeMirror(typeBinding, _env); 54 if(type == null ) 55 return Factory.createErrorClassType(retType.toString()); 56 return type; 57 } 58 } 59 60 public MirrorKind kind(){ return MirrorKind.METHOD; } 61 62 } 63 | Popular Tags |