• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Wildcard类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: resolveType

import org.eclipse.jdt.internal.compiler.ast.Wildcard; //导入依赖的package包/类
@Override
public TypeBinding resolveType(BlockScope scope) {
	
	final CompilerOptions compilerOptions = scope.compilerOptions();
	TypeBinding lhsType;
	boolean typeArgumentsHaveErrors;

	this.constant = Constant.NotAConstant;
	lhsType = this.lhs.resolveType(scope);
	if (this.typeArguments != null) {
		int length = this.typeArguments.length;
		typeArgumentsHaveErrors = compilerOptions.sourceLevel < ClassFileConstants.JDK1_5;
		this.resolvedTypeArguments = new TypeBinding[length];
		for (int i = 0; i < length; i++) {
			TypeReference typeReference = this.typeArguments[i];
			if ((this.resolvedTypeArguments[i] = typeReference.resolveType(scope, true /* check bounds*/)) == null) {
				typeArgumentsHaveErrors = true;
			}
			if (typeArgumentsHaveErrors && typeReference instanceof Wildcard) { // resolveType on wildcard always return null above, resolveTypeArgument is the real workhorse.
				scope.problemReporter().illegalUsageOfWildcard(typeReference);
			}
		}
		if (typeArgumentsHaveErrors || lhsType == null)
			throw new CompletionNodeFound();
	}
   	
	if (lhsType != null && lhsType.isValidBinding())
		throw new CompletionNodeFound(this, lhsType, scope);
	throw new CompletionNodeFound();
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:31,代码来源:CompletionOnReferenceExpressionName.java


示例17: parseWildcard

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


示例18: isUpperbound

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


示例19: consumeWildcard

import org.eclipse.jdt.internal.compiler.ast.Wildcard; //导入依赖的package包/类
protected void consumeWildcard() {
	final Wildcard wildcard = new Wildcard(Wildcard.UNBOUND);
	wildcard.sourceEnd = this.intStack[this.intPtr--];
	wildcard.sourceStart = this.intStack[this.intPtr--];
	annotateTypeReference(wildcard);
	pushOnGenericsStack(wildcard);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:8,代码来源:Parser.java


示例20: consumeWildcard1

import org.eclipse.jdt.internal.compiler.ast.Wildcard; //导入依赖的package包/类
protected void consumeWildcard1() {
	final Wildcard wildcard = new Wildcard(Wildcard.UNBOUND);
	wildcard.sourceEnd = this.intStack[this.intPtr--];
	wildcard.sourceStart = this.intStack[this.intPtr--];
	annotateTypeReference(wildcard);
	pushOnGenericsStack(wildcard);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:8,代码来源:Parser.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java UILabel类代码示例发布时间:2022-05-23
下一篇:
Java DatanodeStorageInfo类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap