Java Code Examples for org.eclipse.jdt.core.dom.PrefixExpression#Operator
The following examples show how to use
org.eclipse.jdt.core.dom.PrefixExpression#Operator .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JdtUtils.java From j2cl with Apache License 2.0 | 6 votes |
public static PrefixOperator getPrefixOperator(PrefixExpression.Operator operator) { switch (operator.toString()) { case "++": return PrefixOperator.INCREMENT; case "--": return PrefixOperator.DECREMENT; case "+": return PrefixOperator.PLUS; case "-": return PrefixOperator.MINUS; case "~": return PrefixOperator.COMPLEMENT; case "!": return PrefixOperator.NOT; default: return null; } }
Example 2
Source File: ExtractTempRefactoring.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
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; }
Example 3
Source File: ExtractFieldRefactoring.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
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; }
Example 4
Source File: AccessAnalyzer.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
@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; }
Example 5
Source File: ExtractTempRefactoring.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
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; }
Example 6
Source File: AccessAnalyzer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@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; }
Example 7
Source File: FlowAnalyzer.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
@Override public void endVisit(PrefixExpression node) { PrefixExpression.Operator op = node.getOperator(); if (PrefixExpression.Operator.INCREMENT.equals(op) || PrefixExpression.Operator.DECREMENT.equals(op)) { endVisitIncDecOperation(node, node.getOperand()); } else { assignFlowInfo(node, node.getOperand()); } }
Example 8
Source File: FlowAnalyzer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public void endVisit(PrefixExpression node) { PrefixExpression.Operator op= node.getOperator(); if (PrefixExpression.Operator.INCREMENT.equals(op) || PrefixExpression.Operator.DECREMENT.equals(op)) { endVisitIncDecOperation(node, node.getOperand()); } else { assignFlowInfo(node, node.getOperand()); } }
Example 9
Source File: OccurrencesFinder.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public boolean visit(PrefixExpression node) { PrefixExpression.Operator operator= node.getOperator(); if (operator == Operator.INCREMENT || operator == Operator.DECREMENT) { SimpleName name= getSimpleName(node.getOperand()); if (name != null) addWrite(name, name.resolveBinding()); } return true; }
Example 10
Source File: ASTResolving.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public static boolean isWriteAccess(Name selectedNode) { ASTNode curr= selectedNode; ASTNode parent= curr.getParent(); while (parent != null) { switch (parent.getNodeType()) { case ASTNode.QUALIFIED_NAME: if (((QualifiedName) parent).getQualifier() == curr) { return false; } break; case ASTNode.FIELD_ACCESS: if (((FieldAccess) parent).getExpression() == curr) { return false; } break; case ASTNode.SUPER_FIELD_ACCESS: break; case ASTNode.ASSIGNMENT: return ((Assignment) parent).getLeftHandSide() == curr; case ASTNode.VARIABLE_DECLARATION_FRAGMENT: case ASTNode.SINGLE_VARIABLE_DECLARATION: return ((VariableDeclaration) parent).getName() == curr; case ASTNode.POSTFIX_EXPRESSION: return true; case ASTNode.PREFIX_EXPRESSION: PrefixExpression.Operator op= ((PrefixExpression) parent).getOperator(); return op == PrefixExpression.Operator.DECREMENT || op == PrefixExpression.Operator.INCREMENT; default: return false; } curr= parent; parent= curr.getParent(); } return false; }
Example 11
Source File: AbstractMethodFragment.java From JDeodorant with MIT License | 5 votes |
private Set<PrefixExpression> getMatchingPrefixAssignments(SimpleName simpleName, List<Expression> prefixExpressions) { Set<PrefixExpression> matchingPrefixAssignments = new LinkedHashSet<PrefixExpression>(); for(Expression expression : prefixExpressions) { PrefixExpression prefixExpression = (PrefixExpression)expression; Expression operand = prefixExpression.getOperand(); PrefixExpression.Operator operator = prefixExpression.getOperator(); SimpleName operandName = MethodDeclarationUtility.getRightMostSimpleName(operand); if(operandName != null && operandName.equals(simpleName) && (operator.equals(PrefixExpression.Operator.INCREMENT) || operator.equals(PrefixExpression.Operator.DECREMENT))) { matchingPrefixAssignments.add(prefixExpression); } } return matchingPrefixAssignments; }
Example 12
Source File: PrefixExpr.java From SimFix with GNU General Public License v2.0 | 4 votes |
public void setOperator(PrefixExpression.Operator operator){ _operator = operator; }
Example 13
Source File: JavaASTFlattener.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
@Override public boolean visit(final PrefixExpression node) { final Expression operand = node.getOperand(); PrefixExpression.Operator _operator = node.getOperator(); boolean _matched = false; if (Objects.equal(_operator, PrefixExpression.Operator.DECREMENT)) { _matched=true; } if (!_matched) { if (Objects.equal(_operator, PrefixExpression.Operator.INCREMENT)) { _matched=true; } } if (_matched) { if ((operand instanceof ArrayAccess)) { final String arrayName = this.computeArrayName(((ArrayAccess)operand)); StringConcatenation _builder = new StringConcatenation(); _builder.append("_tPreInx_"); _builder.append(arrayName); final String idxName = _builder.toString(); String op = "-"; PrefixExpression.Operator _operator_1 = node.getOperator(); boolean _equals = Objects.equal(_operator_1, PrefixExpression.Operator.INCREMENT); if (_equals) { op = "+"; } StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("{val "); _builder_1.append(idxName); _builder_1.append("="); this.appendToBuffer(_builder_1.toString()); ((ArrayAccess)operand).getIndex().accept(this); StringConcatenation _builder_2 = new StringConcatenation(); _builder_2.append(" "); _builder_2.append("val "); _builder_2.append(idxName, " "); _builder_2.append("_res="); _builder_2.append(arrayName, " "); _builder_2.append(".get("); _builder_2.append(idxName, " "); _builder_2.append(")"); _builder_2.append(op, " "); _builder_2.append("1"); this.appendToBuffer(_builder_2.toString()); StringConcatenation _builder_3 = new StringConcatenation(); _builder_3.append(" "); _builder_3.append(arrayName, " "); _builder_3.append(".set("); _builder_3.append(idxName, " "); _builder_3.append(", "); _builder_3.append(idxName, " "); _builder_3.append("_res) "); _builder_3.append(idxName, " "); _builder_3.append("_res}"); this.appendToBuffer(_builder_3.toString()); return false; } else { final AST dummyAST = AST.newAST(node.getAST().apiLevel()); final Assignment assigment = dummyAST.newAssignment(); final InfixExpression infixOp = dummyAST.newInfixExpression(); ASTNode _copySubtree = ASTNode.copySubtree(dummyAST, operand); infixOp.setLeftOperand(((Expression) _copySubtree)); PrefixExpression.Operator _operator_2 = node.getOperator(); boolean _equals_1 = Objects.equal(_operator_2, PrefixExpression.Operator.DECREMENT); if (_equals_1) { infixOp.setOperator(InfixExpression.Operator.MINUS); } else { infixOp.setOperator(InfixExpression.Operator.PLUS); } infixOp.setRightOperand(dummyAST.newNumberLiteral("1")); ASTNode _copySubtree_1 = ASTNode.copySubtree(dummyAST, operand); final Expression leftSide = ((Expression) _copySubtree_1); assigment.setLeftHandSide(leftSide); assigment.setRightHandSide(infixOp); this.appendToBuffer("{"); Type type = null; if ((operand instanceof SimpleName)) { type = this._aSTFlattenerUtils.findDeclaredType(((SimpleName)operand)); } this.handleAssignment(assigment, leftSide, type); this.appendToBuffer("}"); return false; } } if (!_matched) { if (Objects.equal(_operator, PrefixExpression.Operator.COMPLEMENT)) { _matched=true; node.getOperand().accept(this); this.appendToBuffer(".bitwiseNot"); } } if (!_matched) { { this.appendToBuffer(node.getOperator().toString()); node.getOperand().accept(this); } } return false; }