com.sun.tools.javac.code.Symbol.CompletionFailure Java Examples

The following examples show how to use com.sun.tools.javac.code.Symbol.CompletionFailure. 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: ClassDependingOnGenerated.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public boolean process(Set<? extends TypeElement> annotations,
                       RoundEnvironment roundEnv) {

    try {
        processingEnv.getElementUtils().getTypeElement("SuperClass");
    } catch (CompletionFailure cf) {
        cf.printStackTrace();
    }
    if (round++ == 1) {
        try (Writer out = filer.createSourceFile("SuperClass").openWriter()) {
            String code = "class SuperClass { public int get() { return 0; } }";
            out.write(code);
            out.close();
        } catch (IOException e) {
            processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, e.toString());
        }
    }

    return false;
}
 
Example #2
Source File: ClassFinder.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/** Load a toplevel class with given fully qualified name
 *  The class is entered into `classes' only if load was successful.
 */
public ClassSymbol loadClass(ModuleSymbol msym, Name flatname) throws CompletionFailure {
    Assert.checkNonNull(msym);
    Name packageName = Convert.packagePart(flatname);
    PackageSymbol ps = syms.lookupPackage(msym, packageName);

    Assert.checkNonNull(ps.modle, () -> "msym=" + msym + "; flatName=" + flatname);

    boolean absent = syms.getClass(ps.modle, flatname) == null;
    ClassSymbol c = syms.enterClass(ps.modle, flatname);

    if (c.members_field == null) {
        try {
            c.complete();
        } catch (CompletionFailure ex) {
            if (absent) syms.removeClass(ps.modle, flatname);
            throw ex;
        }
    }
    return c;
}
 
Example #3
Source File: JavahTask.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    try {
        Set<TypeElement> classes = getAllClasses(ElementFilter.typesIn(roundEnv.getRootElements()));
        if (classes.size() > 0) {
            checkMethodParameters(classes);
            g.setProcessingEnvironment(processingEnv);
            g.setClasses(classes);
            g.run();
        }
    } catch (CompletionFailure cf) {
        messager.printMessage(ERROR, getMessage("class.not.found", cf.sym.getQualifiedName().toString()));
    } catch (ClassNotFoundException cnfe) {
        messager.printMessage(ERROR, getMessage("class.not.found", cnfe.getMessage()));
    } catch (IOException ioe) {
        messager.printMessage(ERROR, getMessage("io.exception", ioe.getMessage()));
    } catch (Util.Exit e) {
        exit = e;
    }

    return true;
}
 
Example #4
Source File: JavadocTool.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 *  Construct a new javadoc tool.
 */
public static JavadocTool make0(Context context) {
    Messager messager = null;
    try {
        // force the use of Javadoc's class reader
        JavadocClassReader.preRegister(context);

        // force the use of Javadoc's own enter phase
        JavadocEnter.preRegister(context);

        // force the use of Javadoc's own member enter phase
        JavadocMemberEnter.preRegister(context);

        // force the use of Javadoc's own todo phase
        JavadocTodo.preRegister(context);

        // force the use of Messager as a Log
        messager = Messager.instance0(context);

        return new JavadocTool(context);
    } catch (CompletionFailure ex) {
        messager.error(Position.NOPOS, ex.getMessage());
        return null;
    }
}
 
Example #5
Source File: JavadocTool.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 *  Construct a new javadoc tool.
 */
public static JavadocTool make0(Context context) {
    Messager messager = null;
    try {
        // force the use of Javadoc's class reader
        JavadocClassReader.preRegister(context);

        // force the use of Javadoc's own enter phase
        JavadocEnter.preRegister(context);

        // force the use of Javadoc's own member enter phase
        JavadocMemberEnter.preRegister(context);

        // force the use of Javadoc's own todo phase
        JavadocTodo.preRegister(context);

        // force the use of Messager as a Log
        messager = Messager.instance0(context);

        return new JavadocTool(context);
    } catch (CompletionFailure ex) {
        messager.error(Position.NOPOS, ex.getMessage());
        return null;
    }
}
 
