Example usage for org.eclipse.jdt.internal.compiler.ast Javadoc print

List of usage examples for org.eclipse.jdt.internal.compiler.ast Javadoc print

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.compiler.ast Javadoc print.

Prototype

@Override
    public StringBuffer print(int indent, StringBuffer output) 

Source Link

Usage

From source file:com.android.build.gradle.tasks.annotations.TypedefCollector.java

License:Apache License

private boolean recordTypedefs(TypeDeclaration declaration) {
    SourceTypeBinding binding = declaration.binding;
    if (binding == null) {
        return false;
    }/*from  ww w. ja  va2 s  .c  o m*/
    Annotation[] annotations = declaration.annotations;
    if (annotations != null) {
        if (declaration.binding.isAnnotationType()) {
            for (Annotation annotation : annotations) {
                String typeName = Extractor.getFqn(annotation);
                if (typeName == null) {
                    continue;
                }

                if (Extractor.isNestedAnnotation(typeName)) {
                    String fqn = new String(binding.readableName());

                    List<Annotation> list = mMap.get(fqn);
                    if (list == null) {
                        list = new ArrayList<Annotation>(2);
                        mMap.put(fqn, list);
                    }
                    list.add(annotation);

                    if (mRequireHide) {
                        Javadoc javadoc = declaration.javadoc;
                        if (javadoc != null) {
                            StringBuffer stringBuffer = new StringBuffer(200);
                            javadoc.print(0, stringBuffer);
                            String documentation = stringBuffer.toString();
                            if (!documentation.contains("@hide")) {
                                Extractor.warning(getFileName() + ": The typedef annotation " + fqn
                                        + " should specify @hide in a doc comment");
                            }
                        }
                    }
                    if (mRequireSourceRetention && !Extractor.hasSourceRetention(annotations)) {
                        Extractor.warning(getFileName() + ": The typedef annotation " + fqn
                                + " should have @Retention(RetentionPolicy.SOURCE)");
                    }
                    if (declaration.binding != null
                            && (declaration.modifiers & ClassFileConstants.AccPublic) == 0) {
                        StringBuilder sb = new StringBuilder(100);
                        for (char c : declaration.binding.qualifiedPackageName()) {
                            if (c == '.') {
                                sb.append('/');
                            } else {
                                sb.append(c);
                            }
                        }
                        sb.append(File.separatorChar);
                        for (char c : declaration.binding.qualifiedSourceName()) {
                            if (c == '.') {
                                sb.append('$');
                            } else {
                                sb.append(c);
                            }
                        }
                        mTypedefClasses.add(sb.toString());
                    }
                }
            }
        }
    }
    return true;
}