Java Code Examples for javax.tools.JavaFileObject#isNameCompatible()

The following examples show how to use javax.tools.JavaFileObject#isNameCompatible() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JavacProcessingEnvironment.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private boolean isPkgInfo(JavaFileObject fo, JavaFileObject.Kind kind) {
    return fo.isNameCompatible("package-info", kind);
}
 
Example 2
Source File: JavacProcessingEnvironment.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
private boolean isPkgInfo(JavaFileObject fo, JavaFileObject.Kind kind) {
    return fo.isNameCompatible("package-info", kind);
}
 
Example 3
Source File: JavadocClassReader.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Override extraFileActions to check for package documentation
 */
@Override
protected void extraFileActions(PackageSymbol pack, JavaFileObject fo) {
    if (fo.isNameCompatible("package", JavaFileObject.Kind.HTML))
        docenv.getPackageDoc(pack).setDocPath(fo);
}
 
Example 4
Source File: JavacProcessingEnvironment.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
private boolean isPkgInfo(JavaFileObject fo, JavaFileObject.Kind kind) {
    return fo.isNameCompatible("package-info", kind);
}
 
Example 5
Source File: Checker.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public Void scan(DocCommentTree tree, TreePath p) {
    env.initTypes();
    env.setCurrent(p, tree);

    boolean isOverridingMethod = !env.currOverriddenMethods.isEmpty();
    JavaFileObject fo = p.getCompilationUnit().getSourceFile();

    if (p.getLeaf().getKind() == Tree.Kind.PACKAGE) {
        // If p points to a package, the implied declaration is the
        // package declaration (if any) for the compilation unit.
        // Handle this case specially, because doc comments are only
        // expected in package-info files.
        boolean isPkgInfo = fo.isNameCompatible("package-info", JavaFileObject.Kind.SOURCE);
        if (tree == null) {
            if (isPkgInfo)
                reportMissing("dc.missing.comment");
            return null;
        } else {
            if (!isPkgInfo)
                reportReference("dc.unexpected.comment");
        }
    } else if (tree != null && fo.isNameCompatible("package", JavaFileObject.Kind.HTML)) {
        // a package.html file with a DocCommentTree
        if (tree.getFullBody().isEmpty()) {
            reportMissing("dc.missing.comment");
            return null;
        }
    } else {
        if (tree == null) {
            if (!isSynthetic() && !isOverridingMethod)
                reportMissing("dc.missing.comment");
            return null;
        }
    }

    tagStack.clear();
    currHeaderTag = null;

    foundParams.clear();
    foundThrows.clear();
    foundInheritDoc = false;
    foundReturn = false;

    scan(new DocTreePath(p, tree), null);

    if (!isOverridingMethod) {
        switch (env.currElement.getKind()) {
            case METHOD:
            case CONSTRUCTOR: {
                ExecutableElement ee = (ExecutableElement) env.currElement;
                checkParamsDocumented(ee.getTypeParameters());
                checkParamsDocumented(ee.getParameters());
                switch (ee.getReturnType().getKind()) {
                    case VOID:
                    case NONE:
                        break;
                    default:
                        if (!foundReturn
                                && !foundInheritDoc
                                && !env.types.isSameType(ee.getReturnType(), env.java_lang_Void)) {
                            reportMissing("dc.missing.return");
                        }
                }
                checkThrowsDocumented(ee.getThrownTypes());
            }
        }
    }

    return null;
}
 
Example 6
Source File: JavacProcessingEnvironment.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
private boolean isPkgInfo(JavaFileObject fo, JavaFileObject.Kind kind) {
    return fo.isNameCompatible("package-info", kind);
}
 
Example 7
Source File: JavacProcessingEnvironment.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
private boolean isPkgInfo(JavaFileObject fo, JavaFileObject.Kind kind) {
    return fo.isNameCompatible("package-info", kind);
}
 
Example 8
Source File: JavadocClassReader.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Override extraFileActions to check for package documentation
 */
@Override
protected void extraFileActions(PackageSymbol pack, JavaFileObject fo) {
    if (fo.isNameCompatible("package", JavaFileObject.Kind.HTML))
        docenv.getPackageDoc(pack).setDocPath(fo);
}
 
Example 9
Source File: JavadocClassReader.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Override extraFileActions to check for package documentation
 */
