Java Code Examples for com.sun.tools.javac.util.ListBuffer

The following examples show how to use com.sun.tools.javac.util.ListBuffer. These examples are extracted from open source projects. 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 Project: lua-for-android   Author: qtiuto   File: DocCommentParser.java    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
List<JCTree> parseParams(String s) throws ParseException {
    if (s.trim().isEmpty())
        return List.nil();

    JavacParser p = fac.newParser(s.replace("...", "[]"), false, false, false);
    ListBuffer<JCTree> paramTypes = new ListBuffer<>();
    paramTypes.add(p.parseType());

    if (p.token().kind == TokenKind.IDENTIFIER)
        p.nextToken();

    while (p.token().kind == TokenKind.COMMA) {
        p.nextToken();
        paramTypes.add(p.parseType());

        if (p.token().kind == TokenKind.IDENTIFIER)
            p.nextToken();
    }

    if (p.token().kind != TokenKind.EOF)
        throw new ParseException("dc.ref.unexpected.input");

    return paramTypes.toList();
}
 
Example #2
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: PackageDocImpl.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return a list of all classes contained in this package, including
 * member classes of those classes, and their member classes, etc.
 */
private List<ClassDocImpl> getClasses(boolean filtered) {
    if (allClasses != null && !filtered) {
        return allClasses;
    }
    if (allClassesFiltered != null && filtered) {
        return allClassesFiltered;
    }
    ListBuffer<ClassDocImpl> classes = new ListBuffer<>();
    for (Symbol enumerated : sym.members().getSymbols(NON_RECURSIVE)) {
        if (enumerated != null) {
            ClassSymbol s = (ClassSymbol)enumerated;
            ClassDocImpl c = env.getClassDoc(s);
            if (c != null && !c.isSynthetic())
                c.addAllClasses(classes, filtered);
        }
    }
    if (filtered)
        return allClassesFiltered = classes.toList();
    else
        return allClasses = classes.toList();
}
 
Example #3
Source Project: javaide   Author: tranleduy2000   File: Types.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public Type visitClassType(ClassType t, Void s) {
    ListBuffer<Type> rewritten = new ListBuffer<Type>();
    boolean changed = false;
    for (Type arg : t.allparams()) {
        Type bound = visit(arg);
        if (arg != bound) {
            changed = true;
        }
        rewritten.append(bound);
    }
    if (changed)
        return subst(t.tsym.type,
                t.tsym.type.allparams(),
                rewritten.toList());
    else
        return t;
}
 
Example #4
Source Project: java-n-IDE-for-Android   Author: shenghuntianlang   File: Types.java    License: Apache License 2.0 6 votes vote down vote up
public List<Type> freshTypeVariables(List<Type> types) {
    ListBuffer<Type> result = lb();
    for (Type t : types) {
        if (t.tag == WILDCARD) {
            Type bound = ((WildcardType)t).getExtendsBound();
            if (bound == null)
                bound = syms.objectType;
            result.append(new CapturedType(capturedName,
                                           syms.noSymbol,
                                           bound,
                                           syms.botType,
                                           (WildcardType)t));
        } else {
            result.append(t);
        }
    }
    return result.toList();
}
 
Example #5
Source Project: openjdk-jdk8u-backup   Author: AdoptOpenJDK   File: PackageDocImpl.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return a list of all classes contained in this package, including
 * member classes of those classes, and their member classes, etc.
 */
private List<ClassDocImpl> getClasses(boolean filtered) {
    if (allClasses != null && !filtered) {
        return allClasses;
    }
    if (allClassesFiltered != null && filtered) {
        return allClassesFiltered;
    }
    ListBuffer<ClassDocImpl> classes = new ListBuffer<ClassDocImpl>();
    for (Scope.Entry e = sym.members().elems; e != null; e = e.sibling) {
        if (e.sym != null) {
            ClassSymbol s = (ClassSymbol)e.sym;
            ClassDocImpl c = env.getClassDoc(s);
            if (c != null && !c.isSynthetic())
                c.addAllClasses(classes, filtered);
        }
    }
    if (filtered)
        return allClassesFiltered = classes.toList();
    else
        return allClasses = classes.toList();
}
 
