spoon.reflect.code.CtUnaryOperator Java Examples
The following examples show how to use
spoon.reflect.code.CtUnaryOperator.
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: ExpressionRevolver.java From astor with GNU General Public License v2.0 | 6 votes |
public static List<CtExpression<Boolean>> getExpressions(CtExpression<Boolean> element) { List<CtExpression<Boolean>> expsRetrieved = new ArrayList<CtExpression<Boolean>>(); if (element instanceof CtUnaryOperator) { expsRetrieved.add(element); element = ((CtUnaryOperator) element).getOperand(); } if (element instanceof CtBinaryOperator) { expsRetrieved.add(element); CtBinaryOperator bin = (CtBinaryOperator) element; if (bin.getKind().equals(BinaryOperatorKind.AND) || bin.getKind().equals(BinaryOperatorKind.OR)) { expsRetrieved.addAll(getExpressions(bin.getLeftHandOperand())); expsRetrieved.addAll(getExpressions(bin.getRightHandOperand())); } } else { if (element instanceof CtInvocation && element.getType().getSimpleName().equals(boolean.class.getSimpleName())) { expsRetrieved.add(element); } } return expsRetrieved; }
Example #2
Source File: ReturnExpresionMutOp.java From astor with GNU General Public License v2.0 | 5 votes |
@Override public boolean canBeAppliedToPoint(ModificationPoint point) { return (point.getCodeElement() instanceof CtReturn) && (point.getCodeElement().getElements(new TypeFilter(CtBinaryOperator.class)).size() > 0 || point.getCodeElement().getElements(new TypeFilter(CtUnaryOperator.class)).size() > 0); }
Example #3
Source File: TransformStrategy.java From astor with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings({ "unchecked", "rawtypes" }) public List<String> transform () { CtStatement targetStmt = (CtStatement) this.modificationPoint.getCodeElement(); if (targetStmt instanceof CtInvocation) this.visitCtInvocation((CtInvocation) targetStmt); else if (targetStmt instanceof CtConstructorCall) this.visitCtConstructorCall((CtConstructorCall) targetStmt); else if (targetStmt instanceof CtIf) this.visitCtIf ((CtIf)targetStmt); else if (targetStmt instanceof CtReturn) this.visitCtReturn((CtReturn) targetStmt); else if (targetStmt instanceof CtSwitch) this.visitCtSwitch((CtSwitch) targetStmt); else if (targetStmt instanceof CtCase) this.visitCtCase((CtCase) targetStmt); else if (targetStmt instanceof CtAssignment) this.visitCtAssignment((CtAssignment) targetStmt); else if (targetStmt instanceof CtAssert) this.visitCtAssert((CtAssert) targetStmt); else if (targetStmt instanceof CtFor) this.visitCtFor((CtFor) targetStmt); else if (targetStmt instanceof CtForEach) this.visitCtForEach((CtForEach) targetStmt); else if (targetStmt instanceof CtWhile) this.visitCtWhile((CtWhile) targetStmt); else if (targetStmt instanceof CtUnaryOperator) this.visitCtUnaryOperator((CtUnaryOperator) targetStmt); else if (targetStmt instanceof CtSynchronized) this.visitCtSynchronized((CtSynchronized) targetStmt); return list; }
Example #4
Source File: TransformStrategy.java From astor with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override public <T> void visitCtUnaryOperator(CtUnaryOperator<T> operator) { super.visitCtUnaryOperator(operator); CtExpression exper=operator.getOperand(); if (candidates.containsKey(exper)) { operator.setOperand(candidates.get(exper)); saveSketchAndSynthesize(); operator.setOperand(exper); resoreDiskFile(); } }
Example #5
Source File: BinaryOperatorAnalyzer.java From coming with MIT License | 4 votes |
private boolean scannotoperator (CtExpression expressiontostudy) { List<String> unaryOps = new ArrayList(); CtScanner scanner = new CtScanner() { @Override public <T> void visitCtUnaryOperator(CtUnaryOperator<T> operator) { super.visitCtUnaryOperator(operator); unaryOps.add(operator.getKind().toString()); } }; scanner.scan(expressiontostudy); return unaryOps.contains(UnaryOperatorKind.NOT.toString()); }
Example #6
Source File: LabelFinder.java From gumtree-spoon-ast-diff with Apache License 2.0 | 4 votes |
@Override public <T> void visitCtUnaryOperator(CtUnaryOperator<T> operator) { label = operator.getKind().toString(); }