@Override
protected void extraFileActions(PackageSymbol pack, JavaFileObject fo) {
    if (fo.isNameCompatible("package", JavaFileObject.Kind.HTML))
        docenv.getPackageDoc(pack).setDocPath(fo);
}
 
Example 10
Source File: JavacProcessingEnvironment.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private boolean isModuleInfo(JavaFileObject fo, JavaFileObject.Kind kind) {
    return fo.isNameCompatible("module-info", kind);
}
 
Example 11
Source File: Checker.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public Void scan(DocCommentTree tree, TreePath p) {
    env.setCurrent(p, tree);

    boolean isOverridingMethod = !env.currOverriddenMethods.isEmpty();

    if (p.getLeaf() == p.getCompilationUnit()) {
        // If p points to a compilation unit, the implied declaration is the
        // package declaration (if any) for the compilation unit.
        // Handle this case specially, because doc comments are only
        // expected in package-info files.
        JavaFileObject fo = p.getCompilationUnit().getSourceFile();
        boolean isPkgInfo = fo.isNameCompatible("package-info", JavaFileObject.Kind.SOURCE);
        if (tree == null) {
            if (isPkgInfo)
                reportMissing("dc.missing.comment");
            return null;
        } else {
            if (!isPkgInfo)
                reportReference("dc.unexpected.comment");
        }
    } else {
        if (tree == null) {
            if (!isSynthetic() && !isOverridingMethod)
                reportMissing("dc.missing.comment");
            return null;
        }
    }

    tagStack.clear();
    currHeaderTag = null;

    foundParams.clear();
    foundThrows.clear();
    foundInheritDoc = false;
    foundReturn = false;

    scan(new DocTreePath(p, tree), null);

    if (!isOverridingMethod) {
        switch (env.currElement.getKind()) {
            case METHOD:
            case CONSTRUCTOR: {
                ExecutableElement ee = (ExecutableElement) env.currElement;
                checkParamsDocumented(ee.getTypeParameters());
                checkParamsDocumented(ee.getParameters());
                switch (ee.getReturnType().getKind()) {
                    case VOID:
                    case NONE:
                        break;
                    default:
                        if (!foundReturn
                                && !foundInheritDoc
                                && !env.types.isSameType(ee.getReturnType(), env.java_lang_Void)) {
                            reportMissing("dc.missing.return");
                        }
                }
                checkThrowsDocumented(ee.getThrownTypes());
            }
        }
    }

    return null;
}
 
Example 12
Source File: JavacProcessingEnvironment.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
private boolean isPkgInfo(JavaFileObject fo, JavaFileObject.Kind kind) {
    return fo.isNameCompatible("package-info", kind);
}
 
Example 13
Source File: JavadocClassReader.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Override extraFileActions to check for package documentation
 */
@Override
protected void extraFileActions(PackageSymbol pack, JavaFileObject fo) {
    if (fo.isNameCompatible("package", JavaFileObject.Kind.HTML))
        docenv.getPackageDoc(pack).setDocPath(fo);
}
 
Example 14
Source File: Checker.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public Void scan(DocCommentTree tree, TreePath p) {
    env.setCurrent(p, tree);

    boolean isOverridingMethod = !env.currOverriddenMethods.isEmpty();

    if (p.getLeaf() == p.getCompilationUnit()) {
        // If p points to a compilation unit, the implied declaration is the
        // package declaration (if any) for the compilation unit.
        // Handle this case specially, because doc comments are only
        // expected in package-info files.
        JavaFileObject fo = p.getCompilationUnit().getSourceFile();
        boolean isPkgInfo = fo.isNameCompatible("package-info", JavaFileObject.Kind.SOURCE);
        if (tree == null) {
            if (isPkgInfo)
                reportMissing("dc.missing.comment");
            return null;
        } else {
            if (!isPkgInfo)
                reportReference("dc.unexpected.comment");
        }
    } else {
        if (tree == null) {
            if (!isSynthetic() && !isOverridingMethod)
                reportMissing("dc.missing.comment");
            return null;
        }
    }

    tagStack.clear();
    currHeaderTag = null;

    foundParams.clear();
    foundThrows.clear();
    foundInheritDoc = false;
    foundReturn = false;

    scan(new DocTreePath(p, tree), null);

    if (!isOverridingMethod) {
        switch (env.currElement.getKind()) {
            case METHOD:
            case CONSTRUCTOR: {
                ExecutableElement ee = (ExecutableElement) env.currElement;
                checkParamsDocumented(ee.getTypeParameters());
                checkParamsDocumented(ee.getParameters());
                switch (ee.getReturnType().getKind()) {
                    case VOID:
                    case NONE:
                        break;
                    default:
                        if (!foundReturn
                                && !foundInheritDoc
                                && !env.types.isSameType(ee.getReturnType(), env.java_lang_Void)) {
                            reportMissing("dc.missing.return");
                        }
                }
                checkThrowsDocumented(ee.getThrownTypes());
            }
        }
    }

    return null;
}
 
