| Method from org.codehaus.groovy.ast.MethodNode Detail: |
public Statement getCode() {
return code;
}
|
public ClassNode[] getExceptions() {
return exceptions;
}
|
public Statement getFirstStatement() {
if (code == null) return null;
Statement first = code;
while (first instanceof BlockStatement) {
List list = ((BlockStatement) first).getStatements();
if (list.isEmpty()) {
first=null;
} else {
first = (Statement) list.get(0);
}
}
return first;
}
|
public GenericsType[] getGenericsTypes() {
return genericsTypes;
}
|
public int getModifiers() {
return modifiers;
}
|
public String getName() {
return name;
}
|
public Parameter[] getParameters() {
return parameters;
}
|
public ClassNode getReturnType() {
return returnType;
}
|
public String getTypeDescriptor() {
if (typeDescriptor==null) {
StringBuffer buf = new StringBuffer(name.length()+parameters.length*10);
buf.append(returnType.getName());
buf.append(' ");
buf.append(name);
buf.append('(");
for (int i = 0; i < parameters.length; i++) {
if (i > 0) {
buf.append(", ");
}
Parameter param = parameters[i];
buf.append(param.getType().getName());
}
buf.append(')");
typeDescriptor = buf.toString();
}
return typeDescriptor;
}
The type descriptor for a method node is a string containing the name of the method, its return type,
and its parameter types in a canonical form. For simplicity, I'm using the format of a Java declaration
without parameter names. |
public VariableScope getVariableScope() {
return variableScope;
}
|
public boolean hasAnnotationDefault() {
return hasDefault;
}
|
public boolean hasDefaultValue() {
return this.hasDefaultValue;
}
|
public boolean isAbstract() {
return (modifiers & ACC_ABSTRACT) != 0;
}
|
public boolean isDynamicReturnType() {
return dynamicReturnType;
}
|
public boolean isPrivate() {
return (modifiers & ACC_PRIVATE) != 0;
}
|
public boolean isProtected() {
return (modifiers & ACC_PROTECTED) != 0;
}
|
public boolean isPublic() {
return (modifiers & ACC_PUBLIC) != 0;
}
|
public boolean isStatic() {
return (modifiers & ACC_STATIC) != 0;
}
|
public boolean isVoidMethod() {
return returnType==ClassHelper.VOID_TYPE;
}
|
public void setAnnotationDefault(boolean b) {
this.hasDefault = b;
}
|
public void setCode(Statement code) {
this.code = code;
}
|
public void setGenericsTypes(GenericsType[] genericsTypes) {
invalidateCachedData();
this.genericsTypes = genericsTypes;
}
|
public void setModifiers(int modifiers) {
invalidateCachedData();
this.modifiers = modifiers;
}
|
public void setParameters(Parameter[] parameters) {
invalidateCachedData();
VariableScope scope = new VariableScope();
this.parameters = parameters;
if (parameters != null && parameters.length > 0) {
for (int i = 0; i < parameters.length; i++) {
Parameter para = parameters[i];
if (para.hasInitialExpression()) {
this.hasDefaultValue = true;
}
para.setInStaticContext(isStatic());
scope.putDeclaredVariable(para);
}
}
setVariableScope(scope);
}
|
public void setReturnType(ClassNode returnType) {
invalidateCachedData();
dynamicReturnType |= ClassHelper.DYNAMIC_TYPE==returnType;
this.returnType = returnType;
if (returnType==null) this.returnType = ClassHelper.OBJECT_TYPE;
}
|
public void setVariableScope(VariableScope variableScope) {
this.variableScope = variableScope;
variableScope.setInStaticContext(isStatic());
}
|
public String toString() {
return "MethodNode@"+hashCode()+"[" + getTypeDescriptor() + "]";
}
|