当前位置: 首页>>代码示例>>Java>>正文


Java MethodBinding类代码示例

本文整理汇总了Java中org.eclipse.jdt.internal.compiler.lookup.MethodBinding的典型用法代码示例。如果您正苦于以下问题:Java MethodBinding类的具体用法?Java MethodBinding怎么用?Java MethodBinding使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MethodBinding类属于org.eclipse.jdt.internal.compiler.lookup包,在下文中一共展示了MethodBinding类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: failIfContainsAnnotation

import org.eclipse.jdt.internal.compiler.lookup.MethodBinding; //导入依赖的package包/类
private static void failIfContainsAnnotation(TypeBinding parent, Binding[] bindings) throws DelegateRecursion {
	if (bindings == null) return;
	
	for (Binding b : bindings) {
		AnnotationBinding[] anns = null;
		if (b instanceof MethodBinding) anns = ((MethodBinding) b).getAnnotations();
		if (b instanceof FieldBinding) anns = ((FieldBinding) b).getAnnotations();
		// anns = b.getAnnotations() would make a heck of a lot more sense, but that is a late addition to ecj, so would cause NoSuchMethodErrors! Don't use that!
		if (anns == null) continue;
		for (AnnotationBinding ann : anns) {
			char[][] name = null;
			try {
				name = ann.getAnnotationType().compoundName;
			} catch (Exception ignore) {}
			
			if (name == null || name.length < 2 || name.length > 3) continue;
			if (!Arrays.equals(STRING_LOMBOK, name[0])) continue;
			if (!Arrays.equals(STRING_DELEGATE, name[name.length - 1])) continue;
			if (name.length == 3 && !Arrays.equals(STRING_EXPERIMENTAL, name[1])) continue;
			
			throw new DelegateRecursion(parent.readableName(), b.readableName());
		}
	}
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:25,代码来源:PatchDelegate.java

示例2: getJavaCompletionProposals

import org.eclipse.jdt.internal.compiler.lookup.MethodBinding; //导入依赖的package包/类
public static IJavaCompletionProposal[] getJavaCompletionProposals(IJavaCompletionProposal[] javaCompletionProposals,
		CompletionProposalCollector completionProposalCollector) {
	
	List<IJavaCompletionProposal> proposals = new ArrayList<IJavaCompletionProposal>(Arrays.asList(javaCompletionProposals));
	if (canExtendCodeAssist(proposals)) {
		IJavaCompletionProposal firstProposal = proposals.get(0);
		int replacementOffset = getReplacementOffset(firstProposal);
		for (Extension extension : getExtensionMethods(completionProposalCollector)) {
			for (MethodBinding method : extension.extensionMethods) {
				ExtensionMethodCompletionProposal newProposal = new ExtensionMethodCompletionProposal(replacementOffset);
				copyNameLookupAndCompletionEngine(completionProposalCollector, firstProposal, newProposal);
				ASTNode node = getAssistNode(completionProposalCollector);
				newProposal.setMethodBinding(method, node);
				createAndAddJavaCompletionProposal(completionProposalCollector, newProposal, proposals);
			}
		}
	}
	return proposals.toArray(new IJavaCompletionProposal[proposals.size()]);
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:20,代码来源:PatchExtensionMethodCompletionProposal.java

示例3: getApplicableExtensionMethodsDefinedInProvider

import org.eclipse.jdt.internal.compiler.lookup.MethodBinding; //导入依赖的package包/类
private static List<MethodBinding> getApplicableExtensionMethodsDefinedInProvider(EclipseNode typeNode, ReferenceBinding extensionMethodProviderBinding,
		TypeBinding receiverType) {
	
	List<MethodBinding> extensionMethods = new ArrayList<MethodBinding>();
	CompilationUnitScope cuScope = ((CompilationUnitDeclaration) typeNode.top().get()).scope;
	for (MethodBinding method : extensionMethodProviderBinding.methods()) {
		if (!method.isStatic()) continue;
		if (!method.isPublic()) continue;
		if (method.parameters == null || method.parameters.length == 0) continue;
		TypeBinding firstArgType = method.parameters[0];
		if (receiverType.isProvablyDistinct(firstArgType) && !receiverType.isCompatibleWith(firstArgType.erasure())) continue;
		TypeBinding[] argumentTypes = Arrays.copyOfRange(method.parameters, 1, method.parameters.length);
		if ((receiverType instanceof ReferenceBinding) && ((ReferenceBinding) receiverType).getExactMethod(method.selector, argumentTypes, cuScope) != null) continue;
		extensionMethods.add(method);
	}
	return extensionMethods;
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:18,代码来源:PatchExtensionMethod.java

示例4: findSuperMethodBinding

import org.eclipse.jdt.internal.compiler.lookup.MethodBinding; //导入依赖的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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:EcjParser.java

示例5: getConstructors

import org.eclipse.jdt.internal.compiler.lookup.MethodBinding; //导入依赖的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();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:EcjParser.java

示例6: getElementValues

import org.eclipse.jdt.internal.compiler.lookup.MethodBinding; //导入依赖的package包/类
/**
 * @return all the members of this annotation mirror that have explicit values.
 * Default values are not included.
 */
public Map<? extends ExecutableElement, ? extends AnnotationValue> getElementValues() {
	if (this._binding == null) {
		return Collections.emptyMap();
	}
	ElementValuePair[] pairs = _binding.getElementValuePairs();
	Map<ExecutableElement, AnnotationValue> valueMap =
		new LinkedHashMap<ExecutableElement, AnnotationValue>(pairs.length);
	for (ElementValuePair pair : pairs) {
		MethodBinding method = pair.getMethodBinding();
		if (method == null) {
			// ideally we should be able to create a fake ExecutableElementImpl
			continue;
		}
		ExecutableElement e = new ExecutableElementImpl(_env, method);
		AnnotationValue v = new AnnotationMemberValue(_env, pair.getValue(), method);
		valueMap.put(e, v);
	}
	return Collections.unmodifiableMap(valueMap);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:24,代码来源:AnnotationMirrorImpl.java

示例7: varargsConflict

import org.eclipse.jdt.internal.compiler.lookup.MethodBinding; //导入依赖的package包/类
public void varargsConflict(MethodBinding method1, MethodBinding method2, SourceTypeBinding type) {
	this.handle(
		IProblem.VarargsConflict,
		new String[] {
		        new String(method1.selector),
		        typesAsString(method1, false),
		        new String(method1.declaringClass.readableName()),
		        typesAsString(method2, false),
		        new String(method2.declaringClass.readableName())
		},
		new String[] {
		        new String(method1.selector),
		        typesAsString(method1, true),
		        new String(method1.declaringClass.shortReadableName()),
		        typesAsString(method2, true),
		        new String(method2.declaringClass.shortReadableName())
		},
		method1.declaringClass == type ? method1.sourceStart() : type.sourceStart(),
		method1.declaringClass == type ? method1.sourceEnd() : type.sourceEnd());
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:21,代码来源:ProblemReporter.java

示例8: inheritedMethodReducesVisibility

import org.eclipse.jdt.internal.compiler.lookup.MethodBinding; //导入依赖的package包/类
private void inheritedMethodReducesVisibility(int sourceStart, int sourceEnd, MethodBinding concreteMethod, MethodBinding[] abstractMethods) {
	StringBuffer concreteSignature = new StringBuffer();
	concreteSignature
		.append(concreteMethod.declaringClass.readableName())
		.append('.')
		.append(concreteMethod.readableName());
	StringBuffer shortSignature = new StringBuffer();
	shortSignature
		.append(concreteMethod.declaringClass.shortReadableName())
		.append('.')
		.append(concreteMethod.shortReadableName());
	this.handle(
		// The inherited method %1 cannot hide the public abstract method in %2
		IProblem.InheritedMethodReducesVisibility,
		new String[] {
			concreteSignature.toString(),
			new String(abstractMethods[0].declaringClass.readableName())},
		new String[] {
			shortSignature.toString(),
			new String(abstractMethods[0].declaringClass.shortReadableName())},
		sourceStart,
		sourceEnd);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:24,代码来源:ProblemReporter.java

示例9: getKind

import org.eclipse.jdt.internal.compiler.lookup.MethodBinding; //导入依赖的package包/类
@Override
public ElementKind getKind() {
	MethodBinding binding = (MethodBinding)_binding;
	if (binding.isConstructor()) {
		return ElementKind.CONSTRUCTOR;
	}
	else if (CharOperation.equals(binding.selector, TypeConstants.CLINIT)) {
		return ElementKind.STATIC_INIT;
	}
	else if (CharOperation.equals(binding.selector, TypeConstants.INIT)) {
		return ElementKind.INSTANCE_INIT;
	}
	else {
		return ElementKind.METHOD;
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:17,代码来源:ExecutableElementImpl.java

示例10: annotationCannotOverrideMethod

import org.eclipse.jdt.internal.compiler.lookup.MethodBinding; //导入依赖的package包/类
public void annotationCannotOverrideMethod(MethodBinding overrideMethod, MethodBinding inheritedMethod) {
	ASTNode location = overrideMethod.sourceMethod();
	this.handle(
		IProblem.AnnotationCannotOverrideMethod,
		new String[] {
				new String(overrideMethod.declaringClass.readableName()),
				new String(inheritedMethod.declaringClass.readableName()),
				new String(inheritedMethod.selector),
				typesAsString(inheritedMethod, false)},
		new String[] {
				new String(overrideMethod.declaringClass.shortReadableName()),
				new String(inheritedMethod.declaringClass.shortReadableName()),
				new String(inheritedMethod.selector),
				typesAsString(inheritedMethod, true)},
		location.sourceStart,
		location.sourceEnd);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:18,代码来源:ProblemReporter.java

示例11: generateMethodInfoHeader

import org.eclipse.jdt.internal.compiler.lookup.MethodBinding; //导入依赖的package包/类
/**
 * INTERNAL USE-ONLY
 * That method generates the header of a method info:
 * The header consists in:
 * - the access flags
 * - the name index of the method name inside the constant pool
 * - the descriptor index of the signature of the method inside the constant pool.
 *
 * @param methodBinding org.eclipse.jdt.internal.compiler.lookup.MethodBinding
 * @param accessFlags the access flags
 */
public void generateMethodInfoHeader(MethodBinding methodBinding, int accessFlags) {
	// check that there is enough space to write all the bytes for the method info corresponding
	// to the @methodBinding
	this.methodCount++; // add one more method
	if (this.contentsOffset + 10 >= this.contents.length) {
		resizeContents(10);
	}
	if (this.targetJDK < ClassFileConstants.JDK1_5) {
		// pre 1.5, synthetic is an attribute, not a modifier
		// pre 1.5, varargs is an attribute, not a modifier (-target jsr14 mode)
		accessFlags &= ~(ClassFileConstants.AccSynthetic | ClassFileConstants.AccVarargs);
	}
	if ((methodBinding.tagBits & TagBits.ClearPrivateModifier) != 0) {
		accessFlags &= ~ClassFileConstants.AccPrivate;
	}
	this.contents[this.contentsOffset++] = (byte) (accessFlags >> 8);
	this.contents[this.contentsOffset++] = (byte) accessFlags;
	int nameIndex = this.constantPool.literalIndex(methodBinding.selector);
	this.contents[this.contentsOffset++] = (byte) (nameIndex >> 8);
	this.contents[this.contentsOffset++] = (byte) nameIndex;
	int descriptorIndex = this.constantPool.literalIndex(methodBinding.signature(this));
	this.contents[this.contentsOffset++] = (byte) (descriptorIndex >> 8);
	this.contents[this.contentsOffset++] = (byte) descriptorIndex;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:36,代码来源:ClassFile.java

示例12: illegalReturnRedefinition

import org.eclipse.jdt.internal.compiler.lookup.MethodBinding; //导入依赖的package包/类
public void illegalReturnRedefinition(AbstractMethodDeclaration abstractMethodDecl, MethodBinding inheritedMethod, char[][] nonNullAnnotationName) {
	MethodDeclaration methodDecl = (MethodDeclaration) abstractMethodDecl;
	StringBuffer methodSignature = new StringBuffer();
	methodSignature
		.append(inheritedMethod.declaringClass.readableName())
		.append('.')
		.append(inheritedMethod.readableName());

	StringBuffer shortSignature = new StringBuffer();
	shortSignature
		.append(inheritedMethod.declaringClass.shortReadableName())
		.append('.')
		.append(inheritedMethod.shortReadableName());
	int sourceStart = methodDecl.returnType.sourceStart;
	Annotation[] annotations = methodDecl.annotations;
	Annotation annotation = findAnnotation(annotations, TypeIds.T_ConfiguredAnnotationNullable);
	if (annotation != null) {
		sourceStart = annotation.sourceStart;
	}
	this.handle(
		IProblem.IllegalReturnNullityRedefinition, 
		new String[] { methodSignature.toString(), CharOperation.toString(nonNullAnnotationName)},
		new String[] { shortSignature.toString(), new String(nonNullAnnotationName[nonNullAnnotationName.length-1])},
		sourceStart,
		methodDecl.returnType.sourceEnd);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:27,代码来源:ProblemReporter.java

示例13: consumeTypeVariable

import org.eclipse.jdt.internal.compiler.lookup.MethodBinding; //导入依赖的package包/类
public void consumeTypeVariable(char[] position, char[] typeVariableName) {
	if (position.length > 0) {
		if (this.typeBinding == null)
			return;
		int pos = Integer.parseInt(new String(position));
		MethodBinding[] methods = ((ReferenceBinding) this.typeBinding).availableMethods(); // resilience
		if (methods != null && pos < methods.length) {
			this.methodBinding = methods[pos];
		}
	}
 	TypeVariableBinding[] typeVariableBindings;
 	if (this.methodBinding != null) {
 		typeVariableBindings = this.methodBinding.typeVariables();
 	} else if (this.typeBinding != null) {
 		typeVariableBindings = this.typeBinding.typeVariables();
 	} else {
 		return;
 	}
 	for (int i = 0, length = typeVariableBindings.length; i < length; i++) {
		TypeVariableBinding typeVariableBinding = typeVariableBindings[i];
		if (CharOperation.equals(typeVariableName, typeVariableBinding.sourceName())) {
			this.typeBinding = typeVariableBinding;
			return;
		}
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:27,代码来源:BindingKeyResolver.java

示例14: getEnclosedElements

import org.eclipse.jdt.internal.compiler.lookup.MethodBinding; //导入依赖的package包/类
@Override
public List<? extends Element> getEnclosedElements() {
	ReferenceBinding binding = (ReferenceBinding)_binding;
	List<Element> enclosed = new ArrayList<Element>(binding.fieldCount() + binding.methods().length);
	for (MethodBinding method : binding.methods()) {
		ExecutableElement executable = new ExecutableElementImpl(_env, method);
		enclosed.add(executable);
	}
	for (FieldBinding field : binding.fields()) {
		// TODO no field should be excluded according to the JLS
		if (!field.isSynthetic()) {
			 VariableElement variable = new VariableElementImpl(_env, field);
			 enclosed.add(variable);
		}
	}
	for (ReferenceBinding memberType : binding.memberTypes()) {
		TypeElement type = new TypeElementImpl(_env, memberType, null);
		enclosed.add(type);
	}
	return Collections.unmodifiableList(enclosed);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:22,代码来源:TypeElementImpl.java

示例15: enumConstantMustImplementAbstractMethod

import org.eclipse.jdt.internal.compiler.lookup.MethodBinding; //导入依赖的package包/类
public void enumConstantMustImplementAbstractMethod(AbstractMethodDeclaration method, FieldDeclaration field) {
	MethodBinding abstractMethod = method.binding;
	this.handle(
		IProblem.EnumConstantMustImplementAbstractMethod,
		new String[] {
		        new String(abstractMethod.selector),
		        typesAsString(abstractMethod, false),
		        new String(field.name),
		},
		new String[] {
		        new String(abstractMethod.selector),
		        typesAsString(abstractMethod, true),
		        new String(field.name),
		},
		field.sourceStart(),
		field.sourceEnd());
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:18,代码来源:ProblemReporter.java


注:本文中的org.eclipse.jdt.internal.compiler.lookup.MethodBinding类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。