Example 15
Source File: JavacProcessingEnvironment.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
private boolean isPkgInfo(JavaFileObject fo, JavaFileObject.Kind kind) {
    return fo.isNameCompatible("package-info", kind);
}
 
Example 16
Source File: JavacProcessingEnvironment.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
private boolean isPkgInfo(JavaFileObject fo, JavaFileObject.Kind kind) {
    return fo.isNameCompatible("package-info", kind);
}
 
Example 17
Source File: JavadocClassReader.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Override extraFileActions to check for package documentation
 */
@Override
protected void extraFileActions(PackageSymbol pack, JavaFileObject fo) {
    if (fo.isNameCompatible("package", JavaFileObject.Kind.HTML))
        docenv.getPackageDoc(pack).setDocPath(fo);
}
 
Example 18
Source File: Checker.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public Void scan(DocCommentTree tree, TreePath p) {
    env.setCurrent(p, tree);

    boolean isOverridingMethod = !env.currOverriddenMethods.isEmpty();

    if (p.getLeaf() == p.getCompilationUnit()) {
        // If p points to a compilation unit, the implied declaration is the
        // package declaration (if any) for the compilation unit.
        // Handle this case specially, because doc comments are only
        // expected in package-info files.
        JavaFileObject fo = p.getCompilationUnit().getSourceFile();
        boolean isPkgInfo = fo.isNameCompatible("package-info", JavaFileObject.Kind.SOURCE);
        if (tree == null) {
            if (isPkgInfo)
                reportMissing("dc.missing.comment");
            return null;
        } else {
            if (!isPkgInfo)
                reportReference("dc.unexpected.comment");
        }
    } else {
        if (tree == null) {
            if (!isSynthetic() && !isOverridingMethod)
                reportMissing("dc.missing.comment");
            return null;
        }
    }

    tagStack.clear();
    currHeaderTag = null;

    foundParams.clear();
    foundThrows.clear();
    foundInheritDoc = false;
    foundReturn = false;

    scan(new DocTreePath(p, tree), null);

    if (!isOverridingMethod) {
        switch (env.currElement.getKind()) {
            case METHOD:
            case CONSTRUCTOR: {
                ExecutableElement ee = (ExecutableElement) env.currElement;
                checkParamsDocumented(ee.getTypeParameters());
                checkParamsDocumented(ee.getParameters());
                switch (ee.getReturnType().getKind()) {
                    case VOID:
                    case NONE:
                        break;
                    default:
                        if (!foundReturn
                                && !foundInheritDoc
                                && !env.types.isSameType(ee.getReturnType(), env.java_lang_Void)) {
                            reportMissing("dc.missing.return");
                        }
                }
                checkThrowsDocumented(ee.getThrownTypes());
            }
        }
    }

    return null;
}
 
Example 19
Source File: JavadocClassReader.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Override extraFileActions to check for package documentation
 */
@Override
protected void extraFileActions(PackageSymbol pack, JavaFileObject fo) {
    if (fo.isNameCompatible("package", JavaFileObject.Kind.HTML))
        docenv.getPackageDoc(pack).setDocPath(fo);
}
 
Example 20
Source File: JavadocClassReader.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Override extraFileActions to check for package documentation
 */
@Override
protected void extraFileActions(PackageSymbol pack, JavaFileObject fo) {
    if (fo.isNameCompatible("package", JavaFileObject.Kind.HTML))
        docenv.getPackageDoc(pack).setDocPath(fo);
}