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


Java Wildcard类代码示例

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


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

示例1: cloneParamType

import org.eclipse.jdt.internal.compiler.ast.Wildcard; //导入依赖的package包/类
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);
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:20,代码来源:EclipseSingularsRecipes.java

示例2: visit

import org.eclipse.jdt.internal.compiler.ast.Wildcard; //导入依赖的package包/类
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,代码行数:24,代码来源:CodeFormatterVisitor.java

示例3: consumeWildCard

import org.eclipse.jdt.internal.compiler.ast.Wildcard; //导入依赖的package包/类
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,代码行数:21,代码来源:KeyToSignature.java

示例4: consumeWildCard

import org.eclipse.jdt.internal.compiler.ast.Wildcard; //导入依赖的package包/类
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,代码行数:20,代码来源:BindingKeyResolver.java

示例5: annotateTypeReference

import org.eclipse.jdt.internal.compiler.ast.Wildcard; //导入依赖的package包/类
protected void annotateTypeReference(Wildcard ref) {
	int length;
	if ((length = this.typeAnnotationLengthStack[this.typeAnnotationLengthPtr--]) != 0) {
		if (ref.annotations == null)
			ref.annotations = new Annotation[ref.getAnnotatableLevels()][];
		System.arraycopy(
				this.typeAnnotationStack,
				(this.typeAnnotationPtr -= length) + 1,
				ref.annotations[0] = new Annotation[length],
				0,
				length);
		if (ref.sourceStart > ref.annotations[0][0].sourceStart) {
			ref.sourceStart = ref.annotations[0][0].sourceStart;
		}
		ref.bits |= ASTNode.HasTypeAnnotations;
	}
	if (ref.bound != null) {
		ref.bits |= (ref.bound.bits & ASTNode.HasTypeAnnotations);
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:21,代码来源:Parser.java

示例6: instantiateGetClass

import org.eclipse.jdt.internal.compiler.ast.Wildcard; //导入依赖的package包/类
/**
 * The type of x.getClass() is substituted from 'Class<? extends Object>' into: 'Class<? extends raw(X)>
 */
public static ParameterizedMethodBinding instantiateGetClass(TypeBinding receiverType, MethodBinding originalMethod, Scope scope) {
	ParameterizedMethodBinding method = new ParameterizedMethodBinding();
	method.modifiers = originalMethod.modifiers;
	method.selector = originalMethod.selector;
	method.declaringClass = originalMethod.declaringClass;
	method.typeVariables = Binding.NO_TYPE_VARIABLES;
	method.originalMethod = originalMethod;
	method.parameters = originalMethod.parameters;
	method.thrownExceptions = originalMethod.thrownExceptions;
	method.tagBits = originalMethod.tagBits;
	ReferenceBinding genericClassType = scope.getJavaLangClass();
	LookupEnvironment environment = scope.environment();
	TypeBinding rawType = environment.convertToRawType(receiverType.erasure(), false /*do not force conversion of enclosing types*/);
	method.returnType = environment.createParameterizedType(
		genericClassType,
		new TypeBinding[] {  environment.createWildcard(genericClassType, 0, rawType, null /*no extra bound*/, Wildcard.EXTENDS) },
		null);
	if ((method.returnType.tagBits & TagBits.HasMissingType) != 0) {
		method.tagBits |=  TagBits.HasMissingType;
	}
	return method;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:26,代码来源:ParameterizedMethodBinding.java

示例7: boundCheck

import org.eclipse.jdt.internal.compiler.ast.Wildcard; //导入依赖的package包/类
/**
 * 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);
    }
   }
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:20,代码来源:WildcardBinding.java

示例8: computeUniqueKey

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

示例9: annotatedDebugName

import org.eclipse.jdt.internal.compiler.ast.Wildcard; //导入依赖的package包/类
public String annotatedDebugName() {
	StringBuffer buffer = new StringBuffer(16);
	AnnotationBinding [] annotations = getTypeAnnotations();
	for (int i = 0, length = annotations == null ? 0 : annotations.length; i < length; i++) {
		buffer.append(annotations[i]);
		buffer.append(' ');
	}
	switch (this.boundKind) {
           case Wildcard.UNBOUND :
               return buffer.append(TypeConstants.WILDCARD_NAME).toString();
           case Wildcard.EXTENDS :
           	if (this.otherBounds == null)
               	return buffer.append(CharOperation.concat(TypeConstants.WILDCARD_NAME, TypeConstants.WILDCARD_EXTENDS, this.bound.annotatedDebugName().toCharArray())).toString();
           	buffer.append(this.bound.annotatedDebugName());
           	for (int i = 0, length = this.otherBounds.length; i < length; i++) {
           		buffer.append(" & ").append(this.otherBounds[i].annotatedDebugName()); //$NON-NLS-1$
           	}
           	return buffer.toString();
		default: // SUPER
		    return buffer.append(CharOperation.concat(TypeConstants.WILDCARD_NAME, TypeConstants.WILDCARD_SUPER, this.bound.annotatedDebugName().toCharArray())).toString();
       }
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:23,代码来源:WildcardBinding.java

示例10: superclass

import org.eclipse.jdt.internal.compiler.ast.Wildcard; //导入依赖的package包/类
public ReferenceBinding superclass() {
if (this.superclass == null) {
	TypeBinding superType = null;
	if (this.boundKind == Wildcard.EXTENDS && !this.bound.isInterface()) {
		superType = this.bound;
	} else {
		TypeVariableBinding variable = typeVariable();
		if (variable != null) superType = variable.firstBound;
	}
	this.superclass = superType instanceof ReferenceBinding && !superType.isInterface()
		? (ReferenceBinding) superType
		: this.environment.getResolvedType(TypeConstants.JAVA_LANG_OBJECT, null);
}

return this.superclass;
  }
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:17,代码来源:WildcardBinding.java

示例11: toString

import org.eclipse.jdt.internal.compiler.ast.Wildcard; //导入依赖的package包/类
/**
 * @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()));
       }
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:22,代码来源:WildcardBinding.java

示例12: visit

import org.eclipse.jdt.internal.compiler.ast.Wildcard; //导入依赖的package包/类
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,代码行数:21,代码来源:CodeFormatterVisitor.java

示例13: toString

import org.eclipse.jdt.internal.compiler.ast.Wildcard; //导入依赖的package包/类
/**
 * @see java.lang.Object#toString()
 */
public String toString() {
       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()));
       }
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:20,代码来源:WildcardBinding.java

示例14: getExtendsBound

import org.eclipse.jdt.internal.compiler.ast.Wildcard; //导入依赖的package包/类
@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);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:9,代码来源:WildcardTypeImpl.java

示例15: getSuperBound

import org.eclipse.jdt.internal.compiler.ast.Wildcard; //导入依赖的package包/类
@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,代码行数:9,代码来源:WildcardTypeImpl.java


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