Search in sources :

Example 26 with ListBuffer

use of com.sun.tools.javac.util.ListBuffer in project lombok by rzwitserloot.

the class JavacHandlerUtil method addAllButOne.

private static List<JCTree> addAllButOne(List<JCTree> defs, int idx) {
    ListBuffer<JCTree> out = new ListBuffer<JCTree>();
    int i = 0;
    for (JCTree def : defs) {
        if (i++ != idx)
            out.append(def);
    }
    return out.toList();
}
Also used : ListBuffer(com.sun.tools.javac.util.ListBuffer) JCTree(com.sun.tools.javac.tree.JCTree)

Example 27 with ListBuffer

use of com.sun.tools.javac.util.ListBuffer in project error-prone by google.

the class RefasterScanner method visitClass.

@Override
public Void visitClass(ClassTree node, Context context) {
    Symbol sym = ASTHelpers.getSymbol(node);
    if (sym == null || !sym.getQualifiedName().contentEquals(rule().qualifiedTemplateClass())) {
        ListBuffer<JCStatement> statements = new ListBuffer<>();
        for (Tree tree : node.getMembers()) {
            if (tree instanceof JCStatement) {
                statements.append((JCStatement) tree);
            } else {
                tree.accept(this, context);
            }
        }
        scan(TreeMaker.instance(context).Block(0, statements.toList()), context);
    }
    return null;
}
Also used : Symbol(com.sun.tools.javac.code.Symbol) ListBuffer(com.sun.tools.javac.util.ListBuffer) Tree(com.sun.source.tree.Tree) ClassTree(com.sun.source.tree.ClassTree) ParenthesizedTree(com.sun.source.tree.ParenthesizedTree) IfTree(com.sun.source.tree.IfTree) JCTree(com.sun.tools.javac.tree.JCTree) DoWhileLoopTree(com.sun.source.tree.DoWhileLoopTree) SynchronizedTree(com.sun.source.tree.SynchronizedTree) WhileLoopTree(com.sun.source.tree.WhileLoopTree) JCStatement(com.sun.tools.javac.tree.JCTree.JCStatement)

Example 28 with ListBuffer

use of com.sun.tools.javac.util.ListBuffer in project error-prone by google.

the class Template method checkBounds.

private boolean checkBounds(Unifier unifier, Inliner inliner, Warner warner) throws CouldNotResolveImportException {
    Types types = unifier.types();
    ListBuffer<Type> varsBuffer = new ListBuffer<>();
    ListBuffer<Type> bindingsBuffer = new ListBuffer<>();
    for (UTypeVar typeVar : typeVariables(unifier.getContext())) {
        varsBuffer.add(inliner.inlineAsVar(typeVar));
        bindingsBuffer.add(unifier.getBinding(typeVar.key()).type());
    }
    List<Type> vars = varsBuffer.toList();
    List<Type> bindings = bindingsBuffer.toList();
    for (UTypeVar typeVar : typeVariables(unifier.getContext())) {
        List<Type> bounds = types.getBounds(inliner.inlineAsVar(typeVar));
        bounds = types.subst(bounds, vars, bindings);
        if (!types.isSubtypeUnchecked(unifier.getBinding(typeVar.key()).type(), bounds, warner)) {
            logger.log(FINE, String.format("%s is not a subtype of %s", inliner.getBinding(typeVar.key()), bounds));
            return false;
        }
    }
    return true;
}
Also used : Types(com.sun.tools.javac.code.Types) MethodType(com.sun.tools.javac.code.Type.MethodType) Type(com.sun.tools.javac.code.Type) ListBuffer(com.sun.tools.javac.util.ListBuffer)

Example 29 with ListBuffer

use of com.sun.tools.javac.util.ListBuffer in project jangaroo-tools by CoreMedia.

the class JoodocTool method getRootDocImpl.

