public void putVarsNotDuplicated(CtElement elementToAnalyze, List<CtVariableAccess> varsToBeParameters) { List<CtVariableAccess> varsFromExpression = elementToAnalyze.getElements(e -> e instanceof CtVariableAccess); for (CtVariableAccess ctVariableAccess : varsFromExpression) { if (!varsToBeParameters.contains(ctVariableAccess)) varsToBeParameters.add(ctVariableAccess); } }
void removeAllStageAnnotations(CtElement element) { element.getElements(e -> { List<CtAnnotation<? extends Annotation>> stagedAnnotations = e.getAnnotations().stream().filter(a -> { CtTypeReference<? extends Annotation> annType = a.getAnnotationType(); TypeFactory tf = a.getFactory().Type(); return annType.equals(tf.createReference(Stage.class)) || annType.equals(tf.createReference(Staged.class)) || annType.equals(tf.createReference(StageRef.class)); }).collect(toList()); if (!stagedAnnotations.isEmpty()) { stagedAnnotations.forEach(e::removeAnnotation); } return false; }); }
public static void clearPosition(CtElement expCloned) { expCloned.setPosition(new NoSourcePosition()); expCloned.getElements(e -> true).stream().forEach(e -> e.setPosition(new NoSourcePosition())); }
Map elements; if (cls.equals(CtType.class)) { elements = locations.stream().flatMap(l -> l.getElements(new TypeFilter<CtType>(CtType.class) { @Override public boolean matches(CtType element) { for (CtElement location : locations) { List<CtExecutable> elementsfromLocation = location .getElements(new TypeFilter<CtExecutable>(CtExecutable.class) { @Override public boolean matches(CtExecutable element) {
if (cls.equals(CtType.class)) { elements = locations.stream() .flatMap(l -> l.getElements(new TypeFilter<CtType>(CtType.class) { @Override public boolean matches(CtType element) { List<CtExecutable> elementsfromLocation = location.getElements(new TypeFilter<CtExecutable>(CtExecutable.class) { @Override public boolean matches(CtExecutable element) {
private MapList<CtInvocation, Ingredient> retrieveMethodHasCompatibleParameterAndReturnSameMethod( CtElement suspiciousElement) { MapList<CtInvocation, Ingredient> result = new MapList<CtInvocation, Ingredient>(); List<CtInvocation> invocations = suspiciousElement.getElements(e -> (e instanceof CtInvocation)).stream() .map(CtInvocation.class::cast).collect(Collectors.toList()); for (CtInvocation invocation : invocations) { for (Object oparameter : invocation.getArguments()) { CtExpression argument = (CtExpression) oparameter; if (SupportOperators.compareTypes(invocation.getType(), argument.getType())) { CtExpression clonedExpressionArgument = argument.clone(); MutationSupporter.clearPosition(clonedExpressionArgument); Ingredient newIngredient = new Ingredient(clonedExpressionArgument); result.add(invocation, newIngredient); } } } return result; }
while ((executable = executablesToScan.poll()) != null) { scannedExecutables.add(executable); executable.getElements(addDependencies);
List invocations = suspiciousElement.getElements(e -> (e instanceof CtInvocation)); for (Object invocationInSuspicious : invocations) { CtInvocation invocationToReplace = (CtInvocation) invocationInSuspicious;
.getElements(e -> e.getType() != null && e.getType().unbox().getSimpleName().equals("boolean")); .getElements(e -> e instanceof CtVariableAccess); for (CtVariableAccess ctVariableAccess : varsFromExpression) { if (!varsToBeParameters.contains(ctVariableAccess))