All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.codemodder.CompositeJavaParserChanger Maven / Gradle / Ivy

There is a newer version: 0.98.6
Show newest version
package io.codemodder;

import com.github.javaparser.ast.CompilationUnit;
import io.codemodder.javaparser.JavaParserChanger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;

/**
 * A type that allows composing multiple {@link JavaParserChanger} instances are under the same
 * umbrella.
 *
 * 

For instance, you might want to have multiple changers, each with their own SARIF collection, * all be reported under the same {@link Codemod#id()}. */ public abstract class CompositeJavaParserChanger extends JavaParserChanger { private final List changers; protected CompositeJavaParserChanger( final CodemodReporterStrategy reporterStrategy, final JavaParserChanger... changers) { super(reporterStrategy); this.changers = Arrays.asList(Objects.requireNonNull(changers)); } protected CompositeJavaParserChanger(final JavaParserChanger... changers) { this.changers = Arrays.asList(Objects.requireNonNull(changers)); } @Override public List visit( final CodemodInvocationContext context, final CompilationUnit cu) { List changes = new ArrayList<>(); changers.forEach(changer -> changes.addAll(changer.visit(context, cu))); return changes; } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy