コード例 #1
0
 /**
  * Replaces the element by an statement list containing all unary operators in the element
  *
  * @param element
  */
 private void replaceByUnaryBlock(CtElement element) {
   CtBlock<CtUnaryOperator> opBlock = new CtBlockImpl<CtUnaryOperator>();
   for (CtUnaryOperator s :
       element.getElements(new TypeFilter<CtUnaryOperator>(CtUnaryOperator.class)))
     if (s.getKind().compareTo(UnaryOperatorKind.PREINC) >= 0) {
       s.setParent(null);
       opBlock.addStatement(s);
       s.setParent(opBlock);
     }
   element.replace(opBlock);
 }
コード例 #2
0
 /**
  * Indicates that contains operation assignment over variables non local to the element
  *
  * @param element
  * @return
  */
 private boolean containNonLocalOperatorAssignment(CtElement element) {
   // Handling operators assignment
   for (CtOperatorAssignment op :
       element.getElements(new TypeFilter<CtOperatorAssignment>(CtOperatorAssignment.class))) {
     for (CtVariableAccess a : accessOfExpression(op.getAssigned())) {
       // Add cyclic dependencies
       if (!declaredInsideBlock.contains(a.getVariable())) return true;
     }
   }
   return false;
 }
コード例 #3
0
 /**
  * Indicates if the element contains unary operators acting on variables declared outside the
  * block being degraded
  *
  * @param element Element to inspect
  * @return True if contains
  */
 private boolean containsNonLocalUnaryOperators(CtElement element) {
   // Handling unary operators
   for (CtUnaryOperator op :
       element.getElements(new TypeFilter<CtUnaryOperator>(CtUnaryOperator.class))) {
     for (CtVariableAccess a : accessOfExpression(op)) {
       // We don't care about cyclic dependencies to vars declared inside the block being degraded
       if (!declaredInsideBlock.contains(a.getVariable())) return true;
     }
   }
   return false;
 }