本文整理匯總了Java中org.eclipse.jdt.core.dom.IMethodBinding.getName方法的典型用法代碼示例。如果您正苦於以下問題:Java IMethodBinding.getName方法的具體用法?Java IMethodBinding.getName怎麽用?Java IMethodBinding.getName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jdt.core.dom.IMethodBinding
的用法示例。
在下文中一共展示了IMethodBinding.getName方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: getSimpleName
import org.eclipse.jdt.core.dom.IMethodBinding; //導入方法依賴的package包/類
private static String getSimpleName(IMethodBinding imb) {
try {
// imb = imb.getMethodDeclaration();
String name = imb.getName();
if (imb.isConstructor())
name = "<init>";
String args = "";
/*
* for (ITypeBinding itb : imb.getParameterTypes()) { if
* (args.length()>0) args+=","; args += getQualifiedName(itb); }
*/
args = "(" + args + ")";
return name + args;
} catch (NullPointerException e) {
return "";
}
}
示例5: 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);
}
示例6: extractDataFromVariableBinding
import org.eclipse.jdt.core.dom.IMethodBinding; //導入方法依賴的package包/類
/**
* Extracts the fully qualified name from a variable binding and applies
* them to the name in a SourceCodeEntity.
* @param binding The variable binding.
* @param sce SourceCodeEntity to which to apply changes. Name must be set
* to the entity's unqualified name.
*/
private static void extractDataFromVariableBinding(
IVariableBinding binding, SourceCodeEntity sce) {
if (binding != null) {
//Type member variable.
ITypeBinding type = binding.getDeclaringClass();
if (type != null)
sce.name = type.getQualifiedName() + "." + sce.name;
//Variable declared in method.
else {
IMethodBinding method = binding.getDeclaringMethod();
if (method != null) {
type = method.getDeclaringClass();
if (type != null) {
sce.name = type.getQualifiedName() + "."
+ method.getName() + "." + sce.name;
} else
sce.name = "?." + method.getName() + "." + sce.name;
} else
sce.name = "?." + sce.name;
}
} else {
//If binding fails, mark the qualification as "?" to show it could
//not be determined.
sce.name = "?." + sce.name;
}
}
示例7: getOverriddenMethod
import org.eclipse.jdt.core.dom.IMethodBinding; //導入方法依賴的package包/類
/**
* General, recursive version.
* @param declaringClass
* @param methodBinding
* @return
*/
private static IMethodBinding getOverriddenMethod(ITypeBinding declaringClass, IMethodBinding methodBinding) {
IMethodBinding overriddenMethod = null;
ITypeBinding[] paramTypes = methodBinding.getParameterTypes();
String methodName = methodBinding.getName();
ITypeBinding returnType = methodBinding.getReturnType();
// Look at superclass
ITypeBinding superclass = declaringClass.getSuperclass();
if (superclass != null) {
overriddenMethod = getMethodBinding(superclass, methodName, paramTypes, returnType);
// Recursively look at superclass
if (overriddenMethod == null ) {
overriddenMethod = getOverriddenMethod(superclass, methodBinding);
}
}
// Look at interfaces
if (overriddenMethod == null) {
for (ITypeBinding itfTypeBinding : declaringClass.getInterfaces()) {
overriddenMethod = getMethodBinding(itfTypeBinding, methodName, paramTypes, returnType);
if ( overriddenMethod != null ) {
break;
}
}
}
return overriddenMethod;
}
示例8: getMethodComment
import org.eclipse.jdt.core.dom.IMethodBinding; //導入方法依賴的package包/類
/**
* Returns the comment for a method or constructor using the comment code templates (constructor / method / overriding method).
* <code>null</code> is returned if the template is empty.
* @param cu The compilation unit to which the method belongs. The compilation unit does not need to exist.
* @param declaringTypeName Name of the type to which the method belongs. For inner types the name must be qualified and include the outer
* types names (dot separated). See {@link org.eclipse.jdt.core.IType#getTypeQualifiedName(char)}.
* @param decl The MethodDeclaration AST node that will be added as new
* method. The node does not need to exist in an AST (no parent needed) and does not need to resolve.
* See {@link org.eclipse.jdt.core.dom.AST#newMethodDeclaration()} for how to create such a node.
* @param overridden The binding of the method to which to add an "@see" link or
* <code>null</code> if no link should be created.
* @param lineDelimiter The line delimiter to be used.
* @return Returns the generated method comment or <code>null</code> if the
* code template is empty. The returned content is unformatted and not indented (formatting required).
* @throws CoreException Thrown when the evaluation of the code template fails.
*/
public static String getMethodComment(ICompilationUnit cu, String declaringTypeName, MethodDeclaration decl, IMethodBinding overridden, String lineDelimiter) throws CoreException {
if (overridden != null) {
overridden= overridden.getMethodDeclaration();
String declaringClassQualifiedName= overridden.getDeclaringClass().getQualifiedName();
String linkToMethodName= overridden.getName();
String[] parameterTypesQualifiedNames= StubUtility.getParameterTypeNamesForSeeTag(overridden);
return StubUtility.getMethodComment(cu, declaringTypeName, decl, overridden.isDeprecated(), linkToMethodName, declaringClassQualifiedName, parameterTypesQualifiedNames, false, lineDelimiter);
} else {
return StubUtility.getMethodComment(cu, declaringTypeName, decl, false, null, null, null, false, lineDelimiter);
}
}