Найдите параметр типа типа возврата метода в процессоре Java 6 аннотации

Первый раунд двоичных файлов для Вашего поля Linux был основан на некотором другом поле Linux (вероятно).

двоичные файлы для первой системы Linux были основаны приблизительно на на другом платформа.

двоичные файлы для того компьютера могут проследить свой корень до исходной системы, которая была основана все же другой платформа.

...

Нажатие настолько далеко достаточно, и Вы находите компиляторы созданными с более примитивными инструментами, которые были в свою очередь основаны на машинах кроме их хоста.

...

Продолжают продвигать, и Вы находите компьютеры созданными так, чтобы их инструкции могли быть введены [1 111], установка включает переднюю панель машины .

Очень интересный материал.

правило является "сборкой инструменты для создания инструментов для создания инструментов...". Очень как инструменты, которые выполняют нашу физическую среду. Также известный как "тянуть себя начальными загрузками".

9
задан Victor Stafusa 9 February 2015 в 16:05
поделиться

1 ответ

 public AnnotationProcessor getProcessorFor(
            Set<AnnotationTypeDeclaration> atds,
            AnnotationProcessorEnvironment env) {
        return new SomeAnnotationProcessor(env);
    }

    private static class SomeAnnotationProcessor implements AnnotationProcessor {
        private final AnnotationProcessorEnvironment env;

        SomeAnnotationProcessor(AnnotationProcessorEnvironment env) {
            this.env = env;
        }

        public void process() {
            for (TypeDeclaration typeDecl : env.getSpecifiedTypeDeclarations()) {
                System.out.println("in class: " + typeDecl);
                typeDecl.accept(getDeclarationScanner(
                        new SomeClassVisitor(), NO_OP));
            }
        }

        private static class SomeClassVisitor extends SimpleDeclarationVisitor {
            @Override
            public void visitMethodDeclaration(
                    MethodDeclaration methodDeclaration) {
                System.out.println("visiting method: "+methodDeclaration + " -> "+methodDeclaration.getReturnType());
                methodDeclaration.getReturnType().accept(new SomeTypeVisitor());
            }
        }
    }

    private static class SomeTypeVisitor implements TypeVisitor {

        public void visitClassType(ClassType classType) {           
            System.out.println("classType: " + classType + " -> "+classType.getClass());                
        }

        @Override
        public void visitInterfaceType(InterfaceType interfaceType) {
            Types types = annotationProcessorEnvironment.getTypeUtils();
            TypeDeclaration typeDeclaration = annotationProcessorEnvironment
                    .getTypeDeclaration("A");           
            Collection<InterfaceType> superinterfaces = interfaceType
                    .getSuperinterfaces();                      
            System.out.println("interfaceType: " + interfaceType + " -> "
                    + superinterfaces);
            DeclaredType typeOfA = types.getDeclaredType(typeDeclaration);
            boolean isSubTypeOfA = types.isSubtype(interfaceType, typeOfA);         
            if (isSubTypeOfA) {
                findTypeVariable(types, superinterfaces, typeOfA);
            }
            Iterator<TypeMirror> iterator = interfaceType
                    .getActualTypeArguments().iterator();
            while (iterator.hasNext()) {
                TypeMirror next = iterator.next();
                next.accept(new SomeTypeVisitor());
            }
        }

        public void visitTypeVariable(TypeVariable typeVariable) {          
            System.out.println("typeVariable: "
                    + typeVariable.getDeclaration() + " -> "+typeVariable.getClass());              
        }

        private void findTypeVariable(Types types,
                Collection<InterfaceType> superinterfaces, DeclaredType typeOfA) {
            for (InterfaceType superInterface : superinterfaces) {
                TypeMirror erasure = types.getErasure(superInterface);
                if (erasure.equals(typeOfA)) {
                    System.out.println("true, "+superInterface.getActualTypeArguments());
                } else {
                    System.out.println("false: " + typeOfA + " =!= "
                            + erasure);
                    findTypeVariable(types, superInterface.getSuperinterfaces(), typeOfA);
                }
            }
        }


    }
3
ответ дан 4 December 2019 в 19:35
поделиться
Другие вопросы по тегам:

Похожие вопросы: