本文整理汇总了Java中org.eclipse.jdt.core.dom.PrefixExpression.getOperand方法的典型用法代码示例。如果您正苦于以下问题:Java PrefixExpression.getOperand方法的具体用法?Java PrefixExpression.getOperand怎么用?Java PrefixExpression.getOperand使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.dom.PrefixExpression
的用法示例。
在下文中一共展示了PrefixExpression.getOperand方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visit
import org.eclipse.jdt.core.dom.PrefixExpression; //导入方法依赖的package包/类
@Override
public boolean visit(PrefixExpression exp) {
if(exp.getOperand() instanceof SimpleName) {
String varName = exp.getOperand().toString();
VariableOperation op = null;
if(exp.getOperator() == PrefixExpression.Operator.INCREMENT)
op = new VariableOperation(varName, VariableOperation.Type.INC);
else if(exp.getOperator() == PrefixExpression.Operator.DECREMENT)
op = new VariableOperation(varName, VariableOperation.Type.DEC);
if(op != null)
current.addOperation(op);
}
return true;
}
示例2: getNumber
import org.eclipse.jdt.core.dom.PrefixExpression; //导入方法依赖的package包/类
protected String getNumber(PrefixExpression prefixExpression) {
String number = null;
Expression operand = prefixExpression.getOperand();
if (operand.getNodeType() == ASTNode.NUMBER_LITERAL) {
org.eclipse.jdt.core.dom.PrefixExpression.Operator operator = prefixExpression
.getOperator();
if (org.eclipse.jdt.core.dom.PrefixExpression.Operator.MINUS
.equals(operator)) {
number = "-" + operand.toString();
} else if (org.eclipse.jdt.core.dom.PrefixExpression.Operator.PLUS
.equals(operator)
|| org.eclipse.jdt.core.dom.PrefixExpression.Operator.DECREMENT
.equals(operator)
|| org.eclipse.jdt.core.dom.PrefixExpression.Operator.INCREMENT
.equals(operator)) {
number = operand.toString();
} else {
number = "0";
}
}
return number;
}
示例3: visit
import org.eclipse.jdt.core.dom.PrefixExpression; //导入方法依赖的package包/类
@Override
public boolean visit(PrefixExpression node) {
Expression operand = node.getOperand();
if (!considerBinding(resolveBinding(operand), operand)) return true;
PrefixExpression.Operator operator = node.getOperator();
if (operator != PrefixExpression.Operator.INCREMENT
&& operator != PrefixExpression.Operator.DECREMENT) return true;
checkParent(node);
fRewriter.replace(
node,
createInvocation(node.getAST(), node.getOperand(), node.getOperator().toString()),
createGroupDescription(PREFIX_ACCESS));
return false;
}
示例4: visit
import org.eclipse.jdt.core.dom.PrefixExpression; //导入方法依赖的package包/类
@Override
public boolean visit(PrefixExpression prefixExpression) {
if (prefixExpression.getOperand() == null)
return true;
if (! (prefixExpression.getOperand() instanceof SimpleName))
return true;
if (! prefixExpression.getOperator().equals(Operator.DECREMENT) &&
! prefixExpression.getOperator().equals(Operator.INCREMENT))
return true;
SimpleName simpleName= (SimpleName)prefixExpression.getOperand();
if (! isNameReferenceToTemp(simpleName))
return true;
fFirstAssignment= prefixExpression;
return false;
}
示例5: visit
import org.eclipse.jdt.core.dom.PrefixExpression; //导入方法依赖的package包/类
@Override
public boolean visit(PrefixExpression node) {
Expression operand= node.getOperand();
if (!considerBinding(resolveBinding(operand), operand))
return true;
PrefixExpression.Operator operator= node.getOperator();
if (operator != PrefixExpression.Operator.INCREMENT && operator != PrefixExpression.Operator.DECREMENT)
return true;
checkParent(node);
fRewriter.replace(node,
createInvocation(node.getAST(), node.getOperand(), node.getOperator().toString()),
createGroupDescription(PREFIX_ACCESS));
return false;
}
示例6: setPrefixExpression
import org.eclipse.jdt.core.dom.PrefixExpression; //导入方法依赖的package包/类
/**
* @param expression
*/
public void setPrefixExpression(PrefixExpression expression) {
this.prefixExpressions.add(expression);
Expression operand = expression.getOperand();
expressionPrefixes.put(operand, expression.getOperator());
analyze(operand);
}
示例7: visit
import org.eclipse.jdt.core.dom.PrefixExpression; //导入方法依赖的package包/类
@Override
public boolean visit(PrefixExpression prefixExpression) {
if (prefixExpression.getOperand() == null) return true;
if (!(prefixExpression.getOperand() instanceof SimpleName)) return true;
if (!prefixExpression.getOperator().equals(Operator.DECREMENT)
&& !prefixExpression.getOperator().equals(Operator.INCREMENT)) return true;
SimpleName simpleName = (SimpleName) prefixExpression.getOperand();
if (!isNameReferenceToTemp(simpleName)) return true;
fFirstAssignment = prefixExpression;
return false;
}
示例8: retrieveVariableReference
import org.eclipse.jdt.core.dom.PrefixExpression; //导入方法依赖的package包/类
private VariableReference retrieveVariableReference(PrefixExpression prefixExpr,
Class<?> numberClass) {
if (prefixExpr.getOperator() == org.eclipse.jdt.core.dom.PrefixExpression.Operator.MINUS) {
NumberLiteral numberLiteral = (NumberLiteral) prefixExpr.getOperand();
Number value = (Number) numberLiteral.resolveConstantExpressionValue();
value = negate(value);
PrimitiveStatement<?> numberAssignment = createPrimitiveStatement(numberClass,
value);
testCase.addStatement(numberAssignment);
return numberAssignment.getReturnValue();
}
throw new UnsupportedOperationException("Prefix " + prefixExpr
+ " not implemented!");
}