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


Java PostfixExpression类代码示例

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


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

示例1: visit

import org.eclipse.jdt.core.dom.PostfixExpression; //导入依赖的package包/类
@Override
public boolean visit(PostfixExpression exp) {
	if(exp.getOperand() instanceof SimpleName) {
		String varName = exp.getOperand().toString(); 
		VariableOperation op = null;
		if(exp.getOperator() == PostfixExpression.Operator.INCREMENT)
			op = new VariableOperation(varName, VariableOperation.Type.INC);

		else if(exp.getOperator() == PostfixExpression.Operator.DECREMENT)
			op = new VariableOperation(varName, VariableOperation.Type.DEC);

		if(op != null)
			current.addOperation(op);
	}
	return true;
}
 
开发者ID:andre-santos-pt,项目名称:pandionj,代码行数:17,代码来源:VarParser.java

示例2: analyze

import org.eclipse.jdt.core.dom.PostfixExpression; //导入依赖的package包/类
/**
 * @param expression
 */
public void analyze(Expression expression) {
    // param == null, null == param
    if (expression.getNodeType() == ASTNode.NULL_LITERAL) {
	setNullLiteral((NullLiteral) expression);
    } else if (expression.getNodeType() == ASTNode.SIMPLE_NAME) {
	setSimpleName((SimpleName) expression);
    } else if (expression.getNodeType() == ASTNode.NUMBER_LITERAL) {
	setNumberLiteral((NumberLiteral) expression);
    } else if (expression.getNodeType() == ASTNode.PREFIX_EXPRESSION) {
	setPrefixExpression((PrefixExpression) expression);
    } else if (expression.getNodeType() == ASTNode.POSTFIX_EXPRESSION) {
	setPostfixExpression((PostfixExpression) expression);
    } else if (expression.getNodeType() == ASTNode.PARENTHESIZED_EXPRESSION
	    || expression.getNodeType() == ASTNode.INFIX_EXPRESSION
	    || expression.getNodeType() == ASTNode.METHOD_INVOCATION) {
	// addTestCasesToMerge(processIfExpressions(expression,
	// tmlMethod));
    } else {
	// TODO
	System.out.println("Expression could not be analyzed: "
		+ expression.getNodeType() + ". Expression: "
		+ expression.toString());
    }
}
 
开发者ID:junit-tools-team,项目名称:junit-tools,代码行数:28,代码来源:TestCasesGenerator.java

示例3: visit

import org.eclipse.jdt.core.dom.PostfixExpression; //导入依赖的package包/类
@Override
public boolean visit(PostfixExpression node) {
  Expression operand = node.getOperand();
  if (!considerBinding(resolveBinding(operand), operand)) return true;

  ASTNode parent = node.getParent();
  if (!(parent instanceof ExpressionStatement)) {
    fStatus.addError(
        RefactoringCoreMessages
            .SelfEncapsulateField_AccessAnalyzer_cannot_convert_postfix_expression,
        JavaStatusContext.create(fCUnit, SourceRangeFactory.create(node)));
    return false;
  }
  fRewriter.replace(
      node,
      createInvocation(node.getAST(), node.getOperand(), node.getOperator().toString()),
      createGroupDescription(POSTFIX_ACCESS));
  return false;
}
 
开发者ID:eclipse,项目名称:che,代码行数:20,代码来源:AccessAnalyzer.java

示例4: isLeftValue

