本文整理匯總了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());
}
}
示例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;
}
}
示例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;
}
示例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);
}
}