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


Java CompoundAssignment类代码示例

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


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

示例1: invalidOperator

import org.eclipse.jdt.internal.compiler.ast.CompoundAssignment; //导入依赖的package包/类
public void invalidOperator(CompoundAssignment assign, 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.InvalidOperator,
		new String[] {
			assign.operatorToString(),
			leftName + ", " + rightName}, //$NON-NLS-1$
		new String[] {
			assign.operatorToString(),
			leftShortName + ", " + rightShortName}, //$NON-NLS-1$
		assign.sourceStart,
		assign.sourceEnd);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:21,代码来源:ProblemReporter.java

示例2: operatorOnlyValidOnNumericType

import org.eclipse.jdt.internal.compiler.ast.CompoundAssignment; //导入依赖的package包/类
public void operatorOnlyValidOnNumericType(CompoundAssignment  assignment, 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.TypeMismatch,
		new String[] {leftName, rightName },
		new String[] {leftShortName, rightShortName },
		assignment.sourceStart,
		assignment.sourceEnd);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:17,代码来源:ProblemReporter.java

示例3: consumeAssignment

import org.eclipse.jdt.internal.compiler.ast.CompoundAssignment; //导入依赖的package包/类
protected void consumeAssignment() {
	// Assignment ::= LeftHandSide AssignmentOperator AssignmentExpression
	//optimize the push/pop

	int op = this.intStack[this.intPtr--] ; //<--the encoded operator

	this.expressionPtr -- ; this.expressionLengthPtr -- ;
	Expression expression = this.expressionStack[this.expressionPtr+1];
	this.expressionStack[this.expressionPtr] =
		(op != EQUAL ) ?
			new CompoundAssignment(
				this.expressionStack[this.expressionPtr] ,
				expression,
				op,
				expression.sourceEnd):
			new Assignment(
				this.expressionStack[this.expressionPtr] ,
				expression,
				expression.sourceEnd);

	if (this.pendingRecoveredType != null) {
		// Used only in statements recovery.
		// This is not a real assignment but a placeholder for an existing anonymous type.
		// The assignment must be replace by the anonymous type.
		if (this.pendingRecoveredType.allocation != null &&
				this.scanner.startPosition - 1 <= this.pendingRecoveredType.declarationSourceEnd) {
			this.expressionStack[this.expressionPtr] = this.pendingRecoveredType.allocation;
			this.pendingRecoveredType = null;
			return;
		}
		this.pendingRecoveredType = null;
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:34,代码来源:Parser.java

示例4: visit

import org.eclipse.jdt.internal.compiler.ast.CompoundAssignment; //导入依赖的package包/类
@Override public boolean visit(CompoundAssignment node, BlockScope scope) {
	fixPositions(setGeneratedBy(node, source));
	return super.visit(node, scope);
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:5,代码来源:SetGeneratedByVisitor.java

示例5: visit

import org.eclipse.jdt.internal.compiler.ast.CompoundAssignment; //导入依赖的package包/类
public boolean visit(
	CompoundAssignment compoundAssignment,
	BlockScope scope) {
		addRealFragment(compoundAssignment);
		return false;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:7,代码来源:BinaryExpressionFragmentBuilder.java

示例6: visit

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

	final int numberOfParens = (compoundAssignment.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
	if (numberOfParens > 0) {
		manageOpeningParenthesizedExpression(compoundAssignment, numberOfParens);
	}
	compoundAssignment.lhs.traverse(this, scope);

	/*
	 * Print the operator
	 */
	int operator;
	switch(compoundAssignment.operator) {
		case OperatorIds.PLUS :
			operator = TerminalTokens.TokenNamePLUS_EQUAL;
			break;
		case OperatorIds.MINUS :
			operator = TerminalTokens.TokenNameMINUS_EQUAL;
			break;
		case OperatorIds.MULTIPLY :
			operator = TerminalTokens.TokenNameMULTIPLY_EQUAL;
			break;
		case OperatorIds.DIVIDE :
			operator = TerminalTokens.TokenNameDIVIDE_EQUAL;
			break;
		case OperatorIds.AND :
			operator = TerminalTokens.TokenNameAND_EQUAL;
			break;
		case OperatorIds.OR :
			operator = TerminalTokens.TokenNameOR_EQUAL;
			break;
		case OperatorIds.XOR :
			operator = TerminalTokens.TokenNameXOR_EQUAL;
			break;
		case OperatorIds.REMAINDER :
			operator = TerminalTokens.TokenNameREMAINDER_EQUAL;
			break;
		case OperatorIds.LEFT_SHIFT :
			operator = TerminalTokens.TokenNameLEFT_SHIFT_EQUAL;
			break;
		case OperatorIds.RIGHT_SHIFT :
			operator = TerminalTokens.TokenNameRIGHT_SHIFT_EQUAL;
			break;
		default: // OperatorIds.UNSIGNED_RIGHT_SHIFT :
			operator = TerminalTokens.TokenNameUNSIGNED_RIGHT_SHIFT_EQUAL;
	}

	this.scribe.printNextToken(operator, this.preferences.insert_space_before_assignment_operator);
	if (this.preferences.insert_space_after_assignment_operator) {
		this.scribe.space();
	}
	Alignment assignmentAlignment = this.scribe.createAlignment(
			Alignment.COMPOUND_ASSIGNMENT,
			this.preferences.alignment_for_assignment,
			Alignment.R_OUTERMOST,
			1,
			this.scribe.scanner.currentPosition);
	this.scribe.enterAlignment(assignmentAlignment);
	boolean ok = false;
	do {
		try {
			this.scribe.alignFragment(assignmentAlignment, 0);
			compoundAssignment.expression.traverse(this, scope);
			ok = true;
		} catch(AlignmentException e){
			this.scribe.redoAlignment(e);
		}
	} while (!ok);
	this.scribe.exitAlignment(assignmentAlignment, true);

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

示例7: generatePostIncrement

import org.eclipse.jdt.internal.compiler.ast.CompoundAssignment; //导入依赖的package包/类
public void generatePostIncrement(BlockScope currentScope, CodeStream codeStream, CompoundAssignment postIncrement, boolean valueRequired) {
	boolean isStatic;
	FieldBinding codegenBinding = this.binding.original();
	if (codegenBinding.canBeSeenBy(this.actualReceiverType, this, currentScope)) {
		super.generatePostIncrement(currentScope, codeStream, postIncrement, valueRequired);
	} else {
		this.receiver.generateCode(currentScope, codeStream, !(isStatic = codegenBinding.isStatic()));
		if (isStatic) {
			codeStream.aconst_null();
		}
		// the actual stack is: receiver
		codeStream.dup();
		// the actual stack is: receiver receiver
		codeStream.generateEmulatedReadAccessForField(codegenBinding);
		// the actual stack is: receiver value
		// receiver value
		// value receiver value 							dup_x1 or dup2_x1 if value required
		// value value receiver value					dup_x1 or dup2_x1
		// value value receiver							pop or pop2
		// value value receiver field						generateEmulationForField
		// value value field receiver 					swap
		// value field receiver value field receiver 	dup2_x1 or dup2_x2
		// value field receiver value 				 	pop2
		// value field receiver newvalue 				generate constant + op
		// value 												store
		int typeID;
		switch (typeID = codegenBinding.type.id) {
			case TypeIds.T_long :
			case TypeIds.T_double :
				if (valueRequired) {
					codeStream.dup2_x1();
				}
				codeStream.dup2_x1();
				codeStream.pop2();
				break;
			default :
				if (valueRequired) {
					codeStream.dup_x1();
				}
				codeStream.dup_x1();
				codeStream.pop();
				break;
		}
		codeStream.generateEmulationForField(codegenBinding);
		codeStream.swap();
		switch (typeID) {
			case TypeIds.T_long :
			case TypeIds.T_double :
				codeStream.dup2_x2();
				break;
			default :
				codeStream.dup2_x1();
				break;
		}
		codeStream.pop2();

		codeStream.generateConstant(postIncrement.expression.constant, this.implicitConversion);
		codeStream.sendOperator(postIncrement.operator, codegenBinding.type.id);
		codeStream.generateImplicitConversion(postIncrement.preAssignImplicitConversion);
		codeStream.generateEmulatedWriteAccessForField(codegenBinding);
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:63,代码来源:CodeSnippetFieldReference.java

示例8: generatePostIncrement

import org.eclipse.jdt.internal.compiler.ast.CompoundAssignment; //导入依赖的package包/类
public void generatePostIncrement(BlockScope currentScope, CodeStream codeStream, CompoundAssignment postIncrement, boolean valueRequired) {
	switch (this.bits & RestrictiveFlagMASK) {
		case Binding.FIELD : // assigning to a field
			FieldBinding codegenField = ((FieldBinding) this.binding).original();
			if (codegenField.canBeSeenBy(getReceiverType(currentScope), this, currentScope)) {
				super.generatePostIncrement(currentScope, codeStream, postIncrement, valueRequired);
			} else {
				if (codegenField.isStatic()) {
					codeStream.aconst_null();
				} else {
					if ((this.bits & DepthMASK) != 0) {
						// internal error, per construction we should have found it
						// not yet supported
						currentScope.problemReporter().needImplementation(this);
					} else {
						generateReceiver(codeStream);
					}
				}
				codeStream.generateEmulatedReadAccessForField(codegenField);
				if (valueRequired) {
					switch (codegenField.type.id) {
						case TypeIds.T_long :
						case TypeIds.T_double :
							codeStream.dup2();
							break;
						default:
							codeStream.dup();
							break;
					}
				}
				codeStream.generateEmulationForField(codegenField);
				switch (codegenField.type.id) {
					case TypeIds.T_long :
					case TypeIds.T_double :
						codeStream.dup_x2();
						codeStream.pop();
						if (codegenField.isStatic()) {
							codeStream.aconst_null();
						} else {
							generateReceiver(codeStream);
						}
						codeStream.dup_x2();
						codeStream.pop();
						break;
					default:
						codeStream.dup_x1();
					codeStream.pop();
					if (codegenField.isStatic()) {
						codeStream.aconst_null();
					} else {
						generateReceiver(codeStream);
					}
					codeStream.dup_x1();
					codeStream.pop();
						break;
				}
				codeStream.generateConstant(postIncrement.expression.constant, this.implicitConversion);
				codeStream.sendOperator(postIncrement.operator, codegenField.type.id);
				codeStream.generateImplicitConversion(postIncrement.preAssignImplicitConversion);
				codeStream.generateEmulatedWriteAccessForField(codegenField);
			}
			return;
		case Binding.LOCAL : // assigning to a local variable
			super.generatePostIncrement(currentScope, codeStream, postIncrement, valueRequired);
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:67,代码来源:CodeSnippetSingleNameReference.java

示例9: generatePostIncrement

import org.eclipse.jdt.internal.compiler.ast.CompoundAssignment; //导入依赖的package包/类
public void generatePostIncrement(BlockScope currentScope, CodeStream codeStream, CompoundAssignment postIncrement, boolean valueRequired) {
    FieldBinding lastFieldBinding = this.otherBindings == null ? (FieldBinding) this.binding : this.otherBindings[this.otherBindings.length-1];
	if (lastFieldBinding.canBeSeenBy(getFinalReceiverType(), this, currentScope)) {
		super.generatePostIncrement(currentScope, codeStream, postIncrement, valueRequired);
		return;
	}
	lastFieldBinding = generateReadSequence(currentScope, codeStream);
	codeStream.generateEmulatedReadAccessForField(lastFieldBinding);
	if (valueRequired) {
		switch (lastFieldBinding.type.id) {
			case TypeIds.T_long :
			case TypeIds.T_double :
				codeStream.dup2();
				break;
			default :
				codeStream.dup();
			break;	
		}		
	}
	codeStream.generateEmulationForField(lastFieldBinding);
	if ((TypeBinding.equalsEquals(lastFieldBinding.type, TypeBinding.LONG)) || (TypeBinding.equalsEquals(lastFieldBinding.type, TypeBinding.DOUBLE))) {
		codeStream.dup_x2();
		codeStream.pop();
		if (lastFieldBinding.isStatic()) {
			codeStream.aconst_null();
		} else {
			generateReadSequence(currentScope, codeStream);
		}
		codeStream.dup_x2();
		codeStream.pop();
	} else {
		codeStream.dup_x1();
		codeStream.pop();
		if (lastFieldBinding.isStatic()) {
			codeStream.aconst_null();
		} else {
			generateReadSequence(currentScope, codeStream);
		}
		codeStream.dup_x1();
		codeStream.pop();
	}
	codeStream.generateConstant(postIncrement.expression.constant, this.implicitConversion);
	codeStream.sendOperator(postIncrement.operator, lastFieldBinding.type.id);
	codeStream.generateImplicitConversion(postIncrement.preAssignImplicitConversion);
	codeStream.generateEmulatedWriteAccessForField(lastFieldBinding);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:47,代码来源:CodeSnippetQualifiedNameReference.java

示例10: generatePostIncrement

import org.eclipse.jdt.internal.compiler.ast.CompoundAssignment; //导入依赖的package包/类
public void generatePostIncrement(BlockScope currentScope, CodeStream codeStream, CompoundAssignment postIncrement, boolean valueRequired) {
    FieldBinding lastFieldBinding = this.otherBindings == null ? (FieldBinding) this.binding : this.otherBindings[this.otherBindings.length-1];
	if (lastFieldBinding.canBeSeenBy(getFinalReceiverType(), this, currentScope)) {
		super.generatePostIncrement(currentScope, codeStream, postIncrement, valueRequired);
		return;
	}
	lastFieldBinding = generateReadSequence(currentScope, codeStream);
	codeStream.generateEmulatedReadAccessForField(lastFieldBinding);
	if (valueRequired) {
		switch (lastFieldBinding.type.id) {
			case TypeIds.T_long :
			case TypeIds.T_double :
				codeStream.dup2();
				break;
			default :
				codeStream.dup();
			break;	
		}		
	}
	codeStream.generateEmulationForField(lastFieldBinding);
	if ((lastFieldBinding.type == TypeBinding.LONG) || (lastFieldBinding.type == TypeBinding.DOUBLE)) {
		codeStream.dup_x2();
		codeStream.pop();
		if (lastFieldBinding.isStatic()) {
			codeStream.aconst_null();
		} else {
			generateReadSequence(currentScope, codeStream);
		}
		codeStream.dup_x2();
		codeStream.pop();
	} else {
		codeStream.dup_x1();
		codeStream.pop();
		if (lastFieldBinding.isStatic()) {
			codeStream.aconst_null();
		} else {
			generateReadSequence(currentScope, codeStream);
		}
		codeStream.dup_x1();
		codeStream.pop();
	}
	codeStream.generateConstant(postIncrement.expression.constant, this.implicitConversion);
	codeStream.sendOperator(postIncrement.operator, lastFieldBinding.type.id);
	codeStream.generateImplicitConversion(postIncrement.preAssignImplicitConversion);
	codeStream.generateEmulatedWriteAccessForField(lastFieldBinding);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:47,代码来源:CodeSnippetQualifiedNameReference.java

示例11: endVisit

import org.eclipse.jdt.internal.compiler.ast.CompoundAssignment; //导入依赖的package包/类
@Override
public void endVisit(CompoundAssignment x, BlockScope scope) {
  JBinaryOperator op;
  switch (x.operator) {
    case OperatorIds.PLUS:
      if (javaLangString == typeMap.get(x.resolvedType)) {
        op = JBinaryOperator.ASG_CONCAT;
      } else {
        op = JBinaryOperator.ASG_ADD;
      }
      break;
    case OperatorIds.MINUS:
      op = JBinaryOperator.ASG_SUB;
      break;
    case OperatorIds.MULTIPLY:
      op = JBinaryOperator.ASG_MUL;
      break;
    case OperatorIds.DIVIDE:
      op = JBinaryOperator.ASG_DIV;
      break;
    case OperatorIds.AND:
      op = JBinaryOperator.ASG_BIT_AND;
      break;
    case OperatorIds.OR:
      op = JBinaryOperator.ASG_BIT_OR;
      break;
    case OperatorIds.XOR:
      op = JBinaryOperator.ASG_BIT_XOR;
      break;
    case OperatorIds.REMAINDER:
      op = JBinaryOperator.ASG_MOD;
      break;
    case OperatorIds.LEFT_SHIFT:
      op = JBinaryOperator.ASG_SHL;
      break;
    case OperatorIds.RIGHT_SHIFT:
      op = JBinaryOperator.ASG_SHR;
      break;
    case OperatorIds.UNSIGNED_RIGHT_SHIFT:
      op = JBinaryOperator.ASG_SHRU;
      break;
    default:
      throw translateException(x, new InternalCompilerException(
          "Unexpected operator for CompoundAssignment"));
  }
  pushBinaryOp(x, op);
}
 
开发者ID:WeTheInternet,项目名称:xapi,代码行数:48,代码来源:GwtAstBuilder.java

示例12: visit

import org.eclipse.jdt.internal.compiler.ast.CompoundAssignment; //导入依赖的package包/类
@Override public boolean visit(CompoundAssignment node, BlockScope scope) {
	setGeneratedBy(node, source);
	applyOffsetExpression(node);
	return super.visit(node, scope);
}
 
开发者ID:redundent,项目名称:lombok,代码行数:6,代码来源:SetGeneratedByVisitor.java


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