-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathErrorEmitter.java
More file actions
92 lines (77 loc) · 2.61 KB
/
ErrorEmitter.java
File metadata and controls
92 lines (77 loc) · 2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package liquidjava.errors;
import java.net.URI;
import java.util.HashMap;
import liquidjava.processor.context.PlacementInCode;
import spoon.reflect.cu.SourcePosition;
public class ErrorEmitter {
private String titleMessage;
private String fullMessage;
private URI filePath;
private ErrorPosition position;
private int errorStatus;
private HashMap<String, PlacementInCode> map;
public ErrorEmitter() {
}
public void addError(String titleMessage, String msg, SourcePosition p, int errorStatus,
HashMap<String, PlacementInCode> map) {
this.titleMessage = titleMessage;
fullMessage = msg;
try {
position = new ErrorPosition(p.getLine(), p.getColumn(), p.getEndLine(), p.getEndColumn());
filePath = p.getFile().toURI();
} catch (Exception ignored) {
fullMessage = "Seems like this error is created in generated part of source code, so no precise"
+ " position is provided. " + fullMessage;
position = null;
filePath = null;
}
this.errorStatus = errorStatus;
this.map = map;
}
public void addError(String titleMessage, String msg, SourcePosition p, int errorStatus) {
this.titleMessage = titleMessage;
fullMessage = msg;
try {
position = new ErrorPosition(p.getLine(), p.getColumn(), p.getEndLine(), p.getEndColumn());
filePath = p.getFile().toURI();
} catch (Exception ignored) {
fullMessage = "Seems like this error is created in generated part of source code, so no precise"
+ " position is provided. " + fullMessage;
position = null;
filePath = null;
}
this.errorStatus = errorStatus;
}
public void addError(String titleMessage, String msg, int errorStatus) {
this.titleMessage = titleMessage;
fullMessage = msg;
this.errorStatus = errorStatus;
}
public boolean foundError() {
return fullMessage != null && position != null;
}
public String getTitleMessage() {
return titleMessage;
}
public String getFullMessage() {
return fullMessage;
}
public URI getFilePath() {
return filePath;
}
public void reset() {
fullMessage = null;
position = null;
errorStatus = 0;
map = null;
}
public ErrorPosition getPosition() {
return position;
}
public int getErrorStatus() {
return errorStatus;
}
public HashMap<String, PlacementInCode> getVCMap() {
return map;
}
}