Java Code Examples for spoon.reflect.code.CtExpression#getElements()
The following examples show how to use
spoon.reflect.code.CtExpression#getElements() .
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: AbstractCodeAnalyzer.java From coming with MIT License | 6 votes |
/** * Return if the Condition is a guard * * @param condition * @return */ // we want the condition not to be null related check public boolean checkNormalGuardCondition(CtExpression condition) { if (condition != null) { List<CtBinaryOperator> binOp = condition.getElements(new TypeFilter<>(CtBinaryOperator.class)); if (binOp != null && binOp.size() > 0) { for (CtBinaryOperator ctBinaryOperator : binOp) { if (ctBinaryOperator.getRightHandOperand().toString().equals("null") || ctBinaryOperator.getLeftHandOperand().toString().equals("null")) { return false; } } } return true; } return false; }
Example 2
Source File: AbstractCodeAnalyzer.java From coming with MIT License | 6 votes |
public boolean checkNullCheckGuardCondition(CtExpression condition) { if (condition != null) { List<CtBinaryOperator> binOp = condition.getElements(new TypeFilter<>(CtBinaryOperator.class)); if (binOp != null && binOp.size() > 0) { for (CtBinaryOperator ctBinaryOperator : binOp) { if (!ctBinaryOperator.getRightHandOperand().toString().equals("null") && !ctBinaryOperator.getLeftHandOperand().toString().equals("null")) { return false; } } return true; } return false; } return false; }
Example 3
Source File: BinaryOperatorAnalyzer.java From coming with MIT License | 5 votes |
private void analyzeBinaryLogicalOperator(CtBinaryOperator operatorunderstudy, int operatorindex, Cntx<Object> context) { boolean whethercontainnotoperator = false; BinaryOperatorKind operatorkind = operatorunderstudy.getKind(); if(logicalOperator.contains(operatorkind)) { CtExpression leftexpression = operatorunderstudy.getLeftHandOperand(); CtExpression rightexpression = operatorunderstudy.getRightHandOperand(); List<CtBinaryOperator> logicalOperatorLeft = leftexpression.getElements( e -> e instanceof CtBinaryOperator && logicalOperator.contains(((CtBinaryOperator) e).getKind())); List<CtBinaryOperator> logicalOperatorRight = rightexpression.getElements( e -> e instanceof CtBinaryOperator && logicalOperator.contains(((CtBinaryOperator) e).getKind())); if(logicalOperatorLeft.size() == 0) { if(scannotoperator(leftexpression)) whethercontainnotoperator=true; } if(!whethercontainnotoperator && logicalOperatorRight.size() == 0) { if(scannotoperator(rightexpression)) whethercontainnotoperator=true; } } writeGroupedInfo(context, Integer.toString(operatorindex)+"_"+operatorunderstudy, CodeFeatures.O2_LOGICAL_CONTAIN_NOT, whethercontainnotoperator, "FEATURES_BINARYOPERATOR"); }