Repository navigation
Expand file tree
/
Copy pathWarning.java
More file actions
72 lines (59 loc) · 1.67 KB
/
Copy pathWarning.java
File metadata and controls
72 lines (59 loc) · 1.67 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
package org.javacs;
import com.sun.source.tree.LineMap;
import com.sun.source.util.*;
import java.util.Locale;
import javax.tools.*;
import javax.tools.JavaFileObject;
class Warning implements Diagnostic<JavaFileObject> {
private final JavaFileObject source;
private final LineMap lines;
private final long start, end;
private final Diagnostic.Kind kind;
private final String code, message;
Warning(JavacTask task, TreePath path, Diagnostic.Kind kind, String code, String message) {
this.source = path.getCompilationUnit().getSourceFile();
this.lines = path.getCompilationUnit().getLineMap();
var pos = Trees.instance(task).getSourcePositions();
this.start = pos.getStartPosition(path.getCompilationUnit(), path.getLeaf());
this.end = pos.getEndPosition(path.getCompilationUnit(), path.getLeaf());
this.kind = kind;
this.code = code;
this.message = message;
}
@Override
public Kind getKind() {
return kind;
}
@Override
public JavaFileObject getSource() {
return source;
}
@Override
public long getPosition() {
return start;
}
@Override
public long getStartPosition() {
return start;
}
@Override
public long getEndPosition() {
return end;
}
@Override
public long getLineNumber() {
return lines.getLineNumber(start);
}
@Override
public long getColumnNumber() {
return lines.getColumnNumber(start);
}
@Override
public String getCode() {
return code;
}
@Override
public String getMessage(Locale locale) {
return message;
}
}