Example #6
Source Project: openjdk-jdk8u-backup   Author: AdoptOpenJDK   File: TypeAnnotations.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void locateNestedTypes(Type type, TypeAnnotationPosition p) {
    // The number of "steps" to get from the full type to the
    // left-most outer type.
    ListBuffer<TypePathEntry> depth = new ListBuffer<>();

    Type encl = type.getEnclosingType();
    while (encl != null &&
            encl.getKind() != TypeKind.NONE &&
            encl.getKind() != TypeKind.ERROR) {
        depth = depth.append(TypePathEntry.INNER_TYPE);
        encl = encl.getEnclosingType();
    }
    if (depth.nonEmpty()) {
        p.location = p.location.prependList(depth.toList());
    }
}
 
Example #7
Source Project: EasyMPermission   Author: mobmead   File: JavacJavaUtilListSetSingularizer.java    License: MIT License 6 votes vote down vote up
void generateSingularMethod(JavacTreeMaker maker, JCExpression returnType, JCStatement returnStatement, SingularData data, JavacNode builderType, JCTree source, boolean fluent) {
	List<JCTypeParameter> typeParams = List.nil();
	List<JCExpression> thrown = List.nil();
	
	JCModifiers mods = maker.Modifiers(Flags.PUBLIC);
	ListBuffer<JCStatement> statements = new ListBuffer<JCStatement>();
	statements.append(createConstructBuilderVarIfNeeded(maker, data, builderType, false, source));
	JCExpression thisDotFieldDotAdd = chainDots(builderType, "this", data.getPluralName().toString(), "add");
	JCExpression invokeAdd = maker.Apply(List.<JCExpression>nil(), thisDotFieldDotAdd, List.<JCExpression>of(maker.Ident(data.getSingularName())));
	statements.append(maker.Exec(invokeAdd));
	if (returnStatement != null) statements.append(returnStatement);
	JCBlock body = maker.Block(0, statements.toList());
	Name name = data.getSingularName();
	long paramFlags = JavacHandlerUtil.addFinalIfNeeded(Flags.PARAMETER, builderType.getContext());
	if (!fluent) name = builderType.toName(HandlerUtil.buildAccessorName("add", name.toString()));
	JCExpression paramType = cloneParamType(0, maker, data.getTypeArgs(), builderType, source);
	JCVariableDecl param = maker.VarDef(maker.Modifiers(paramFlags), data.getSingularName(), paramType, null);
	JCMethodDecl method = maker.MethodDef(mods, name, returnType, typeParams, List.of(param), thrown, body, null);
	injectMethod(builderType, method);
}
 
Example #8
Source Project: jdk8u60   Author: chenghanpeng   File: JavacPathFileManager.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public Iterable<JavaFileObject> list(Location location,
        String packageName, Set<Kind> kinds, boolean recurse)
        throws IOException {
    // validatePackageName(packageName);
    nullCheck(packageName);
    nullCheck(kinds);

    Iterable<? extends Path> paths = getLocation(location);
    if (paths == null)
        return List.nil();
    ListBuffer<JavaFileObject> results = new ListBuffer<JavaFileObject>();

    for (Path path : paths)
        list(path, packageName, kinds, recurse, results);

    return results.toList();
}
 
Example #9
Source Project: TencentKona-8   Author: Tencent   File: CommandLine.java    License: GNU General Public License v2.0 6 votes vote down vote up
private static void loadCmdFile(String name, ListBuffer<String> args)
    throws IOException
{
    Reader r = new BufferedReader(new FileReader(name));
    StreamTokenizer st = new StreamTokenizer(r);
    st.resetSyntax();
    st.wordChars(' ', 255);
    st.whitespaceChars(0, ' ');
    st.commentChar('#');
    st.quoteChar('"');
    st.quoteChar('\'');
    while (st.nextToken() != StreamTokenizer.TT_EOF) {
        args.append(st.sval);
    }
    r.close();
}
 
Example #10
Source Project: openjdk-8   Author: bpupadhyaya   File: ListBufferTest.java    License: GNU General Public License v2.0 6 votes vote down vote up
private static void testCopiedEndsWithList_nil() {
    ListBuffer<String> lb = new ListBuffer<>();

    lb.add("a");
    lb.add("b");
    lb.add("c");

    List<String> l1 = lb.toList();

    assertListEquals(l1, "a", "b", "c");
    assertEndsWithNil(l1);

    lb.add("d");

    List<String> l2 = lb.toList();
    assertListEquals(l2, "a", "b", "c", "d");
    assertEndsWithNil(l2);
    assertListEquals(l1, "a", "b", "c");
}
 
Example #11
Source Project: openjdk-8   Author: bpupadhyaya   File: SmartFileManager.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public Iterable<JavaFileObject> list(Location location,
                                     String packageName,
                                     Set<Kind> kinds,
                                     boolean recurse)
    throws IOException
{
    // Acquire the list of files.
    Iterable<JavaFileObject> files = super.list(location, packageName, kinds, recurse);
    if (visibleSources.isEmpty()) {
        return files;
    }
    // Now filter!
    ListBuffer<JavaFileObject> filteredFiles = new ListBuffer<JavaFileObject>();
    for (JavaFileObject f : files) {
        URI uri = f.toUri();
        String t = uri.toString();
        if (t.startsWith("jar:")
            || t.endsWith(".class")
            || visibleSources.contains(uri))
        {
            filteredFiles.add(f);
        }
    }
    return filteredFiles;
}
 
Example #12
Source Project: openjdk-8-source   Author: keerath   File: ListBufferTest.java    License: GNU General Public License v2.0 6 votes vote down vote up
private static void testRemove() {
    ListBuffer<String> lb1 = new ListBuffer<>();

    lb1.add("a");
    lb1.add("b");
    lb1.add("c");

    assertListEquals(lb1.toList(), "a", "b", "c");
    assertEquals(lb1.next(), "a");
    assertListEquals(lb1.toList(), "b", "c");
    assertEquals(lb1.next(), "b");
    assertListEquals(lb1.toList(), "c");
    assertEquals(lb1.next(), "c");
    assertListEquals(lb1.toList());
    assertEquals(lb1.next(), null);

    lb1.add("d");

    assertEquals(lb1.next(), "d");
}
 
Example #13
Source Project: TencentKona-8   Author: Tencent   File: SymbolMetadata.java    License: GNU General Public License v2.0 6 votes vote down vote up
private <T extends Attribute.Compound> T replaceOne(Placeholder<T> placeholder, Annotate.AnnotateRepeatedContext<T> ctx) {
    Log log = ctx.log;

    // Process repeated annotations
    T validRepeated = ctx.processRepeatedAnnotations(placeholder.getPlaceholderFor(), sym);

    if (validRepeated != null) {
        // Check that the container isn't manually
        // present along with repeated instances of
        // its contained annotation.
        ListBuffer<T> manualContainer = ctx.annotated.get(validRepeated.type.tsym);
        if (manualContainer != null) {
            log.error(ctx.pos.get(manualContainer.first()), "invalid.repeatable.annotation.repeated.and.container.present",
                    manualContainer.first().type.tsym);
        }
    }

    // A null return will delete the Placeholder
    return validRepeated;
}
 
Example #14
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: PackageGenerator.java    License: GNU General Public License v2.0 6 votes vote down vote up
ListBuffer<JCTree> processConstants(Element constNode, HashMap<String, Integer> scope) {
    String baseName = constNode.getAttribute("basename");
    int count = 1;
    try {
        count = Integer.parseInt(constNode.getAttribute("count"));
    } catch (Exception e) {} // nothing to do, will use count = 1

    long declFlags = Flags.PUBLIC | Flags.STATIC | Flags.FINAL | Flags.ENUM;
    ListBuffer<JCTree> fields = new ListBuffer<>();

    for (int i = 0; i < count; i++) {
        String declName = baseName +
                          ((count == 1) ? "" : getUniqIndex(scope, baseName));

        JCVariableDecl constDecl = make.VarDef(
                                       make.Modifiers(declFlags),
                                       names.fromString(declName),
                                       null,  // no need for type in enum decl
                                       null); // no init

        fields.append(constDecl);
    }
    return fields;
}
 
Example #15
Source Project: openjdk-8-source   Author: keerath   File: TypeAnnotations.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void locateNestedTypes(Type type, TypeAnnotationPosition p) {
    // The number of "steps" to get from the full type to the
    // left-most outer type.
    ListBuffer<TypePathEntry> depth = new ListBuffer<>();

    Type encl = type.getEnclosingType();
    while (encl != null &&
            encl.getKind() != TypeKind.NONE &&
            encl.getKind() != TypeKind.ERROR) {
        depth = depth.append(TypePathEntry.INNER_TYPE);
        encl = encl.getEnclosingType();
    }
    if (depth.nonEmpty()) {
        p.location = p.location.prependList(depth.toList());
    }
}
 
