com.sun.tools.javac.code.Scope.StarImportScope Java Examples

The following examples show how to use com.sun.tools.javac.code.Scope.StarImportScope. 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: StarImportTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
         * Create a star-import scope and a model thereof, from the packages and
         * classes created by setupPackages and setupClasses.
         * @throws Exception for fatal errors, such as from reflection
         */
        void createStarImportScope() throws Exception {
            log ("createStarImportScope");
            PackageSymbol pkg = new PackageSymbol(names.fromString("pkg"), symtab.rootPackage);

            starImportScope = new StarImportScope(pkg);
            starImportModel = new Model();

            for (Symbol imp: imports) {
                Scope members = imp.members();
//                    log("importAll", members);
                starImportScope.importAll(types, members, new ImportFilter() {
                    @Override
                    public boolean accepts(Scope origin, Symbol t) {
                        return t.kind == TYP;
                    }
                }, make.Import(null, false), (i, cf) -> { throw new IllegalStateException(); });

                for (Symbol sym : members.getSymbols()) {
                    starImportModel.enter(sym);
                }
            }

//            log("star-import scope", starImportScope);
            starImportModel.check(starImportScope);
        }
 
Example #2
Source File: JCTree.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
protected JCCompilationUnit(List<JCAnnotation> packageAnnotations,
                            JCExpression pid,
                            List<JCTree> defs,
                            JavaFileObject sourcefile,
                            PackageSymbol packge,
                            ImportScope namedImportScope,
                            StarImportScope starImportScope) {
    this.packageAnnotations = packageAnnotations;
    this.pid = pid;
    this.defs = defs;
    this.sourcefile = sourcefile;
    this.packge = packge;
    this.namedImportScope = namedImportScope;
    this.starImportScope = starImportScope;
}
 
Example #3
Source File: Enter.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
/** Create a fresh environment for toplevels.
 *  @param tree     The toplevel tree.
 */
Env<AttrContext> topLevelEnv(JCCompilationUnit tree) {
    Env<AttrContext> localEnv = new Env<AttrContext>(tree, new AttrContext());
    localEnv.toplevel = tree;
    localEnv.enclClass = predefClassDef;
    tree.namedImportScope = new ImportScope(tree.packge);
    tree.starImportScope = new StarImportScope(tree.packge);
    localEnv.info.scope = tree.namedImportScope;
    localEnv.info.lint = lint;
    return localEnv;
}
 
Example #4
Source File: Enter.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/** Create a fresh environment for toplevels.
 *  @param tree     The toplevel tree.
 */
Env<AttrContext> topLevelEnv(JCCompilationUnit tree) {
    Env<AttrContext> localEnv = new Env<>(tree, new AttrContext());
    localEnv.toplevel = tree;
    localEnv.enclClass = predefClassDef;
    tree.toplevelScope = WriteableScope.create(tree.packge);
    tree.namedImportScope = new NamedImportScope(tree.packge, tree.toplevelScope);
    tree.starImportScope = new StarImportScope(tree.packge);
    localEnv.info.scope = tree.toplevelScope;
    localEnv.info.lint = lint;
    return localEnv;
}
 
Example #5
Source File: TypeEnter.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/** Import all static members of a class or package on demand.
 *  @param imp           The import that is being handled.
 *  @param tsym          The class or package the members of which are imported.
 *  @param env           The env in which the imported classes will be entered.
 */
private void importStaticAll(JCImport imp,
                             final TypeSymbol tsym,
                             Env<AttrContext> env) {
    final StarImportScope toScope = env.toplevel.starImportScope;
    final TypeSymbol origin = tsym;

    toScope.importAll(types, origin.members(), staticImportFilter, imp, cfHandler);
}
 
Example #6
Source File: JCTree.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
protected JCCompilationUnit(List<JCAnnotation> packageAnnotations,
                            JCExpression pid,
                            List<JCTree> defs,
                            JavaFileObject sourcefile,
                            PackageSymbol packge,
                            ImportScope namedImportScope,
                            StarImportScope starImportScope) {
    this.packageAnnotations = packageAnnotations;
    this.pid = pid;
    this.defs = defs;
    this.sourcefile = sourcefile;
    this.packge = packge;
    this.namedImportScope = namedImportScope;
    this.starImportScope = starImportScope;
}
 
Example #7
Source File: Enter.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
/** Create a fresh environment for toplevels.
 *  @param tree     The toplevel tree.
 */
Env<AttrContext> topLevelEnv(JCCompilationUnit tree) {
    Env<AttrContext> localEnv = new Env<AttrContext>(tree, new AttrContext());
    localEnv.toplevel = tree;
    localEnv.enclClass = predefClassDef;
    tree.namedImportScope = new ImportScope(tree.packge);
    tree.starImportScope = new StarImportScope(tree.packge);
    localEnv.info.scope = tree.namedImportScope;
    localEnv.info.lint = lint;
    return localEnv;
}
 
Example #8
Source File: TypeEnter.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/** Import all static members of a class or package on demand.
 *  @param imp           The import that is being handled.
 *  @param tsym          The class or package the members of which are imported.
 *  @param env           The env in which the imported classes will be entered.
 */
private void importStaticAll(JCImport imp,
                             final TypeSymbol tsym,
                             Env<AttrContext> env) {
    final StarImportScope toScope = env.toplevel.starImportScope;
    final TypeSymbol origin = tsym;

    toScope.importAll(types, origin.members(), staticImportFilter, imp, cfHandler);
}