Search in sources :

Example 1 with Completion

use of javax.annotation.processing.Completion in project ceylon-compiler by ceylon.

the class TestCompletions method main.

public static void main(String... argv) {
    String value = "value";
    String message = "message";
    Completion c = of(value, message);
    if (!value.equals(c.getValue()) || !message.equals(c.getMessage()))
        throw new RuntimeException("Bad full completion" + c);
    c = of(value);
    if (!value.equals(c.getValue()) || !"".equals(c.getMessage()))
        throw new RuntimeException("Bad value completion" + c);
}
Also used : Completion(javax.annotation.processing.Completion)

Example 2 with Completion

use of javax.annotation.processing.Completion in project java-common-lib by sosy-lab.

the class OptionAnnotationProcessor method returnPackagePrefixCompletions.

private Iterable<? extends Completion> returnPackagePrefixCompletions(Element element, String userText) {
    List<Completion> packages = new ArrayList<>();
    PackageElement pkg = elementUtils().getPackageOf(element);
    if (!pkg.isUnnamed()) {
        @Var String name = pkg.getQualifiedName().toString();
        do {
            if (!name.startsWith(userText)) {
                break;
            }
            packages.add(Completions.of(name));
            int pos = name.lastIndexOf('.');
            name = name.substring(0, Math.max(pos, 0));
        } while (!name.isEmpty());
    }
    return packages;
}
Also used : Completion(javax.annotation.processing.Completion) Var(com.google.errorprone.annotations.Var) ArrayList(java.util.ArrayList) PackageElement(javax.lang.model.element.PackageElement)

Example 3 with Completion

use of javax.annotation.processing.Completion in project ceylon by eclipse.

the class TestCompletions method main.

public static void main(String... argv) {
    String value = "value";
    String message = "message";
    Completion c = of(value, message);
    if (!value.equals(c.getValue()) || !message.equals(c.getMessage()))
        throw new RuntimeException("Bad full completion" + c);
    c = of(value);
    if (!value.equals(c.getValue()) || !"".equals(c.getMessage()))
        throw new RuntimeException("Bad value completion" + c);
}
Also used : Completion(javax.annotation.processing.Completion)

Aggregations

Completion (javax.annotation.processing.Completion)3 Var (com.google.errorprone.annotations.Var)1 ArrayList (java.util.ArrayList)1 PackageElement (javax.lang.model.element.PackageElement)1