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


Java CastExpression类代码示例

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


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

示例1: longToIntForHashCode

import org.eclipse.jdt.internal.compiler.ast.CastExpression; //导入依赖的package包/类
/** Give 2 clones! */
public Expression longToIntForHashCode(Expression ref1, Expression ref2, ASTNode source) {
	int pS = source.sourceStart, pE = source.sourceEnd;
	/* (int)(ref >>> 32 ^ ref) */
	IntLiteral int32 = makeIntLiteral("32".toCharArray(), source);
	BinaryExpression higherBits = new BinaryExpression(ref1, int32, OperatorIds.UNSIGNED_RIGHT_SHIFT);
	setGeneratedBy(higherBits, source);
	BinaryExpression xorParts = new BinaryExpression(ref2, higherBits, OperatorIds.XOR);
	setGeneratedBy(xorParts, source);
	TypeReference intRef = TypeReference.baseTypeReference(TypeIds.T_int, 0);
	intRef.sourceStart = pS; intRef.sourceEnd = pE;
	setGeneratedBy(intRef, source);
	CastExpression expr = makeCastExpression(xorParts, intRef, source);
	expr.sourceStart = pS; expr.sourceEnd = pE;
	return expr;
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:17,代码来源:HandleEqualsAndHashCode.java

示例2: visit

import org.eclipse.jdt.internal.compiler.ast.CastExpression; //导入依赖的package包/类
/**
 * @see org.eclipse.jdt.internal.compiler.ASTVisitor#visit(org.eclipse.jdt.internal.compiler.ast.CastExpression, org.eclipse.jdt.internal.compiler.lookup.BlockScope)
 */
public boolean visit(CastExpression castExpression, BlockScope scope) {

	final int numberOfParens = (castExpression.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
	if (numberOfParens > 0) {
		manageOpeningParenthesizedExpression(castExpression, numberOfParens);
	}
	this.scribe.printNextToken(TerminalTokens.TokenNameLPAREN);
	if (this.preferences.insert_space_after_opening_paren_in_cast) {
		this.scribe.space();
	}
	castExpression.type.traverse(this, scope);

	this.scribe.printNextToken(TerminalTokens.TokenNameRPAREN, this.preferences.insert_space_before_closing_paren_in_cast);
	if (this.preferences.insert_space_after_closing_paren_in_cast) {
		this.scribe.space();
	}
	castExpression.expression.traverse(this, scope);

	if (numberOfParens > 0) {
		manageClosingParenthesizedExpression(castExpression, numberOfParens);
	}
	return false;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:27,代码来源:CodeFormatterVisitor.java

示例3: consumeCastExpressionLL1

import org.eclipse.jdt.internal.compiler.ast.CastExpression; //导入依赖的package包/类
protected void consumeCastExpressionLL1() {
	//CastExpression ::= '(' Name ')' InsideCastExpressionLL1 UnaryExpressionNotPlusMinus
	

	//optimize push/pop

	Expression cast;
	Expression exp;
	this.expressionPtr--;
	this.expressionStack[this.expressionPtr] =
		cast = new CastExpression(
			exp=this.expressionStack[this.expressionPtr+1] ,
			(TypeReference) this.expressionStack[this.expressionPtr]);
	this.expressionLengthPtr -- ;
	updateSourcePosition(cast);
	cast.sourceEnd=exp.sourceEnd;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:18,代码来源:Parser.java

示例4: consumeCastExpressionLL1WithBounds

import org.eclipse.jdt.internal.compiler.ast.CastExpression; //导入依赖的package包/类
protected void consumeCastExpressionLL1WithBounds() {
	//CastExpression ::= '(' Name AdditionalBoundsList ')' UnaryExpressionNotPlusMinus
	Expression cast;
	Expression exp;
	int length;
	exp = this.expressionStack[this.expressionPtr--];
	this.expressionLengthPtr --;
	TypeReference[] bounds = new TypeReference[length = this.expressionLengthStack[this.expressionLengthPtr]];
	System.arraycopy(this.expressionStack, this.expressionPtr -= (length - 1), bounds, 0, length);
	this.expressionStack[this.expressionPtr] =
		cast = new CastExpression(
			exp,
			createIntersectionCastTypeReference(bounds));
	this.expressionLengthStack[this.expressionLengthPtr] = 1;
	updateSourcePosition(cast);
	cast.sourceEnd=exp.sourceEnd;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:18,代码来源:Parser.java

示例5: typeCastError

import org.eclipse.jdt.internal.compiler.ast.CastExpression; //导入依赖的package包/类
public void typeCastError(CastExpression expression, TypeBinding leftType, TypeBinding rightType) {
	String leftName = new String(leftType.readableName());
	String rightName = new String(rightType.readableName());
	String leftShortName = new String(leftType.shortReadableName());
	String rightShortName = new String(rightType.shortReadableName());
	if (leftShortName.equals(rightShortName)){
		leftShortName = leftName;
		rightShortName = rightName;
	}
	this.handle(
		IProblem.IllegalCast,
		new String[] { rightName, leftName },
		new String[] { rightShortName, leftShortName },
		expression.sourceStart,
		expression.sourceEnd);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:17,代码来源:ProblemReporter.java

示例6: unsafeCast

import org.eclipse.jdt.internal.compiler.ast.CastExpression; //导入依赖的package包/类
public void unsafeCast(CastExpression castExpression, Scope scope) {
	if (this.options.sourceLevel < ClassFileConstants.JDK1_5) return; // https://bugs.eclipse.org/bugs/show_bug.cgi?id=305259
	int severity = computeSeverity(IProblem.UnsafeGenericCast);
	if (severity == ProblemSeverities.Ignore) return;
	TypeBinding castedExpressionType = castExpression.expression.resolvedType;
	TypeBinding castExpressionResolvedType = castExpression.resolvedType;
	this.handle(
		IProblem.UnsafeGenericCast,
		new String[]{
			new String(castedExpressionType.readableName()),
			new String(castExpressionResolvedType.readableName())
		},
		new String[]{
			new String(castedExpressionType.shortReadableName()),
			new String(castExpressionResolvedType.shortReadableName())
		},
		severity,
		castExpression.sourceStart,
		castExpression.sourceEnd);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:21,代码来源:ProblemReporter.java

示例7: unsafeNullnessCast

import org.eclipse.jdt.internal.compiler.ast.CastExpression; //导入依赖的package包/类
public void unsafeNullnessCast(CastExpression castExpression, Scope scope) {
	TypeBinding castedExpressionType = castExpression.expression.resolvedType;
	TypeBinding castExpressionResolvedType = castExpression.resolvedType;
	this.handle(
		IProblem.UnsafeNullnessCast,
		new String[]{
			new String(castedExpressionType.nullAnnotatedReadableName(this.options, false)),
			new String(castExpressionResolvedType.nullAnnotatedReadableName(this.options, false))
		},
		new String[]{
			new String(castedExpressionType.nullAnnotatedReadableName(this.options, true)),
			new String(castExpressionResolvedType.nullAnnotatedReadableName(this.options, true))
		},
		castExpression.sourceStart,
		castExpression.sourceEnd);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:17,代码来源:ProblemReporter.java

示例8: longToIntForHashCode

import org.eclipse.jdt.internal.compiler.ast.CastExpression; //导入依赖的package包/类
/** Give 2 clones! */
private Expression longToIntForHashCode(Expression ref1, Expression ref2, ASTNode source) {
	int pS = source.sourceStart, pE = source.sourceEnd;
	/* (int)(ref >>> 32 ^ ref) */
	IntLiteral int32 = makeIntLiteral("32".toCharArray(), source);
	BinaryExpression higherBits = new BinaryExpression(ref1, int32, OperatorIds.UNSIGNED_RIGHT_SHIFT);
	setGeneratedBy(higherBits, source);
	BinaryExpression xorParts = new BinaryExpression(ref2, higherBits, OperatorIds.XOR);
	setGeneratedBy(xorParts, source);
	TypeReference intRef = TypeReference.baseTypeReference(TypeIds.T_int, 0);
	intRef.sourceStart = pS; intRef.sourceEnd = pE;
	setGeneratedBy(intRef, source);
	CastExpression expr = makeCastExpression(xorParts, intRef, source);
	expr.sourceStart = pS; expr.sourceEnd = pE;
	return expr;
}
 
开发者ID:redundent,项目名称:lombok,代码行数:17,代码来源:HandleEqualsAndHashCode.java

示例9: doAssignmentCheck0

import org.eclipse.jdt.internal.compiler.ast.CastExpression; //导入依赖的package包/类
private void doAssignmentCheck0(EclipseNode node, Statement statement, char[] varName) {
	if (statement instanceof Assignment)
		doAssignmentCheck0(node, ((Assignment)statement).expression, varName);
	else if (statement instanceof LocalDeclaration)
		doAssignmentCheck0(node, ((LocalDeclaration)statement).initialization, varName);
	else if (statement instanceof CastExpression)
		doAssignmentCheck0(node, ((CastExpression)statement).expression, varName);
	else if (statement instanceof SingleNameReference) {
		if (Arrays.equals(((SingleNameReference)statement).token, varName)) {
			EclipseNode problemNode = node.getNodeFor(statement);
			if (problemNode != null) problemNode.addWarning(
					"You're assigning an auto-cleanup variable to something else. This is a bad idea.");
		}
	}
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:16,代码来源:HandleCleanup.java

示例10: consumeCastExpressionWithGenericsArray

import org.eclipse.jdt.internal.compiler.ast.CastExpression; //导入依赖的package包/类
protected void consumeCastExpressionWithGenericsArray() {
	// CastExpression ::= PushLPAREN Name TypeArguments Dimsopt AdditionalBoundsListOpt PushRPAREN InsideCastExpression UnaryExpressionNotPlusMinus
	
	TypeReference[] bounds = null;
	int additionalBoundsLength = this.genericsLengthStack[this.genericsLengthPtr--];
	if (additionalBoundsLength > 0) {
		bounds = new TypeReference[additionalBoundsLength + 1];
		this.genericsPtr -= additionalBoundsLength;
		System.arraycopy(this.genericsStack, this.genericsPtr + 1, bounds, 1, additionalBoundsLength);
	}
	Expression exp;
	Expression cast;
	TypeReference castType;
	int end = this.intStack[this.intPtr--];

	int dim = this.intStack[this.intPtr--];
	pushOnGenericsIdentifiersLengthStack(this.identifierLengthStack[this.identifierLengthPtr]);
	if (additionalBoundsLength > 0) {
		bounds[0] = getTypeReference(dim);
		castType = createIntersectionCastTypeReference(bounds); 
	} else {
		castType = getTypeReference(dim);
	}
	this.expressionStack[this.expressionPtr] = cast = new CastExpression(exp = this.expressionStack[this.expressionPtr], castType);
	this.intPtr--;  // pop position of '<'
	castType.sourceEnd = end - 1;
	castType.sourceStart = (cast.sourceStart = this.intStack[this.intPtr--]) + 1;
	cast.sourceEnd = exp.sourceEnd;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:30,代码来源:Parser.java

示例11: consumeCastExpressionWithNameArray

import org.eclipse.jdt.internal.compiler.ast.CastExpression; //导入依赖的package包/类
protected void consumeCastExpressionWithNameArray() {
	// CastExpression ::= PushLPAREN Name Dims AdditionalBoundsListOpt PushRPAREN InsideCastExpression UnaryExpressionNotPlusMinus

	Expression exp;
	Expression cast;
	TypeReference castType;
	int end = this.intStack[this.intPtr--];

	TypeReference[] bounds = null;
	int additionalBoundsLength = this.genericsLengthStack[this.genericsLengthPtr--];
	if (additionalBoundsLength > 0) {
		bounds = new TypeReference[additionalBoundsLength + 1];
		this.genericsPtr -= additionalBoundsLength;
		System.arraycopy(this.genericsStack, this.genericsPtr + 1, bounds, 1, additionalBoundsLength);
	}
	// handle type arguments
	pushOnGenericsLengthStack(0);
	pushOnGenericsIdentifiersLengthStack(this.identifierLengthStack[this.identifierLengthPtr]);
	
	if (additionalBoundsLength > 0) {
		bounds[0] = getTypeReference(this.intStack[this.intPtr--]);
		castType = createIntersectionCastTypeReference(bounds);
	} else {
		castType = getTypeReference(this.intStack[this.intPtr--]);
	}
	this.expressionStack[this.expressionPtr] = cast = new CastExpression(exp = this.expressionStack[this.expressionPtr], castType);
	castType.sourceEnd = end - 1;
	castType.sourceStart = (cast.sourceStart = this.intStack[this.intPtr--]) + 1;
	cast.sourceEnd = exp.sourceEnd;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:31,代码来源:Parser.java

示例12: consumeCastExpressionWithPrimitiveType

import org.eclipse.jdt.internal.compiler.ast.CastExpression; //导入依赖的package包/类
protected void consumeCastExpressionWithPrimitiveType() {
	// CastExpression ::= PushLPAREN PrimitiveType Dimsopt AdditionalBoundsListOpt PushRPAREN InsideCastExpression UnaryExpression

	//this.intStack : posOfLeftParen dim posOfRightParen

	TypeReference[] bounds = null;
	int additionalBoundsLength = this.genericsLengthStack[this.genericsLengthPtr--];
	if (additionalBoundsLength > 0) {
		bounds = new TypeReference[additionalBoundsLength + 1];
		this.genericsPtr -= additionalBoundsLength;
		System.arraycopy(this.genericsStack, this.genericsPtr + 1, bounds, 1, additionalBoundsLength);
	}
	
	//optimize the push/pop
	Expression exp;
	Expression cast;
	TypeReference castType;
	int end = this.intStack[this.intPtr--];
	if (additionalBoundsLength > 0) {
		bounds[0] = getTypeReference(this.intStack[this.intPtr--]);
		castType = createIntersectionCastTypeReference(bounds); 
	} else {
		castType = getTypeReference(this.intStack[this.intPtr--]);
	}
	this.expressionStack[this.expressionPtr] = cast = new CastExpression(exp = this.expressionStack[this.expressionPtr], castType);
	castType.sourceEnd = end - 1;
	castType.sourceStart = (cast.sourceStart = this.intStack[this.intPtr--]) + 1;
	cast.sourceEnd = exp.sourceEnd;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:30,代码来源:Parser.java

示例13: consumeCastExpressionWithQualifiedGenericsArray

import org.eclipse.jdt.internal.compiler.ast.CastExpression; //导入依赖的package包/类
protected void consumeCastExpressionWithQualifiedGenericsArray() {
	// CastExpression ::= PushLPAREN Name OnlyTypeArguments '.' ClassOrInterfaceType Dimsopt AdditionalBoundsOpt PushRPAREN InsideCastExpression UnaryExpressionNotPlusMinus

	TypeReference[] bounds = null;
	int additionalBoundsLength = this.genericsLengthStack[this.genericsLengthPtr--];
	if (additionalBoundsLength > 0) {
		bounds = new TypeReference[additionalBoundsLength + 1];
		this.genericsPtr -= additionalBoundsLength;
		System.arraycopy(this.genericsStack, this.genericsPtr + 1, bounds, 1, additionalBoundsLength);
	}

	Expression exp;
	Expression cast;
	TypeReference castType;
	int end = this.intStack[this.intPtr--];
	int dim = this.intStack[this.intPtr--];
	Annotation [][] annotationsOnDimensions = dim == 0 ? null : getAnnotationsOnDimensions(dim);
	TypeReference rightSide = getTypeReference(0);
    castType = computeQualifiedGenericsFromRightSide(rightSide, dim, annotationsOnDimensions);

    if (additionalBoundsLength > 0) {
		bounds[0] = castType;
		castType = createIntersectionCastTypeReference(bounds); 
	}
    
    this.intPtr--;
	this.expressionStack[this.expressionPtr] = cast = new CastExpression(exp = this.expressionStack[this.expressionPtr], castType);
	castType.sourceEnd = end - 1;
	castType.sourceStart = (cast.sourceStart = this.intStack[this.intPtr--]) + 1;
	cast.sourceEnd = exp.sourceEnd;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:32,代码来源:Parser.java

示例14: unnecessaryCast

import org.eclipse.jdt.internal.compiler.ast.CastExpression; //导入依赖的package包/类
public void unnecessaryCast(CastExpression castExpression) {
	if (castExpression.expression instanceof FunctionalExpression)
		return;
	int severity = computeSeverity(IProblem.UnnecessaryCast);
	if (severity == ProblemSeverities.Ignore) return;
	TypeBinding castedExpressionType = castExpression.expression.resolvedType;
	this.handle(
		IProblem.UnnecessaryCast,
		new String[]{ new String(castedExpressionType.readableName()), new String(castExpression.type.resolvedType.readableName())},
		new String[]{ new String(castedExpressionType.shortReadableName()), new String(castExpression.type.resolvedType.shortReadableName())},
		severity,
		castExpression.sourceStart,
		castExpression.sourceEnd);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:15,代码来源:ProblemReporter.java

示例15: unnecessaryCast

import org.eclipse.jdt.internal.compiler.ast.CastExpression; //导入依赖的package包/类
public void unnecessaryCast(CastExpression castExpression) {
	int severity = computeSeverity(IProblem.UnnecessaryCast);
	if (severity == ProblemSeverities.Ignore) return;
	TypeBinding castedExpressionType = castExpression.expression.resolvedType;
	this.handle(
		IProblem.UnnecessaryCast,
		new String[]{ new String(castedExpressionType.readableName()), new String(castExpression.type.resolvedType.readableName())},
		new String[]{ new String(castedExpressionType.shortReadableName()), new String(castExpression.type.resolvedType.shortReadableName())},
		severity,
		castExpression.sourceStart,
		castExpression.sourceEnd);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:13,代码来源:ProblemReporter.java


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