Example #16
Source Project: hottub   Author: dsrg-uoft   File: PackageDocImpl.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return a list of all classes contained in this package, including
 * member classes of those classes, and their member classes, etc.
 */
private List<ClassDocImpl> getClasses(boolean filtered) {
    if (allClasses != null && !filtered) {
        return allClasses;
    }
    if (allClassesFiltered != null && filtered) {
        return allClassesFiltered;
    }
    ListBuffer<ClassDocImpl> classes = new ListBuffer<ClassDocImpl>();
    for (Scope.Entry e = sym.members().elems; e != null; e = e.sibling) {
        if (e.sym != null) {
            ClassSymbol s = (ClassSymbol)e.sym;
            ClassDocImpl c = env.getClassDoc(s);
            if (c != null && !c.isSynthetic())
                c.addAllClasses(classes, filtered);
        }
    }
    if (filtered)
        return allClassesFiltered = classes.toList();
    else
        return allClasses = classes.toList();
}
 
Example #17
Source Project: hottub   Author: dsrg-uoft   File: TypeAnnotations.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void locateNestedTypes(Type type, TypeAnnotationPosition p) {
    // The number of "steps" to get from the full type to the
    // left-most outer type.
    ListBuffer<TypePathEntry> depth = new ListBuffer<>();

    Type encl = type.getEnclosingType();
    while (encl != null &&
            encl.getKind() != TypeKind.NONE &&
            encl.getKind() != TypeKind.ERROR) {
        depth = depth.append(TypePathEntry.INNER_TYPE);
        encl = encl.getEnclosingType();
    }
    if (depth.nonEmpty()) {
        p.location = p.location.prependList(depth.toList());
    }
}
 
Example #18
Source Project: lua-for-android   Author: qtiuto   File: Infer.java    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private List<Pair<Type, Type>> getParameterizedSupers(Type t, Type s) {
    Type lubResult = types.lub(t, s);
    if (lubResult == syms.errType || lubResult == syms.botType) {
        return List.nil();
    }
    List<Type> supertypesToCheck = lubResult.isIntersection() ?
            ((IntersectionClassType)lubResult).getComponents() :
            List.of(lubResult);
    ListBuffer<Pair<Type, Type>> commonSupertypes = new ListBuffer<>();
    for (Type sup : supertypesToCheck) {
        if (sup.isParameterized()) {
            Type asSuperOfT = asSuper(t, sup);
            Type asSuperOfS = asSuper(s, sup);
            commonSupertypes.add(new Pair<>(asSuperOfT, asSuperOfS));
        }
    }
    return commonSupertypes.toList();
}
 
Example #19
Source Project: openjdk-8-source   Author: keerath   File: Locations.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Split a path into its elements. If emptyPathDefault is not null, all
 * empty elements in the path, including empty elements at either end of
 * the path, will be replaced with the value of emptyPathDefault.
 * @param path The path to be split
 * @param emptyPathDefault The value to substitute for empty path elements,
 *  or null, to ignore empty path elements
 * @return The elements of the path
 */
private static Iterable<File> getPathEntries(String path, File emptyPathDefault) {
    ListBuffer<File> entries = new ListBuffer<File>();
    int start = 0;
    while (start <= path.length()) {
        int sep = path.indexOf(File.pathSeparatorChar, start);
        if (sep == -1)
            sep = path.length();
        if (start < sep)
            entries.add(new File(path.substring(start, sep)));
        else if (emptyPathDefault != null)
            entries.add(emptyPathDefault);
        start = sep + 1;
    }
    return entries;
}
 
Example #20
Source Project: hottub   Author: dsrg-uoft   File: JavacFileManager.java    License: GNU General Public License v2.0 6 votes vote down vote up
public Iterable<JavaFileObject> list(Location location,
                                     String packageName,
                                     Set<JavaFileObject.Kind> kinds,
                                     boolean recurse)
    throws IOException
{
    // validatePackageName(packageName);
    nullCheck(packageName);
    nullCheck(kinds);

    Iterable<? extends File> path = getLocation(location);
    if (path == null)
        return List.nil();
    RelativeDirectory subdirectory = RelativeDirectory.forPackage(packageName);
    ListBuffer<JavaFileObject> results = new ListBuffer<JavaFileObject>();

    for (File directory : path)
        listContainer(directory, subdirectory, kinds, recurse, results);
    return results.toList();
}
 
