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

The following are Jave code examples for showing how to use isNameCompatible() of the javax.tools.JavaFileObject class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: openjdk-jdk10   File: JavadocClassFinder.java   View Source Code Vote up 5 votes
/**
 * Override extraFileActions to check for package documentation
 */
@Override
protected void extraFileActions(PackageSymbol pack, JavaFileObject fo) {
    if (fo.isNameCompatible("package", JavaFileObject.Kind.HTML)) {
        pack.sourcefile = fo;
    }
}
 
Example 2
Project: javaide   File: JavacProcessingEnvironment.java   View Source Code Vote up 4 votes
private boolean isPkgInfo(JavaFileObject fo, JavaFileObject.Kind kind) {
    return fo.isNameCompatible("package-info", kind);
}
 
Example 3
Project: OpenJSharp   File: Checker.java   View Source Code Vote up 4 votes
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 4
Project: OpenJSharp   File: JavadocClassReader.java   View Source Code Vote up 4 votes
/**
 * 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 5
Project: OpenJSharp   File: JavacProcessingEnvironment.java   View Source Code Vote up 4 votes
private boolean isPkgInfo(JavaFileObject fo, JavaFileObject.Kind kind) {
    return fo.isNameCompatible("package-info", kind);
}
 
Example 6
Project: openjdk-jdk10   File: Checker.java   View Source Code Vote up 4 votes
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;
    hasNonWhitespaceText = 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 7
Project: openjdk-jdk10   File: JavacProcessingEnvironment.java   View Source Code Vote up 4 votes
private boolean isPkgInfo(JavaFileObject fo, JavaFileObject.Kind kind) {
    return fo.isNameCompatible("package-info", kind);
}
 
Example 8
Project: openjdk-jdk10   File: JavacProcessingEnvironment.java   View Source Code Vote up 4 votes
private boolean isModuleInfo(JavaFileObject fo, JavaFileObject.Kind kind) {
    return fo.isNameCompatible("module-info", kind);
}
 
Example 9
Project: openjdk-jdk10   File: JavadocClassFinder.java   View Source Code Vote up 4 votes
/**
 * 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);
}