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
|
package org.javacs;
import javax.lang.model.element.Element;
import org.javacs.Completion.PackagePart;
/**
* Union of the different types of completion provided by JavaCompilerService. Only one of the members will be non-null.
*/
public class Completion {
public final Element element;
public final PackagePart packagePart;
public final String keyword;
public final ClassName className;
public final Snippet snippet; // TODO separate label and insertText
private Completion(Element element, PackagePart packagePart, String keyword, ClassName className, Snippet snippet) {
this.element = element;
this.packagePart = packagePart;
this.keyword = keyword;
this.className = className;
this.snippet = snippet;
}
public static Completion ofElement(Element element) {
return new Completion(element, null, null, null, null);
}
public static Completion ofPackagePart(String fullName, String name) {
return new Completion(null, new PackagePart(fullName, name), null, null, null);
}
public static Completion ofKeyword(String keyword) {
return new Completion(null, null, keyword, null, null);
}
public static Completion ofClassName(String className, boolean isImported) {
return new Completion(null, null, null, new ClassName(className, isImported), null);
}
public static Completion ofSnippet(String label, String snippet) {
return new Completion(null, null, null, null, new Snippet(label, snippet));
}
public static class ClassName {
// TODO keep package and class name separate to avoid inner-class problems
public final String name;
public final boolean isImported;
public ClassName(String name, boolean isImported) {
this.name = name;
this.isImported = isImported;
}
}
public static class PackagePart {
public final String fullName, name;
public PackagePart(String fullName, String name) {
this.fullName = fullName;
this.name = name;
}
}
public static class Snippet {
public final String label, snippet;
public Snippet(String label, String snippet) {
this.label = label;
this.snippet = snippet;
}
}
public Ptr ptr() {
return new Ptr(element);
}
}
|