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


Java InfixExpression.setLeftOperand方法代码示例

本文整理汇总了Java中org.eclipse.jdt.core.dom.InfixExpression.setLeftOperand方法的典型用法代码示例。如果您正苦于以下问题:Java InfixExpression.setLeftOperand方法的具体用法?Java InfixExpression.setLeftOperand怎么用?Java InfixExpression.setLeftOperand使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jdt.core.dom.InfixExpression的用法示例。


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

示例1: createInvocation

import org.eclipse.jdt.core.dom.InfixExpression; //导入方法依赖的package包/类
private MethodInvocation createInvocation(AST ast, Expression operand, String operator) {
  Expression receiver = getReceiver(operand);
  MethodInvocation invocation = ast.newMethodInvocation();
  invocation.setName(ast.newSimpleName(fSetter));
  if (receiver != null)
    invocation.setExpression((Expression) fRewriter.createCopyTarget(receiver));
  InfixExpression argument = ast.newInfixExpression();
  invocation.arguments().add(argument);
  if ("++".equals(operator)) { // $NON-NLS-1$
    argument.setOperator(InfixExpression.Operator.PLUS);
  } else if ("--".equals(operator)) { // $NON-NLS-1$
    argument.setOperator(InfixExpression.Operator.MINUS);
  } else {
    Assert.isTrue(false, "Should not happen"); // $NON-NLS-1$
  }
  MethodInvocation getter = ast.newMethodInvocation();
  getter.setName(ast.newSimpleName(fGetter));
  if (receiver != null) getter.setExpression((Expression) fRewriter.createCopyTarget(receiver));
  argument.setLeftOperand(getter);
  argument.setRightOperand(ast.newNumberLiteral("1")); // $NON-NLS-1$

  fReferencingGetter = true;
  fReferencingSetter = true;

  return invocation;
}
 
开发者ID:eclipse,项目名称:che,代码行数:27,代码来源:AccessAnalyzer.java

示例2: getLinkedInfixExpression

import org.eclipse.jdt.core.dom.InfixExpression; //导入方法依赖的package包/类
/**
 * Creates an {@link InfixExpression} which is linked to the group of the variableToIncrement.
 *
 * @param rewrite the current {@link ASTRewrite} instance
 * @param variableToIncrement the name of the variable to generate the {@link InfixExpression} for
 * @param rightHandSide the right hand side expression which shall be included in the {@link
 *     InfixExpression}
 * @param operator the {@link org.eclipse.jdt.core.dom.InfixExpression.Operator} to use in the
 *     {@link InfixExpression} to create
 * @return a filled, new {@link InfixExpression} instance
 */
private InfixExpression getLinkedInfixExpression(
    ASTRewrite rewrite,
    String variableToIncrement,
    Expression rightHandSide,
    InfixExpression.Operator operator) {
  AST ast = rewrite.getAST();
  InfixExpression loopExpression = ast.newInfixExpression();
  SimpleName name = ast.newSimpleName(variableToIncrement);
  addLinkedPosition(rewrite.track(name), LinkedPositionGroup.NO_STOP, name.getIdentifier());
  loopExpression.setLeftOperand(name);

  loopExpression.setOperator(operator);

  loopExpression.setRightOperand(rightHandSide);
  return loopExpression;
}
 
开发者ID:eclipse,项目名称:che,代码行数:28,代码来源:GenerateForLoopAssistProposal.java

示例3: createCorrectOddnessCheck

import org.eclipse.jdt.core.dom.InfixExpression; //导入方法依赖的package包/类
/**
 * Creates the new <CODE>InfixExpression</CODE> <CODE>x % 2 != 0</CODE>
 */
@Override
protected InfixExpression createCorrectOddnessCheck(ASTRewrite rewrite, Expression numberExpression) {
    Assert.isNotNull(rewrite);
    Assert.isNotNull(numberExpression);

    final AST ast = rewrite.getAST();
    InfixExpression correctOddnessCheck = ast.newInfixExpression();
    InfixExpression remainderExp = ast.newInfixExpression();

    correctOddnessCheck.setLeftOperand(remainderExp);
    correctOddnessCheck.setOperator(NOT_EQUALS);
    correctOddnessCheck.setRightOperand(ast.newNumberLiteral("0"));

    remainderExp.setLeftOperand((Expression) rewrite.createMoveTarget(numberExpression));
    remainderExp.setOperator(REMAINDER);
    remainderExp.setRightOperand(ast.newNumberLiteral("2"));

    return correctOddnessCheck;
}
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:23,代码来源:CreateRemainderOddnessCheckResolution.java

