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


Java ProblemMethodBinding类代码示例

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


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

示例1: findMethodForArray

import org.eclipse.jdt.internal.compiler.lookup.ProblemMethodBinding; //导入依赖的package包/类
public MethodBinding findMethodForArray(ArrayBinding receiverType, char[] selector, TypeBinding[] argumentTypes, InvocationSite invocationSite) {
	ReferenceBinding object = getJavaLangObject();
	MethodBinding methodBinding = object.getExactMethod(selector, argumentTypes, null);
	if (methodBinding != null) {
		// handle the method clone() specially... cannot be protected or throw exceptions
		if (argumentTypes == Binding.NO_PARAMETERS && CharOperation.equals(selector, TypeConstants.CLONE))
			return new MethodBinding((methodBinding.modifiers & ~ClassFileConstants.AccProtected) | ClassFileConstants.AccPublic, TypeConstants.CLONE, methodBinding.returnType, argumentTypes, null, object);
		if (canBeSeenByForCodeSnippet(methodBinding, receiverType, invocationSite, this))
			return methodBinding;
	}

	// answers closest approximation, may not check argumentTypes or visibility
	methodBinding = findMethod(object, selector, argumentTypes, invocationSite, false);
	if (methodBinding == null)
		return new ProblemMethodBinding(selector, argumentTypes, ProblemReasons.NotFound);
	if (methodBinding.isValidBinding()) {
	    MethodBinding compatibleMethod = computeCompatibleMethod(methodBinding, argumentTypes, invocationSite, Scope.FULL_INFERENCE);
	    if (compatibleMethod == null)
			return new ProblemMethodBinding(methodBinding, selector, argumentTypes, ProblemReasons.NotFound);
	    methodBinding = compatibleMethod;
		if (!canBeSeenByForCodeSnippet(methodBinding, receiverType, invocationSite, this))
			return new ProblemMethodBinding(methodBinding, selector, methodBinding.parameters, ProblemReasons.NotVisible);
	}
	return methodBinding;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:26,代码来源:CodeSnippetScope.java

示例2: getMarkerInterfaces

import org.eclipse.jdt.internal.compiler.lookup.ProblemMethodBinding; //导入依赖的package包/类
public TypeBinding[] getMarkerInterfaces() {
	if (this.expectedType instanceof IntersectionCastTypeBinding) {
		Set markerBindings = new LinkedHashSet();
		TypeBinding[] intersectionTypes = ((IntersectionCastTypeBinding)this.expectedType).intersectingTypes;
		for (int i = 0,max = intersectionTypes.length; i < max; i++) {
			TypeBinding typeBinding = intersectionTypes[i];
			MethodBinding methodBinding = typeBinding.getSingleAbstractMethod(this.scope, true);
			// Why doesn't getSingleAbstractMethod do as the javadoc says, and return null
			// when it is not a SAM type
			if (!(methodBinding instanceof ProblemMethodBinding && ((ProblemMethodBinding)methodBinding).problemId()==ProblemReasons.NoSuchSingleAbstractMethod)) {
				continue;
			}
			if (typeBinding.id == TypeIds.T_JavaIoSerializable) {
				// Serializable is captured as a bitflag
				continue;
			}
			markerBindings.add(typeBinding);
		}
		if (markerBindings.size() > 0) {
			return (TypeBinding[])markerBindings.toArray(new TypeBinding[markerBindings.size()]);
		}
	}
	return null;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:25,代码来源:LambdaExpression.java

示例3: findMethodForArray

import org.eclipse.jdt.internal.compiler.lookup.ProblemMethodBinding; //导入依赖的package包/类
public MethodBinding findMethodForArray(ArrayBinding receiverType, char[] selector, TypeBinding[] argumentTypes, InvocationSite invocationSite) {
	ReferenceBinding object = getJavaLangObject();
	MethodBinding methodBinding = object.getExactMethod(selector, argumentTypes, null);
	if (methodBinding != null) {
		// handle the method clone() specially... cannot be protected or throw exceptions
		if (argumentTypes == Binding.NO_PARAMETERS && CharOperation.equals(selector, TypeConstants.CLONE))
			return new MethodBinding((methodBinding.modifiers & ~ClassFileConstants.AccProtected) | ClassFileConstants.AccPublic, TypeConstants.CLONE, methodBinding.returnType, argumentTypes, null, object);
		if (canBeSeenByForCodeSnippet(methodBinding, receiverType, invocationSite, this))
			return methodBinding;
	}

	// answers closest approximation, may not check argumentTypes or visibility
	methodBinding = findMethod(object, selector, argumentTypes, invocationSite);
	if (methodBinding == null)
		return new ProblemMethodBinding(selector, argumentTypes, ProblemReasons.NotFound);
	if (methodBinding.isValidBinding()) {
	    MethodBinding compatibleMethod = computeCompatibleMethod(methodBinding, argumentTypes, invocationSite);
	    if (compatibleMethod == null)
			return new ProblemMethodBinding(methodBinding, selector, argumentTypes, ProblemReasons.NotFound);
	    methodBinding = compatibleMethod;
		if (!canBeSeenByForCodeSnippet(methodBinding, receiverType, invocationSite, this))
			return new ProblemMethodBinding(methodBinding, selector, methodBinding.parameters, ProblemReasons.NotVisible);
	}
	return methodBinding;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:26,代码来源:CodeSnippetScope.java

示例4: resolve

import org.eclipse.jdt.internal.compiler.lookup.ProblemMethodBinding; //导入依赖的package包/类
private ResolvedNode resolve(@Nullable Binding binding) {
    if (binding == null || binding instanceof ProblemBinding) {
        return null;
    }

    if (binding instanceof TypeBinding) {
        TypeBinding tb = (TypeBinding) binding;
        return new EcjResolvedClass(tb);
    } else if (binding instanceof MethodBinding) {
        MethodBinding mb = (MethodBinding) binding;
        if (mb instanceof ProblemMethodBinding) {
            return null;
        }
        //noinspection VariableNotUsedInsideIf
        if (mb.declaringClass != null) {
            return new EcjResolvedMethod(mb);
        }
    } else if (binding instanceof LocalVariableBinding) {
        LocalVariableBinding lvb = (LocalVariableBinding) binding;
        //noinspection VariableNotUsedInsideIf
        if (lvb.type != null) {
            return new EcjResolvedVariable(lvb);
        }
    } else if (binding instanceof FieldBinding) {
        FieldBinding fb = (FieldBinding) binding;
        if (fb instanceof ProblemFieldBinding) {
            return null;
        }
        if (fb.type != null && fb.declaringClass != null) {
            return new EcjResolvedField(fb);
        }
    }

    return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:36,代码来源:EcjParser.java

示例5: visit

import org.eclipse.jdt.internal.compiler.lookup.ProblemMethodBinding; //导入依赖的package包/类
public boolean visit(LambdaExpression lambdaExpression, BlockScope scope) {
	Integer level = (Integer) this.nodeSet.matchingNodes.removeKey(lambdaExpression);
	try {
		if (lambdaExpression.resolvedType != null && lambdaExpression.resolvedType.isValidBinding() &&
				!(lambdaExpression.descriptor instanceof ProblemMethodBinding))
			this.locator.reportMatching(lambdaExpression, this.enclosingElement, level != null ? level.intValue() : -1, this.nodeSet, this.typeInHierarchy);
		else 
			return true;
	} catch (CoreException e) {
		throw new WrappedCoreException(e);
	}
	return false; // Don't visit the children as they get traversed under control of reportMatching.
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:14,代码来源:MemberDeclarationVisitor.java

示例6: findMethod

import org.eclipse.jdt.internal.compiler.lookup.ProblemMethodBinding; //导入依赖的package包/类
public MethodBinding findMethod(ReferenceBinding receiverType, char[] selector, TypeBinding[] argumentTypes, InvocationSite invocationSite, boolean inStaticContext) {
	MethodBinding methodBinding = super.findMethod(receiverType, selector, argumentTypes, invocationSite, inStaticContext);
	if (methodBinding != null && methodBinding.isValidBinding())
		if (!canBeSeenByForCodeSnippet(methodBinding, receiverType, invocationSite, this))
			return new ProblemMethodBinding(methodBinding, selector, argumentTypes, ProblemReasons.NotVisible);
	return methodBinding;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:8,代码来源:CodeSnippetScope.java

示例7: getConstructor

import org.eclipse.jdt.internal.compiler.lookup.ProblemMethodBinding; //导入依赖的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);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:39,代码来源:CodeSnippetScope.java

示例8: getImplicitMethod

import org.eclipse.jdt.internal.compiler.lookup.ProblemMethodBinding; //导入依赖的package包/类
public MethodBinding getImplicitMethod(ReferenceBinding receiverType, char[] selector, TypeBinding[] argumentTypes, InvocationSite invocationSite) {
	// retrieve an exact visible match (if possible)
	MethodBinding methodBinding = findExactMethod(receiverType, selector, argumentTypes, invocationSite);
	if (methodBinding == null)
		methodBinding = findMethod(receiverType, selector, argumentTypes, invocationSite, false);
	if (methodBinding != null) { // skip it if we did not find anything
		if (methodBinding.isValidBinding())
		    if (!canBeSeenByForCodeSnippet(methodBinding, receiverType, invocationSite, this))
				return new ProblemMethodBinding(methodBinding, selector, argumentTypes, ProblemReasons.NotVisible);
		return methodBinding;
	}
	return new ProblemMethodBinding(selector, argumentTypes, ProblemReasons.NotFound);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:14,代码来源:CodeSnippetScope.java

示例9: getMethodBinding

import org.eclipse.jdt.internal.compiler.lookup.ProblemMethodBinding; //导入依赖的package包/类
public MethodBinding getMethodBinding() {
	if (this.actualMethodBinding == null) {
		if (this.binding != null) {
			this.actualMethodBinding = new MethodBinding(this.binding.modifiers, this.binding.selector, this.binding.returnType, 
					this.binding instanceof SyntheticMethodBinding ? this.descriptor.parameters : this.binding.parameters,  // retain any faults in parameter list.
							this.binding.thrownExceptions, this.binding.declaringClass);
			this.actualMethodBinding.tagBits = this.binding.tagBits;
		} else {
			this.actualMethodBinding = new ProblemMethodBinding(CharOperation.NO_CHAR, null, ProblemReasons.NoSuchSingleAbstractMethod);
		}
	}
	return this.actualMethodBinding;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:14,代码来源:LambdaExpression.java

示例10: findMethod

import org.eclipse.jdt.internal.compiler.lookup.ProblemMethodBinding; //导入依赖的package包/类
public MethodBinding findMethod(ReferenceBinding receiverType, char[] selector, TypeBinding[] argumentTypes, InvocationSite invocationSite) {
	MethodBinding methodBinding = super.findMethod(receiverType, selector, argumentTypes, invocationSite);
	if (methodBinding != null && methodBinding.isValidBinding())
		if (!canBeSeenByForCodeSnippet(methodBinding, receiverType, invocationSite, this))
			return new ProblemMethodBinding(methodBinding, selector, argumentTypes, ProblemReasons.NotVisible);
	return methodBinding;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:8,代码来源:CodeSnippetScope.java

示例11: getConstructor

import org.eclipse.jdt.internal.compiler.lookup.ProblemMethodBinding; //导入依赖的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);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:38,代码来源:CodeSnippetScope.java

示例12: getImplicitMethod

import org.eclipse.jdt.internal.compiler.lookup.ProblemMethodBinding; //导入依赖的package包/类
public MethodBinding getImplicitMethod(ReferenceBinding receiverType, char[] selector, TypeBinding[] argumentTypes, InvocationSite invocationSite) {
	// retrieve an exact visible match (if possible)
	MethodBinding methodBinding = findExactMethod(receiverType, selector, argumentTypes, invocationSite);
	if (methodBinding == null)
		methodBinding = findMethod(receiverType, selector, argumentTypes, invocationSite);
	if (methodBinding != null) { // skip it if we did not find anything
		if (methodBinding.isValidBinding())
		    if (!canBeSeenByForCodeSnippet(methodBinding, receiverType, invocationSite, this))
				return new ProblemMethodBinding(methodBinding, selector, argumentTypes, ProblemReasons.NotVisible);
		return methodBinding;
	}
	return new ProblemMethodBinding(selector, argumentTypes, ProblemReasons.NotFound);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:14,代码来源:CodeSnippetScope.java

示例13: checkForContraditions

import org.eclipse.jdt.internal.compiler.lookup.ProblemMethodBinding; //导入依赖的package包/类
/**
 * After a method has substituted type parameters, check if this resulted in any contradictory null annotations.
 * Problems are either reported directly (if scope != null) or by returning a ProblemMethodBinding.
 */
public static MethodBinding checkForContraditions(
		final MethodBinding method, final InvocationSite invocationSite, final Scope scope) {
	
	class SearchContradictions extends TypeBindingVisitor {
		ReferenceBinding typeWithContradiction;
		@Override
		public boolean visit(ReferenceBinding referenceBinding) {
			if ((referenceBinding.tagBits & TagBits.AnnotationNullMASK) == TagBits.AnnotationNullMASK) {
				this.typeWithContradiction = referenceBinding;
				return false;
			}
			return true;
		}
		@Override
		public boolean visit(TypeVariableBinding typeVariable) {
			return visit((ReferenceBinding)typeVariable);
		}
		@Override
		public boolean visit(RawTypeBinding rawType) {
			return visit((ReferenceBinding)rawType);
		}
	}

	SearchContradictions searchContradiction = new SearchContradictions();
	TypeBindingVisitor.visit(searchContradiction, method.returnType);
	if (searchContradiction.typeWithContradiction != null) {
		if (scope == null)
			return new ProblemMethodBinding(method, method.selector, method.parameters, ProblemReasons.ContradictoryNullAnnotations);
		scope.problemReporter().contradictoryNullAnnotationsInferred(method, invocationSite);
		// note: if needed, we might want to update the method by removing the contradictory annotations??
		return method;
	}

	Expression[] arguments = null;
	if (invocationSite instanceof Invocation)
		arguments = ((Invocation)invocationSite).arguments();
	for (int i = 0; i < method.parameters.length; i++) {
		TypeBindingVisitor.visit(searchContradiction, method.parameters[i]);
		if (searchContradiction.typeWithContradiction != null) {
			if (scope == null)
				return new ProblemMethodBinding(method, method.selector, method.parameters, ProblemReasons.ContradictoryNullAnnotations);
			if (arguments != null && i < arguments.length)
				scope.problemReporter().contradictoryNullAnnotationsInferred(method, arguments[i]);
			else
				scope.problemReporter().contradictoryNullAnnotationsInferred(method, invocationSite);
			return method;
		}
	}
	return method;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:55,代码来源:NullAnnotationMatching.java

示例14: findMethodBinding

import org.eclipse.jdt.internal.compiler.lookup.ProblemMethodBinding; //导入依赖的package包/类
/**
 * Find the method binding; 
 * if this.innersNeedUpdate allow for two attempts where the first round may stop
 * after applicability checking (18.5.1) to include more information into the final
 * invocation type inference (18.5.2).
 */
protected void findMethodBinding(BlockScope scope, TypeBinding[] argumentTypes) {
	this.binding = this.receiver.isImplicitThis()
			? scope.getImplicitMethod(this.selector, argumentTypes, this)
			: scope.getMethod(this.actualReceiverType, this.selector, argumentTypes, this);
	resolvePolyExpressionArguments(this, this.binding, argumentTypes, scope);
	
	/* There are embedded assumptions in the JLS8 type inference scheme that a successful solution of the type equations results in an
	   applicable method. This appears to be a tenuous assumption, at least one not made by the JLS7 engine or the reference compiler and 
	   there are cases where this assumption would appear invalid: See https://bugs.eclipse.org/bugs/show_bug.cgi?id=426537, where we allow 
	   certain compatibility constrains around raw types to be violated. 
       
       Here, we filter out such inapplicable methods with raw type usage that may have sneaked past overload resolution and type inference, 
       playing the devils advocate, blaming the invocations with raw arguments that should not go blameless. At this time this is in the 
       nature of a point fix and is not a general solution which needs to come later (that also includes AE, QAE and ECC)
    */
	final CompilerOptions compilerOptions = scope.compilerOptions();
	if (compilerOptions.sourceLevel >= ClassFileConstants.JDK1_8 && this.binding instanceof ParameterizedGenericMethodBinding && this.binding.isValidBinding()) {
		if (!compilerOptions.postResolutionRawTypeCompatibilityCheck)
			return;
		ParameterizedGenericMethodBinding pgmb = (ParameterizedGenericMethodBinding) this.binding;
		InferenceContext18 ctx = getInferenceContext(pgmb);
		if (ctx == null || ctx.stepCompleted < InferenceContext18.BINDINGS_UPDATED)
			return;
		int length = pgmb.typeArguments == null ? 0 : pgmb.typeArguments.length;
		boolean sawRawType = false;
		for (int i = 0;  i < length; i++) {
			/* Must check compatibility against capture free method. Formal parameters cannot have captures, but our machinery is not up to snuff to
			   construct a PGMB without captures at the moment - for one thing ITCB does not support uncapture() yet, for another, INTERSECTION_CAST_TYPE
			   does not appear fully hooked up into isCompatibleWith and isEquivalent to everywhere. At the moment, bail out if we see capture.
			*/   
			if (pgmb.typeArguments[i].isCapture())
				return;
			if (pgmb.typeArguments[i].isRawType())
				sawRawType = true;
		}
		if (!sawRawType)
			return;
		length = this.arguments == null ? 0 : this.arguments.length;
		if (length == 0)
			return;
		TypeBinding [] finalArgumentTypes = new TypeBinding[length];
		for (int i = 0; i < length; i++) {
			TypeBinding finalArgumentType = this.arguments[i].resolvedType;
			if (finalArgumentType == null || !finalArgumentType.isValidBinding())  // already sided with the devil.
				return;
			finalArgumentTypes[i] = finalArgumentType; 
		}
		if (scope.parameterCompatibilityLevel(this.binding, finalArgumentTypes, false) == Scope.NOT_COMPATIBLE)
			this.binding = new ProblemMethodBinding(this.binding.original(), this.binding.selector, finalArgumentTypes, ProblemReasons.NotFound);
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:58,代码来源:MessageSend.java


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