本文整理汇总了Java中org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding.getMethods方法的典型用法代码示例。如果您正苦于以下问题:Java ReferenceBinding.getMethods方法的具体用法?Java ReferenceBinding.getMethods怎么用?Java ReferenceBinding.getMethods使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding
的用法示例。
在下文中一共展示了ReferenceBinding.getMethods方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findSuperMethodBinding
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; //导入方法依赖的package包/类
/** Computes the super method, if any, given a method binding */
private static MethodBinding findSuperMethodBinding(@NonNull MethodBinding binding) {
try {
ReferenceBinding superclass = binding.declaringClass.superclass();
while (superclass != null) {
MethodBinding[] methods = superclass.getMethods(binding.selector,
binding.parameters.length);
for (MethodBinding method : methods) {
if (method.areParameterErasuresEqual(binding)) {
return method;
}
}
superclass = superclass.superclass();
}
} catch (Exception ignore) {
// Work around ECJ bugs; see https://code.google.com/p/android/issues/detail?id=172268
}
return null;
}
示例2: getConstructors
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; //导入方法依赖的package包/类
@Override
@NonNull
public Iterable<ResolvedMethod> getConstructors() {
if (mBinding instanceof ReferenceBinding) {
ReferenceBinding cls = (ReferenceBinding) mBinding;
MethodBinding[] methods = cls.getMethods(TypeConstants.INIT);
if (methods != null) {
int count = methods.length;
List<ResolvedMethod> result = Lists.newArrayListWithExpectedSize(count);
for (MethodBinding method : methods) {
if (method.isConstructor()) {
result.add(new EcjResolvedMethod(method));
}
}
return result;
}
}
return Collections.emptyList();
}
示例3: getMethodBinding
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; //导入方法依赖的package包/类
/**
* Find a particular annotation member by name.
* @return a compiler method binding, or null if no member was found.
*/
private MethodBinding getMethodBinding(String name) {
ReferenceBinding annoType = _binding.getAnnotationType();
MethodBinding[] methods = annoType.getMethods(name.toCharArray());
for (MethodBinding method : methods) {
// annotation members have no parameters
if (method.parameters.length == 0) {
return method;
}
}
return null;
}
示例4: findNonDefaultAbstractMethod
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; //导入方法依赖的package包/类
private MethodBinding findNonDefaultAbstractMethod(MethodBinding methodBinding) {
ReferenceBinding[] itsInterfaces = methodBinding.declaringClass.superInterfaces();
if (itsInterfaces != Binding.NO_SUPERINTERFACES) {
ReferenceBinding[] interfacesToVisit = itsInterfaces;
int nextPosition = interfacesToVisit.length;
for (int i = 0; i < nextPosition; i++) {
ReferenceBinding currentType = interfacesToVisit[i];
MethodBinding[] methods = currentType.getMethods(methodBinding.selector);
if(methods != null) {
for (int k = 0; k < methods.length; k++) {
if(methodBinding.areParametersEqual(methods[k]))
return methods[k];
}
}
if ((itsInterfaces = currentType.superInterfaces()) != Binding.NO_SUPERINTERFACES) {
int itsLength = itsInterfaces.length;
if (nextPosition + itsLength >= interfacesToVisit.length)
System.arraycopy(interfacesToVisit, 0, interfacesToVisit = new ReferenceBinding[nextPosition + itsLength + 5], 0, nextPosition);
nextInterface : for (int a = 0; a < itsLength; a++) {
ReferenceBinding next = itsInterfaces[a];
for (int b = 0; b < nextPosition; b++)
if (TypeBinding.equalsEquals(next, interfacesToVisit[b])) continue nextInterface;
interfacesToVisit[nextPosition++] = next;
}
}
}
}
return methodBinding;
}
示例5: getConstructor
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; //导入方法依赖的package包/类
public MethodBinding getConstructor(ReferenceBinding receiverType, TypeBinding[] argumentTypes, InvocationSite invocationSite) {
MethodBinding methodBinding = receiverType.getExactConstructor(argumentTypes);
if (methodBinding != null) {
if (canBeSeenByForCodeSnippet(methodBinding, receiverType, invocationSite, this)) {
return methodBinding;
}
}
MethodBinding[] methods = receiverType.getMethods(TypeConstants.INIT);
if (methods == Binding.NO_METHODS) {
return new ProblemMethodBinding(TypeConstants.INIT, argumentTypes, ProblemReasons.NotFound);
}
MethodBinding[] compatible = new MethodBinding[methods.length];
int compatibleIndex = 0;
for (int i = 0, length = methods.length; i < length; i++) {
MethodBinding compatibleMethod = computeCompatibleMethod(methods[i], argumentTypes, invocationSite, Scope.APPLICABILITY);
if (compatibleMethod != null)
compatible[compatibleIndex++] = compatibleMethod;
}
if (compatibleIndex == 0)
return new ProblemMethodBinding(TypeConstants.INIT, argumentTypes, ProblemReasons.NotFound); // need a more descriptive error... cannot convert from X to Y
MethodBinding[] visible = new MethodBinding[compatibleIndex];
int visibleIndex = 0;
for (int i = 0; i < compatibleIndex; i++) {
MethodBinding method = compatible[i];
if (canBeSeenByForCodeSnippet(method, receiverType, invocationSite, this)) {
visible[visibleIndex++] = method;
}
}
if (visibleIndex == 1) {
// 1.8: Give inference a chance to perform outstanding tasks (18.5.2):
return inferInvocationType(invocationSite, visible[0], argumentTypes);
}
if (visibleIndex == 0) {
return new ProblemMethodBinding(compatible[0], TypeConstants.INIT, compatible[0].parameters, ProblemReasons.NotVisible);
}
return mostSpecificClassMethodBinding(visible, visibleIndex, invocationSite);
}
示例6: findNonDefaultAbstractMethod
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; //导入方法依赖的package包/类
private MethodBinding findNonDefaultAbstractMethod(MethodBinding methodBinding) {
ReferenceBinding[] itsInterfaces = methodBinding.declaringClass.superInterfaces();
if (itsInterfaces != Binding.NO_SUPERINTERFACES) {
ReferenceBinding[] interfacesToVisit = itsInterfaces;
int nextPosition = interfacesToVisit.length;
for (int i = 0; i < nextPosition; i++) {
ReferenceBinding currentType = interfacesToVisit[i];
MethodBinding[] methods = currentType.getMethods(methodBinding.selector);
if(methods != null) {
for (int k = 0; k < methods.length; k++) {
if(methodBinding.areParametersEqual(methods[k]))
return methods[k];
}
}
if ((itsInterfaces = currentType.superInterfaces()) != Binding.NO_SUPERINTERFACES) {
int itsLength = itsInterfaces.length;
if (nextPosition + itsLength >= interfacesToVisit.length)
System.arraycopy(interfacesToVisit, 0, interfacesToVisit = new ReferenceBinding[nextPosition + itsLength + 5], 0, nextPosition);
nextInterface : for (int a = 0; a < itsLength; a++) {
ReferenceBinding next = itsInterfaces[a];
for (int b = 0; b < nextPosition; b++)
if (next == interfacesToVisit[b]) continue nextInterface;
interfacesToVisit[nextPosition++] = next;
}
}
}
}
return methodBinding;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:33,代码来源:SelectionOnMessageSend.java
示例7: getConstructor
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; //导入方法依赖的package包/类
public MethodBinding getConstructor(ReferenceBinding receiverType, TypeBinding[] argumentTypes, InvocationSite invocationSite) {
MethodBinding methodBinding = receiverType.getExactConstructor(argumentTypes);
if (methodBinding != null) {
if (canBeSeenByForCodeSnippet(methodBinding, receiverType, invocationSite, this)) {
return methodBinding;
}
}
MethodBinding[] methods = receiverType.getMethods(TypeConstants.INIT);
if (methods == Binding.NO_METHODS) {
return new ProblemMethodBinding(TypeConstants.INIT, argumentTypes, ProblemReasons.NotFound);
}
MethodBinding[] compatible = new MethodBinding[methods.length];
int compatibleIndex = 0;
for (int i = 0, length = methods.length; i < length; i++) {
MethodBinding compatibleMethod = computeCompatibleMethod(methods[i], argumentTypes, invocationSite);
if (compatibleMethod != null)
compatible[compatibleIndex++] = compatibleMethod;
}
if (compatibleIndex == 0)
return new ProblemMethodBinding(TypeConstants.INIT, argumentTypes, ProblemReasons.NotFound); // need a more descriptive error... cannot convert from X to Y
MethodBinding[] visible = new MethodBinding[compatibleIndex];
int visibleIndex = 0;
for (int i = 0; i < compatibleIndex; i++) {
MethodBinding method = compatible[i];
if (canBeSeenByForCodeSnippet(method, receiverType, invocationSite, this)) {
visible[visibleIndex++] = method;
}
}
if (visibleIndex == 1) {
return visible[0];
}
if (visibleIndex == 0) {
return new ProblemMethodBinding(compatible[0], TypeConstants.INIT, compatible[0].parameters, ProblemReasons.NotVisible);
}
return mostSpecificClassMethodBinding(visible, visibleIndex, invocationSite);
}
示例8: getPackedAnnotationBindings
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; //导入方法依赖的package包/类
public static AnnotationBinding [] getPackedAnnotationBindings(AnnotationBinding [] annotations) {
int length = annotations == null ? 0 : annotations.length;
if (length == 0)
return annotations;
AnnotationBinding[] repackagedBindings = annotations; // only replicate if repackaging.
for (int i = 0; i < length; i++) {
AnnotationBinding annotation = repackagedBindings[i];
if (annotation == null) continue;
ReferenceBinding annotationType = annotation.getAnnotationType();
if (!annotationType.isRepeatableAnnotationType())
continue;
ReferenceBinding containerType = annotationType.containerAnnotationType();
if (containerType == null)
continue; // FUBAR.
MethodBinding [] values = containerType.getMethods(TypeConstants.VALUE);
if (values == null || values.length != 1)
continue; // FUBAR.
MethodBinding value = values[0];
if (value.returnType == null || value.returnType.dimensions() != 1 || TypeBinding.notEquals(value.returnType.leafComponentType(), annotationType))
continue; // FUBAR
// We have a kosher repeatable annotation with a kosher containing type. See if actually repeats.
List<AnnotationBinding> containees = null;
for (int j = i + 1; j < length; j++) {
AnnotationBinding otherAnnotation = repackagedBindings[j];
if (otherAnnotation == null) continue;
if (otherAnnotation.getAnnotationType() == annotationType) { //$IDENTITY-COMPARISON$
if (repackagedBindings == annotations)
System.arraycopy(repackagedBindings, 0, repackagedBindings = new AnnotationBinding[length], 0, length);
repackagedBindings[j] = null; // so it is not double packed.
if (containees == null) {
containees = new ArrayList<AnnotationBinding>();
containees.add(annotation);
}
containees.add(otherAnnotation);
}
}
if (containees != null) {
ElementValuePair [] elementValuePairs = new ElementValuePair [] { new ElementValuePair(TypeConstants.VALUE, containees.toArray(), value) };
repackagedBindings[i] = new AnnotationBinding(containerType, elementValuePairs);
}
}
if (repackagedBindings == annotations)
return annotations;
int finalTally = 0;
for (int i = 0; i < length; i++) {
if (repackagedBindings[i] != null)
finalTally++;
}
annotations = new AnnotationBinding [finalTally];
for (int i = 0, j = 0; i < length; i++) {
if (repackagedBindings[i] != null)
annotations[j++] = repackagedBindings[i];
}
return annotations;
}
示例9: getUnpackedAnnotationBindings
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; //导入方法依赖的package包/类
public static AnnotationBinding [] getUnpackedAnnotationBindings(AnnotationBinding [] annotations) {
int length = annotations == null ? 0 : annotations.length;
if (length == 0)
return annotations;
List<AnnotationBinding> unpackedAnnotations = new ArrayList<AnnotationBinding>();
for (int i = 0; i < length; i++) {
AnnotationBinding annotation = annotations[i];
if (annotation == null) continue;
unpackedAnnotations.add(annotation);
ReferenceBinding annotationType = annotation.getAnnotationType();
MethodBinding [] values = annotationType.getMethods(TypeConstants.VALUE);
if (values == null || values.length != 1)
continue;
MethodBinding value = values[0];
if (value.returnType.dimensions() != 1)
continue;
TypeBinding containeeType = value.returnType.leafComponentType();
if (containeeType == null || !containeeType.isAnnotationType() || !containeeType.isRepeatableAnnotationType())
continue;
if (containeeType.containerAnnotationType() != annotationType) //$IDENTITY-COMPARISON$
continue;
// We have a kosher container: unwrap the contained annotations.
ElementValuePair [] elementValuePairs = annotation.getElementValuePairs();
for (ElementValuePair elementValuePair : elementValuePairs) {
if (CharOperation.equals(elementValuePair.getName(), TypeConstants.VALUE)) {
Object [] containees = (Object []) elementValuePair.getValue();
for (Object object : containees) {
unpackedAnnotations.add((AnnotationBinding) object);
}
break;
}
}
}
return (AnnotationBinding[]) unpackedAnnotations.toArray(new AnnotationBinding [unpackedAnnotations.size()]);
}