Java 类javax.annotation.processing.Completion 实例源码

项目:GitHub    文件:ProxyProcessor.java   
@Override
public Iterable<? extends Completion> getCompletions(
    Element element,
    AnnotationMirror annotation,
    ExecutableElement member,
    String userText) {
  return delegate.getCompletions(element, annotation, member, userText);
}
项目:incubator-netbeans    文件:SourceUtils.java   
/**
 * Returns a list of completions for an annotation attribute value suggested by
 * annotation processors.
 * 
 * @param info the CompilationInfo used to resolve annotation processors
 * @param element the element being annotated
 * @param annotation the (perhaps partial) annotation being applied to the element
 * @param member the annotation member to return possible completions for
 * @param userText source code text to be completed
 * @return suggested completions to the annotation member
 * 
 * @since 0.57
 */
public static List<? extends Completion> getAttributeValueCompletions(CompilationInfo info, Element element, AnnotationMirror annotation, ExecutableElement member, String userText) {
    List<Completion> completions = new LinkedList<>();
    if (info.getPhase().compareTo(Phase.ELEMENTS_RESOLVED) >= 0) {
        String fqn = ((TypeElement) annotation.getAnnotationType().asElement()).getQualifiedName().toString();
        Iterable<? extends Processor> processors =
                JavacParser.ProcessorHolder.instance(info.impl.getJavacTask().getContext()).getProcessors();
        if (processors != null) {
            for (Processor processor : processors) {
                boolean match = false;
                for (String sat : processor.getSupportedAnnotationTypes()) {
                    if ("*".equals(sat)) { //NOI18N
                        match = true;
                        break;
                    } else if (sat.endsWith(".*")) { //NOI18N
                        sat = sat.substring(0, sat.length() - 1);
                        if (fqn.startsWith(sat)) {
                            match = true;
                            break;
                        }
                    } else if (fqn.equals(sat)) {
                        match = true;
                        break;
                    }
                }
                if (match) {
                    try {
                        for (Completion c : processor.getCompletions(element, annotation, member, userText)) {
                            completions.add(c);
                        }
                    } catch (Exception e) {
                        Logger.getLogger(processor.getClass().getName()).log(Level.INFO, e.getMessage(), e);
                    }
                }
            }
        }
    }
    return completions;
}
项目:incubator-netbeans    文件:OptionAnnotationProcessor.java   
@Override
public Iterable<? extends Completion> getCompletions(Element element, AnnotationMirror annotation, ExecutableElement member, String userText) {
    if (delegate() != null) {
        return delegate().getCompletions(element, annotation, member, userText);
    } else {
        return Collections.emptySet();
    }
}
项目:openjdk-jdk10    文件:TestCompletions.java   
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);
}
项目:openjdk9    文件:TestCompletions.java   
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);
}
项目:lookaside_java-1.8.0-openjdk    文件:TestCompletions.java   
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);
}
项目:jsr308-langtools    文件:TestCompletions.java   
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);
}
项目:form-follows-function    文件:TestCompletions.java   
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);
}
项目:infobip-open-jdk-8    文件:TestCompletions.java   
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);
}
项目:openjdk-source-code-learn    文件:TestCompletions.java   
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);
}
项目:OLD-OpenJDK8    文件:TestCompletions.java   
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);
}
项目:s4j    文件:TestCompletions.java   
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);
}
项目:jdk7-langtools    文件:TestCompletions.java   
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);
}
项目:svm-fasttagging    文件:DislClassFinder.java   
@Override
public Iterable <? extends Completion> getCompletions (
    final Element element, final AnnotationMirror annotation,
    final ExecutableElement member, final String userText
) {
    return Collections.emptyList ();
}
项目:openjdk-icedtea7    文件:TestCompletions.java   
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);
}
项目:metricgenerator-jdk-compiler    文件:TestCompletions.java   
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);
}
项目:buck    文件:TracingProcessorWrapper.java   
@Override
public Iterable<? extends Completion> getCompletions(
    Element element, AnnotationMirror annotation, ExecutableElement member, String userText) {
  try (Scope scope = new Scope(AnnotationProcessingEvent.Operation.GET_COMPLETIONS)) {
    return innerProcessor.getCompletions(element, annotation, member, userText);
  }
}
项目:immutables    文件:ProxyProcessor.java   
@Override
public Iterable<? extends Completion> getCompletions(
    Element element,
    AnnotationMirror annotation,
    ExecutableElement member,
    String userText) {
  return delegate.getCompletions(element, annotation, member, userText);
}
项目:INF5000-StaticProxy    文件:TestCompletions.java   
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);
}
项目:annotation-processor-toolkit    文件:AnnotationProcessorWrapper.java   
@Override
public Iterable<? extends Completion> getCompletions(Element element, AnnotationMirror annotation, ExecutableElement member, String userText) {
    return wrappedProcessor.getCompletions(element, annotation, member, userText);
}
项目:incubator-netbeans    文件:CreateRegistrationProcessor.java   
@Override
public Iterable<? extends Completion> getCompletions(Element annotated, AnnotationMirror annotation, ExecutableElement attr, String userText) {
    if (processingEnv == null || annotated == null || !annotated.getKind().isClass()) {
        return Collections.emptyList();
    }

    if (   annotation == null
        || !"org.netbeans.api.editor.mimelookup.MimeRegistration".contentEquals(((TypeElement) annotation.getAnnotationType().asElement()).getQualifiedName())) {
        return Collections.emptyList();
    }

    if ("mimeType".contentEquals(attr.getSimpleName())) { // NOI18N
        return completeMimePath(annotated, annotation, attr, userText);
    }
    if (!"service".contentEquals(attr.getSimpleName())) {
        return Collections.emptyList();
    }

    TypeElement jlObject = processingEnv.getElementUtils().getTypeElement("java.lang.Object");

    if (jlObject == null) {
        return Collections.emptyList();
    }

    Collection<Completion> result = new LinkedList<Completion>();
    List<TypeElement> toProcess = new LinkedList<TypeElement>();

    toProcess.add((TypeElement) annotated);

    while (!toProcess.isEmpty()) {
        TypeElement c = toProcess.remove(0);

        result.add(new TypeCompletion(c.getQualifiedName().toString() + ".class"));

        List<TypeMirror> parents = new LinkedList<TypeMirror>();

        parents.add(c.getSuperclass());
        parents.addAll(c.getInterfaces());

        for (TypeMirror tm : parents) {
            if (tm == null || tm.getKind() != TypeKind.DECLARED) {
                continue;
            }

            TypeElement type = (TypeElement) processingEnv.getTypeUtils().asElement(tm);

            if (!jlObject.equals(type)) {
                toProcess.add(type);
            }
        }
    }

    return result;
}
项目:incubator-netbeans    文件:SupportedAnnotationTypesCompletion.java   
@Override
    public Iterable<? extends Completion> getCompletions(Element element, AnnotationMirror annotation, ExecutableElement member, String userText) {
        ProcessingEnvironment processingEnv = this.processingEnv.get();

        if (processingEnv == null)
            return Collections.emptyList();

        TypeElement annotationObj = processingEnv.getElementUtils().getTypeElement("java.lang.annotation.Annotation");

        if (annotationObj == null)
            return Collections.emptyList();

        Trees trees = Trees.instance(processingEnv);
        TreePath path = trees.getPath(element);

        if (path == null)
            return Collections.emptyList();

        FileObject owner;

        try {
            owner = URLMapper.findFileObject(path.getCompilationUnit().getSourceFile().toUri().toURL());
        } catch (MalformedURLException ex) {
            Exceptions.printStackTrace(ex);
            return Collections.emptyList();
        }

        ClassIndex ci = ClasspathInfo.create(owner).getClassIndex();

        if (ci == null)
            return Collections.emptyList();

        List<Completion> result = new LinkedList<Completion>();

//        for (ElementHandle<TypeElement> eh : ci.getElements(ElementHandle.create(annotationObj), EnumSet.of(SearchKind.IMPLEMENTORS), EnumSet.of(SearchScope.DEPENDENCIES, SearchScope.SOURCE))) {
//            result.add(new CompletionImpl(eh.getQualifiedName()));
//        }

        for (ElementHandle<TypeElement> eh : ci.getDeclaredTypes("", ClassIndex.NameKind.PREFIX, EnumSet.of(SearchScope.DEPENDENCIES, SearchScope.SOURCE))) {
            if (eh.getKind() != ElementKind.ANNOTATION_TYPE) continue;

            result.add(new CompletionImpl('\"' + eh.getQualifiedName() + '\"'));
        }

        return result;
    }