Example #6
Source File: JavadocTool.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 *  Construct a new javadoc tool.
 */
public static JavadocTool make0(Context context) {
    Messager messager = null;
    try {
        // force the use of Javadoc's class reader
        JavadocClassReader.preRegister(context);

        // force the use of Javadoc's own enter phase
        JavadocEnter.preRegister(context);

        // force the use of Javadoc's own member enter phase
        JavadocMemberEnter.preRegister(context);

        // force the use of Javadoc's own todo phase
        JavadocTodo.preRegister(context);

        // force the use of Messager as a Log
        messager = Messager.instance0(context);

        return new JavadocTool(context);
    } catch (CompletionFailure ex) {
        messager.error(Position.NOPOS, ex.getMessage());
        return null;
    }
}
 
Example #7
Source File: JavadocTool.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 *  Construct a new javadoc tool.
 */
public static JavadocTool make0(Context context) {
    Messager messager = null;
    try {
        // force the use of Javadoc's class reader
        JavadocClassReader.preRegister(context);

        // force the use of Javadoc's own enter phase
        JavadocEnter.preRegister(context);

        // force the use of Javadoc's own member enter phase
        JavadocMemberEnter.preRegister(context);

        // force the use of Javadoc's own todo phase
        JavadocTodo.preRegister(context);

        // force the use of Messager as a Log
        messager = Messager.instance0(context);

        return new JavadocTool(context);
    } catch (CompletionFailure ex) {
        messager.error(Position.NOPOS, ex.getMessage());
        return null;
    }
}
 
Example #8
Source File: Modules.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private Completer getUnnamedModuleCompleter() {
    moduleFinder.findAllModules();
    return new Symbol.Completer() {
        @Override
        public void complete(Symbol sym) throws CompletionFailure {
            if (inInitModules) {
                sym.completer = this;
                return ;
            }
            ModuleSymbol msym = (ModuleSymbol) sym;
            Set<ModuleSymbol> allModules = new HashSet<>(allModules());
            allModules.remove(syms.unnamedModule);
            for (ModuleSymbol m : allModules) {
                m.complete();
            }
            initVisiblePackages(msym, allModules);
        }

        @Override
        public String toString() {
            return "unnamedModule Completer";
        }
    };
}
 
Example #9
Source File: JavahTask.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    try {
        Set<TypeElement> classes = getAllClasses(ElementFilter.typesIn(roundEnv.getRootElements()));
        if (classes.size() > 0) {
            checkMethodParameters(classes);
            g.setProcessingEnvironment(processingEnv);
            g.setClasses(classes);
            g.run();
        }
    } catch (CompletionFailure cf) {
        messager.printMessage(ERROR, getMessage("class.not.found", cf.sym.getQualifiedName().toString()));
    } catch (ClassNotFoundException cnfe) {
        messager.printMessage(ERROR, getMessage("class.not.found", cnfe.getMessage()));
    } catch (IOException ioe) {
        messager.printMessage(ERROR, getMessage("io.exception", ioe.getMessage()));
    } catch (Util.Exit e) {
        exit = e;
    }

    return true;
}
 
Example #10
Source File: JavahTask.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    try {
        Set<TypeElement> classes = getAllClasses(ElementFilter.typesIn(roundEnv.getRootElements()));
        if (classes.size() > 0) {
            checkMethodParameters(classes);
            g.setProcessingEnvironment(processingEnv);
            g.setClasses(classes);
            g.run();
        }
    } catch (CompletionFailure cf) {
        messager.printMessage(ERROR, getMessage("class.not.found", cf.sym.getQualifiedName().toString()));
    } catch (ClassNotFoundException cnfe) {
        messager.printMessage(ERROR, getMessage("class.not.found", cnfe.getMessage()));
    } catch (IOException ioe) {
        messager.printMessage(ERROR, getMessage("io.exception", ioe.getMessage()));
    } catch (Util.Exit e) {
        exit = e;
    }

    return true;
}
 
Example #11
Source File: Symtab.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public void synthesizeEmptyInterfaceIfMissing(final Type type) {
    final Completer completer = type.tsym.completer;
    type.tsym.completer = new Completer() {
        @Override
        public void complete(Symbol sym) throws CompletionFailure {
            try {
                completer.complete(sym);
            } catch (CompletionFailure e) {
                sym.flags_field |= (PUBLIC | INTERFACE);
                ((ClassType) sym.type).supertype_field = objectType;
            }
        }

        @Override
        public boolean isTerminal() {
            return completer.isTerminal();
        }
    };
}
 
Example #12
Source File: JavahTask.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    try {
        Set<TypeElement> classes = getAllClasses(ElementFilter.typesIn(roundEnv.getRootElements()));
        if (classes.size() > 0) {
            checkMethodParameters(classes);
            g.setProcessingEnvironment(processingEnv);
            g.setClasses(classes);
            g.run();
        }
    } catch (CompletionFailure cf) {
        messager.printMessage(ERROR, getMessage("class.not.found", cf.sym.getQualifiedName().toString()));
    } catch (ClassNotFoundException cnfe) {
        messager.printMessage(ERROR, getMessage("class.not.found", cnfe.getMessage()));
    } catch (IOException ioe) {
        messager.printMessage(ERROR, getMessage("io.exception", ioe.getMessage()));
    } catch (Util.Exit e) {
        exit = e;
    }

    return true;
}
 
Example #13
Source File: ClassFinder.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/** Completion for classes to be loaded. Before a class is loaded
 *  we make sure its enclosing class (if any) is loaded.
 */
private void complete(Symbol sym) throws CompletionFailure {
    if (sym.kind == TYP) {
        try {
            ClassSymbol c = (ClassSymbol) sym;
            dependencies.push(c, CompletionCause.CLASS_READER);
            annotate.blockAnnotations();
            c.members_field = new Scope.ErrorScope(c); // make sure it's always defined
            completeOwners(c.owner);
            completeEnclosing(c);
            fillIn(c);
        } finally {
            annotate.unblockAnnotationsNoFlush();
            dependencies.pop();
        }
    } else if (sym.kind == PCK) {
        PackageSymbol p = (PackageSymbol)sym;
        try {
            fillIn(p);
        } catch (IOException ex) {
            throw new CompletionFailure(sym, ex.getLocalizedMessage()).initCause(ex);
        }
    }
    if (!reader.filling)
        annotate.flush(); // finish attaching annotations
}
 
Example #14
Source File: JavahTask.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    try {
        Set<TypeElement> classes = getAllClasses(ElementFilter.typesIn(roundEnv.getRootElements()));
        if (classes.size() > 0) {
            checkMethodParameters(classes);
            g.setProcessingEnvironment(processingEnv);
            g.setClasses(classes);
            g.run();
        }
    } catch (CompletionFailure cf) {
        messager.printMessage(ERROR, getMessage("class.not.found", cf.sym.getQualifiedName().toString()));
    } catch (ClassNotFoundException cnfe) {
        messager.printMessage(ERROR, getMessage("class.not.found", cnfe.getMessage()));
    } catch (IOException ioe) {
        messager.printMessage(ERROR, getMessage("io.exception", ioe.getMessage()));
    } catch (Util.Exit e) {
        exit = e;
    }

    return true;
}
 
Example #15
Source File: JavacElements.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Returns a symbol given the type's or package's canonical name,
 * or null if the name isn't found.
 */
private <S extends Symbol> S nameToSymbol(ModuleSymbol module, String nameStr, Class<S> clazz) {
    Name name = names.fromString(nameStr);
    // First check cache.
    Symbol sym = (clazz == ClassSymbol.class)
                ? syms.getClass(module, name)
                : syms.lookupPackage(module, name);

    try {
        if (sym == null)
            sym = javaCompiler.resolveIdent(module, nameStr);

        sym.complete();

        return (sym.kind != ERR &&
                sym.exists() &&
                clazz.isInstance(sym) &&
                name.equals(sym.getQualifiedName()))
            ? clazz.cast(sym)
            : null;
    } catch (CompletionFailure e) {
        return null;
    }
}
 
Example #16
Source File: JavahTask.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@DefinedBy(Api.ANNOTATION_PROCESSING)
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    try {
        Set<TypeElement> classes = getAllClasses(ElementFilter.typesIn(roundEnv.getRootElements()));
        if (classes.size() > 0) {
            checkMethodParameters(classes);
            g.setProcessingEnvironment(processingEnv);
            g.setClasses(classes);
            g.run();
        }
    } catch (CompletionFailure cf) {
        messager.printMessage(ERROR, getMessage("class.not.found", cf.sym.getQualifiedName().toString()));
    } catch (ClassNotFoundException cnfe) {
        messager.printMessage(ERROR, getMessage("class.not.found", cnfe.getMessage()));
    } catch (IOException ioe) {
        messager.printMessage(ERROR, getMessage("io.exception", ioe.getMessage()));
    } catch (Util.Exit e) {
        exit = e;
    }

    return true;
}
 
Example #17
Source File: Scope.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public Iterable<Symbol> getSymbols(final Filter<Symbol> sf, final LookupKind lookupKind) {
    if (filterName != null)
        return getSymbolsByName(filterName, sf, lookupKind);
    try {
        SymbolImporter si = new SymbolImporter(imp.staticImport) {
            @Override
            Iterable<Symbol> doLookup(TypeSymbol tsym) {
                return tsym.members().getSymbols(sf, lookupKind);
            }
        };
        List<Iterable<Symbol>> results =
                si.importFrom((TypeSymbol) origin.owner, List.nil());
        return () -> createFilterIterator(createCompoundIterator(results,
                                                                 Iterable::iterator),
                                          s -> filter.accepts(origin, s));
    } catch (CompletionFailure cf) {
        cfHandler.accept(imp, cf);
        return Collections.emptyList();
    }
}
 
Example #18
Source File: Scope.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public Iterable<Symbol> getSymbolsByName(final Name name,
                                         final Filter<Symbol> sf,
                                         final LookupKind lookupKind) {
    if (filterName != null && filterName != name)
        return Collections.emptyList();
    try {
        SymbolImporter si = new SymbolImporter(imp.staticImport) {
            @Override
            Iterable<Symbol> doLookup(TypeSymbol tsym) {
                return tsym.members().getSymbolsByName(name, sf, lookupKind);
            }
        };
        List<Iterable<Symbol>> results =
                si.importFrom((TypeSymbol) origin.owner, List.nil());
        return () -> createFilterIterator(createCompoundIterator(results,
                                                                 Iterable::iterator),
                                          s -> filter.accepts(origin, s));
    } catch (CompletionFailure cf) {
        cfHandler.accept(imp, cf);
        return Collections.emptyList();
    }
}
 
Example #19
Source File: Symtab.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void synthesizeEmptyInterfaceIfMissing(final Type type) {
    final Completer completer = type.tsym.completer;
    type.tsym.completer = new Completer() {
        @Override
        public void complete(Symbol sym) throws CompletionFailure {
            try {
                completer.complete(sym);
            } catch (CompletionFailure e) {
                sym.flags_field |= (PUBLIC | INTERFACE);
                ((ClassType) sym.type).supertype_field = objectType;
            }
        }

        @Override
        public boolean isTerminal() {
            return completer.isTerminal();
        }
    };
}
 
Example #20
Source File: ClassFinder.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/** Load a toplevel class with given fully qualified name
 *  The class is entered into `classes' only if load was successful.
 */
public ClassSymbol loadClass(ModuleSymbol msym, Name flatname) throws CompletionFailure {
    Assert.checkNonNull(msym);
    Name packageName = Convert.packagePart(flatname);
    PackageSymbol ps = syms.lookupPackage(msym, packageName);

    Assert.checkNonNull(ps.modle, () -> "msym=" + msym + "; flatName=" + flatname);

    boolean absent = syms.getClass(ps.modle, flatname) == null;
    ClassSymbol c = syms.enterClass(ps.modle, flatname);

    if (c.members_field == null) {
        try {
            c.complete();
        } catch (CompletionFailure ex) {
            if (absent) syms.removeClass(ps.modle, flatname);
            throw ex;
        }
    }
    return c;
}
 
Example #21
Source File: JavadocTool.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 *  Construct a new javadoc tool.
 */
public static JavadocTool make0(Context context) {
    Messager messager = null;
    try {
        // force the use of Javadoc's class reader
        JavadocClassReader.preRegister(context);

        // force the use of Javadoc's own enter phase
        JavadocEnter.preRegister(context);

        // force the use of Javadoc's own member enter phase
        JavadocMemberEnter.preRegister(context);

        // force the use of Javadoc's own todo phase
        JavadocTodo.preRegister(context);

        // force the use of Messager as a Log
        messager = Messager.instance0(context);

        return new JavadocTool(context);
    } catch (CompletionFailure ex) {
        messager.error(Position.NOPOS, ex.getMessage());
        return null;
    }
}
 
Example #22
Source File: JavahTask.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    try {
        Set<TypeElement> classes = getAllClasses(ElementFilter.typesIn(roundEnv.getRootElements()));
        if (classes.size() > 0) {
            checkMethodParameters(classes);
            g.setProcessingEnvironment(processingEnv);
            g.setClasses(classes);
            g.run();
        }
    } catch (CompletionFailure cf) {
        messager.printMessage(ERROR, getMessage("class.not.found", cf.sym.getQualifiedName().toString()));
    } catch (ClassNotFoundException cnfe) {
        messager.printMessage(ERROR, getMessage("class.not.found", cnfe.getMessage()));
    } catch (IOException ioe) {
        messager.printMessage(ERROR, getMessage("io.exception", ioe.getMessage()));
    } catch (Util.Exit e) {
        exit = e;
    }

    return true;
}
 
Example #23
Source File: JavaSource.java    From netbeans with Apache License 2.0 6 votes vote down vote up
static long createTaggedController(final FileObject fo, int position, final long timestamp, final Object[] controller) throws IOException {
    ClasspathInfo cpi = ClasspathInfo.create(fo);
    Collection<Source> sources = Collections.singleton(Source.create(fo));
    CompilationController cc = (CompilationController) controller[0];
    final NewComilerTask _task = new NewComilerTask(cpi, position, cc, timestamp);
    try {
        ParserManager.parse(sources, _task);
        controller[0] = _task.getCompilationController();
        return _task.getTimeStamp();
    } catch (final ParseException pe) {
        final Throwable rootCase = pe.getCause();
        if (rootCase instanceof CompletionFailure) {
            throw new IOException (rootCase);
        } else if (rootCase instanceof RuntimeException) {
            throw (RuntimeException) rootCase;
        } else {
            throw new IOException (rootCase);
        }
    }
}
 
Example #24
Source File: Check.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void validateTree(JCTree tree, boolean checkRaw, boolean isOuter) {
    if (tree != null) {
        boolean prevCheckRaw = this.checkRaw;
        this.checkRaw = checkRaw;
        this.isOuter = isOuter;

        try {
            tree.accept(this);
            if (checkRaw)
                checkRaw(tree, env);
        } catch (CompletionFailure ex) {
            completionError(tree.pos(), ex);
        } finally {
            this.checkRaw = prevCheckRaw;
        }
    }
}
 
Example #25
Source File: JavadocTool.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 *  Construct a new javadoc tool.
 */
public static JavadocTool make0(Context context) {
    Messager messager = null;
    try {
        // force the use of Javadoc's class finder
        JavadocClassFinder.preRegister(context);

        // force the use of Javadoc's own enter phase
        JavadocEnter.preRegister(context);

        // force the use of Javadoc's own member enter phase
        JavadocMemberEnter.preRegister(context);

        // force the use of Javadoc's own todo phase
        JavadocTodo.preRegister(context);

        // force the use of Messager as a Log
        messager = Messager.instance0(context);

        return new JavadocTool(context);
    } catch (CompletionFailure ex) {
        messager.error(Position.NOPOS, ex.getMessage());
        return null;
    }
}
 
