blob: 3bb8811558184c63de2e1cf8a6bfc4ecae590660 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2000, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.internal.core;
import org.eclipse.jdt.core.*;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.env.ISourceMethod;
/**
* Element info for IMethod elements.
*/
public abstract class SourceMethodElementInfo extends AnnotatableInfo implements ISourceMethod {
/**
* For a source method (that is, a method contained in a compilation unit)
* this is a collection of the names of the parameters for this method,
* in the order the parameters are delcared. For a binary method (that is,
* a method declared in a binary type), these names are invented as
* "arg"i where i starts at 1. This is an empty array if this method
* has no parameters.
*/
protected char[][] argumentNames;
/**
* A collection of type names of the exceptions this
* method throws, or an empty collection if this method
* does not declare to throw any exceptions. A name is a simple
* name or a qualified, dot separated name.
* For example, Hashtable or java.util.Hashtable.
*/
protected char[][] exceptionTypes;
/*
* The type parameters of this source type. Empty if none.
*/
protected ITypeParameter[] typeParameters = TypeParameter.NO_TYPE_PARAMETERS;
public char[][] getArgumentNames() {
return this.argumentNames;
}
public char[][] getExceptionTypeNames() {
return this.exceptionTypes;
}
public abstract char[] getReturnTypeName();
public char[][][] getTypeParameterBounds() {
int length = this.typeParameters.length;
char[][][] typeParameterBounds = new char[length][][];
for (int i = 0; i < length; i++) {
try {
TypeParameterElementInfo info = (TypeParameterElementInfo) ((JavaElement)this.typeParameters[i]).getElementInfo();
typeParameterBounds[i] = info.bounds;
} catch (JavaModelException e) {
// type parameter does not exist: ignore
}
}
return typeParameterBounds;
}
public char[][] getTypeParameterNames() {
int length = this.typeParameters.length;
if (length == 0) return CharOperation.NO_CHAR_CHAR;
char[][] typeParameterNames = new char[length][];
for (int i = 0; i < length; i++) {
typeParameterNames[i] = this.typeParameters[i].getElementName().toCharArray();
}
return typeParameterNames;
}
public abstract boolean isConstructor();
public abstract boolean isAnnotationMethod();
protected void setArgumentNames(char[][] names) {
this.argumentNames = names;
}
protected void setExceptionTypeNames(char[][] types) {
this.exceptionTypes = types;
}
protected abstract void setReturnType(char[] type);
}