當前位置: 首頁>>代碼示例>>Java>>正文


Java IMethodBinding.getName方法代碼示例

本文整理匯總了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());
	}
}
 
開發者ID:linzeqipku,項目名稱:SnowGraph,代碼行數:21,代碼來源:APIMethodData.java

示例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();
}
 
開發者ID:aserg-ufmg,項目名稱:RefDiff,代碼行數:23,代碼來源:AstUtils.java

示例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();
}
 
開發者ID:aserg-ufmg,項目名稱:RefDiff,代碼行數:23,代碼來源:AstUtils.java

示例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 "";
	}
}
 
開發者ID:aserg-ufmg,項目名稱:RefDiff,代碼行數:18,代碼來源:ASTVisitorAtomicChange.java

示例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);
}
 
開發者ID:aroog,項目名稱:code,代碼行數:27,代碼來源:DeclarationVisitor.java

示例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;
    }
}
 
開發者ID:SERESLab,項目名稱:iTrace-Archive,代碼行數:34,代碼來源:AstManager.java

示例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;
}
 
開發者ID:aroog,項目名稱:code,代碼行數:36,代碼來源:Utils.java

示例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);
	}
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:28,代碼來源:CodeGeneration.java


注:本文中的org.eclipse.jdt.core.dom.IMethodBinding.getName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。