Skip to content

Commit

Permalink
Internal linter mode for unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aNNiMON committed Sep 20, 2024
1 parent 40294b5 commit 0421fd5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import java.util.List;

public class LinterStage implements Stage<Node, Node> {
public enum Mode { NONE, SEMANTIC, FULL }
public enum Mode { NONE, INTERNAL, SEMANTIC, FULL }

private final Mode mode;

Expand All @@ -29,10 +29,14 @@ public Node perform(StagesData stagesData, Node input) {
validators.add(new IncludeSourceValidator(results));
validators.add(new LoopStatementsValidator(results));

if (mode == Mode.SEMANTIC) {
if (mode == Mode.SEMANTIC || mode == Mode.INTERNAL) {
validators.forEach(input::accept);
if (results.hasErrors()) {
throw new OwnLangParserException(results.errors().toList());
if (mode == Mode.INTERNAL) {
System.err.println(results.errors().toList());
} else {
throw new OwnLangParserException(results.errors().toList());
}
}
return input;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static void createStage() {
testPipeline = new SourceLoaderStage()
.then(new LexerStage())
.then(new ParserStage())
.then(new LinterStage(LinterStage.Mode.SEMANTIC))
.then(new LinterStage(LinterStage.Mode.INTERNAL))
.thenConditional(true, new OptimizationStage(9))
.then(new MockOUnitStage())
.then(new ExecutionStage())
Expand Down

0 comments on commit 0421fd5

Please sign in to comment.