Skip to content

Commit

Permalink
#9 XML as argument
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Nov 19, 2024
1 parent 50d1da2 commit 68307b3
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/main/java/org/eolang/lints/Program.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.jcabi.xml.XML;
import com.jcabi.xml.XMLDocument;
import io.github.secretx33.resourceresolver.PathMatchingResourcePatternResolver;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Arrays;
Expand All @@ -48,16 +49,25 @@ public final class Program {
private static final Iterable<Lint> LINTS = Program.all();

/**
* Absolute path of the XMIR file to analyze.
* The XMIR program to analyze.
*/
private final Path path;
private final XML xmir;

/**
* Ctor.
* @param xml The XMIR
*/
public Program(final XML xml) {
this.xmir = xml;
}

/**
* Ctor.
* @param file The absolute path of the XMIR file
* @throws FileNotFoundException If file not found
*/
public Program(final Path file) {
this.path = file;
public Program(final Path file) throws FileNotFoundException {
this(new XMLDocument(file));
}

/**
Expand All @@ -66,9 +76,8 @@ public Program(final Path file) {
*/
public Collection<Defect> defects() throws IOException {
final Collection<Defect> messages = new LinkedList<>();
final XML xmir = new XMLDocument(this.path);
for (final Lint lint : Program.LINTS) {
messages.addAll(lint.defects(xmir));
messages.addAll(lint.defects(this.xmir));
}
return messages;
}
Expand Down

0 comments on commit 68307b3

Please sign in to comment.