import org.eclipse.jdt.core.dom.PostfixExpression; //导入依赖的package包/类
private static boolean isLeftValue(ASTNode node) {
	ASTNode parent= node.getParent();
	if (parent instanceof Assignment) {
		Assignment assignment= (Assignment) parent;
		if (assignment.getLeftHandSide() == node)
			return true;
	}
	if (parent instanceof PostfixExpression)
		return true;
	if (parent instanceof PrefixExpression) {
		PrefixExpression.Operator op= ((PrefixExpression) parent).getOperator();
		if (op.equals(PrefixExpression.Operator.DECREMENT))
			return true;
		if (op.equals(PrefixExpression.Operator.INCREMENT))
			return true;
		return false;
	}
	return false;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:20,代码来源:ExtractTempRefactoring.java

示例5: visit

import org.eclipse.jdt.core.dom.PostfixExpression; //导入依赖的package包/类
@Override
public boolean visit(PostfixExpression node) {
	Expression operand= node.getOperand();
	if (!considerBinding(resolveBinding(operand), operand))
		return true;

	ASTNode parent= node.getParent();
	if (!(parent instanceof ExpressionStatement)) {
		fStatus.addError(RefactoringCoreMessages.SelfEncapsulateField_AccessAnalyzer_cannot_convert_postfix_expression,
			JavaStatusContext.create(fCUnit, SourceRangeFactory.create(node)));
		return false;
	}
	fRewriter.replace(node,
		createInvocation(node.getAST(), node.getOperand(), node.getOperator().toString()),
		createGroupDescription(POSTFIX_ACCESS));
	return false;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:18,代码来源:AccessAnalyzer.java

示例6: getExpressionPrecedence

import org.eclipse.jdt.core.dom.PostfixExpression; //导入依赖的package包/类
/**
 * Returns the precedence of the expression. Expression
 * with higher precedence are executed before expressions
 * with lower precedence.
 * i.e. in:
 * <br><code> int a= ++3--;</code></br>
 *
 * the  precedence order is
 * <ul>
 * <li>3</li>
 * <li>++</li>
 * <li>--</li>
 * <li>=</li>
 * </ul>
 * 1. 3 -(++)-> 4<br>
 * 2. 4 -(--)-> 3<br>
 * 3. 3 -(=)-> a<br>
 *
 * @param expression the expression to determine the precedence for
 * @return the precedence the higher to stronger the binding to its operand(s)
 */
public static int getExpressionPrecedence(Expression expression) {
	if (expression instanceof InfixExpression) {
		return getOperatorPrecedence(((InfixExpression)expression).getOperator());
	} else if (expression instanceof Assignment) {
		return ASSIGNMENT;
	} else if (expression instanceof ConditionalExpression) {
		return CONDITIONAL;
	} else if (expression instanceof InstanceofExpression) {
		return RELATIONAL;
	} else if (expression instanceof CastExpression) {
		return TYPEGENERATION;
	} else if (expression instanceof ClassInstanceCreation) {
		return POSTFIX;
	} else if (expression instanceof PrefixExpression) {
		return PREFIX;
	} else if (expression instanceof FieldAccess) {
		return POSTFIX;
	} else if (expression instanceof MethodInvocation) {
		return POSTFIX;
	} else if (expression instanceof ArrayAccess) {
		return POSTFIX;
	} else if (expression instanceof PostfixExpression) {
		return POSTFIX;
	}
	return Integer.MAX_VALUE;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:48,代码来源:OperatorPrecedence.java

示例7: setPostfixExpression

import org.eclipse.jdt.core.dom.PostfixExpression; //导入依赖的package包/类
/**
 * @param expression
 */
public void setPostfixExpression(PostfixExpression expression) {
    this.postfixExpressions.add(expression);
    Expression operand = expression.getOperand();
    expressionPostfixes.put(operand, expression.getOperator());
    analyze(operand);
}
 
开发者ID:junit-tools-team,项目名称:junit-tools,代码行数:10,代码来源:TestCasesGenerator.java

示例8: visit

import org.eclipse.jdt.core.dom.PostfixExpression; //导入依赖的package包/类
@Override
public boolean visit(PostfixExpression postfixExpression) {
  if (postfixExpression.getOperand() == null) return true;
  if (!(postfixExpression.getOperand() instanceof SimpleName)) return true;
  SimpleName simpleName = (SimpleName) postfixExpression.getOperand();
  if (!isNameReferenceToTemp(simpleName)) return true;

  fFirstAssignment = postfixExpression;
  return false;
}
 
开发者ID:eclipse,项目名称:che,代码行数:11,代码来源:TempAssignmentFinder.java

示例9: isLeftValue

import org.eclipse.jdt.core.dom.PostfixExpression; //导入依赖的package包/类
private static boolean isLeftValue(ASTNode node) {
  ASTNode parent = node.getParent();
  if (parent instanceof Assignment) {
    Assignment assignment = (Assignment) parent;
    if (assignment.getLeftHandSide() == node) return true;
  }
  if (parent instanceof PostfixExpression) return true;
  if (parent instanceof PrefixExpression) {
    PrefixExpression.Operator op = ((PrefixExpression) parent).getOperator();
    if (op.equals(PrefixExpression.Operator.DECREMENT)) return true;
    if (op.equals(PrefixExpression.Operator.INCREMENT)) return true;
    return false;
  }
  return false;
}
 
开发者ID:eclipse,项目名称:che,代码行数:16,代码来源:ExtractTempRefactoring.java

示例10: getExpressionPrecedence

import org.eclipse.jdt.core.dom.PostfixExpression; //导入依赖的package包/类
/**
 * Returns the precedence of the expression. Expression with higher precedence are executed before
 * expressions with lower precedence. i.e. in: <br>
 * <code> int a= ++3--;</code></br>
 *
 * <p>the precedence order is
 *
 * <ul>
 *   <li>3
 *   <li>++
 *   <li>--
 *   <li>=
 * </ul>
 *
 * 1. 3 -(++)-> 4<br>
 * 2. 4 -(--)-> 3<br>
 * 3. 3 -(=)-> a<br>
 *
 * @param expression the expression to determine the precedence for
 * @return the precedence the higher to stronger the binding to its operand(s)
 */
public static int getExpressionPrecedence(Expression expression) {
  if (expression instanceof InfixExpression) {
    return getOperatorPrecedence(((InfixExpression) expression).getOperator());
  } else if (expression instanceof Assignment) {
    return ASSIGNMENT;
  } else if (expression instanceof ConditionalExpression) {
    return CONDITIONAL;
  } else if (expression instanceof InstanceofExpression) {
    return RELATIONAL;
  } else if (expression instanceof CastExpression) {
    return TYPEGENERATION;
  } else if (expression instanceof ClassInstanceCreation) {
    return POSTFIX;
  } else if (expression instanceof PrefixExpression) {
    return PREFIX;
  } else if (expression instanceof FieldAccess) {
    return POSTFIX;
  } else if (expression instanceof MethodInvocation) {
    return POSTFIX;
  } else if (expression instanceof ArrayAccess) {
    return POSTFIX;
  } else if (expression instanceof PostfixExpression) {
    return POSTFIX;
  }
  return Integer.MAX_VALUE;
}
 
开发者ID:eclipse,项目名称:che,代码行数:48,代码来源:OperatorPrecedence.java

示例11: getLinkedIncrementExpression

import org.eclipse.jdt.core.dom.PostfixExpression; //导入依赖的package包/类
/**
 * Creates a {@link PostfixExpression} used to increment the loop variable of a <code>for</code>
 * loop to iterate over an array.
 *
 * @param rewrite the current {@link ASTRewrite} instance
 * @param variableToIncrement the name of the variable to increment
 * @return a filled {@link PostfixExpression} realizing an incrementation of the specified
 *     variable
 */
private Expression getLinkedIncrementExpression(ASTRewrite rewrite, String variableToIncrement) {
  AST ast = rewrite.getAST();
  PostfixExpression incrementLoopVariable = ast.newPostfixExpression();
  SimpleName name = ast.newSimpleName(variableToIncrement);
  addLinkedPosition(rewrite.track(name), LinkedPositionGroup.NO_STOP, name.getIdentifier());
  incrementLoopVariable.setOperand(name);
  incrementLoopVariable.setOperator(PostfixExpression.Operator.INCREMENT);
  return incrementLoopVariable;
}
 
开发者ID:eclipse,项目名称:che,代码行数:19,代码来源:GenerateForLoopAssistProposal.java

示例12: visit

import org.eclipse.jdt.core.dom.PostfixExpression; //导入依赖的package包/类
@Override
public final boolean visit(final PostfixExpression node) {
	final IVariableBinding binding= getFieldBinding(node.getOperand());
	if (binding != null)
		fWritten.add(binding.getKey());
	return true;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:8,代码来源:MoveInstanceMethodProcessor.java

示例13: visit

import org.eclipse.jdt.core.dom.PostfixExpression; //导入依赖的package包/类
@Override
public boolean visit(PostfixExpression postfixExpression) {
	if (postfixExpression.getOperand() == null)
		return true;
	if (! (postfixExpression.getOperand() instanceof SimpleName))
		return true;
	SimpleName simpleName= (SimpleName)postfixExpression.getOperand();
	if (! isNameReferenceToTemp(simpleName))
		return true;

	fFirstAssignment= postfixExpression;
	return false;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:14,代码来源:TempAssignmentFinder.java

示例14: visit

import org.eclipse.jdt.core.dom.PostfixExpression; //导入依赖的package包/类
@Override
public boolean visit(PostfixExpression node) {
	SimpleName name= getSimpleName(node.getOperand());
	if (name != null)
		addWrite(name, name.resolveBinding());
	return true;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:8,代码来源:OccurrencesFinder.java

示例15: getLinkedIncrementExpression

import org.eclipse.jdt.core.dom.PostfixExpression; //导入依赖的package包/类
/**
 * Creates a {@link PostfixExpression} used to increment the loop variable of a <code>for</code>
 * loop to iterate over an array.
 * 
 * @param rewrite the current {@link ASTRewrite} instance
 * @param variableToIncrement the name of the variable to increment
 * @return a filled {@link PostfixExpression} realizing an incrementation of the specified
 *         variable
 */
private Expression getLinkedIncrementExpression(ASTRewrite rewrite, String variableToIncrement) {
	AST ast= rewrite.getAST();
	PostfixExpression incrementLoopVariable= ast.newPostfixExpression();
	SimpleName name= ast.newSimpleName(variableToIncrement);
	addLinkedPosition(rewrite.track(name), LinkedPositionGroup.NO_STOP, name.getIdentifier());
	incrementLoopVariable.setOperand(name);
	incrementLoopVariable.setOperator(PostfixExpression.Operator.INCREMENT);
	return incrementLoopVariable;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:19,代码来源:GenerateForLoopAssistProposal.java


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