1 19 package org.netbeans.modules.javacore.parser; 20 21 import org.netbeans.lib.java.parser.ASTree; 22 import org.netbeans.lib.java.parser.ASTreeTypes; 23 import org.netbeans.modules.javacore.jmiimpl.javamodel.CallableFeatureImpl; 24 import org.netbeans.modules.javacore.jmiimpl.javamodel.MetadataElement; 25 import org.netbeans.modules.javacore.jmiimpl.javamodel.SemiPersistentElement; 26 27 31 public final class MethodInfo extends FeatureInfo { 32 public static final int METHOD_TYPE = ASTreeTypes.METHOD_DECLARATION; 33 public static final int CONSTRUCTOR_TYPE = ASTreeTypes.CONSTRUCTOR_DECLARATION; 34 35 public final TypeRef type; public final ParameterInfo[] parameters; 37 public final TypeParamRef[] exceptions; public final TypeParamInfo[] typeParams; 39 40 private CallableFeatureImpl owner = null; 41 42 public MethodInfo(ASTree tree, int infoType, String name, int modifiers, 43 TypeRef type, ParameterInfo[] parameters, TypeParamRef[] exceptions, 44 TypeParamInfo[] typeParams, AnnotationInfo[] annotations) 45 { 46 super(tree, infoType, name, modifiers, annotations); 47 this.type = type; 48 this.parameters = parameters == null ? EMPTY_PARAMETERS : parameters; 49 this.exceptions = exceptions == null ? EMPTY_TPREFS : exceptions; 50 this.typeParams = typeParams == null ? EMPTY_TYPE_PARAMS : typeParams; 51 } 52 53 public ASTree[] getExceptionsAST(CallableFeatureImpl owner) { 54 ASTree namesAST; 55 ASTree tree = owner.getASTree(); 56 if (tree != null) { 57 namesAST = tree.getSubTrees()[4]; 58 } else { 59 namesAST = null; 60 } 61 return MetadataElement.getChildNodes(namesAST, ASTreeTypes.TYPE_LIST); 62 } 63 64 public ASTree getTypeAST(SemiPersistentElement owner) { 65 ASTree tree = owner.getASTree(); 66 if (tree != null) { 67 return tree.getSubTrees()[2]; 68 } 69 return null; 70 } 71 } 72 | Popular Tags |