示例4: createAddQualifiedHashCode

import org.eclipse.jdt.core.dom.InfixExpression; //导入方法依赖的package包/类
private Statement createAddQualifiedHashCode(IVariableBinding binding) {

		MethodInvocation invoc= fAst.newMethodInvocation();
		invoc.setExpression(getThisAccessForHashCode(binding.getName()));
		invoc.setName(fAst.newSimpleName(METHODNAME_HASH_CODE));

		InfixExpression expr= fAst.newInfixExpression();
		expr.setOperator(Operator.EQUALS);
		expr.setLeftOperand(getThisAccessForHashCode(binding.getName()));
		expr.setRightOperand(fAst.newNullLiteral());

		ConditionalExpression cexpr= fAst.newConditionalExpression();
		cexpr.setThenExpression(fAst.newNumberLiteral("0")); //$NON-NLS-1$
		cexpr.setElseExpression(invoc);
		cexpr.setExpression(parenthesize(expr));

		return prepareAssignment(parenthesize(cexpr));
	}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:19,代码来源:GenerateHashCodeEqualsOperation.java

示例5: createCorrectOddnessCheck

import org.eclipse.jdt.core.dom.InfixExpression; //导入方法依赖的package包/类
/**
 * Creates the new <CODE>InfixExpression</CODE> <CODE>(x & 1) == 1</CODE>.
 */
@Override
protected InfixExpression createCorrectOddnessCheck(ASTRewrite rewrite, Expression numberExpression) {
    Assert.isNotNull(rewrite);
    Assert.isNotNull(numberExpression);

    final AST ast = rewrite.getAST();
    InfixExpression andOddnessCheck = ast.newInfixExpression();
    ParenthesizedExpression parenthesizedExpression = ast.newParenthesizedExpression();
    InfixExpression andExpression = ast.newInfixExpression();

    andExpression.setLeftOperand((Expression) rewrite.createMoveTarget(numberExpression));
    andExpression.setOperator(AND);
    andExpression.setRightOperand(ast.newNumberLiteral("1"));
    parenthesizedExpression.setExpression(andExpression);
    andOddnessCheck.setLeftOperand(parenthesizedExpression);
    andOddnessCheck.setOperator(EQUALS);
    andOddnessCheck.setRightOperand(ast.newNumberLiteral("1"));

    return andOddnessCheck;

}
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:25,代码来源:CreateAndOddnessCheckResolution.java

示例6: createShiftAssignment

