Java Code Examples for com.sun.tools.javac.util.List#reverse()

The following examples show how to use com.sun.tools.javac.util.List#reverse() . 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: JavacProcessingEnvironment.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
/** Enter a set of generated class files. */
private List<ClassSymbol> enterClassFiles(Map<String, JavaFileObject> classFiles) {
    ClassReader reader = ClassReader.instance(context);
    Names names = Names.instance(context);
    List<ClassSymbol> list = List.nil();

    for (Map.Entry<String,JavaFileObject> entry : classFiles.entrySet()) {
        Name name = names.fromString(entry.getKey());
        JavaFileObject file = entry.getValue();
        if (file.getKind() != JavaFileObject.Kind.CLASS)
            throw new AssertionError(file);
        ClassSymbol cs;
        if (isPkgInfo(file, JavaFileObject.Kind.CLASS)) {
            Name packageName = Convert.packagePart(name);
            PackageSymbol p = reader.enterPackage(packageName);
            if (p.package_info == null)
                p.package_info = reader.enterClass(Convert.shortName(name), p);
            cs = p.package_info;
            if (cs.classfile == null)
                cs.classfile = file;
        } else
            cs = reader.enterClass(name, file);
        list = list.prepend(cs);
    }
    return list.reverse();
}
 
Example 2
Source File: JavacProcessingEnvironment.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
/** Enter a set of generated class files. */
private List<ClassSymbol> enterClassFiles(Map<String, JavaFileObject> classFiles) {
    ClassReader reader = ClassReader.instance(context);
    Names names = Names.instance(context);
    List<ClassSymbol> list = List.nil();

    for (Map.Entry<String,JavaFileObject> entry : classFiles.entrySet()) {
        Name name = names.fromString(entry.getKey());
        JavaFileObject file = entry.getValue();
        if (file.getKind() != JavaFileObject.Kind.CLASS)
            throw new AssertionError(file);
        ClassSymbol cs;
        if (isPkgInfo(file, JavaFileObject.Kind.CLASS)) {
            Name packageName = Convert.packagePart(name);
            PackageSymbol p = reader.enterPackage(packageName);
            if (p.package_info == null)
                p.package_info = reader.enterClass(Convert.shortName(name), p);
            cs = p.package_info;
            if (cs.classfile == null)
                cs.classfile = file;
        } else
            cs = reader.enterClass(name, file);
        list = list.prepend(cs);
    }
    return list.reverse();
}
 
Example 3
Source File: JavacProcessingEnvironment.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/** Enter a set of generated class files. */
private List<ClassSymbol> enterClassFiles(Map<String, JavaFileObject> classFiles) {
    ClassReader reader = ClassReader.instance(context);
    Names names = Names.instance(context);
    List<ClassSymbol> list = List.nil();

    for (Map.Entry<String,JavaFileObject> entry : classFiles.entrySet()) {
        Name name = names.fromString(entry.getKey());
        JavaFileObject file = entry.getValue();
        if (file.getKind() != JavaFileObject.Kind.CLASS)
            throw new AssertionError(file);
        ClassSymbol cs;
        if (isPkgInfo(file, JavaFileObject.Kind.CLASS)) {
            Name packageName = Convert.packagePart(name);
            PackageSymbol p = reader.enterPackage(packageName);
            if (p.package_info == null)
                p.package_info = reader.enterClass(Convert.shortName(name), p);
            cs = p.package_info;
            if (cs.classfile == null)
                cs.classfile = file;
        } else
            cs = reader.enterClass(name, file);
        list = list.prepend(cs);
    }
    return list.reverse();
}
 
Example 4
Source File: ClassReader.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/** Convert signature to type parameters, where signature is implicit.
 */
List<Type> sigToTypeParams() {
    List<Type> tvars = List.nil();
    if (signature[sigp] == '<') {
        sigp++;
        int start = sigp;
        sigEnterPhase = true;
        while (signature[sigp] != '>')
            tvars = tvars.prepend(sigToTypeParam());
        sigEnterPhase = false;
        sigp = start;
        while (signature[sigp] != '>')
            sigToTypeParam();
        sigp++;
    }
    return tvars.reverse();
}
 
Example 5
Source File: Gen.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
List<Pair<List<Attribute.TypeCompound>, JCExpression>> catchTypesWithAnnotationsFromMulticatch(JCTypeUnion tree, List<TypeCompound> first) {
    List<JCExpression> alts = tree.alternatives;
    List<Pair<List<TypeCompound>, JCExpression>> res = List.of(new Pair<>(first, alts.head));
    alts = alts.tail;

    while(alts != null && alts.head != null) {
        JCExpression alt = alts.head;
        if (alt instanceof JCAnnotatedType) {
            JCAnnotatedType a = (JCAnnotatedType)alt;
            res = res.prepend(new Pair<>(annotate.fromAnnotations(a.annotations), alt));
        } else {
            res = res.prepend(new Pair<>(List.nil(), alt));
        }
        alts = alts.tail;
    }
    return res.reverse();
}
 
