本文整理汇总了Java中org.eclipse.jdt.internal.compiler.ast.Wildcard.EXTENDS属性的典型用法代码示例。如果您正苦于以下问题:Java Wildcard.EXTENDS属性的具体用法?Java Wildcard.EXTENDS怎么用?Java Wildcard.EXTENDS使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.eclipse.jdt.internal.compiler.ast.Wildcard
的用法示例。
在下文中一共展示了Wildcard.EXTENDS属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: cloneParamType
protected TypeReference cloneParamType(int index, List<TypeReference> typeArgs, EclipseNode builderType) {
if (typeArgs != null && typeArgs.size() > index) {
TypeReference originalType = typeArgs.get(index);
if (originalType instanceof Wildcard) {
Wildcard wOriginalType = (Wildcard) originalType;
if (wOriginalType.kind == Wildcard.EXTENDS) {
try {
return copyType(wOriginalType.bound);
} catch (Exception e) {
// fallthrough
}
}
} else {
return copyType(originalType);
}
}
return new QualifiedTypeReference(TypeConstants.JAVA_LANG_OBJECT, NULL_POSS);
}
示例2: visit
public boolean visit(Wildcard wildcard, BlockScope scope) {
if (wildcard.annotations != null) {
if (formatInlineAnnotations(wildcard.annotations[0], false)) this.scribe.space();
}
this.scribe.printNextToken(TerminalTokens.TokenNameQUESTION, this.preferences.insert_space_before_question_in_wilcard);
switch(wildcard.kind) {
case Wildcard.SUPER :
this.scribe.printNextToken(TerminalTokens.TokenNamesuper, true);
this.scribe.space();
wildcard.bound.traverse(this, scope);
break;
case Wildcard.EXTENDS :
this.scribe.printNextToken(TerminalTokens.TokenNameextends, true);
this.scribe.space();
wildcard.bound.traverse(this, scope);
break;
case Wildcard.UNBOUND :
if (this.preferences.insert_space_after_question_in_wilcard) {
this.scribe.space();
}
}
return false;
}
示例3: boundCheck
/**
* Returns true if the argument type satisfies the wildcard bound(s)
*/
public boolean boundCheck(TypeBinding argumentType) {
switch (this.boundKind) {
case Wildcard.UNBOUND :
return true;
case Wildcard.EXTENDS :
if (!argumentType.isCompatibleWith(this.bound)) return false;
// check other bounds (lub scenario)
for (int i = 0, length = this.otherBounds == null ? 0 : this.otherBounds.length; i < length; i++) {
if (!argumentType.isCompatibleWith(this.otherBounds[i])) return false;
}
return true;
default: // SUPER
// ? super Exception ok for: IOException, since it would be ok for (Exception)ioException
return argumentType.isCompatibleWith(this.bound);
}
}
示例4: consumeWildCard
public void consumeWildCard(int kind) {
switch (kind) {
case Wildcard.EXTENDS:
case Wildcard.SUPER:
BindingKeyResolver boundResolver = (BindingKeyResolver) this.types.get(0);
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=157847, do not allow creation of
// internally inconsistent wildcards of the form '? super <null>' or '? extends <null>'
final Binding boundBinding = boundResolver.compilerBinding;
if (boundBinding instanceof TypeBinding) {
this.typeBinding = this.environment.createWildcard((ReferenceBinding) this.typeBinding, this.wildcardRank, (TypeBinding) boundBinding, null /*no extra bound*/, kind);
} else {
this.typeBinding = null;
}
break;
case Wildcard.UNBOUND:
this.typeBinding = this.environment.createWildcard((ReferenceBinding) this.typeBinding, this.wildcardRank, null/*no bound*/, null /*no extra bound*/, kind);
break;
}
}
示例5: visit
public boolean visit(Wildcard wildcard, BlockScope scope) {
this.scribe.printNextToken(TerminalTokens.TokenNameQUESTION, this.preferences.insert_space_before_question_in_wilcard);
switch(wildcard.kind) {
case Wildcard.SUPER :
this.scribe.printNextToken(TerminalTokens.TokenNamesuper, true);
this.scribe.space();
wildcard.bound.traverse(this, scope);
break;
case Wildcard.EXTENDS :
this.scribe.printNextToken(TerminalTokens.TokenNameextends, true);
this.scribe.space();
wildcard.bound.traverse(this, scope);
break;
case Wildcard.UNBOUND :
if (this.preferences.insert_space_after_question_in_wilcard) {
this.scribe.space();
}
}
return false;
}
示例6: computeUniqueKey
public char[] computeUniqueKey(boolean isLeaf) {
char[] genericTypeKey = this.genericType.computeUniqueKey(false/*not a leaf*/);
char[] wildCardKey;
// We now encode the rank also in the binding key - https://bugs.eclipse.org/bugs/show_bug.cgi?id=234609
char[] rankComponent = ('{' + String.valueOf(this.rank) + '}').toCharArray();
switch (this.boundKind) {
case Wildcard.UNBOUND :
wildCardKey = TypeConstants.WILDCARD_STAR;
break;
case Wildcard.EXTENDS :
wildCardKey = CharOperation.concat(TypeConstants.WILDCARD_PLUS, this.bound.computeUniqueKey(false/*not a leaf*/));
break;
default: // SUPER
wildCardKey = CharOperation.concat(TypeConstants.WILDCARD_MINUS, this.bound.computeUniqueKey(false/*not a leaf*/));
break;
}
return CharOperation.concat(genericTypeKey, rankComponent, wildCardKey);
}
示例7: toString
/**
* @see java.lang.Object#toString()
*/
public String toString() {
if (this.hasTypeAnnotations())
return annotatedDebugName();
switch (this.boundKind) {
case Wildcard.UNBOUND :
return new String(TypeConstants.WILDCARD_NAME);
case Wildcard.EXTENDS :
if (this.otherBounds == null)
return new String(CharOperation.concat(TypeConstants.WILDCARD_NAME, TypeConstants.WILDCARD_EXTENDS, this.bound.debugName().toCharArray()));
StringBuffer buffer = new StringBuffer(this.bound.debugName());
for (int i = 0, length = this.otherBounds.length; i < length; i++) {
buffer.append('&').append(this.otherBounds[i].debugName());
}
return buffer.toString();
default: // SUPER
return new String(CharOperation.concat(TypeConstants.WILDCARD_NAME, TypeConstants.WILDCARD_SUPER, this.bound.debugName().toCharArray()));
}
}
示例8: getExtendsBound
@Override
public TypeMirror getExtendsBound() {
WildcardBinding wildcardBinding = (WildcardBinding) this._binding;
if (wildcardBinding.boundKind != Wildcard.EXTENDS) return null;
TypeBinding bound = wildcardBinding.bound;
if (bound == null) return null;
return _env.getFactory().newTypeMirror(bound);
}
示例9: signature
/**
* @see org.eclipse.jdt.internal.compiler.lookup.TypeBinding#signature()
*/
public char[] signature() {
// should not be called directly on a wildcard; signature should only be asked on
// original methods or type erasures (which cannot denote wildcards at first level)
if (this.signature == null) {
switch (this.boundKind) {
case Wildcard.EXTENDS :
return this.bound.signature();
default: // SUPER | UNBOUND
return typeVariable().signature();
}
}
return this.signature;
}
示例10: isUpperbound
public boolean isUpperbound() {
switch (this.binding.kind()) {
case Binding.WILDCARD_TYPE :
return ((WildcardBinding) this.binding).boundKind == Wildcard.EXTENDS;
case Binding.INTERSECTION_TYPE :
return true;
}
return false;
}
示例11: consumeWildcardBounds2Extends
protected void consumeWildcardBounds2Extends() {
Wildcard wildcard = new Wildcard(Wildcard.EXTENDS);
wildcard.bound = (TypeReference) this.genericsStack[this.genericsPtr];
wildcard.sourceEnd = wildcard.bound.sourceEnd;
this.intPtr--; // remove end position of the '?'
wildcard.sourceStart = this.intStack[this.intPtr--];
annotateTypeReference(wildcard);
this.genericsStack[this.genericsPtr] = wildcard;
}
示例12: consumeWildcardBounds3Extends
protected void consumeWildcardBounds3Extends() {
Wildcard wildcard = new Wildcard(Wildcard.EXTENDS);
wildcard.bound = (TypeReference) this.genericsStack[this.genericsPtr];
wildcard.sourceEnd = wildcard.bound.sourceEnd;
this.intPtr--; // remove end position of the '?'
wildcard.sourceStart = this.intStack[this.intPtr--];
annotateTypeReference(wildcard);
this.genericsStack[this.genericsPtr] = wildcard;
}
示例13: consumeWildcardBoundsExtends
protected void consumeWildcardBoundsExtends() {
Wildcard wildcard = new Wildcard(Wildcard.EXTENDS);
wildcard.bound = getTypeReference(this.intStack[this.intPtr--]);
wildcard.sourceEnd = wildcard.bound.sourceEnd;
this.intPtr--; // remove end position of the '?'
wildcard.sourceStart = this.intStack[this.intPtr--];
annotateTypeReference(wildcard);
pushOnGenericsStack(wildcard);
}
示例14: createBoundsForFunctionalInterfaceParameterizationInference
/**
* Create initial bound set for 18.5.3 Functional Interface Parameterization Inference
* @param functionalInterface the functional interface F<A1,..Am>
* @return the parameter types Q1..Qk of the function type of the type F<α1, ..., αm>, or null
*/
TypeBinding[] createBoundsForFunctionalInterfaceParameterizationInference(ParameterizedTypeBinding functionalInterface) {
if (this.currentBounds == null)
this.currentBounds = new BoundSet();
TypeBinding[] a = functionalInterface.arguments;
if (a == null)
return null;
InferenceVariable[] alpha = addInitialTypeVariableSubstitutions(a);
for (int i = 0; i < a.length; i++) {
TypeBound bound;
if (a[i].kind() == Binding.WILDCARD_TYPE) {
WildcardBinding wildcard = (WildcardBinding) a[i];
switch(wildcard.boundKind) {
case Wildcard.EXTENDS :
bound = new TypeBound(alpha[i], wildcard.allBounds(), ReductionResult.SUBTYPE);
break;
case Wildcard.SUPER :
bound = new TypeBound(alpha[i], wildcard.bound, ReductionResult.SUPERTYPE);
break;
case Wildcard.UNBOUND :
bound = new TypeBound(alpha[i], this.object, ReductionResult.SUBTYPE);
break;
default:
continue; // cannot
}
} else {
bound = new TypeBound(alpha[i], a[i], ReductionResult.SAME);
}
this.currentBounds.addBound(bound, this.environment);
}
TypeBinding falpha = substitute(functionalInterface);
return falpha.getSingleAbstractMethod(this.scope, true).parameters;
}
示例15: genericTypeSignature
public char[] genericTypeSignature() {
if (this.genericSignature == null) {
switch (this.boundKind) {
case Wildcard.UNBOUND :
this.genericSignature = TypeConstants.WILDCARD_STAR;
break;
case Wildcard.EXTENDS :
this.genericSignature = CharOperation.concat(TypeConstants.WILDCARD_PLUS, this.bound.genericTypeSignature());
break;
default: // SUPER
this.genericSignature = CharOperation.concat(TypeConstants.WILDCARD_MINUS, this.bound.genericTypeSignature());
}
}
return this.genericSignature;
}