io.codemodder.remediation.FixCandidateSearcher Maven / Gradle / Ivy
package io.codemodder.remediation;
import com.github.javaparser.ast.CompilationUnit;
import com.github.javaparser.ast.expr.MethodCallExpr;
import io.codemodder.codetf.DetectorRule;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.function.Function;
import java.util.function.Predicate;
/** Searches for potential fix locations in the source code. */
public interface FixCandidateSearcher {
/** Searches for potential fix locations in the source code. */
FixCandidateSearchResults search(
CompilationUnit cu,
String path,
DetectorRule rule,
List issuesForFile,
Function getKey,
Function getLine,
Function getColumn);
/** Builder for {@link FixCandidateSearcher}. */
final class Builder {
private String methodName;
private final List> methodMatchers;
public Builder() {
this.methodMatchers = new ArrayList<>();
}
public Builder withMethodName(final String methodName) {
this.methodName = Objects.requireNonNull(methodName);
return this;
}
public Builder withMatcher(final Predicate methodMatcher) {
this.methodMatchers.add(Objects.requireNonNull(methodMatcher));
return this;
}
public FixCandidateSearcher build() {
return new DefaultFixCandidateSearcher<>(methodName, List.copyOf(methodMatchers));
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy