com.sun.tools.javac.tree.JCTree.JCPackageDecl Java Examples

The following examples show how to use com.sun.tools.javac.tree.JCTree.JCPackageDecl. 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: Lower.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private boolean needPackageInfoClass(JCPackageDecl pd) {
    switch (pkginfoOpt) {
        case ALWAYS:
            return true;
        case LEGACY:
            return pd.getAnnotations().nonEmpty();
        case NONEMPTY:
            for (Attribute.Compound a :
                     pd.packge.getDeclarationAttributes()) {
                Attribute.RetentionPolicy p = types.getRetention(a);
                if (p != Attribute.RetentionPolicy.SOURCE)
                    return true;
            }
            return false;
    }
    throw new AssertionError();
}
 
Example #2
Source File: TypeEnter.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void checkClassPackageClash(JCPackageDecl tree) {
    // check that no class exists with same fully qualified name as
    // toplevel package
    if (checkClash && tree.pid != null) {
        Symbol p = env.toplevel.packge;
        while (p.owner != syms.rootPackage) {
            p.owner.complete(); // enter all class members of p
            //need to lookup the owning module/package:
            PackageSymbol pack = syms.lookupPackage(env.toplevel.modle, p.owner.getQualifiedName());
            if (syms.getClass(pack.modle, p.getQualifiedName()) != null) {
                log.error(tree.pos,
                          Errors.PkgClashesWithClassOfSameName(p));
            }
            p = p.owner;
        }
    }
    // process package annotations
    annotate.annotateLater(tree.annotations, env, env.toplevel.packge, null);
}
 
Example #3
Source File: Lower.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void visitPackageDef(JCPackageDecl tree) {
    if (!needPackageInfoClass(tree))
                    return;

    long flags = Flags.ABSTRACT | Flags.INTERFACE;
    // package-info is marked SYNTHETIC in JDK 1.6 and later releases
    flags = flags | Flags.SYNTHETIC;
    ClassSymbol c = tree.packge.package_info;
    c.setAttributes(tree.packge);
    c.flags_field |= flags;
    ClassType ctype = (ClassType) c.type;
    ctype.supertype_field = syms.objectType;
    ctype.interfaces_field = List.nil();
    createInfoClass(tree.annotations, c);
}
 
Example #4
Source File: Flow.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public void visitPackageDef(JCPackageDecl tree) {
    // Do nothing for PackageDecl
}
 
Example #5
Source File: ToolEnvironment.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
TreePath getTreePath(JCCompilationUnit toplevel, JCPackageDecl tree) {
    TreePath p = treePaths.get(tree);
    if (p == null)
        treePaths.put(tree, p = new TreePath(getTreePath(toplevel), tree));
    return p;
}
 
Example #6
Source File: DocEnv.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
TreePath getTreePath(JCCompilationUnit toplevel, JCPackageDecl tree) {
    TreePath p = treePaths.get(tree);
    if (p == null)
        treePaths.put(tree, p = new TreePath(getTreePath(toplevel), tree));
    return p;
}