项目:incubator-netbeans    文件:ServiceProviderProcessor.java   
@Override
public Iterable<? extends Completion> getCompletions(Element annotated, AnnotationMirror annotation, ExecutableElement attr, String userText) {
    if (processingEnv == null || annotated == null || !annotated.getKind().isClass()) {
        return Collections.emptyList();
    }

    if (   annotation == null
        || !"org.openide.util.lookup.ServiceProvider".contentEquals(((TypeElement) annotation.getAnnotationType().asElement()).getQualifiedName())) {
        return Collections.emptyList();
    }

    if (!"service".contentEquals(attr.getSimpleName())) {
        return Collections.emptyList();
    }

    TypeElement jlObject = processingEnv.getElementUtils().getTypeElement("java.lang.Object");

    if (jlObject == null) {
        return Collections.emptyList();
    }

    Collection<Completion> result = new LinkedList<Completion>();
    List<TypeElement> toProcess = new LinkedList<TypeElement>();

    toProcess.add((TypeElement) annotated);

    while (!toProcess.isEmpty()) {
        TypeElement c = toProcess.remove(0);

        result.add(new TypeCompletion(c.getQualifiedName().toString() + ".class"));

        List<TypeMirror> parents = new LinkedList<TypeMirror>();

        parents.add(c.getSuperclass());
        parents.addAll(c.getInterfaces());

        for (TypeMirror tm : parents) {
            if (tm == null || tm.getKind() != TypeKind.DECLARED) {
                continue;
            }

            TypeElement type = (TypeElement) processingEnv.getTypeUtils().asElement(tm);

            if (!jlObject.equals(type)) {
                toProcess.add(type);
            }
        }
    }

    return result;
}
项目:immu    文件:ImmuCompiler.java   
@Override
public Iterable<? extends Completion> getCompletions(Element element, AnnotationMirror annotationMirror, ExecutableElement executableElement, String s) {
  return Collections.emptyList();
}
项目:auto-nav    文件:NavProcessor.java   
@Override
public Iterable<? extends Completion> getCompletions(Element element, AnnotationMirror annotationMirror, ExecutableElement executableElement, String s) {
    return super.getCompletions(element, annotationMirror, executableElement, s);
}
项目:lombok-ianchiu    文件:AnnotationProcessor.java   
@Override public Iterable<? extends Completion> getCompletions(Element element, AnnotationMirror annotation, ExecutableElement member, String userText) {
    return instance.getCompletions(element, annotation, member, userText);
}
项目:spring-web-api-test-stubber    文件:RestControllerProcessor.java   
@Override
public Iterable<? extends Completion> getCompletions(Element element, AnnotationMirror annotation, ExecutableElement member, String userText) {
    return Collections.emptyList();
}
项目:aidl2    文件:AidlProcessor.java   
@Override
public Iterable<? extends Completion> getCompletions(Element element, AnnotationMirror annotationMirror, ExecutableElement executableElement, String s) {
    return Collections.emptyList();
}
项目:EasyMPermission    文件:AnnotationProcessor.java   
@Override public Iterable<? extends Completion> getCompletions(Element element, AnnotationMirror annotation, ExecutableElement member, String userText) {
    return instance.getCompletions(element, annotation, member, userText);
}
项目:vertx-codegen    文件:Generator.java   
@Override
public Iterable<? extends Completion> getCompletions(Element element, AnnotationMirror annotation, ExecutableElement member, String userText) {
  return Collections.emptyList();
}
项目:buildergen    文件:GenerateBuilderProcessor.java   
@Override
public Iterable<? extends Completion> getCompletions(Element element,
        AnnotationMirror annotation, ExecutableElement member,
        String userText) {
    return Collections.emptyList();
}
项目:ormlite-android    文件:OrmliteTransactionalProcessor.java   
@Override
public Iterable<? extends Completion> getCompletions(Element element, AnnotationMirror annotation,
        ExecutableElement member, String userText) {
    return Collections.emptyList();
}
项目:buck    文件:TreeBackedProcessorWrapper.java   
@Override
public Iterable<? extends Completion> getCompletions(
    Element element, AnnotationMirror annotation, ExecutableElement member, String userText) {
  // This method is only ever called from IDEs, which is not a scenario for Buck right now
  throw new UnsupportedOperationException();
}
项目:buck    文件:TreeBackedProcessorWrapperTest.java   
private void runTestProcessor(
    BiFunction<Set<? extends TypeElement>, RoundEnvironment, Boolean> processMethod)
    throws IOException {
  testCompiler.useFrontendOnlyJavacTask();
  testCompiler.addSourceFileContents(
      "Foo.java",
      "package com.example.buck;",
      "@FooAnno",
      "public class Foo {}",
      "@interface FooAnno {}");

  testCompiler.setProcessors(
      Collections.singletonList(
          new Processor() {
            @Override
            public Set<String> getSupportedOptions() {
              return Collections.emptySet();
            }

            @Override
            public Set<String> getSupportedAnnotationTypes() {
              return Collections.singleton("com.example.buck.FooAnno");
            }

            @Override
            public SourceVersion getSupportedSourceVersion() {
              return SourceVersion.RELEASE_8;
            }

            @Override
            public void init(ProcessingEnvironment processingEnv) {
              TreeBackedProcessorWrapperTest.this.processingEnv = processingEnv;
              elements = processingEnv.getElementUtils();
              messager = processingEnv.getMessager();
            }

            @Override
            public Iterable<? extends Completion> getCompletions(
                Element element,
                AnnotationMirror annotation,
                ExecutableElement member,
                String userText) {
              fail("Should never be called");
              return null;
            }

            @Override
            public boolean process(
                Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
              return processMethod.apply(annotations, roundEnv);
            }
          }));

  testCompiler.enter();
}
项目:damapping    文件:DAAnnotationProcessor.java   
@Override
public Iterable<? extends Completion> getCompletions(Element element, AnnotationMirror annotationMirror,
                                                     ExecutableElement executableElement, String s) {
  return null;
}
项目:damapping    文件:DAFileWriterTest.java   
@Override
public Iterable<? extends Completion> getCompletions(Element element, AnnotationMirror annotation,
                                                     ExecutableElement member, String userText) {
  return null;  //To change body of implemented methods use File | Settings | File Templates.
}
项目:Assembler    文件:InterceptorCompiler.java   
/**
 * Returns an empty iterable of completions.
 *
 * @param element
 * @param annotationMirror
 * @param executableElement
 * @param s
 * @return
 */
@Override
public Iterable<? extends Completion> getCompletions(Element element,
                                                     AnnotationMirror annotationMirror,
                                                     ExecutableElement executableElement,
                                                     String s) {
    return super.getCompletions(element, annotationMirror, executableElement, s);
}