本文整理汇总了Java中org.eclipse.jdt.internal.compiler.lookup.TypeBinding.notEquals方法的典型用法代码示例。如果您正苦于以下问题:Java TypeBinding.notEquals方法的具体用法?Java TypeBinding.notEquals怎么用?Java TypeBinding.notEquals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.internal.compiler.lookup.TypeBinding
的用法示例。
在下文中一共展示了TypeBinding.notEquals方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: manageSyntheticAccessIfNecessary
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; //导入方法依赖的package包/类
public void manageSyntheticAccessIfNecessary(BlockScope currentScope, FlowInfo flowInfo) {
if ((flowInfo.tagBits & FlowInfo.UNREACHABLE_OR_DEAD) == 0) {
// if method from parameterized type got found, use the original method at codegen time
MethodBinding codegenBinding = this.binding.original();
if (codegenBinding != this.binding) {
// extra cast needed if method return type was type variable
if (codegenBinding.returnType.isTypeVariable()) {
TypeVariableBinding variableReturnType = (TypeVariableBinding) codegenBinding.returnType;
if (TypeBinding.notEquals(variableReturnType.firstBound, this.binding.returnType)) { // no need for extra cast if same as first bound anyway
this.valueCast = this.binding.returnType;
}
}
}
}
}
示例2: areSameTypes
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; //导入方法依赖的package包/类
/** Are both types identical wrt the unannotated type and any null type annotations? Only unstructured types and captures are considered. */
protected static boolean areSameTypes(TypeBinding requiredType, TypeBinding providedType, TypeBinding providedSubstitute) {
if (requiredType == providedType) //$IDENTITY-COMPARISON$ // short cut for really-really-same types
return true;
if (requiredType.isParameterizedType() || requiredType.isArrayType())
return false; // not analysing details here
if (TypeBinding.notEquals(requiredType, providedType)) {
if (requiredType instanceof CaptureBinding) {
// when providing exactly the lower bound of the required type we're definitely fine:
TypeBinding lowerBound = ((CaptureBinding)requiredType).lowerBound;
if (lowerBound != null && areSameTypes(lowerBound, providedType, providedSubstitute))
return true;
} else if (requiredType.kind() == Binding.TYPE_PARAMETER && requiredType == providedSubstitute) { //$IDENTITY-COMPARISON$
return true;
} else if (providedType instanceof CaptureBinding) {
// when requiring exactly the upper bound of the provided type we're fine, too:
TypeBinding upperBound = ((CaptureBinding)providedType).upperBound();
if (upperBound != null && areSameTypes(requiredType, upperBound, providedSubstitute))
return true;
}
return false;
}
return (requiredType.tagBits & TagBits.AnnotationNullMASK) == (providedType.tagBits & TagBits.AnnotationNullMASK);
}
示例3: checkInvocationArgument
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; //导入方法依赖的package包/类
private static int checkInvocationArgument(BlockScope scope, Expression argument, TypeBinding parameterType, TypeBinding argumentType, TypeBinding originalParameterType) {
argument.computeConversion(scope, parameterType, argumentType);
if (argumentType != TypeBinding.NULL && parameterType.kind() == Binding.WILDCARD_TYPE) { // intersection types are tolerated
WildcardBinding wildcard = (WildcardBinding) parameterType;
if (wildcard.boundKind != Wildcard.SUPER) {
return INVOCATION_ARGUMENT_WILDCARD;
}
}
TypeBinding checkedParameterType = parameterType; // originalParameterType == null ? parameterType : originalParameterType;
if (TypeBinding.notEquals(argumentType, checkedParameterType) && argumentType.needsUncheckedConversion(checkedParameterType)) {
scope.problemReporter().unsafeTypeConversion(argument, argumentType, checkedParameterType);
return INVOCATION_ARGUMENT_UNCHECKED;
}
return INVOCATION_ARGUMENT_OK;
}
示例4: isIndirectlyUsed
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; //导入方法依赖的package包/类
/**
* Determines whether apparent unnecessary cast wasn't actually used to
* perform return type inference of generic method invocation or boxing.
*/
private boolean isIndirectlyUsed() {
if (this.expression instanceof MessageSend) {
MethodBinding method = ((MessageSend)this.expression).binding;
if (method instanceof ParameterizedGenericMethodBinding
&& ((ParameterizedGenericMethodBinding)method).inferredReturnType) {
if (this.expectedType == null)
return true;
if (TypeBinding.notEquals(this.resolvedType, this.expectedType))
return true;
}
}
if (this.expectedType != null && this.resolvedType.isBaseType() && !this.resolvedType.isCompatibleWith(this.expectedType)) {
// boxing: Short s = (short) _byte
return true;
}
return false;
}
示例5: generateCode
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; //导入方法依赖的package包/类
/**
* Cast expression code generation
*
* @param currentScope org.eclipse.jdt.internal.compiler.lookup.BlockScope
* @param codeStream org.eclipse.jdt.internal.compiler.codegen.CodeStream
* @param valueRequired boolean
*/
public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) {
int pc = codeStream.position;
boolean annotatedCast = (this.type.bits & ASTNode.HasTypeAnnotations) != 0;
boolean needRuntimeCheckcast = (this.bits & ASTNode.GenerateCheckcast) != 0;
if (this.constant != Constant.NotAConstant) {
if (valueRequired || needRuntimeCheckcast || annotatedCast) { // Added for: 1F1W9IG: IVJCOM:WINNT - Compiler omits casting check
codeStream.generateConstant(this.constant, this.implicitConversion);
if (needRuntimeCheckcast || annotatedCast) {
codeStream.checkcast(this.type, this.resolvedType);
}
if (!valueRequired) {
// the resolveType cannot be double or long
codeStream.pop();
}
}
codeStream.recordPositionsFrom(pc, this.sourceStart);
return;
}
this.expression.generateCode(currentScope, codeStream, annotatedCast || valueRequired || needRuntimeCheckcast);
if (annotatedCast || (needRuntimeCheckcast && TypeBinding.notEquals(this.expression.postConversionType(currentScope), this.resolvedType.erasure()))) { // no need to issue a checkcast if already done as genericCast
codeStream.checkcast(this.type, this.resolvedType);
}
if (valueRequired) {
codeStream.generateImplicitConversion(this.implicitConversion);
} else if (needRuntimeCheckcast) {
boolean isUnboxing = (this.implicitConversion & TypeIds.UNBOXING) != 0;
switch (isUnboxing ? postConversionType(currentScope).id : this.resolvedType.id) {
case T_long :
case T_double :
codeStream.pop2();
break;
default :
codeStream.pop();
break;
}
}
codeStream.recordPositionsFrom(pc, this.sourceStart);
}
示例6: getPackedAnnotationBindings
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; //导入方法依赖的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;
}
示例7: asMemberOf
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; //导入方法依赖的package包/类
@Override
public TypeMirror asMemberOf(DeclaredType containing, Element element) {
// throw new UnsupportedOperationException("NYI: TypesImpl.asMemberOf(" + containing + ", " + element + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
ElementImpl elementImpl = (ElementImpl) element;
DeclaredTypeImpl declaredTypeImpl = (DeclaredTypeImpl) containing;
ReferenceBinding referenceBinding = (ReferenceBinding) declaredTypeImpl._binding;
switch(element.getKind()) {
case CONSTRUCTOR :
case METHOD :
MethodBinding methodBinding = (MethodBinding) elementImpl._binding;
if (TypeBinding.notEquals(methodBinding.declaringClass, referenceBinding)) {
throw new IllegalArgumentException("element is not valid for the containing declared type"); //$NON-NLS-1$
}
for (MethodBinding method : referenceBinding.methods()) {
if (CharOperation.equals(method.selector, methodBinding.selector)
&& method.areParameterErasuresEqual(methodBinding)) {
return this._env.getFactory().newTypeMirror(method);
}
}
break;
case FIELD :
case ENUM_CONSTANT:
FieldBinding fieldBinding = (FieldBinding) elementImpl._binding;
if (TypeBinding.notEquals(fieldBinding.declaringClass, referenceBinding)) {
throw new IllegalArgumentException("element is not valid for the containing declared type"); //$NON-NLS-1$
}
for (FieldBinding field : referenceBinding.fields()) {
if (CharOperation.equals(field.name, fieldBinding.name)) {
return this._env.getFactory().newTypeMirror(field);
}
}
break;
case ENUM :
case ANNOTATION_TYPE :
case INTERFACE :
case CLASS :
ReferenceBinding referenceBinding2 = (ReferenceBinding) elementImpl._binding;
if (TypeBinding.notEquals(referenceBinding2.enclosingType(), referenceBinding)) {
throw new IllegalArgumentException("element is not valid for the containing declared type"); //$NON-NLS-1$
}
for (ReferenceBinding referenceBinding3 : referenceBinding.memberTypes()) {
if (CharOperation.equals(referenceBinding3.compoundName, referenceBinding3.compoundName)) {
return this._env.getFactory().newTypeMirror(referenceBinding3);
}
}
break;
default:
break;
}
throw new IllegalArgumentException("element is not valid for the containing declared type: element kind " + element.getKind()); //$NON-NLS-1$
}
示例8: canBeSeenByForCodeSnippet
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; //导入方法依赖的package包/类
public final boolean canBeSeenByForCodeSnippet(FieldBinding fieldBinding, TypeBinding receiverType, InvocationSite invocationSite, Scope scope) {
if (fieldBinding.isPublic()) return true;
ReferenceBinding invocationType = (ReferenceBinding) receiverType;
if (TypeBinding.equalsEquals(invocationType, fieldBinding.declaringClass)) return true;
if (fieldBinding.isProtected()) {
// answer true if the invocationType is the declaringClass or they are in the same package
// OR the invocationType is a subclass of the declaringClass
// AND the receiverType is the invocationType or its subclass
// OR the field is a static field accessed directly through a type
if (TypeBinding.equalsEquals(invocationType, fieldBinding.declaringClass)) return true;
if (invocationType.fPackage == fieldBinding.declaringClass.fPackage) return true;
if (fieldBinding.declaringClass.isSuperclassOf(invocationType)) {
if (invocationSite.isSuperAccess()) return true;
// receiverType can be an array binding in one case... see if you can change it
if (receiverType instanceof ArrayBinding)
return false;
if (invocationType.isSuperclassOf((ReferenceBinding) receiverType))
return true;
if (fieldBinding.isStatic())
return true; // see 1FMEPDL - return invocationSite.isTypeAccess();
}
return false;
}
if (fieldBinding.isPrivate()) {
// answer true if the receiverType is the declaringClass
// AND the invocationType and the declaringClass have a common enclosingType
if (TypeBinding.notEquals(receiverType, fieldBinding.declaringClass)) return false;
if (TypeBinding.notEquals(invocationType, fieldBinding.declaringClass)) {
ReferenceBinding outerInvocationType = invocationType;
ReferenceBinding temp = outerInvocationType.enclosingType();
while (temp != null) {
outerInvocationType = temp;
temp = temp.enclosingType();
}
ReferenceBinding outerDeclaringClass = fieldBinding.declaringClass;
temp = outerDeclaringClass.enclosingType();
while (temp != null) {
outerDeclaringClass = temp;
temp = temp.enclosingType();
}
if (TypeBinding.notEquals(outerInvocationType, outerDeclaringClass)) return false;
}
return true;
}
// isDefault()
if (invocationType.fPackage != fieldBinding.declaringClass.fPackage) return false;
// receiverType can be an array binding in one case... see if you can change it
if (receiverType instanceof ArrayBinding)
return false;
ReferenceBinding type = (ReferenceBinding) receiverType;
PackageBinding declaringPackage = fieldBinding.declaringClass.fPackage;
TypeBinding originalDeclaringClass = fieldBinding.declaringClass .original();
do {
if (type.isCapture()) { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=285002
if (TypeBinding.equalsEquals(originalDeclaringClass, type.erasure().original())) return true;
} else {
if (TypeBinding.equalsEquals(originalDeclaringClass, type.original())) return true;
}
if (declaringPackage != type.fPackage) return false;
} while ((type = type.superclass()) != null);
return false;
}
示例9: resolveType
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; //导入方法依赖的package包/类
public TypeBinding resolveType(BlockScope scope) {
// compute a new constant if the cast is effective
this.constant = Constant.NotAConstant;
this.implicitConversion = TypeIds.T_undefined;
boolean exprContainCast = false;
TypeBinding castType = this.resolvedType = this.type.resolveType(scope);
if (scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_8) {
this.expression.setExpressionContext(CASTING_CONTEXT);
if (this.expression instanceof FunctionalExpression) {
this.expression.setExpectedType(this.resolvedType);
this.bits |= ASTNode.DisableUnnecessaryCastCheck;
}
}
if (this.expression instanceof CastExpression) {
this.expression.bits |= ASTNode.DisableUnnecessaryCastCheck;
exprContainCast = true;
}
TypeBinding expressionType = this.expression.resolveType(scope);
if (this.expression instanceof MessageSend) {
MessageSend messageSend = (MessageSend) this.expression;
MethodBinding methodBinding = messageSend.binding;
if (methodBinding != null && methodBinding.isPolymorphic()) {
messageSend.binding = scope.environment().updatePolymorphicMethodReturnType((PolymorphicMethodBinding) methodBinding, castType);
if (TypeBinding.notEquals(expressionType, castType)) {
expressionType = castType;
this.bits |= ASTNode.DisableUnnecessaryCastCheck;
}
}
}
if (castType != null) {
if (expressionType != null) {
boolean nullAnnotationMismatch = scope.compilerOptions().isAnnotationBasedNullAnalysisEnabled
&& NullAnnotationMatching.analyse(castType, expressionType, -1).isAnyMismatch();
boolean isLegal = checkCastTypesCompatibility(scope, castType, expressionType, this.expression);
if (isLegal) {
this.expression.computeConversion(scope, castType, expressionType);
if ((this.bits & ASTNode.UnsafeCast) != 0) { // unsafe cast
if (scope.compilerOptions().reportUnavoidableGenericTypeProblems
|| !(expressionType.isRawType() && this.expression.forcedToBeRaw(scope.referenceContext()))) {
scope.problemReporter().unsafeCast(this, scope);
}
} else if (nullAnnotationMismatch) {
// report null annotation issue at medium priority
scope.problemReporter().unsafeNullnessCast(this, scope);
} else {
if (castType.isRawType() && scope.compilerOptions().getSeverity(CompilerOptions.RawTypeReference) != ProblemSeverities.Ignore){
scope.problemReporter().rawTypeReference(this.type, castType);
}
if ((this.bits & (ASTNode.UnnecessaryCast|ASTNode.DisableUnnecessaryCastCheck)) == ASTNode.UnnecessaryCast) { // unnecessary cast
if (!isIndirectlyUsed()) // used for generic type inference or boxing ?
scope.problemReporter().unnecessaryCast(this);
}
}
} else { // illegal cast
if ((castType.tagBits & TagBits.HasMissingType) == 0) { // no complaint if secondary error
scope.problemReporter().typeCastError(this, castType, expressionType);
}
this.bits |= ASTNode.DisableUnnecessaryCastCheck; // disable further secondary diagnosis
}
}
this.resolvedType = castType.capture(scope, this.sourceEnd);
if (exprContainCast) {
checkNeedForCastCast(scope, this);
}
}
return this.resolvedType;
}
示例10: duplicateInheritedMethods
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; //导入方法依赖的package包/类
public void duplicateInheritedMethods(SourceTypeBinding type, MethodBinding inheritedMethod1, MethodBinding inheritedMethod2, boolean isJava8) {
if (TypeBinding.notEquals(inheritedMethod1.declaringClass, inheritedMethod2.declaringClass)) {
int problemID = IProblem.DuplicateInheritedMethods;
if (inheritedMethod1.isDefaultMethod() && inheritedMethod2.isDefaultMethod()) {
if (isJava8)
problemID = IProblem.DuplicateInheritedDefaultMethods;
else
return; // don't report this error at 1.7-
}
this.handle(
problemID,
new String[] {
new String(inheritedMethod1.selector),
typesAsString(inheritedMethod1, inheritedMethod1.original().parameters, false),
typesAsString(inheritedMethod2, inheritedMethod2.original().parameters, false),
new String(inheritedMethod1.declaringClass.readableName()),
new String(inheritedMethod2.declaringClass.readableName()),
},
new String[] {
new String(inheritedMethod1.selector),
typesAsString(inheritedMethod1, inheritedMethod1.original().parameters, true),
typesAsString(inheritedMethod2, inheritedMethod2.original().parameters, true),
new String(inheritedMethod1.declaringClass.shortReadableName()),
new String(inheritedMethod2.declaringClass.shortReadableName()),
},
type.sourceStart(),
type.sourceEnd());
return;
}
// Handle duplicates from same class.
this.handle(
IProblem.DuplicateParameterizedMethods,
new String[] {
new String(inheritedMethod1.selector),
new String(inheritedMethod1.declaringClass.readableName()),
typesAsString(inheritedMethod1, inheritedMethod1.original().parameters, false),
typesAsString(inheritedMethod2, inheritedMethod2.original().parameters, false)},
new String[] {
new String(inheritedMethod1.selector),
new String(inheritedMethod1.declaringClass.shortReadableName()),
typesAsString(inheritedMethod1, inheritedMethod1.original().parameters, true),
typesAsString(inheritedMethod2, inheritedMethod2.original().parameters, true)},
type.sourceStart(),
type.sourceEnd());
}