Example 6
Source File: Gen.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
List<Pair<List<Attribute.TypeCompound>, JCExpression>> catchTypesWithAnnotationsFromMulticatch(JCTypeUnion tree, List<TypeCompound> first) {
    List<JCExpression> alts = tree.alternatives;
    List<Pair<List<TypeCompound>, JCExpression>> res = List.of(new Pair<>(first, alts.head));
    alts = alts.tail;

    while(alts != null && alts.head != null) {
        JCExpression alt = alts.head;
        if (alt instanceof JCAnnotatedType) {
            JCAnnotatedType a = (JCAnnotatedType)alt;
            res = res.prepend(new Pair<>(annotate.fromAnnotations(a.annotations), alt));
        } else {
            res = res.prepend(new Pair<>(List.nil(), alt));
        }
        alts = alts.tail;
    }
    return res.reverse();
}
 
Example 7
Source File: JavacProcessingEnvironment.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/** Enter a set of generated class files. */
private List<ClassSymbol> enterClassFiles(Map<String, JavaFileObject> classFiles) {
    ClassReader reader = ClassReader.instance(context);
    Names names = Names.instance(context);
    List<ClassSymbol> list = List.nil();

    for (Map.Entry<String,JavaFileObject> entry : classFiles.entrySet()) {
        Name name = names.fromString(entry.getKey());
        JavaFileObject file = entry.getValue();
        if (file.getKind() != JavaFileObject.Kind.CLASS)
            throw new AssertionError(file);
        ClassSymbol cs;
        if (isPkgInfo(file, JavaFileObject.Kind.CLASS)) {
            Name packageName = Convert.packagePart(name);
            PackageSymbol p = reader.enterPackage(packageName);
            if (p.package_info == null)
                p.package_info = reader.enterClass(Convert.shortName(name), p);
            cs = p.package_info;
            if (cs.classfile == null)
                cs.classfile = file;
        } else
            cs = reader.enterClass(name, file);
        list = list.prepend(cs);
    }
    return list.reverse();
}
 
Example 8
Source File: JavacProcessingEnvironment.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private List<PackageSymbol> getPackageInfoFilesFromClasses(List<? extends ClassSymbol> syms) {
    List<PackageSymbol> packages = List.nil();
    for (ClassSymbol sym : syms) {
        if (isPkgInfo(sym)) {
            packages = packages.prepend((PackageSymbol) sym.owner);
        }
    }
    return packages.reverse();
}
 
Example 9
Source File: JavacProcessingEnvironment.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private List<PackageSymbol> getPackageInfoFiles(List<? extends JCCompilationUnit> units) {
    List<PackageSymbol> packages = List.nil();
    for (JCCompilationUnit unit : units) {
        if (isPkgInfo(unit.sourcefile, JavaFileObject.Kind.SOURCE)) {
            packages = packages.prepend(unit.packge);
        }
    }
    return packages.reverse();
}
 
Example 10
Source File: JavacProcessingEnvironment.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
private List<PackageSymbol> getPackageInfoFiles(List<? extends JCCompilationUnit> units) {
    List<PackageSymbol> packages = List.nil();
    for (JCCompilationUnit unit : units) {
        if (isPkgInfo(unit.sourcefile, JavaFileObject.Kind.SOURCE)) {
            packages = packages.prepend(unit.packge);
        }
    }
    return packages.reverse();
}
 
Example 11
Source File: JavacProcessingEnvironment.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private List<PackageSymbol> getPackageInfoFiles(List<? extends JCCompilationUnit> units) {
    List<PackageSymbol> packages = List.nil();
    for (JCCompilationUnit unit : units) {
        if (isPkgInfo(unit.sourcefile, JavaFileObject.Kind.SOURCE)) {
            packages = packages.prepend(unit.packge);
        }
    }
    return packages.reverse();
}
 
Example 12
Source File: JavacProcessingEnvironment.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private List<PackageSymbol> getPackageInfoFilesFromClasses(List<? extends ClassSymbol> syms) {
    List<PackageSymbol> packages = List.nil();
    for (ClassSymbol sym : syms) {
        if (isPkgInfo(sym)) {
            packages = packages.prepend((PackageSymbol) sym.owner);
        }
    }
    return packages.reverse();
}
 
Example 13
Source File: JavacProcessingEnvironment.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private List<PackageSymbol> getPackageInfoFiles(List<? extends JCCompilationUnit> units) {
    List<PackageSymbol> packages = List.nil();
    for (JCCompilationUnit unit : units) {
        if (isPkgInfo(unit.sourcefile, JavaFileObject.Kind.SOURCE)) {
            packages = packages.prepend(unit.packge);
        }
    }
    return packages.reverse();
}
 
Example 14
Source File: JavacProcessingEnvironment.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private List<PackageSymbol> getPackageInfoFilesFromClasses(List<? extends ClassSymbol> syms) {
    List<PackageSymbol> packages = List.nil();
    for (ClassSymbol sym : syms) {
        if (isPkgInfo(sym)) {
            packages = packages.prepend((PackageSymbol) sym.owner);
        }
    }
    return packages.reverse();
}
 
Example 15
Source File: JavacProcessingEnvironment.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private List<ClassSymbol> getTopLevelClassesFromClasses(List<? extends ClassSymbol> syms) {
    List<ClassSymbol> classes = List.nil();
    for (ClassSymbol sym : syms) {
        if (!isPkgInfo(sym)) {
            classes = classes.prepend(sym);
        }
    }
    return classes.reverse();
}
 
Example 16
Source File: JavacProcessingEnvironment.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private List<ClassSymbol> getTopLevelClasses(List<? extends JCCompilationUnit> units) {
    List<ClassSymbol> classes = List.nil();
    for (JCCompilationUnit unit : units) {
        for (JCTree node : unit.defs) {
            if (node.hasTag(JCTree.Tag.CLASSDEF)) {
                ClassSymbol sym = ((JCClassDecl) node).sym;
                Assert.checkNonNull(sym);
                classes = classes.prepend(sym);
            }
        }
    }
    return classes.reverse();
}
 
Example 17
Source File: JavacProcessingEnvironment.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private List<PackageSymbol> getPackageInfoFiles(List<? extends JCCompilationUnit> units) {
    List<PackageSymbol> packages = List.nil();
    for (JCCompilationUnit unit : units) {
        if (isPkgInfo(unit.sourcefile, JavaFileObject.Kind.SOURCE)) {
            packages = packages.prepend(unit.packge);
        }
    }
    return packages.reverse();
}
 
Example 18
Source File: JavacProcessingEnvironment.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private List<ClassSymbol> getTopLevelClassesFromClasses(List<? extends ClassSymbol> syms) {
    List<ClassSymbol> classes = List.nil();
    for (ClassSymbol sym : syms) {
        if (!isPkgInfo(sym)) {
            classes = classes.prepend(sym);
        }
    }
    return classes.reverse();
}
 
Example 19
Source File: SymbolMetadata.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private List<Attribute.Compound> getPlaceholders() {
    List<Attribute.Compound> res = List.<Attribute.Compound>nil();
    for (Attribute.Compound a : filterDeclSentinels(attributes)) {
        if (a instanceof Placeholder) {
            res = res.prepend(a);
        }
    }
    return res.reverse();
}
 
Example 20
Source File: SymbolMetadata.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
private <T extends Attribute.Compound> List<T> getAttributesForCompletion(
        final Annotate.AnnotateRepeatedContext<T> ctx) {

    Map<Symbol.TypeSymbol, ListBuffer<T>> annotated = ctx.annotated;
    boolean atLeastOneRepeated = false;
    List<T> buf = List.<T>nil();
    for (ListBuffer<T> lb : annotated.values()) {
        if (lb.size() == 1) {
            buf = buf.prepend(lb.first());
        } else { // repeated
            // This will break when other subtypes of Attributs.Compound
            // are introduced, because PlaceHolder is a subtype of TypeCompound.
            T res;
            @SuppressWarnings("unchecked")
            T ph = (T) new Placeholder<T>(ctx, lb.toList(), sym);
            res = ph;
            buf = buf.prepend(res);
            atLeastOneRepeated = true;
        }
    }

    if (atLeastOneRepeated) {
        // The Symbol s is now annotated with a combination of
        // finished non-repeating annotations and placeholders for
        // repeating annotations.
        //
        // We need to do this in two passes because when creating
        // a container for a repeating annotation we must
        // guarantee that the @Repeatable on the
        // contained annotation is fully annotated
        //
        // The way we force this order is to do all repeating
        // annotations in a pass after all non-repeating are
        // finished. This will work because @Repeatable
        // is non-repeating and therefore will be annotated in the
        // fist pass.

        // Queue a pass that will replace Attribute.Placeholders
        // with Attribute.Compound (made from synthesized containers).
        ctx.annotateRepeated(new Annotate.Worker() {
            @Override
            public String toString() {
                return "repeated annotation pass of: " + sym + " in: " + sym.owner;
            }

            @Override
            public void run() {
                complete(ctx);
            }
        });
    }
    // Add non-repeating attributes
    return buf.reverse();
}