本文整理匯總了Java中org.eclipse.jdt.core.dom.IMethodBinding.getParameterTypes方法的典型用法代碼示例。如果您正苦於以下問題:Java IMethodBinding.getParameterTypes方法的具體用法?Java IMethodBinding.getParameterTypes怎麽用?Java IMethodBinding.getParameterTypes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jdt.core.dom.IMethodBinding
的用法示例。
在下文中一共展示了IMethodBinding.getParameterTypes方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initByIMethodBinding
import org.eclipse.jdt.core.dom.IMethodBinding; //導入方法依賴的package包/類
public void initByIMethodBinding(IMethodBinding mBinding) {
IMethod iMethod = (IMethod) mBinding.getJavaElement();
try {
key = iMethod.getKey().substring(0, iMethod.getKey().indexOf("("))
+ iMethod.getSignature();
projectName = mBinding.getJavaElement().getJavaProject()
.getElementName();
} catch (Exception e) {
projectName = "";
}
packageName = mBinding.getDeclaringClass().getPackage().getName();
className = mBinding.getDeclaringClass().getName();
name = mBinding.getName();
parameters = new ArrayList<>();
ITypeBinding[] parameterBindings = mBinding.getParameterTypes();
for (int i = 0; i < parameterBindings.length; i++) {
parameters.add(parameterBindings[i].getName());
}
}
示例2: getKeyFromMethodBinding
import org.eclipse.jdt.core.dom.IMethodBinding; //導入方法依賴的package包/類
public static String getKeyFromMethodBinding(IMethodBinding binding) {
StringBuilder sb = new StringBuilder();
String className = binding.getDeclaringClass().getErasure().getQualifiedName();
sb.append(className);
sb.append('.');
String methodName = binding.isConstructor() ? "" : binding.getName();
sb.append(methodName);
//if (methodName.equals("allObjectsSorted")) {
// System.out.println();
//}
sb.append('(');
ITypeBinding[] parameters = binding.getParameterTypes();
for (int i = 0; i < parameters.length; i++) {
if (i > 0) {
sb.append(", ");
}
ITypeBinding type = parameters[i];
sb.append(type.getErasure().getName());
}
sb.append(')');
return sb.toString();
}
示例3: getKeyFromMethodBinding
import org.eclipse.jdt.core.dom.IMethodBinding; //導入方法依賴的package包/類
public static String getKeyFromMethodBinding(IMethodBinding binding) {
StringBuilder sb = new StringBuilder();
String className = binding.getDeclaringClass().getErasure().getQualifiedName();
sb.append(className);
sb.append('#');
String methodName = binding.isConstructor() ? "" : binding.getName();
sb.append(methodName);
//if (methodName.equals("allObjectsSorted")) {
// System.out.println();
//}
sb.append('(');
ITypeBinding[] parameters = binding.getParameterTypes();
for (int i = 0; i < parameters.length; i++) {
if (i > 0) {
sb.append(", ");
}
ITypeBinding type = parameters[i];
sb.append(type.getErasure().getName());
}
sb.append(')');
return sb.toString();
}
示例4: asString
import org.eclipse.jdt.core.dom.IMethodBinding; //導入方法依賴的package包/類
private static String asString(IMethodBinding method) {
StringBuffer result= new StringBuffer();
result.append(method.getDeclaringClass().getName());
result.append(':');
result.append(method.getName());
result.append('(');
ITypeBinding[] parameters= method.getParameterTypes();
int lastComma= parameters.length - 1;
for (int i= 0; i < parameters.length; i++) {
ITypeBinding parameter= parameters[i];
result.append(parameter.getName());
if (i < lastComma)
{
result.append(", "); //$NON-NLS-1$
}
}
result.append(')');
return result.toString();
}
示例5: sameParameters
import org.eclipse.jdt.core.dom.IMethodBinding; //導入方法依賴的package包/類
private static boolean sameParameters(IMethodBinding method, IMethod candidate) throws JavaModelException {
ITypeBinding[] methodParamters= method.getParameterTypes();
String[] candidateParameters= candidate.getParameterTypes();
if (methodParamters.length != candidateParameters.length) {
return false;
}
IType scope= candidate.getDeclaringType();
for (int i= 0; i < methodParamters.length; i++) {
ITypeBinding methodParameter= methodParamters[i];
String candidateParameter= candidateParameters[i];
if (!sameParameter(methodParameter, candidateParameter, scope)) {
return false;
}
}
return true;
}
示例6: getDimensions
import org.eclipse.jdt.core.dom.IMethodBinding; //導入方法依賴的package包/類
public static int getDimensions(VariableDeclaration declaration) {
int dim= declaration.getExtraDimensions();
if (declaration instanceof VariableDeclarationFragment && declaration.getParent() instanceof LambdaExpression) {
LambdaExpression lambda= (LambdaExpression) declaration.getParent();
IMethodBinding methodBinding= lambda.resolveMethodBinding();
if (methodBinding != null) {
ITypeBinding[] parameterTypes= methodBinding.getParameterTypes();
int index= lambda.parameters().indexOf(declaration);
ITypeBinding typeBinding= parameterTypes[index];
return typeBinding.getDimensions();
}
} else {
Type type= getType(declaration);
if (type instanceof ArrayType) {
dim+= ((ArrayType) type).getDimensions();
}
}
return dim;
}
示例7: newType
import org.eclipse.jdt.core.dom.IMethodBinding; //導入方法依賴的package包/類
private static Type newType(LambdaExpression lambdaExpression, VariableDeclarationFragment declaration, AST ast, ImportRewrite importRewrite, ImportRewriteContext context) {
IMethodBinding method= lambdaExpression.resolveMethodBinding();
if (method != null) {
ITypeBinding[] parameterTypes= method.getParameterTypes();
int index= lambdaExpression.parameters().indexOf(declaration);
ITypeBinding typeBinding= parameterTypes[index];
if (importRewrite != null) {
return importRewrite.addImport(typeBinding, ast, context);
} else {
String qualifiedName= typeBinding.getQualifiedName();
if (qualifiedName.length() > 0) {
return newType(ast, qualifiedName);
}
}
}
// fall-back
return ast.newSimpleType(ast.newSimpleName("Object")); //$NON-NLS-1$
}
示例8: addParameterMissmatchProposals
import org.eclipse.jdt.core.dom.IMethodBinding; //導入方法依賴的package包/類
private static void addParameterMissmatchProposals(IInvocationContext context, IProblemLocation problem,
List<IMethodBinding> similarElements, ASTNode invocationNode, List<Expression> arguments,
Collection<CUCorrectionProposal> proposals) throws CoreException {
int nSimilarElements= similarElements.size();
ITypeBinding[] argTypes= getArgumentTypes(arguments);
if (argTypes == null || nSimilarElements == 0) {
return;
}
for (int i= 0; i < nSimilarElements; i++) {
IMethodBinding elem = similarElements.get(i);
int diff= elem.getParameterTypes().length - argTypes.length;
if (diff == 0) {
int nProposals= proposals.size();
doEqualNumberOfParameters(context, invocationNode, problem, arguments, argTypes, elem, proposals);
if (nProposals != proposals.size()) {
return; // only suggest for one method (avoid duplicated proposals)
}
} else if (diff > 0) {
doMoreParameters(context, invocationNode, argTypes, elem, proposals);
} else {
doMoreArguments(context, invocationNode, arguments, argTypes, elem, proposals);
}
}
}
示例9: visit
import org.eclipse.jdt.core.dom.IMethodBinding; //導入方法依賴的package包/類
@Override
public boolean visit(MethodDeclaration node) {
if (isDeclarationTarget(DeclarationType.METHOD_DECLARATION)) {
IMethodBinding methodBinding = node.resolveBinding();
if (methodBinding != null) {
ITypeBinding declaringClass = methodBinding.getDeclaringClass();
typeDeclarationFound = declaringClass != null ? declaringClass
.getQualifiedName() : "";
methodParamasFound = methodBinding.getParameterTypes();
methodNameFound = methodBinding.getName();
if (matchTypeDeclaration()
&& TraceUtility
.match(methodNameToFind, methodNameFound)
&& TraceUtility.matchMethodParams(methodParamsToFind,
methodParamasFound)) {
TraceUtility.selectInEditor(node);
setEnclosingDeclaration(node);
}
}
}
return super.visit(node);
}
示例10: extractDataFromMethodBinding
import org.eclipse.jdt.core.dom.IMethodBinding; //導入方法依賴的package包/類
/**
* Extracts the fully qualified name and parameters from a method binding
* and applies them to the name in a SourceCodeEntity.
* @param binding The method binding.
* @param sce SourceCodeEntity to which to apply changes. Name must be set
* to the entity's unqualified name.
*/
private void extractDataFromMethodBinding(IMethodBinding binding,
SourceCodeEntity sce) {
if (binding != null) {
//Get package and type name within which this method is declared.
ITypeBinding type = binding.getDeclaringClass();
if (type != null)
sce.name = type.getQualifiedName() + "." + sce.name;
else
sce.name = "?." + sce.name;
//Get method parameter types
String params = "";
for (ITypeBinding paramType : binding.getParameterTypes()) {
if (paramType != null)
params += paramType.getQualifiedName() + ",";
}
if (params.length() > 0) {
sce.name += "("
+ params.substring(0, params.length() - 1)
+ ")";
} else
sce.name += "()";
} else {
//If binding fails, mark the qualification as "?" to show it could
//not be determined.
sce.name = "?." + sce.name + "(?)";
}
}
示例11: isEqualMethod
import org.eclipse.jdt.core.dom.IMethodBinding; //導入方法依賴的package包/類
/**
* Tests whether the two methods are erasure-equivalent.
* @param method the first method
* @param methodName the name of the second method
* @param parameters the parameters of the second method
* @return return <code>true</code> if the two bindings are equal
* @deprecated use {@link #isSubsignature(IMethodBinding, IMethodBinding)}
*/
//TODO: rename to isErasureEquivalentMethod and change to two IMethodBinding parameters
@Deprecated
public static boolean isEqualMethod(IMethodBinding method, String methodName, ITypeBinding[] parameters) {
if (!method.getName().equals(methodName)) {
return false;
}
ITypeBinding[] methodParameters= method.getParameterTypes();
if (methodParameters.length != parameters.length) {
return false;
}
for (int i= 0; i < parameters.length; i++) {
if (!equals(methodParameters[i].getErasure(), parameters[i].getErasure())) {
return false;
}
}
//Can't use this fix, since some clients assume that this method tests erasure equivalence:
// if (method.getTypeParameters().length == 0) {
// //a method without type parameters cannot be overridden by one that declares type parameters -> can be exact here
// for (int i= 0; i < parameters.length; i++) {
// if ( ! (equals(methodParameters[i], parameters[i])
// || equals(methodParameters[i].getErasure(), parameters[i]))) // subsignature
// return false;
// }
// } else {
// //this will find all overridden methods, but may generate false positives in some cases:
// for (int i= 0; i < parameters.length; i++) {
// if (!equals(methodParameters[i].getErasure(), parameters[i].getErasure()))
// return false;
// }
// }
return true;
}
示例12: getSignature
import org.eclipse.jdt.core.dom.IMethodBinding; //導入方法依賴的package包/類
public String getSignature(IMethodBinding methodBinding) {
StringBuilder builder = new StringBuilder();
// Cannot use this. Due to inheritance.
// builder.append(methodBinding.getDeclaringClass().getQualifiedName());
// builder.append("::");
builder.append(methodBinding.getName());
builder.append(".");
ITypeBinding[] parameters = methodBinding.getParameterTypes();
for (ITypeBinding typeBinding : parameters) {
builder.append(typeBinding.getQualifiedName());
builder.append(".");
}
builder.deleteCharAt(builder.length()-1);
return builder.toString();
}
示例13: getParameterTypeNamesForSeeTag
import org.eclipse.jdt.core.dom.IMethodBinding; //導入方法依賴的package包/類
public static String[] getParameterTypeNamesForSeeTag(IMethodBinding binding) {
ITypeBinding[] typeBindings= binding.getParameterTypes();
String[] result= new String[typeBindings.length];
for (int i= 0; i < result.length; i++) {
ITypeBinding curr= typeBindings[i];
curr= curr.getErasure(); // Javadoc references use erased type
result[i]= curr.getQualifiedName();
}
return result;
}
示例14: getBaseNameFromLocationInParent
import org.eclipse.jdt.core.dom.IMethodBinding; //導入方法依賴的package包/類
private static String getBaseNameFromLocationInParent(Expression assignedExpression, List<Expression> arguments, IMethodBinding binding) {
if (binding == null) {
return null;
}
ITypeBinding[] parameterTypes= binding.getParameterTypes();
if (parameterTypes.length != arguments.size()) {
return null;
}
int index= arguments.indexOf(assignedExpression);
if (index == -1) {
return null;
}
ITypeBinding expressionBinding= assignedExpression.resolveTypeBinding();
if (expressionBinding != null && !expressionBinding.isAssignmentCompatible(parameterTypes[index])) {
return null;
}
try {
IJavaElement javaElement= binding.getJavaElement();
if (javaElement instanceof IMethod) {
IMethod method= (IMethod)javaElement;
if (method.getOpenable().getBuffer() != null) { // avoid dummy names and lookup from Javadoc
String[] parameterNames= method.getParameterNames();
if (index < parameterNames.length) {
return NamingConventions.getBaseName(NamingConventions.VK_PARAMETER, parameterNames[index], method.getJavaProject());
}
}
}
} catch (JavaModelException e) {
// ignore
}
return null;
}
示例15: suggestArgumentNames
import org.eclipse.jdt.core.dom.IMethodBinding; //導入方法依賴的package包/類
public static String[] suggestArgumentNames(IJavaProject project, IMethodBinding binding) {
int nParams = binding.getParameterTypes().length;
if (nParams > 0) {
try {
IMethod method = (IMethod) binding.getMethodDeclaration().getJavaElement();
if (method != null) {
String[] paramNames = method.getParameterNames();
if (paramNames.length == nParams) {
String[] namesArray = EMPTY;
ArrayList<String> newNames = new ArrayList<>(paramNames.length);
// Ensure that the code generation preferences are respected
for (int i = 0; i < paramNames.length; i++) {
String curr = paramNames[i];
String baseName = NamingConventions.getBaseName(NamingConventions.VK_PARAMETER, curr,
method.getJavaProject());
if (!curr.equals(baseName)) {
// make the existing name the favorite
newNames.add(curr);
} else {
newNames.add(suggestArgumentName(project, curr, namesArray));
}
namesArray = newNames.toArray(new String[newNames.size()]);
}
return namesArray;
}
}
} catch (JavaModelException e) {
// ignore
}
}
String[] names = new String[nParams];
for (int i = 0; i < names.length; i++) {
names[i] = "arg" + i; //$NON-NLS-1$
}
return names;
}