-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathGoblintAnalysisResult.java
More file actions
108 lines (88 loc) · 2.75 KB
/
GoblintAnalysisResult.java
File metadata and controls
108 lines (88 loc) · 2.75 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import com.ibm.wala.cast.tree.CAstSourcePositionMap.Position;
import com.ibm.wala.util.collections.Pair;
import java.util.ArrayList;
import java.util.Collections;
import magpiebridge.core.AnalysisResult;
import magpiebridge.core.Kind;
import magpiebridge.util.SourceCodeReader;
import org.eclipse.lsp4j.Command;
import org.eclipse.lsp4j.DiagnosticSeverity;
public class GoblintAnalysisResult implements AnalysisResult {
private String group_text = "";
private String text;
private Position pos;
private String severity;
private Iterable<Pair<Position, String>> related = new ArrayList<>();
public GoblintAnalysisResult(GoblintPosition pos, String text, String severity) {
this.text = text;
this.pos = pos;
this.severity = severity;
}
public GoblintAnalysisResult(GoblintPosition pos, String group_text, String text, String severity) {
this.group_text = group_text;
this.text = text;
this.pos = pos;
this.severity = severity;
}
public GoblintAnalysisResult(Position pos, String text, String severity, Iterable<Pair<Position, String>> related) {
this.text = text;
this.pos = pos;
this.severity = severity;
this.related = related;
}
@Override
public Kind kind() {
return Kind.Diagnostic;
}
@Override
public String toString(boolean useMarkdown) {
return text;
}
public String group_text() {
return group_text;
}
public String text() {
return text;
}
@Override
public Position position() {
return pos;
}
@Override
public Iterable<Pair<Position, String>> related() {
return related;
}
@Override
public DiagnosticSeverity severity() {
DiagnosticSeverity diagnosticSeverity = DiagnosticSeverity.Information;
if (severity.equals("Warning")) {
diagnosticSeverity = DiagnosticSeverity.Warning;
} else if (severity.equals("Error")) {
diagnosticSeverity = DiagnosticSeverity.Error;
}
return diagnosticSeverity;
}
public String severityStr() {
return severity;
}
@Override
public Pair<Position, String> repair() {
// suggest a repair if available
return null;
}
@Override
public String code() {
String code;
try {
code = SourceCodeReader.getLinesInString(pos);
} catch (Exception e) {
throw new RuntimeException(e);
}
return code;
}
@Override
public Iterable<Command> command() {
Command command = new Command("show result", "showresult", Collections.singletonList(position().getFirstLine()));
return Collections.singleton(command);
}
}