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


Java IMethodBinding.getJavaElement方法代碼示例

本文整理匯總了Java中org.eclipse.jdt.core.dom.IMethodBinding.getJavaElement方法的典型用法代碼示例。如果您正苦於以下問題:Java IMethodBinding.getJavaElement方法的具體用法?Java IMethodBinding.getJavaElement怎麽用?Java IMethodBinding.getJavaElement使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.jdt.core.dom.IMethodBinding的用法示例。


在下文中一共展示了IMethodBinding.getJavaElement方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: compareInTheSameType

import org.eclipse.jdt.core.dom.IMethodBinding; //導入方法依賴的package包/類
private int compareInTheSameType(IMethodBinding firstMethodBinding, IMethodBinding secondMethodBinding) {
	try {
		IMethod firstMethod= (IMethod)firstMethodBinding.getJavaElement();
		IMethod secondMethod= (IMethod)secondMethodBinding.getJavaElement();
		if (firstMethod == null || secondMethod == null) {
			return 0;
		}
		ISourceRange firstSourceRange= firstMethod.getSourceRange();
		ISourceRange secondSourceRange= secondMethod.getSourceRange();

		if (!SourceRange.isAvailable(firstSourceRange) || !SourceRange.isAvailable(secondSourceRange)) {
			return firstMethod.getElementName().compareTo(secondMethod.getElementName());
		} else {
			return firstSourceRange.getOffset() - secondSourceRange.getOffset();
		}
	} catch (JavaModelException e) {
		return 0;
	}
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:20,代碼來源:MethodsSourcePositionComparator.java

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

示例4: addCalledMethod

import org.eclipse.jdt.core.dom.IMethodBinding; //導入方法依賴的package包/類
private void addCalledMethod(IMethodBinding methodBinding) {
	IJavaElement calledMethod = methodBinding.getJavaElement();
	if (calledMethod instanceof IMethod) {
		methodDetails.addCall((IMethod) calledMethod);
	}
}
 
開發者ID:ioanaverebi,項目名稱:Sparrow,代碼行數:7,代碼來源:OutCodeVisitor.java


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