Skip to content

Commit c8e8616

Browse files
committed
Remove ErrorEmitter from CommandLineLauncher
1 parent 91d9786 commit c8e8616

File tree

2 files changed

+11
-105
lines changed

2 files changed

+11
-105
lines changed

liquidjava-verifier/src/main/java/liquidjava/api/CommandLineLauncher.java

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,51 +17,38 @@
1717

1818
public class CommandLineLauncher {
1919
public static void main(String[] args) {
20-
// String allPath = "C://Regen/test-projects/src/Main.java";
21-
// In eclipse only needed this:"../liquidjava-example/src/main/java/"
22-
// In VSCode needs:
23-
// "../liquidjava/liquidjava-umbrella/liquidjava-example/src/main/java/liquidjava/test/project";
24-
2520
if (args.length == 0) {
26-
System.out.println("No input files or directories provided");
21+
System.out.println("No input paths provided");
2722
System.out.println("\nUsage: ./liquidjava <...paths>");
28-
System.out.println(" <...paths>: Paths to files or directories to be verified by LiquidJava");
23+
System.out.println(" <...paths>: Paths to be verified by LiquidJava");
2924
System.out.println(
30-
"\nExample: ./liquidjava liquidjava-example/src/main/java/test/currentlyTesting liquidjava-example/src/main/java/testingInProgress/Account.java");
25+
"\nExample: ./liquidjava liquidjava-example/src/main/java/test liquidjava-example/src/main/java/testingInProgress/Account.java");
3126
return;
3227
}
3328
List<String> paths = Arrays.asList(args);
34-
ErrorEmitter ee = launch(paths.toArray(new String[0]));
35-
System.out.println(ee.foundError() ? (ee.getFullMessage()) : ("Correct! Passed Verification."));
29+
launch(paths.toArray(new String[0]));
30+
System.out.println(diagnostics.foundError() ? diagnostics.toString() : "Correct! Passed Verification.");
3631
}
3732

38-
public static ErrorEmitter launch(String... paths) {
33+
public static void launch(String... paths) {
3934
System.out.println("Running LiquidJava on: " + Arrays.toString(paths).replaceAll("[\\[\\]]", ""));
4035

41-
ErrorEmitter ee = new ErrorEmitter();
4236
Launcher launcher = new Launcher();
4337
for (String path : paths) {
4438
if (!new File(path).exists()) {
4539
diagnostics.add(new CustomError("The path " + path + " was not found"));
46-
return ee;
40+
return;
4741
}
4842
launcher.addInputResource(path);
4943
}
50-
launcher.getEnvironment().setNoClasspath(true);
5144

52-
// Get the current classpath from the system
53-
// String classpath = System.getProperty("java.class.path");
54-
// launcher.getEnvironment().setSourceClasspath(classpath.split(File.pathSeparator));
55-
56-
// optional
57-
// launcher.getEnvironment().setSourceClasspath(
58-
// "lib1.jar:lib2.jar".split(":"));
45+
launcher.getEnvironment().setNoClasspath(true);
5946
launcher.getEnvironment().setComplianceLevel(8);
6047
launcher.run();
6148

6249
final Factory factory = launcher.getFactory();
6350
final ProcessingManager processingManager = new QueueProcessingManager(factory);
64-
final RefinementProcessor processor = new RefinementProcessor(factory, ee);
51+
final RefinementProcessor processor = new RefinementProcessor(factory);
6552
processingManager.addProcessor(processor);
6653

6754
try {
@@ -74,6 +61,6 @@ public static ErrorEmitter launch(String... paths) {
7461
throw e;
7562
}
7663

77-
return ee;
64+
return;
7865
}
7966
}
Lines changed: 1 addition & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,8 @@
11
package liquidjava.diagnostics;
22

3-
import java.net.URI;
4-
import spoon.reflect.cu.SourcePosition;
5-
63
public class ErrorEmitter {
74

8-
private String titleMessage;
9-
private String fullMessage;
10-
private URI filePath;
11-
private ErrorPosition position;
12-
private int errorStatus;
13-
private TranslationTable map;
14-
15-
public ErrorEmitter() {
16-
}
17-
18-
public void addError(String titleMessage, String msg, SourcePosition p, int errorStatus, TranslationTable map) {
19-
this.titleMessage = titleMessage;
20-
fullMessage = msg;
21-
try {
22-
position = new ErrorPosition(p.getLine(), p.getColumn(), p.getEndLine(), p.getEndColumn());
23-
filePath = p.getFile().toURI();
24-
} catch (Exception ignored) {
25-
fullMessage = "Seems like this error is created in generated part of source code, so no precise"
26-
+ " position is provided. " + fullMessage;
27-
position = null;
28-
filePath = null;
29-
}
30-
this.errorStatus = errorStatus;
31-
this.map = map;
32-
}
33-
34-
public void addError(String titleMessage, String msg, SourcePosition p, int errorStatus) {
35-
this.titleMessage = titleMessage;
36-
fullMessage = msg;
37-
try {
38-
position = new ErrorPosition(p.getLine(), p.getColumn(), p.getEndLine(), p.getEndColumn());
39-
filePath = p.getFile().toURI();
40-
} catch (Exception ignored) {
41-
fullMessage = "Seems like this error is created in generated part of source code, so no precise"
42-
+ " position is provided. " + fullMessage;
43-
position = null;
44-
filePath = null;
45-
}
46-
this.errorStatus = errorStatus;
47-
}
48-
49-
public void addError(String titleMessage, String msg, int errorStatus) {
50-
this.titleMessage = titleMessage;
51-
fullMessage = msg;
52-
this.errorStatus = errorStatus;
53-
}
54-
555
public boolean foundError() {
56-
return fullMessage != null;
57-
}
58-
59-
public String getTitleMessage() {
60-
return titleMessage;
61-
}
62-
63-
public String getFullMessage() {
64-
return fullMessage;
65-
}
66-
67-
public URI getFilePath() {
68-
return filePath;
69-
}
70-
71-
public void reset() {
72-
fullMessage = null;
73-
position = null;
74-
errorStatus = 0;
75-
map = null;
76-
}
77-
78-
public ErrorPosition getPosition() {
79-
return position;
80-
}
81-
82-
public int getErrorStatus() {
83-
return errorStatus;
84-
}
85-
86-
public TranslationTable getVCMap() {
87-
return map;
6+
return false;
887
}
898
}

0 commit comments

Comments
 (0)