本文整理匯總了Java中org.eclipse.jdt.core.dom.IMethodBinding.getTypeParameters方法的典型用法代碼示例。如果您正苦於以下問題:Java IMethodBinding.getTypeParameters方法的具體用法?Java IMethodBinding.getTypeParameters怎麽用?Java IMethodBinding.getTypeParameters使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jdt.core.dom.IMethodBinding
的用法示例。
在下文中一共展示了IMethodBinding.getTypeParameters方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createTypeParameters
import org.eclipse.jdt.core.dom.IMethodBinding; //導入方法依賴的package包/類
private static void createTypeParameters(ImportRewrite imports, ImportRewriteContext context, AST ast, IMethodBinding binding, MethodDeclaration decl) {
ITypeBinding[] typeParams= binding.getTypeParameters();
List<TypeParameter> typeParameters= decl.typeParameters();
for (int i= 0; i < typeParams.length; i++) {
ITypeBinding curr= typeParams[i];
TypeParameter newTypeParam= ast.newTypeParameter();
newTypeParam.setName(ast.newSimpleName(curr.getName()));
ITypeBinding[] typeBounds= curr.getTypeBounds();
if (typeBounds.length != 1 || !"java.lang.Object".equals(typeBounds[0].getQualifiedName())) {//$NON-NLS-1$
List<Type> newTypeBounds= newTypeParam.typeBounds();
for (int k= 0; k < typeBounds.length; k++) {
newTypeBounds.add(imports.addImport(typeBounds[k], ast, context, TypeLocation.TYPE_BOUND));
}
}
typeParameters.add(newTypeParam);
}
}
示例2: getMethodParameters
import org.eclipse.jdt.core.dom.IMethodBinding; //導入方法依賴的package包/類
/**
* returns the method Parameters as a list of ast.VariableDeclarataion
* */
public static List<ast.VariableDeclaration> getMethodParameters(MethodDeclaration md) {
List<ast.VariableDeclaration> params = new ArrayList<ast.VariableDeclaration>();
IMethodBinding methodBinding = md.resolveBinding();
if(methodBinding != null ) {
ITypeBinding[] typeParameters = methodBinding.getTypeParameters();
List<SingleVariableDeclaration> svdList = md.parameters();
for (SingleVariableDeclaration svd : svdList) {
ast.Type type = getType(svd.getType().resolveBinding());
ast.VariableDeclaration vd = VariableDeclaration.createFrom(svd);
vd.varType = type;
vd.varName = svd.getName().getFullyQualifiedName();
params.add(vd);
}
}
return params;
}