Example #21
Source Project: java-n-IDE-for-Android   Author: shenghuntianlang   File: Paths.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Split a path into its elements. If emptyPathDefault is not null, all
 * empty elements in the path, including empty elements at either end of
 * the path, will be replaced with the value of emptyPathDefault.
 *
 * @param path             The path to be split
 * @param emptyPathDefault The value to substitute for empty path elements,
 *                         or null, to ignore empty path elements
 * @return The elements of the path
 */
private static Iterable<File> getPathEntries(String path, File emptyPathDefault) {
    ListBuffer<File> entries = new ListBuffer<File>();
    int start = 0;

    //System.out.println("SPARTACUS : getPathEntries "+path);

    while (start <= path.length()) {
        int sep = path.indexOf(File.pathSeparatorChar, start);
        if (sep == -1)
            sep = path.length();
        if (start < sep)
            entries.add(new File(path.substring(start, sep)));
        else if (emptyPathDefault != null)
            entries.add(emptyPathDefault);
        start = sep + 1;
    }
    return entries;
}
 
Example #22
Source Project: java-n-IDE-for-Android   Author: shenghuntianlang   File: JavacFileManager.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Insert all files in subdirectory subdirectory of archive archive
 * which match fileKinds into resultList
 */
private void listArchive(Archive archive,
                         RelativeDirectory subdirectory,
                         Set<JavaFileObject.Kind> fileKinds,
                         boolean recurse,
                         ListBuffer<JavaFileObject> resultList) {
    // Get the files directly in the subdir
    List<String> files = archive.getFiles(subdirectory);
    if (files != null) {
        for (; !files.isEmpty(); files = files.tail) {
            String file = files.head;
            if (isValidFile(file, fileKinds)) {
                resultList.append(archive.getFileObject(subdirectory, file));
            }
        }
    }
    if (recurse) {
        for (RelativeDirectory s : archive.getSubdirectories()) {
            if (subdirectory.contains(s)) {
                // Because the archive map is a flat list of directories,
                // the enclosing loop will pick up all child subdirectories.
                // Therefore, there is no need to recurse deeper.
                listArchive(archive, s, fileKinds, false, resultList);
            }
        }
    }
}
 
Example #23
Source Project: EasyMPermission   Author: mobmead   File: JavacGuavaSingularizer.java    License: MIT License 5 votes vote down vote up
void generateSingularMethod(JavacTreeMaker maker, JCExpression returnType, JCStatement returnStatement, SingularData data, JavacNode builderType, JCTree source, boolean fluent) {
	List<JCTypeParameter> typeParams = List.nil();
	List<JCExpression> thrown = List.nil();
	boolean mapMode = isMap();
	
	Name keyName = !mapMode ? data.getSingularName() : builderType.toName(data.getSingularName() + "$key");
	Name valueName = !mapMode ? null : builderType.toName(data.getSingularName() + "$value");
	
	JCModifiers mods = maker.Modifiers(Flags.PUBLIC);
	ListBuffer<JCStatement> statements = new ListBuffer<JCStatement>();
	statements.append(createConstructBuilderVarIfNeeded(maker, data, builderType, mapMode, source));
	JCExpression thisDotFieldDotAdd = chainDots(builderType, "this", data.getPluralName().toString(), mapMode ? "put" : "add");
	List<JCExpression> invokeAddExpr;
	if (mapMode) {
		invokeAddExpr = List.<JCExpression>of(maker.Ident(keyName), maker.Ident(valueName));
	} else {
		invokeAddExpr = List.<JCExpression>of(maker.Ident(keyName));
	}
	JCExpression invokeAdd = maker.Apply(List.<JCExpression>nil(), thisDotFieldDotAdd, invokeAddExpr);
	statements.append(maker.Exec(invokeAdd));
	if (returnStatement != null) statements.append(returnStatement);
	JCBlock body = maker.Block(0, statements.toList());
	Name methodName = data.getSingularName();
	long paramFlags = JavacHandlerUtil.addFinalIfNeeded(Flags.PARAMETER, builderType.getContext());
	if (!fluent) methodName = builderType.toName(HandlerUtil.buildAccessorName(mapMode ? "put" : "add", methodName.toString()));
	List<JCVariableDecl> params;
	if (mapMode) {
		JCExpression keyType = cloneParamType(0, maker, data.getTypeArgs(), builderType, source);
		JCExpression valueType = cloneParamType(1, maker, data.getTypeArgs(), builderType, source);
		JCVariableDecl paramKey = maker.VarDef(maker.Modifiers(paramFlags), keyName, keyType, null);
		JCVariableDecl paramValue = maker.VarDef(maker.Modifiers(paramFlags), valueName, valueType, null);
		params = List.of(paramKey, paramValue);
	} else {
		JCExpression paramType = cloneParamType(0, maker, data.getTypeArgs(), builderType, source);
		params = List.of(maker.VarDef(maker.Modifiers(paramFlags), data.getSingularName(), paramType, null));
	}
	JCMethodDecl method = maker.MethodDef(mods, methodName, returnType, typeParams, params, thrown, body, null);
	injectMethod(builderType, method);
}
 
Example #24
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: InferenceContext.java    License: GNU General Public License v2.0 5 votes vote down vote up
private List<Type> filterVars(Filter<UndetVar> fu) {
    ListBuffer<Type> res = new ListBuffer<>();
    for (Type t : undetvars) {
        UndetVar uv = (UndetVar)t;
        if (fu.accepts(uv)) {
            res.append(uv.qtype);
        }
    }
    return res.toList();
}
 
Example #25
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: JavacFileManager.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override @DefinedBy(Api.COMPILER)
public Iterable<? extends JavaFileObject> getJavaFileObjectsFromStrings(Iterable<String> names) {
    ListBuffer<Path> paths = new ListBuffer<>();
    for (String name : names)
        paths.append(getPath(nullCheck(name)));
    return getJavaFileObjectsFromPaths(paths.toList());
}
 
Example #26
Source Project: netbeans   Author: apache   File: TreeFactory.java    License: Apache License 2.0 5 votes vote down vote up
public OpensTree Opens(ExpressionTree qualId, List<? extends ExpressionTree> moduleNames) {
    ListBuffer<JCExpression> names = null;
    if (moduleNames != null) {
        names = new ListBuffer<>();
        for (ExpressionTree name : moduleNames) {
            names.add((JCExpression) name);
        }
    }
    return make.at(NOPOS).Opens((JCExpression) qualId, names != null ? names.toList() : null);
}
 
Example #27
Source Project: hottub   Author: dsrg-uoft   File: DocCommentParser.java    License: GNU General Public License v2.0 5 votes vote down vote up
protected void entity(ListBuffer<DCTree> list) {
    newline = false;
    addPendingText(list, bp - 1);
    list.add(entity());
    if (textStart == -1) {
        textStart = bp;
        lastNonWhite = -1;
    }
}
 
Example #28
Source Project: openjdk-8-source   Author: keerath   File: TreeCopier.java    License: GNU General Public License v2.0 5 votes vote down vote up
public <T extends JCTree> List<T> copy(List<T> trees, P p) {
    if (trees == null)
        return null;
    ListBuffer<T> lb = new ListBuffer<T>();
    for (T tree: trees)
        lb.append(copy(tree, p));
    return lb.toList();
}
 
Example #29
Source Project: openjdk-jdk8u-backup   Author: AdoptOpenJDK   File: Tokens.java    License: GNU General Public License v2.0 5 votes vote down vote up
private List<Comment> getComments(Comment.CommentStyle style) {
    if (comments == null) {
        return List.nil();
    } else {
        ListBuffer<Comment> buf = new ListBuffer<>();
        for (Comment c : comments) {
            if (c.getStyle() == style) {
                buf.add(c);
            }
        }
        return buf.toList();
    }
}
 
Example #30
Source Project: hottub   Author: dsrg-uoft   File: PackageDocImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get Exception classes in this package.
 *
 * @return included Exceptions in this package.
 */
public ClassDoc[] exceptions() {
    ListBuffer<ClassDocImpl> ret = new ListBuffer<ClassDocImpl>();
    for (ClassDocImpl c : getClasses(true)) {
        if (c.isException()) {
            ret.append(c);
        }
    }
    return ret.toArray(new ClassDocImpl[ret.length()]);
}