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


Java Wildcard.SUPER属性代码示例

本文整理汇总了Java中org.eclipse.jdt.internal.compiler.ast.Wildcard.SUPER属性的典型用法代码示例。如果您正苦于以下问题:Java Wildcard.SUPER属性的具体用法?Java Wildcard.SUPER怎么用?Java Wildcard.SUPER使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.eclipse.jdt.internal.compiler.ast.Wildcard的用法示例。


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

示例1: 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;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:23,代码来源:CodeFormatterVisitor.java

示例2: consumeWildCard

public void consumeWildCard(int wildCardKind) {
	// don't put generic type in signature
	this.signature = new StringBuffer();
	switch (wildCardKind) {
		case Wildcard.UNBOUND:
			this.signature.append('*');
			break;
		case Wildcard.EXTENDS:
			this.signature.append('+');
			this.signature.append(((KeyToSignature) this.arguments.get(0)).signature);
			break;
		case Wildcard.SUPER:
			this.signature.append('-');
			this.signature.append(((KeyToSignature) this.arguments.get(0)).signature);
			break;
		default:
			// malformed
			return;
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:20,代码来源:KeyToSignature.java

示例3: 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;
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:19,代码来源:BindingKeyResolver.java

示例4: 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;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:20,代码来源:CodeFormatterVisitor.java

示例5: getSuperBound

@Override
public TypeMirror getSuperBound() {
	WildcardBinding wildcardBinding = (WildcardBinding) this._binding;
	if (wildcardBinding.boundKind != Wildcard.SUPER) return null;
	TypeBinding bound = wildcardBinding.bound;
	if (bound == null) return null;
	return _env.getFactory().newTypeMirror(bound);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:8,代码来源:WildcardTypeImpl.java

示例6: parseWildcard

private void parseWildcard() {
	parseWildcardRank();
	if (this.scanner.nextToken() != Scanner.WILDCARD) return;
	char[] source = this.scanner.getTokenSource();
	if (source.length == 0) {
		malformedKey();
		return;
	}
	int kind = -1;
	switch (source[0]) {
		case '*':
			kind = Wildcard.UNBOUND;
			break;
		case '+':
			kind = Wildcard.EXTENDS;
			break;
		case '-':
			kind = Wildcard.SUPER;
			break;
	}
	if (kind == -1) {
		malformedKey();
		return;
	}
	if (kind != Wildcard.UNBOUND)
		parseWildcardBound();
	consumeWildCard(kind);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:28,代码来源:BindingKeyParser.java

示例7: consumeWildcardBounds1Super

protected void consumeWildcardBounds1Super() {
	Wildcard wildcard = new Wildcard(Wildcard.SUPER);
	wildcard.bound = (TypeReference) this.genericsStack[this.genericsPtr];
	this.intPtr--; // remove the starting position of the super keyword
	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;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:10,代码来源:Parser.java

示例8: consumeWildcardBounds2Super

protected void consumeWildcardBounds2Super() {
	Wildcard wildcard = new Wildcard(Wildcard.SUPER);
	wildcard.bound = (TypeReference) this.genericsStack[this.genericsPtr];
	this.intPtr--; // remove the starting position of the super keyword
	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;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:10,代码来源:Parser.java

示例9: consumeWildcardBounds3Super

protected void consumeWildcardBounds3Super() {
	Wildcard wildcard = new Wildcard(Wildcard.SUPER);
	wildcard.bound = (TypeReference) this.genericsStack[this.genericsPtr];
	this.intPtr--; // remove the starting position of the super keyword
	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;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:10,代码来源:Parser.java

示例10: consumeWildcardBoundsSuper

protected void consumeWildcardBoundsSuper() {
	Wildcard wildcard = new Wildcard(Wildcard.SUPER);
	wildcard.bound = getTypeReference(this.intStack[this.intPtr--]);
	this.intPtr--; // remove the starting position of the super keyword
	wildcard.sourceEnd = wildcard.bound.sourceEnd;
	this.intPtr--; // remove end position of the '?'
	wildcard.sourceStart = this.intStack[this.intPtr--];
	annotateTypeReference(wildcard);
	pushOnGenericsStack(wildcard);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:10,代码来源:Parser.java

示例11: isSuperclassOf

/**
 * @see org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding#isSuperclassOf(org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding)
 */
public boolean isSuperclassOf(ReferenceBinding otherType) {
    if (this.boundKind == Wildcard.SUPER) {
        if (this.bound instanceof ReferenceBinding) {
            return ((ReferenceBinding) this.bound).isSuperclassOf(otherType);
        } else { // array bound
            return otherType.id == TypeIds.T_JavaLangObject;
        }
    }
    return false;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:13,代码来源:WildcardBinding.java

示例12: getName

public String getName() {
	StringBuffer buffer;
	switch (this.binding.kind()) {

		case Binding.WILDCARD_TYPE :
		case Binding.INTERSECTION_TYPE:
			WildcardBinding wildcardBinding = (WildcardBinding) this.binding;
			buffer = new StringBuffer();
			buffer.append(TypeConstants.WILDCARD_NAME);
			if (wildcardBinding.bound != null) {
				switch(wildcardBinding.boundKind) {
			        case Wildcard.SUPER :
			        	buffer.append(TypeConstants.WILDCARD_SUPER);
			            break;
			        case Wildcard.EXTENDS :
			        	buffer.append(TypeConstants.WILDCARD_EXTENDS);
				}
				buffer.append(getBound().getName());
			}
			return String.valueOf(buffer);

		case Binding.TYPE_PARAMETER :
			if (isCapture()) {
				return NO_NAME;
			}
			TypeVariableBinding typeVariableBinding = (TypeVariableBinding) this.binding;
			return new String(typeVariableBinding.sourceName);

		case Binding.PARAMETERIZED_TYPE :
			ParameterizedTypeBinding parameterizedTypeBinding = (ParameterizedTypeBinding) this.binding;
			buffer = new StringBuffer();
			buffer.append(parameterizedTypeBinding.sourceName());
			ITypeBinding[] tArguments = getTypeArguments();
			final int typeArgumentsLength = tArguments.length;
			if (typeArgumentsLength != 0) {
				buffer.append('<');
				for (int i = 0; i < typeArgumentsLength; i++) {
					if (i > 0) {
						buffer.append(',');
					}
					buffer.append(tArguments[i].getName());
				}
				buffer.append('>');
			}
			return String.valueOf(buffer);

		case Binding.RAW_TYPE :
			return getTypeDeclaration().getName();

		case Binding.ARRAY_TYPE :
			ITypeBinding elementType = getElementType();
			if (elementType.isLocal() || elementType.isAnonymous() || elementType.isCapture()) {
				return NO_NAME;
			}
			int dimensions = getDimensions();
			char[] brackets = new char[dimensions * 2];
			for (int i = dimensions * 2 - 1; i >= 0; i -= 2) {
				brackets[i] = ']';
				brackets[i - 1] = '[';
			}
			buffer = new StringBuffer(elementType.getName());
			buffer.append(brackets);
			return String.valueOf(buffer);

		default :
			if (isPrimitive() || isNullType()) {
				BaseTypeBinding baseTypeBinding = (BaseTypeBinding) this.binding;
				return new String(baseTypeBinding.simpleName);
			}
			if (isAnonymous()) {
				return NO_NAME;
			}
			return new String(this.binding.sourceName());
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:75,代码来源:TypeBinding.java

示例13: wildcardInvocation

public void wildcardInvocation(ASTNode location, TypeBinding receiverType, MethodBinding method, TypeBinding[] arguments) {
	TypeBinding offendingArgument = null;
	TypeBinding offendingParameter = null;
	for (int i = 0, length = method.parameters.length; i < length; i++) {
		TypeBinding parameter = method.parameters[i];
		if (parameter.isWildcard() && (((WildcardBinding) parameter).boundKind != Wildcard.SUPER)) {
			offendingParameter = parameter;
			offendingArgument = arguments[i];
			break;
		}
	}

	if (method.isConstructor()) {
		this.handle(
			IProblem.WildcardConstructorInvocation,
			new String[] {
				new String(receiverType.sourceName()),
				typesAsString(method, false),
				new String(receiverType.readableName()),
				typesAsString(arguments, false),
				new String(offendingArgument.readableName()),
				new String(offendingParameter.readableName()),
			 },
			new String[] {
				new String(receiverType.sourceName()),
				typesAsString(method, true),
				new String(receiverType.shortReadableName()),
				typesAsString(arguments, true),
				new String(offendingArgument.shortReadableName()),
				new String(offendingParameter.shortReadableName()),
			 },
			location.sourceStart,
			location.sourceEnd);
    } else {
		this.handle(
			IProblem.WildcardMethodInvocation,
			new String[] {
				new String(method.selector),
				typesAsString(method, false),
				new String(receiverType.readableName()),
				typesAsString(arguments, false),
				new String(offendingArgument.readableName()),
				new String(offendingParameter.readableName()),
			 },
			new String[] {
				new String(method.selector),
				typesAsString(method, true),
				new String(receiverType.shortReadableName()),
				typesAsString(arguments, true),
				new String(offendingArgument.shortReadableName()),
				new String(offendingParameter.shortReadableName()),
			 },
			location.sourceStart,
			location.sourceEnd);
    }
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:56,代码来源:ProblemReporter.java

示例14: reduceTypeEquality

private Object reduceTypeEquality(TypeBinding object) {
	// 18.2.4
	if (this.left.kind() == Binding.WILDCARD_TYPE) {
		if (this.right.kind() == Binding.WILDCARD_TYPE) {
			// left and right are wildcards ("type arguments")
			WildcardBinding leftWC = (WildcardBinding)this.left;
			WildcardBinding rightWC = (WildcardBinding)this.right;
			if (leftWC.boundKind == Wildcard.UNBOUND && rightWC.boundKind == Wildcard.UNBOUND)
				return TRUE;
			if (leftWC.boundKind == Wildcard.UNBOUND && rightWC.boundKind == Wildcard.EXTENDS)
				return ConstraintTypeFormula.create(object, rightWC.bound, SAME, this.isSoft);
			if (leftWC.boundKind == Wildcard.EXTENDS && rightWC.boundKind == Wildcard.UNBOUND)
				return ConstraintTypeFormula.create(leftWC.bound, object, SAME, this.isSoft);
			if ((leftWC.boundKind == Wildcard.EXTENDS && rightWC.boundKind == Wildcard.EXTENDS)
				||(leftWC.boundKind == Wildcard.SUPER && rightWC.boundKind == Wildcard.SUPER))
			{
				return ConstraintTypeFormula.create(leftWC.bound, rightWC.bound, SAME, this.isSoft);
			}						
		}
	} else {
		if (this.right.kind() != Binding.WILDCARD_TYPE) {
			// left and right are types (vs. wildcards)
			if (this.left.isProperType(true) && this.right.isProperType(true)) {
				if (TypeBinding.equalsEquals(this.left, this.right))
					return TRUE;
				return FALSE;
			}
			if (this.left instanceof InferenceVariable) {
				return new TypeBound((InferenceVariable) this.left, this.right, SAME, this.isSoft);
			}
			if (this.right instanceof InferenceVariable) {
				return new TypeBound((InferenceVariable) this.right, this.left, SAME, this.isSoft);
			}
			if ((this.left.isClass() || this.left.isInterface()) 
					&& (this.right.isClass() || this.right.isInterface())
					&& TypeBinding.equalsEquals(this.left.erasure(), this.right.erasure())) 
			{
				TypeBinding[] leftParams = this.left.typeArguments();
				TypeBinding[] rightParams = this.right.typeArguments();
				if (leftParams == null || rightParams == null)
					return leftParams == rightParams ? TRUE : FALSE;
				if (leftParams.length != rightParams.length)
					return FALSE;
				int len = leftParams.length;
				ConstraintFormula[] constraints = new ConstraintFormula[len];
				for (int i = 0; i < len; i++) {
					constraints[i] = ConstraintTypeFormula.create(leftParams[i], rightParams[i], SAME, this.isSoft);
				}
				return constraints;
			}
			if (this.left.isArrayType() && this.right.isArrayType() && this.left.dimensions() == this.right.dimensions()) {
				// checking dimensions already now is an optimization over reducing one dim at a time
				return ConstraintTypeFormula.create(this.left.leafComponentType(), this.right.leafComponentType(), SAME, this.isSoft);
			}
		}
	}
	return FALSE;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:58,代码来源:ConstraintTypeFormula.java

示例15: getNonWildcardParameterization

public TypeBinding[] getNonWildcardParameterization(Scope scope) {
	// precondition: isValidBinding()
	TypeBinding[] typeArguments = this.arguments; 							// A1 ... An
	if (typeArguments == null)
		return NO_TYPES;
	TypeVariableBinding[] typeParameters = genericType().typeVariables(); 	// P1 ... Pn
	TypeBinding[] types = new TypeBinding[typeArguments.length];  			// T1 ... Tn
	for (int i = 0, length = typeArguments.length; i < length; i++) {
		TypeBinding typeArgument = typeArguments[i];
		if (typeArgument.kind() == Binding.WILDCARD_TYPE) {
			if (typeParameters[i].mentionsAny(typeParameters, i))
				return null;
			WildcardBinding wildcard = (WildcardBinding) typeArgument;
			switch(wildcard.boundKind) {
				case Wildcard.EXTENDS :
					// If Ai is a upper-bounded wildcard ? extends Ui, then Ti = glb(Ui, Bi).
					// Note: neither Ui nor Bi is necessarily scalar -> need to collect all bounds
					TypeBinding[] otherUBounds = wildcard.otherBounds;
					TypeBinding[] otherBBounds = typeParameters[i].otherUpperBounds();
					int len = 1 + (otherUBounds != null ? otherUBounds.length : 0) + otherBBounds.length;
					if (typeParameters[i].firstBound != null)
						len++;
					TypeBinding[] allBounds = new TypeBinding[len]; // TypeBinding so that in this round we accept ArrayBinding, too.
					int idx = 0;
					// Ui
					allBounds[idx++] = wildcard.bound;
					if (otherUBounds != null)
						for (int j = 0; j < otherUBounds.length; j++)
							allBounds[idx++] = otherUBounds[j];
					// Bi
					if (typeParameters[i].firstBound != null)
						allBounds[idx++] = typeParameters[i].firstBound;
					for (int j = 0; j < otherBBounds.length; j++)
						allBounds[idx++] = otherBBounds[j];
					TypeBinding[] glb = Scope.greaterLowerBound(allBounds, null, this.environment);
					if (glb == null || glb.length == 0) {
						return null;
					} else if (glb.length == 1) {
						types[i] = glb[0];
					} else {
						try {
							ReferenceBinding[] refs = new ReferenceBinding[glb.length];
							System.arraycopy(glb, 0, refs, 0, glb.length); // TODO: if an array type plus more types get here, we get ArrayStoreException!
							types[i] = new IntersectionCastTypeBinding(refs, this.environment);
						} catch (ArrayStoreException ase) {
							scope.problemReporter().genericInferenceError("Cannot compute glb of "+Arrays.toString(glb), null); //$NON-NLS-1$
							return null;
						}
					}
					break;
				case Wildcard.SUPER :
					// If Ai is a lower-bounded wildcard ? super Li, then Ti = Li.
					types[i] = wildcard.bound;
					break;
				case Wildcard.UNBOUND :
					// If Ai is an unbound wildcard ?, then Ti = Bi.
					types[i] = typeParameters[i].firstBound;
					if (types[i] == null)
						types[i] = typeParameters[i].superclass; // assumably j.l.Object?
					break;
			}
		} else {
			// If Ai is a type, then Ti = Ai.
			types[i] = typeArgument;
		}
	}
	return types;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:68,代码来源:ParameterizedTypeBinding.java


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