Example #26
Source File: Check.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public boolean importAccessible(Symbol sym, PackageSymbol packge) {
    try {
        int flags = (int)(sym.flags() & AccessFlags);
        switch (flags) {
        default:
        case PUBLIC:
            return true;
        case PRIVATE:
            return false;
        case 0:
        case PROTECTED:
            return sym.packge() == packge;
        }
    } catch (ClassFinder.BadClassFile err) {
        throw err;
    } catch (CompletionFailure ex) {
        return false;
    }
}
 
Example #27
Source File: ElementUtils.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public static TypeElement getTypeElementByBinaryName(JavacTask task, ModuleElement mod, String name) {
    Context ctx = ((JavacTaskImpl) task).getContext();
    Names names = Names.instance(ctx);
    Symtab syms = Symtab.instance(ctx);
    Check chk = Check.instance(ctx);
    final Name wrappedName = names.fromString(name);
    ClassSymbol clazz = chk.getCompiled((ModuleSymbol) mod, wrappedName);
    if (clazz != null) {
        return clazz;
    }
    clazz = syms.enterClass((ModuleSymbol) mod, wrappedName);
    
    try {
        clazz.complete();
        
        if (clazz.kind == Kind.TYP &&
            clazz.flatName() == wrappedName) {
            return clazz;
        }
    } catch (CompletionFailure cf) {
    }

    return null;
}
 
Example #28
Source File: TypeEnter.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
protected void doCompleteEnvs(List<Env<AttrContext>> envs) {
    for (Env<AttrContext> env : envs) {
        JCClassDecl tree = (JCClassDecl)env.tree;

        queue.add(env);

        JavaFileObject prev = log.useSource(env.toplevel.sourcefile);
        DiagnosticPosition prevLintPos = deferredLintHandler.setPos(tree.pos());
        try {
            dependencies.push(env.enclClass.sym, phaseName);
            runPhase(env);
        } catch (CompletionFailure ex) {
            chk.completionError(tree.pos(), ex);
        } finally {
            dependencies.pop();
            deferredLintHandler.setPos(prevLintPos);
            log.useSource(prev);
        }
    }
}
 
Example #29
Source File: Modules.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void completeAutomaticModule(ModuleSymbol msym) throws CompletionFailure {
    ListBuffer<Directive> directives = new ListBuffer<>();

    directives.addAll(msym.directives);

    ListBuffer<RequiresDirective> requires = new ListBuffer<>();

    for (ModuleSymbol ms : allModules()) {
        if (ms == syms.unnamedModule || ms == msym)
            continue;
        Set<RequiresFlag> flags = (ms.flags_field & Flags.AUTOMATIC_MODULE) != 0 ?
                EnumSet.of(RequiresFlag.TRANSITIVE) : EnumSet.noneOf(RequiresFlag.class);
        RequiresDirective d = new RequiresDirective(ms, flags);
        directives.add(d);
        requires.add(d);
    }

    RequiresDirective requiresUnnamed = new RequiresDirective(syms.unnamedModule);
    directives.add(requiresUnnamed);
    requires.add(requiresUnnamed);

    msym.requires = requires.toList();
    msym.directives = directives.toList();
}
 
Example #30
Source File: Modules.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private Completer getUnnamedModuleCompleter() {
    moduleFinder.findAllModules();
    return new Symbol.Completer() {
        @Override
        public void complete(Symbol sym) throws CompletionFailure {
            if (inInitModules) {
                sym.completer = this;
                return ;
            }
            ModuleSymbol msym = (ModuleSymbol) sym;
            Set<ModuleSymbol> allModules = new HashSet<>(allModules());
            allModules.remove(syms.unnamedModule);
            for (ModuleSymbol m : allModules) {
                m.complete();
            }
            initVisiblePackages(msym, allModules);
        }

        @Override
        public String toString() {
            return "unnamedModule Completer";
        }
    };
}