public RootDocImpl getRootDocImpl(String docLocale, String encoding, ModifierFilter showAccess, List list, List optionList, boolean breakiterator, List list2, List list3, boolean flag) {
    ListBuffer listbuffer = new ListBuffer();
    ListBuffer listbuffer1 = new ListBuffer();
    ListBuffer listbuffer2 = new ListBuffer();
    for (List list4 = list; list4.nonEmpty(); list4 = list4.tail) {
        String s2 = (String) list4.head;
        if (s2.endsWith(JS2_SUFFIX) && (new File(s2)).exists()) {
            messager.notice("main.Loading_source_file", s2);
            processSource(s2);
            continue;
        }
        if (isValidPackageName(s2)) {
            listbuffer = listbuffer.append(s2);
            continue;
        }
        if (s2.endsWith(JS2_SUFFIX))
            messager.error(null, "main.file_not_found", s2);
        else
            messager.error(null, "main.illegal_package_name", s2);
    }
    ArrayList units = getCompilationUnits();
    for (int i = 0; i < units.size(); i++) {
        CompilationUnit unit = (CompilationUnit) units.get(i);
        unit.analyze(new AnalyzeContext());
    // searchSubPackages(list2, listbuffer, list3);
    //for(List list5 = listbuffer.toList(); list5.nonEmpty(); list5 = list5.tail)
    //    parsePackageClasses((String)list5.head, listbuffer2, list3);
    //
    }
    return new RootDocImpl(new Context(getCompilationUnits()), optionList);
}
Also used : CompilationUnit(net.jangaroo.jooc.CompilationUnit) AnalyzeContext(net.jangaroo.jooc.AnalyzeContext) AnalyzeContext(net.jangaroo.jooc.AnalyzeContext) ListBuffer(com.sun.tools.javac.util.ListBuffer) ArrayList(java.util.ArrayList) List(com.sun.tools.javac.util.List) ArrayList(java.util.ArrayList) File(java.io.File)

Example 30 with ListBuffer

use of com.sun.tools.javac.util.ListBuffer in project jangaroo-tools by CoreMedia.

the class Start method parseAndExecute.

private boolean parseAndExecute(String[] as) {
    long l = System.currentTimeMillis();
    ListBuffer listbuffer = new ListBuffer();
    try {
        as = CommandLine.parse(as);
    } catch (FileNotFoundException filenotfoundexception) {
        messager.error(null, "main.cant.read", filenotfoundexception.getMessage());
        exit();
    } catch (IOException ioexception) {
        ioexception.printStackTrace();
        exit();
    }
    setDocletInvoker(as);
    ListBuffer listbuffer1 = new ListBuffer();
    ListBuffer listbuffer2 = new ListBuffer();
    Options options1 = Options.instance(context);
    boolean flag = false;
    for (int i = 0; i < as.length; i++) {
        String s = as[i];
        if (s.equals("-subpackages")) {
            oneArg(as, i++);
            addToList(listbuffer1, as[i]);
            continue;
        }
        if (s.equals("-exclude")) {
            oneArg(as, i++);
            addToList(listbuffer2, as[i]);
            continue;
        }
        if (s.equals("-verbose")) {
            setOption(s);
            options1.put("-verbose", "");
            continue;
        }
        if (s.equals("-encoding")) {
            oneArg(as, i++);
            encoding = as[i];
            options1.put("-encoding", as[i]);
            continue;
        }
        if (s.equals("-breakiterator")) {
            breakiterator = true;
            setOption("-breakiterator");
            continue;
        }
        if (s.equals("-help")) {
            usage();
            exit();
            continue;
        }
        if (s.equals("-Xclasses")) {
            setOption(s);
            flag = true;
            continue;
        }
        if (s.equals("-Xwerror")) {
            setOption(s);
            rejectWarnings = true;
            continue;
        }
        if (s.equals("-private")) {
            setOption(s);
            setFilter(-9223372036854775801L);
            continue;
        }
        if (s.equals("-package")) {
            setOption(s);
            setFilter(-9223372036854775803L);
            continue;
        }
        if (s.equals("-protected")) {
            setOption(s);
            setFilter(5L);
            continue;
        }
        if (s.equals("-public")) {
            setOption(s);
            setFilter(1L);
            continue;
        }
        if (s.equals("-source")) {
            oneArg(as, i++);
            if (options1.get("-source") != null)
                usageError("main.option.already.seen", s);
            options1.put("-source", as[i]);
            continue;
        }
        if (s.equals("-gj")) {
            options1.put("-gj", "-gj");
            continue;
        }
        if (s.equals("-prompt")) {
            options1.put("-prompt", "-prompt");
            messager.promptOnError = true;
            continue;
        }
        if (s.equals("-sourcepath")) {
            oneArg(as, i++);
            if (options1.get("-sourcepath") != null)
                usageError("main.option.already.seen", s);
            options1.put("-sourcepath", as[i]);
            continue;
        }
        if (s.equals("-classpath")) {
            oneArg(as, i++);
            if (options1.get("-classpath") != null)
                usageError("main.option.already.seen", s);
            options1.put("-classpath", as[i]);
            continue;
        }
        if (s.equals("-sysclasspath")) {
            oneArg(as, i++);
            if (options1.get("-bootclasspath") != null)
                usageError("main.option.already.seen", s);
            options1.put("-bootclasspath", as[i]);
            continue;
        }
        if (s.equals("-bootclasspath")) {
            oneArg(as, i++);
            if (options1.get("-bootclasspath") != null)
                usageError("main.option.already.seen", s);
            options1.put("-bootclasspath", as[i]);
            continue;
        }
        if (s.equals("-extdirs")) {
            oneArg(as, i++);
            if (options1.get("-extdirs") != null)
                usageError("main.option.already.seen", s);
            options1.put("-extdirs", as[i]);
            continue;
        }
        if (s.equals("-overview")) {
            oneArg(as, i++);
            continue;
        }
        if (s.equals("-doclet")) {
            i++;
            continue;
        }
        if (s.equals("-docletpath")) {
            i++;
            continue;
        }
        if (s.equals("-locale")) {
            if (i != 0)
                usageError("main.locale_first");
            oneArg(as, i++);
            docLocale = as[i];
            continue;
        }
        if (s.startsWith("-XD")) {
            String s1 = s.substring("-XD".length());
            int k = s1.indexOf('=');
            String s2 = k >= 0 ? s1.substring(0, k) : s1;
            String s3 = k >= 0 ? s1.substring(k + 1) : s1;
            options1.put(s2, s3);
            continue;
        }
        if (s.startsWith("-")) {
            int j = docletInvoker.optionLength(s);
            if (j < 0) {
                exit();
                continue;
            }
            if (j == 0) {
                usageError("main.invalid_flag", s);
                continue;
            }
            if (i + j > as.length)
                usageError("main.requires_argument", s);
            ListBuffer listbuffer3 = new ListBuffer();
            for (int i1 = 0; i1 < j - 1; i1++) listbuffer3.append(as[++i]);
            setOption(s, listbuffer3.toList());
        } else {
            listbuffer.append(s);
        }
    }
    if (listbuffer.isEmpty() && listbuffer1.isEmpty())
        usageError("main.No_packages_or_classes_specified");
    if (!docletInvoker.validOptions(options.toList()))
        exit();
    JoodocTool joodocTool = new JoodocTool(messager);
    if (joodocTool == null)
        return false;
    if (showAccess == null)
        setFilter(defaultFilter);
    net.jangaroo.joodoc.RootDocImpl rootdocimpl = joodocTool.getRootDocImpl(docLocale, encoding, showAccess, listbuffer.toList(), options.toList(), breakiterator, listbuffer1.toList(), listbuffer2.toList(), flag);
    boolean flag1 = rootdocimpl != null;
    if (flag1)
        flag1 = docletInvoker.start(rootdocimpl);
    if (options1.get("-verbose") != null) {
        l = System.currentTimeMillis() - l;
        messager.notice("main.done_in", Long.toString(l));
    }
    return flag1;
}
Also used : Options(com.sun.tools.javac.util.Options) ListBuffer(com.sun.tools.javac.util.ListBuffer) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException)

Aggregations

ListBuffer (com.sun.tools.javac.util.ListBuffer)88 JCExpression (com.sun.tools.javac.tree.JCTree.JCExpression)54 JCStatement (com.sun.tools.javac.tree.JCTree.JCStatement)25 JCVariableDecl (com.sun.tools.javac.tree.JCTree.JCVariableDecl)25 JCTree (com.sun.tools.javac.tree.JCTree)22 JCTypeParameter (com.sun.tools.javac.tree.JCTree.JCTypeParameter)22 Name (com.sun.tools.javac.util.Name)19 JavacNode (lombok.javac.JavacNode)18 JCAnnotation (com.sun.tools.javac.tree.JCTree.JCAnnotation)17 JCBlock (com.sun.tools.javac.tree.JCTree.JCBlock)17 JavacTreeMaker (lombok.javac.JavacTreeMaker)17 JCMethodDecl (com.sun.tools.javac.tree.JCTree.JCMethodDecl)14 Type (com.redhat.ceylon.model.typechecker.model.Type)12 JCClassDecl (com.sun.tools.javac.tree.JCTree.JCClassDecl)12 JCModifiers (com.sun.tools.javac.tree.JCTree.JCModifiers)11 JCPrimitiveTypeTree (com.sun.tools.javac.tree.JCTree.JCPrimitiveTypeTree)8 List (com.sun.tools.javac.util.List)7 ArrayList (java.util.ArrayList)7 Tree (com.redhat.ceylon.compiler.typechecker.tree.Tree)6 ModelUtil.appliedType (com.redhat.ceylon.model.typechecker.model.ModelUtil.appliedType)6