import org.eclipse.jdt.core.dom.InfixExpression; //导入方法依赖的package包/类
private Expression createShiftAssignment(Expression shift1, Expression shift2) {
	// (int)(element ^ (element >>> 32));
	// see implementation in Arrays.hashCode(), Double.hashCode() and
	// Long.hashCode()
	CastExpression ce= fAst.newCastExpression();
	ce.setType(fAst.newPrimitiveType(PrimitiveType.INT));

	InfixExpression unsignedShiftRight= fAst.newInfixExpression();
	unsignedShiftRight.setLeftOperand(shift1);
	unsignedShiftRight.setRightOperand(fAst.newNumberLiteral("32")); //$NON-NLS-1$
	unsignedShiftRight.setOperator(Operator.RIGHT_SHIFT_UNSIGNED);

	InfixExpression xor= fAst.newInfixExpression();
	xor.setLeftOperand(shift2);
	xor.setRightOperand(parenthesize(unsignedShiftRight));
	xor.setOperator(InfixExpression.Operator.XOR);

	ce.setExpression(parenthesize(xor));
	return ce;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:21,代码来源:GenerateHashCodeEqualsOperation.java

示例7: combineOperands

import org.eclipse.jdt.core.dom.InfixExpression; //导入方法依赖的package包/类
private static Expression combineOperands(ASTRewrite rewrite, Expression existing, Expression originalNode, boolean removeParentheses, Operator operator) {
	if (existing == null && removeParentheses) {
		while (originalNode instanceof ParenthesizedExpression) {
			originalNode= ((ParenthesizedExpression)originalNode).getExpression();
		}
	}
	Expression newRight= (Expression)rewrite.createMoveTarget(originalNode);
	if (originalNode instanceof InfixExpression) {
		((InfixExpression)newRight).setOperator(((InfixExpression)originalNode).getOperator());
	}

	if (existing == null) {
		return newRight;
	}
	AST ast= rewrite.getAST();
	InfixExpression infix= ast.newInfixExpression();
	infix.setOperator(operator);
	infix.setLeftOperand(existing);
	infix.setRightOperand(newRight);
	return infix;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:22,代码来源:AdvancedQuickAssistProcessor.java

示例8: getInversedAndOrExpression

import org.eclipse.jdt.core.dom.InfixExpression; //导入方法依赖的package包/类
private static Expression getInversedAndOrExpression(ASTRewrite rewrite, InfixExpression infixExpression, Operator newOperator, SimpleNameRenameProvider provider) {
	InfixExpression newExpression= rewrite.getAST().newInfixExpression();
	newExpression.setOperator(newOperator);

	int newOperatorPrecedence= OperatorPrecedence.getOperatorPrecedence(newOperator);
	//
	Expression leftOperand= getInversedExpression(rewrite, infixExpression.getLeftOperand(), provider);
	newExpression.setLeftOperand(parenthesizeIfRequired(leftOperand, newOperatorPrecedence));

	Expression rightOperand= getInversedExpression(rewrite, infixExpression.getRightOperand(), provider);
	newExpression.setRightOperand(parenthesizeIfRequired(rightOperand, newOperatorPrecedence));

	List<Expression> extraOperands= infixExpression.extendedOperands();
	List<Expression> newExtraOperands= newExpression.extendedOperands();
	for (int i= 0; i < extraOperands.size(); i++) {
		Expression extraOperand= getInversedExpression(rewrite, extraOperands.get(i), provider);
		newExtraOperands.add(parenthesizeIfRequired(extraOperand, newOperatorPrecedence));
	}
	return newExpression;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:21,代码来源:AdvancedQuickAssistProcessor.java

示例9: newInfixExpression

import org.eclipse.jdt.core.dom.InfixExpression; //导入方法依赖的package包/类
public static Expression newInfixExpression(AST ast, Operator operator, ArrayList<Expression> operands) {
	if (operands.size() == 1) {
		return operands.get(0);
	}

	InfixExpression result= ast.newInfixExpression();
	result.setOperator(operator);
	result.setLeftOperand(operands.get(0));
	result.setRightOperand(operands.get(1));
	result.extendedOperands().addAll(operands.subList(2, operands.size()));
	return result;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:13,代码来源:ASTNodeFactory.java

示例10: createInfixInvocationFromPostPrefixExpression

import org.eclipse.jdt.core.dom.InfixExpression; //导入方法依赖的package包/类
private static Expression createInfixInvocationFromPostPrefixExpression(InfixExpression.Operator operator, Expression getterExpression, AST ast, ITypeBinding variableType, boolean is50OrHigher) {
	InfixExpression infix = ast.newInfixExpression();
	infix.setLeftOperand(getterExpression);
	infix.setOperator(operator);
	NumberLiteral number = ast.newNumberLiteral();
	number.setToken("1"); //$NON-NLS-1$
	infix.setRightOperand(number);
	ITypeBinding infixType = infix.resolveTypeBinding();
	return createNarrowCastIfNessecary(infix, infixType, ast, variableType, is50OrHigher);
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:11,代码来源:GetterSetterUtil.java

示例11: newInfixExpression

import org.eclipse.jdt.core.dom.InfixExpression; //导入方法依赖的package包/类
public static Expression newInfixExpression(
    AST ast, Operator operator, ArrayList<Expression> operands) {
  if (operands.size() == 1) return operands.get(0);

  InfixExpression result = ast.newInfixExpression();
  result.setOperator(operator);
  result.setLeftOperand(operands.get(0));
  result.setRightOperand(operands.get(1));
  result.extendedOperands().addAll(operands.subList(2, operands.size()));
  return result;
}
 
开发者ID:eclipse,项目名称:che,代码行数:12,代码来源:ASTNodeFactory.java

示例12: createInfixInvocationFromPostPrefixExpression

import org.eclipse.jdt.core.dom.InfixExpression; //导入方法依赖的package包/类
private static Expression createInfixInvocationFromPostPrefixExpression(
    InfixExpression.Operator operator,
    Expression getterExpression,
    AST ast,
    ITypeBinding variableType,
    boolean is50OrHigher) {
  InfixExpression infix = ast.newInfixExpression();
  infix.setLeftOperand(getterExpression);
  infix.setOperator(operator);
  NumberLiteral number = ast.newNumberLiteral();
  number.setToken("1"); // $NON-NLS-1$
  infix.setRightOperand(number);
  ITypeBinding infixType = infix.resolveTypeBinding();
  return createNarrowCastIfNessecary(infix, infixType, ast, variableType, is50OrHigher);
}
 
开发者ID:eclipse,项目名称:che,代码行数:16,代码来源:GetterSetterUtil.java

示例13: visit

import org.eclipse.jdt.core.dom.InfixExpression; //导入方法依赖的package包/类
@Override
public boolean visit(Assignment node) {
  Expression leftHandSide = node.getLeftHandSide();
  if (!considerBinding(resolveBinding(leftHandSide), leftHandSide)) return true;

  checkParent(node);
  Expression rightHandSide = node.getRightHandSide();
  if (!fIsFieldFinal) {
    // Write access.
    AST ast = node.getAST();
    MethodInvocation invocation = ast.newMethodInvocation();
    invocation.setName(ast.newSimpleName(fSetter));
    fReferencingSetter = true;
    Expression receiver = getReceiver(leftHandSide);
    if (receiver != null)
      invocation.setExpression((Expression) fRewriter.createCopyTarget(receiver));
    List<Expression> arguments = invocation.arguments();
    if (node.getOperator() == Assignment.Operator.ASSIGN) {
      arguments.add((Expression) fRewriter.createCopyTarget(rightHandSide));
    } else {
      // This is the compound assignment case: field+= 10;
      InfixExpression exp = ast.newInfixExpression();
      exp.setOperator(ASTNodes.convertToInfixOperator(node.getOperator()));
      MethodInvocation getter = ast.newMethodInvocation();
      getter.setName(ast.newSimpleName(fGetter));
      fReferencingGetter = true;
      if (receiver != null)
        getter.setExpression((Expression) fRewriter.createCopyTarget(receiver));
      exp.setLeftOperand(getter);
      Expression rhs = (Expression) fRewriter.createCopyTarget(rightHandSide);
      if (NecessaryParenthesesChecker.needsParenthesesForRightOperand(
          rightHandSide, exp, leftHandSide.resolveTypeBinding())) {
        ParenthesizedExpression p = ast.newParenthesizedExpression();
        p.setExpression(rhs);
        rhs = p;
      }
      exp.setRightOperand(rhs);
      arguments.add(exp);
    }
    fRewriter.replace(node, invocation, createGroupDescription(WRITE_ACCESS));
  }
  rightHandSide.accept(this);
  return false;
}
 
开发者ID:eclipse,项目名称:che,代码行数:45,代码来源:AccessAnalyzer.java

示例14: createInvocation

import org.eclipse.jdt.core.dom.InfixExpression; //导入方法依赖的package包/类
private MethodInvocation createInvocation(AST ast, Expression operand, String operator) {
	Expression receiver= getReceiver(operand);
	MethodInvocation invocation= ast.newMethodInvocation();
	invocation.setName(ast.newSimpleName(fSetter));
	if (receiver != null)
		invocation.setExpression((Expression)fRewriter.createCopyTarget(receiver));
	InfixExpression argument= ast.newInfixExpression();
	invocation.arguments().add(argument);
	if ("++".equals(operator)) { //$NON-NLS-1$
		argument.setOperator(InfixExpression.Operator.PLUS);
	} else if ("--".equals(operator)) { //$NON-NLS-1$
		argument.setOperator(InfixExpression.Operator.MINUS);
	} else {
		Assert.isTrue(false, "Should not happen"); //$NON-NLS-1$
	}
	MethodInvocation getter= ast.newMethodInvocation();
	getter.setName(ast.newSimpleName(fGetter));
	if (receiver != null)
		getter.setExpression((Expression)fRewriter.createCopyTarget(receiver));
	argument.setLeftOperand(getter);
	argument.setRightOperand(ast.newNumberLiteral("1")); //$NON-NLS-1$

	fReferencingGetter= true;
	fReferencingSetter= true;

	return invocation;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:28,代码来源:AccessAnalyzer.java

示例15: newInfixExpression

import org.eclipse.jdt.core.dom.InfixExpression; //导入方法依赖的package包/类
public static Expression newInfixExpression(AST ast, Operator operator, ArrayList<Expression> operands) {
	if (operands.size() == 1)
		return operands.get(0);

	InfixExpression result= ast.newInfixExpression();
	result.setOperator(operator);
	result.setLeftOperand(operands.get(0));
	result.setRightOperand(operands.get(1));
	result.extendedOperands().addAll(operands.subList(2, operands.size()));
	return result;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:12,代码来源:ASTNodeFactory.java


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