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


Java TypeConstants类代码示例

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


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

示例1: handleValForForEach

import org.eclipse.jdt.internal.compiler.lookup.TypeConstants; //导入依赖的package包/类
public static boolean handleValForForEach(ForeachStatement forEach, BlockScope scope) {
	if (forEach.elementVariable == null) return false;
	
	if (!isVal(forEach.elementVariable.type, scope)) return false;
	
	TypeBinding component = getForEachComponentType(forEach.collection, scope);
	if (component == null) return false;
	TypeReference replacement = makeType(component, forEach.elementVariable.type, false);
	
	forEach.elementVariable.modifiers |= ClassFileConstants.AccFinal;
	forEach.elementVariable.annotations = addValAnnotation(forEach.elementVariable.annotations, forEach.elementVariable.type, scope);
	forEach.elementVariable.type = replacement != null ? replacement :
			new QualifiedTypeReference(TypeConstants.JAVA_LANG_OBJECT, poss(forEach.elementVariable.type, 3));
	
	return false;
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:17,代码来源:PatchVal.java

示例2: generateCompareFloatOrDouble

import org.eclipse.jdt.internal.compiler.lookup.TypeConstants; //导入依赖的package包/类
public IfStatement generateCompareFloatOrDouble(Expression thisRef, Expression otherRef, char[] floatOrDouble, ASTNode source) {
	int pS = source.sourceStart, pE = source.sourceEnd;
	/* if (Float.compare(fieldName, other.fieldName) != 0) return false */
	MessageSend floatCompare = new MessageSend();
	floatCompare.sourceStart = pS; floatCompare.sourceEnd = pE;
	setGeneratedBy(floatCompare, source);
	floatCompare.receiver = generateQualifiedNameRef(source, TypeConstants.JAVA, TypeConstants.LANG, floatOrDouble);
	floatCompare.selector = "compare".toCharArray();
	floatCompare.arguments = new Expression[] {thisRef, otherRef};
	IntLiteral int0 = makeIntLiteral("0".toCharArray(), source);
	EqualExpression ifFloatCompareIsNot0 = new EqualExpression(floatCompare, int0, OperatorIds.NOT_EQUAL);
	ifFloatCompareIsNot0.sourceStart = pS; ifFloatCompareIsNot0.sourceEnd = pE;
	setGeneratedBy(ifFloatCompareIsNot0, source);
	FalseLiteral falseLiteral = new FalseLiteral(pS, pE);
	setGeneratedBy(falseLiteral, source);
	ReturnStatement returnFalse = new ReturnStatement(falseLiteral, pS, pE);
	setGeneratedBy(returnFalse, source);
	IfStatement ifStatement = new IfStatement(ifFloatCompareIsNot0, returnFalse, pS, pE);
	setGeneratedBy(ifStatement, source);
	return ifStatement;
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:22,代码来源:HandleEqualsAndHashCode.java

示例3: cloneParamType

import org.eclipse.jdt.internal.compiler.lookup.TypeConstants; //导入依赖的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

示例4: getConstructors

import org.eclipse.jdt.internal.compiler.lookup.TypeConstants; //导入依赖的package包/类
@Override
@NonNull
public Iterable<ResolvedMethod> getConstructors() {
    if (mBinding instanceof ReferenceBinding) {
        ReferenceBinding cls = (ReferenceBinding) mBinding;
        MethodBinding[] methods = cls.getMethods(TypeConstants.INIT);
        if (methods != null) {
            int count = methods.length;
            List<ResolvedMethod> result = Lists.newArrayListWithExpectedSize(count);
            for (MethodBinding method : methods) {
                if (method.isConstructor()) {
                    result.add(new EcjResolvedMethod(method));
                }
            }
            return result;
        }
    }

    return Collections.emptyList();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:EcjParser.java

示例5: getKind

import org.eclipse.jdt.internal.compiler.lookup.TypeConstants; //导入依赖的package包/类
@Override
public ElementKind getKind() {
	MethodBinding binding = (MethodBinding)_binding;
	if (binding.isConstructor()) {
		return ElementKind.CONSTRUCTOR;
	}
	else if (CharOperation.equals(binding.selector, TypeConstants.CLINIT)) {
		return ElementKind.STATIC_INIT;
	}
	else if (CharOperation.equals(binding.selector, TypeConstants.INIT)) {
		return ElementKind.INSTANCE_INIT;
	}
	else {
		return ElementKind.METHOD;
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:17,代码来源:ExecutableElementImpl.java

示例6: enterEnum

import org.eclipse.jdt.internal.compiler.lookup.TypeConstants; //导入依赖的package包/类
private void enterEnum(TypeInfo typeInfo) {
	// eliminate possible qualifications, given they need to be fully resolved again
	if (typeInfo.superinterfaces != null){
		for (int i = 0, length = typeInfo.superinterfaces.length; i < length; i++){
			typeInfo.superinterfaces[i] = getSimpleName(typeInfo.superinterfaces[i]);
		}
	}
	char[][] typeNames;
	if (this.methodDepth > 0) {
		typeNames = ONE_ZERO_CHAR;
	} else {
		typeNames = enclosingTypeNames();
	}
	char[] superclass = typeInfo.superclass == null ? CharOperation.concatWith(TypeConstants.JAVA_LANG_ENUM, '.'): typeInfo.superclass;
	this.indexer.addEnumDeclaration(typeInfo.modifiers, this.packageName, typeInfo.name, typeNames, superclass, typeInfo.superinterfaces, typeInfo.secondary);
	addDefaultConstructorIfNecessary(typeInfo);
	pushTypeName(typeInfo.name);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:19,代码来源:SourceIndexerRequestor.java

示例7: generateStandardAnnotationsInfos

import org.eclipse.jdt.internal.compiler.lookup.TypeConstants; //导入依赖的package包/类
private void generateStandardAnnotationsInfos(JavaElement javaElement, char[] parameterName, long tagBits, HashMap newElements) {
	if ((tagBits & TagBits.AllStandardAnnotationsMask) == 0)
		return;
	if ((tagBits & TagBits.AnnotationTargetMASK) != 0) {
		generateStandardAnnotation(javaElement, TypeConstants.JAVA_LANG_ANNOTATION_TARGET, getTargetElementTypes(tagBits), newElements);
	}
	if ((tagBits & TagBits.AnnotationRetentionMASK) != 0) {
		generateStandardAnnotation(javaElement, TypeConstants.JAVA_LANG_ANNOTATION_RETENTION, getRetentionPolicy(tagBits), newElements);
	}
	if ((tagBits & TagBits.AnnotationDeprecated) != 0) {
		generateStandardAnnotation(javaElement, TypeConstants.JAVA_LANG_DEPRECATED, Annotation.NO_MEMBER_VALUE_PAIRS, newElements);
	}
	if ((tagBits & TagBits.AnnotationDocumented) != 0) {
		generateStandardAnnotation(javaElement, TypeConstants.JAVA_LANG_ANNOTATION_DOCUMENTED, Annotation.NO_MEMBER_VALUE_PAIRS, newElements);
	}
	if ((tagBits & TagBits.AnnotationInherited) != 0) {
		generateStandardAnnotation(javaElement, TypeConstants.JAVA_LANG_ANNOTATION_INHERITED, Annotation.NO_MEMBER_VALUE_PAIRS, newElements);
	}
	if ((tagBits & TagBits.AnnotationPolymorphicSignature) != 0) {
		generateStandardAnnotation(javaElement, TypeConstants.JAVA_LANG_INVOKE_METHODHANDLE_$_POLYMORPHICSIGNATURE, Annotation.NO_MEMBER_VALUE_PAIRS, newElements);
	}
	if ((tagBits & TagBits.AnnotationSafeVarargs) != 0) {
		generateStandardAnnotation(javaElement, TypeConstants.JAVA_LANG_SAFEVARARGS, Annotation.NO_MEMBER_VALUE_PAIRS, newElements);
	}
	// note that JAVA_LANG_SUPPRESSWARNINGS and JAVA_LANG_OVERRIDE cannot appear in binaries
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:27,代码来源:ClassFileInfo.java

示例8: findMethodForArray

import org.eclipse.jdt.internal.compiler.lookup.TypeConstants; //导入依赖的package包/类
public MethodBinding findMethodForArray(ArrayBinding receiverType, char[] selector, TypeBinding[] argumentTypes, InvocationSite invocationSite) {
	ReferenceBinding object = getJavaLangObject();
	MethodBinding methodBinding = object.getExactMethod(selector, argumentTypes, null);
	if (methodBinding != null) {
		// handle the method clone() specially... cannot be protected or throw exceptions
		if (argumentTypes == Binding.NO_PARAMETERS && CharOperation.equals(selector, TypeConstants.CLONE))
			return new MethodBinding((methodBinding.modifiers & ~ClassFileConstants.AccProtected) | ClassFileConstants.AccPublic, TypeConstants.CLONE, methodBinding.returnType, argumentTypes, null, object);
		if (canBeSeenByForCodeSnippet(methodBinding, receiverType, invocationSite, this))
			return methodBinding;
	}

	// answers closest approximation, may not check argumentTypes or visibility
	methodBinding = findMethod(object, selector, argumentTypes, invocationSite, false);
	if (methodBinding == null)
		return new ProblemMethodBinding(selector, argumentTypes, ProblemReasons.NotFound);
	if (methodBinding.isValidBinding()) {
	    MethodBinding compatibleMethod = computeCompatibleMethod(methodBinding, argumentTypes, invocationSite, Scope.FULL_INFERENCE);
	    if (compatibleMethod == null)
			return new ProblemMethodBinding(methodBinding, selector, argumentTypes, ProblemReasons.NotFound);
	    methodBinding = compatibleMethod;
		if (!canBeSeenByForCodeSnippet(methodBinding, receiverType, invocationSite, this))
			return new ProblemMethodBinding(methodBinding, selector, methodBinding.parameters, ProblemReasons.NotVisible);
	}
	return methodBinding;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:26,代码来源:CodeSnippetScope.java

示例9: FakedTrackingVariable

import org.eclipse.jdt.internal.compiler.lookup.TypeConstants; //导入依赖的package包/类
public FakedTrackingVariable(LocalVariableBinding original, ASTNode location, FlowInfo flowInfo, FlowContext flowContext, int nullStatus) {
	super(original.name, location.sourceStart, location.sourceEnd);
	this.type = new SingleTypeReference(
			TypeConstants.OBJECT,
			((long)this.sourceStart <<32)+this.sourceEnd);
	this.methodScope = original.declaringScope.methodScope();
	this.originalBinding = original;
	// inside a finally block?
	while (flowContext != null) {
		if (flowContext instanceof FinallyFlowContext) {
			// yes -> connect to the corresponding try block:
			this.tryContext = ((FinallyFlowContext) flowContext).tryContext;
			break;
		}
		flowContext = flowContext.parent;
	}
	resolve(original.declaringScope);
	if (nullStatus != 0)
		flowInfo.markNullStatus(this.binding, nullStatus); // mark that this flow has seen the resource
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:21,代码来源:FakedTrackingVariable.java

示例10: findMethodForArray

import org.eclipse.jdt.internal.compiler.lookup.TypeConstants; //导入依赖的package包/类
public MethodBinding findMethodForArray(ArrayBinding receiverType, char[] selector, TypeBinding[] argumentTypes, InvocationSite invocationSite) {
	ReferenceBinding object = getJavaLangObject();
	MethodBinding methodBinding = object.getExactMethod(selector, argumentTypes, null);
	if (methodBinding != null) {
		// handle the method clone() specially... cannot be protected or throw exceptions
		if (argumentTypes == Binding.NO_PARAMETERS && CharOperation.equals(selector, TypeConstants.CLONE))
			return new MethodBinding((methodBinding.modifiers & ~ClassFileConstants.AccProtected) | ClassFileConstants.AccPublic, TypeConstants.CLONE, methodBinding.returnType, argumentTypes, null, object);
		if (canBeSeenByForCodeSnippet(methodBinding, receiverType, invocationSite, this))
			return methodBinding;
	}

	// answers closest approximation, may not check argumentTypes or visibility
	methodBinding = findMethod(object, selector, argumentTypes, invocationSite);
	if (methodBinding == null)
		return new ProblemMethodBinding(selector, argumentTypes, ProblemReasons.NotFound);
	if (methodBinding.isValidBinding()) {
	    MethodBinding compatibleMethod = computeCompatibleMethod(methodBinding, argumentTypes, invocationSite);
	    if (compatibleMethod == null)
			return new ProblemMethodBinding(methodBinding, selector, argumentTypes, ProblemReasons.NotFound);
	    methodBinding = compatibleMethod;
		if (!canBeSeenByForCodeSnippet(methodBinding, receiverType, invocationSite, this))
			return new ProblemMethodBinding(methodBinding, selector, methodBinding.parameters, ProblemReasons.NotVisible);
	}
	return methodBinding;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:26,代码来源:CodeSnippetScope.java

示例11: createSuppressWarningsAll

import org.eclipse.jdt.internal.compiler.lookup.TypeConstants; //导入依赖的package包/类
public static Annotation[] createSuppressWarningsAll(ASTNode source, Annotation[] originalAnnotationArray) {
	int pS = source.sourceStart, pE = source.sourceEnd;
	long p = (long)pS << 32 | pE;
	long[] poss = new long[3];
	Arrays.fill(poss, p);
	QualifiedTypeReference suppressWarningsType = new QualifiedTypeReference(TypeConstants.JAVA_LANG_SUPPRESSWARNINGS, poss);
	setGeneratedBy(suppressWarningsType, source);
	SingleMemberAnnotation ann = new SingleMemberAnnotation(suppressWarningsType, pS);
	ann.declarationSourceEnd = pE;
	ann.memberValue = new StringLiteral(ALL, pS, pE, 0);
	setGeneratedBy(ann, source);
	setGeneratedBy(ann.memberValue, source);
	if (originalAnnotationArray == null) return new Annotation[] { ann };
	Annotation[] newAnnotationArray = new Annotation[originalAnnotationArray.length + 1];
	System.arraycopy(originalAnnotationArray, 0, newAnnotationArray, 0, originalAnnotationArray.length);
	newAnnotationArray[originalAnnotationArray.length] = ann;
	return newAnnotationArray;
}
 
开发者ID:redundent,项目名称:lombok,代码行数:19,代码来源:EclipseHandlerUtil.java

示例12: generateCompareFloatOrDouble

import org.eclipse.jdt.internal.compiler.lookup.TypeConstants; //导入依赖的package包/类
private IfStatement generateCompareFloatOrDouble(Expression thisRef, Expression otherRef, char[] floatOrDouble, ASTNode source) {
	int pS = source.sourceStart, pE = source.sourceEnd;
	/* if (Float.compare(fieldName, other.fieldName) != 0) return false */
	MessageSend floatCompare = new MessageSend();
	floatCompare.sourceStart = pS; floatCompare.sourceEnd = pE;
	setGeneratedBy(floatCompare, source);
	floatCompare.receiver = generateQualifiedNameRef(source, TypeConstants.JAVA, TypeConstants.LANG, floatOrDouble);
	floatCompare.selector = "compare".toCharArray();
	floatCompare.arguments = new Expression[] {thisRef, otherRef};
	IntLiteral int0 = makeIntLiteral("0".toCharArray(), source);
	EqualExpression ifFloatCompareIsNot0 = new EqualExpression(floatCompare, int0, OperatorIds.NOT_EQUAL);
	ifFloatCompareIsNot0.sourceStart = pS; ifFloatCompareIsNot0.sourceEnd = pE;
	setGeneratedBy(ifFloatCompareIsNot0, source);
	FalseLiteral falseLiteral = new FalseLiteral(pS, pE);
	setGeneratedBy(falseLiteral, source);
	ReturnStatement returnFalse = new ReturnStatement(falseLiteral, pS, pE);
	setGeneratedBy(returnFalse, source);
	IfStatement ifStatement = new IfStatement(ifFloatCompareIsNot0, returnFalse, pS, pE);
	setGeneratedBy(ifStatement, source);
	return ifStatement;
}
 
开发者ID:redundent,项目名称:lombok,代码行数:22,代码来源:HandleEqualsAndHashCode.java

示例13: getDefaultExpr

import org.eclipse.jdt.internal.compiler.lookup.TypeConstants; //导入依赖的package包/类
private static Expression getDefaultExpr(TypeReference type, int s, int e) {
	char[] lastToken = type.getLastToken();
	if (Arrays.equals(TypeConstants.BOOLEAN, lastToken)) return new FalseLiteral(s, e);
	if (Arrays.equals(TypeConstants.CHAR, lastToken)) return new CharLiteral(new char[] {'\'', '\\', '0', '\''}, s, e);
	if (Arrays.equals(TypeConstants.BYTE, lastToken) || Arrays.equals(TypeConstants.SHORT, lastToken) ||
		Arrays.equals(TypeConstants.INT, lastToken)) return IntLiteral.buildIntLiteral(new char[] {'0'}, s, e);
	if (Arrays.equals(TypeConstants.LONG, lastToken)) return LongLiteral.buildLongLiteral(new char[] {'0',  'L'}, s, e);
	if (Arrays.equals(TypeConstants.FLOAT, lastToken)) return new FloatLiteral(new char[] {'0', 'F'}, s, e);
	if (Arrays.equals(TypeConstants.DOUBLE, lastToken)) return new DoubleLiteral(new char[] {'0', 'D'}, s, e);
	
	return new NullLiteral(s, e);
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:13,代码来源:HandleConstructor.java

示例14: addSuppressWarningsAll

import org.eclipse.jdt.internal.compiler.lookup.TypeConstants; //导入依赖的package包/类
public static Annotation[] addSuppressWarningsAll(EclipseNode node, ASTNode source, Annotation[] originalAnnotationArray) {
	Annotation[] anns = addAnnotation(source, originalAnnotationArray, TypeConstants.JAVA_LANG_SUPPRESSWARNINGS, new StringLiteral(ALL, 0, 0, 0));
	
	if (Boolean.TRUE.equals(node.getAst().readConfiguration(ConfigurationKeys.ADD_FINDBUGS_SUPPRESSWARNINGS_ANNOTATIONS))) {
		MemberValuePair mvp = new MemberValuePair(JUSTIFICATION, 0, 0, new StringLiteral(GENERATED_CODE, 0, 0, 0));
		anns = addAnnotation(source, anns, EDU_UMD_CS_FINDBUGS_ANNOTATIONS_SUPPRESSFBWARNINGS, mvp);
	}
	
	return anns;
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:11,代码来源:EclipseHandlerUtil.java

示例15: createLockField

import org.eclipse.jdt.internal.compiler.lookup.TypeConstants; //导入依赖的package包/类
public char[] createLockField(AnnotationValues<Synchronized> annotation, EclipseNode annotationNode, boolean isStatic, boolean reportErrors) {
	char[] lockName = annotation.getInstance().value().toCharArray();
	Annotation source = (Annotation) annotationNode.get();
	boolean autoMake = false;
	if (lockName.length == 0) {
		autoMake = true;
		lockName = isStatic ? STATIC_LOCK_NAME : INSTANCE_LOCK_NAME;
	}
	
	if (fieldExists(new String(lockName), annotationNode) == MemberExistsResult.NOT_EXISTS) {
		if (!autoMake) {
			if (reportErrors) annotationNode.addError(String.format("The field %s does not exist.", new String(lockName)));
			return null;
		}
		FieldDeclaration fieldDecl = new FieldDeclaration(lockName, 0, -1);
		setGeneratedBy(fieldDecl, source);
		fieldDecl.declarationSourceEnd = -1;
		
		fieldDecl.modifiers = (isStatic ? Modifier.STATIC : 0) | Modifier.FINAL | Modifier.PRIVATE;
		
		//We use 'new Object[0];' because unlike 'new Object();', empty arrays *ARE* serializable!
		ArrayAllocationExpression arrayAlloc = new ArrayAllocationExpression();
		setGeneratedBy(arrayAlloc, source);
		arrayAlloc.dimensions = new Expression[] { makeIntLiteral("0".toCharArray(), source) };
		arrayAlloc.type = new QualifiedTypeReference(TypeConstants.JAVA_LANG_OBJECT, new long[] { 0, 0, 0 });
		setGeneratedBy(arrayAlloc.type, source);
		fieldDecl.type = new QualifiedTypeReference(TypeConstants.JAVA_LANG_OBJECT, new long[] { 0, 0, 0 });
		setGeneratedBy(fieldDecl.type, source);
		fieldDecl.initialization = arrayAlloc;
		// TODO temporary workaround for issue 217. http://code.google.com/p/projectlombok/issues/detail?id=217
		// injectFieldSuppressWarnings(annotationNode.up().up(), fieldDecl);
		injectField(annotationNode.up().up(), fieldDecl);
	}
	
	return lockName;
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:37,代码来源:HandleSynchronized.java


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