当前位置: 首页>>代码示例>>Java>>正文


Java Completion类代码示例

本文整理汇总了Java中javax.annotation.processing.Completion的典型用法代码示例。如果您正苦于以下问题:Java Completion类的具体用法?Java Completion怎么用?Java Completion使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Completion类属于javax.annotation.processing包,在下文中一共展示了Completion类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCompletions

import javax.annotation.processing.Completion; //导入依赖的package包/类
@Override
public Iterable<? extends Completion> getCompletions(
    Element element,
    AnnotationMirror annotation,
    ExecutableElement member,
    String userText) {
  return delegate.getCompletions(element, annotation, member, userText);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:ProxyProcessor.java

示例2: getAttributeValueCompletions

import javax.annotation.processing.Completion; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:52,代码来源:SourceUtils.java

示例3: getCompletions

import javax.annotation.processing.Completion; //导入依赖的package包/类
@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();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:OptionAnnotationProcessor.java

示例4: main

import javax.annotation.processing.Completion; //导入依赖的package包/类
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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:TestCompletions.java

示例5: getCompletions

import javax.annotation.processing.Completion; //导入依赖的package包/类
@Override
public Iterable <? extends Completion> getCompletions (
    final Element element, final AnnotationMirror annotation,
    final ExecutableElement member, final String userText
) {
    return Collections.emptyList ();
}
 
开发者ID:mur47x111,项目名称:svm-fasttagging,代码行数:8,代码来源:DislClassFinder.java

示例6: getCompletions

import javax.annotation.processing.Completion; //导入依赖的package包/类
@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);
  }
}
 
开发者ID:facebook,项目名称:buck,代码行数:8,代码来源:TracingProcessorWrapper.java

示例7: getCompletions

import javax.annotation.processing.Completion; //导入依赖的package包/类
@Override
public Iterable<? extends Completion> getCompletions(Element element, AnnotationMirror annotation, ExecutableElement member, String userText) {
    return wrappedProcessor.getCompletions(element, annotation, member, userText);
}
 
开发者ID:toolisticon,项目名称:annotation-processor-toolkit,代码行数:5,代码来源:AnnotationProcessorWrapper.java

示例8: getCompletions

import javax.annotation.processing.Completion; //导入依赖的package包/类
@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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:55,代码来源:CreateRegistrationProcessor.java

示例9: getCompletions

import javax.annotation.processing.Completion; //导入依赖的package包/类
@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;
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:47,代码来源:SupportedAnnotationTypesCompletion.java

示例10: getCompletions

import javax.annotation.processing.Completion; //导入依赖的package包/类
@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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:52,代码来源:ServiceProviderProcessor.java

示例11: getCompletions

import javax.annotation.processing.Completion; //导入依赖的package包/类
@Override
public Iterable<? extends Completion> getCompletions(Element element, AnnotationMirror annotationMirror, ExecutableElement executableElement, String s) {
  return Collections.emptyList();
}
 
开发者ID:hf,项目名称:immu,代码行数:5,代码来源:ImmuCompiler.java

示例12: getCompletions

import javax.annotation.processing.Completion; //导入依赖的package包/类
@Override
public Iterable<? extends Completion> getCompletions(Element element, AnnotationMirror annotationMirror, ExecutableElement executableElement, String s) {
    return super.getCompletions(element, annotationMirror, executableElement, s);
}
 
开发者ID:daawa,项目名称:auto-nav,代码行数:5,代码来源:NavProcessor.java

示例13: getCompletions

import javax.annotation.processing.Completion; //导入依赖的package包/类
@Override public Iterable<? extends Completion> getCompletions(Element element, AnnotationMirror annotation, ExecutableElement member, String userText) {
	return instance.getCompletions(element, annotation, member, userText);
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:4,代码来源:AnnotationProcessor.java

示例14: getCompletions

import javax.annotation.processing.Completion; //导入依赖的package包/类
@Override
public Iterable<? extends Completion> getCompletions(Element element, AnnotationMirror annotation, ExecutableElement member, String userText) {
    return Collections.emptyList();
}
 
开发者ID:HomoEfficio,项目名称:spring-web-api-test-stubber,代码行数:5,代码来源:RestControllerProcessor.java

示例15: getCompletions

import javax.annotation.processing.Completion; //导入依赖的package包/类
@Override
public Iterable<? extends Completion> getCompletions(Element element, AnnotationMirror annotationMirror, ExecutableElement executableElement, String s) {
    return Collections.emptyList();
}
 
开发者ID:chdir,项目名称:aidl2,代码行数:5,代码来源:AidlProcessor.java


注:本文中的javax.annotation.processing.Completion类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。