当前位置: 首页>>代码示例>>Java>>正文


Java ListBuffer.add方法代码示例

本文整理汇总了Java中com.sun.tools.javac.util.ListBuffer.add方法的典型用法代码示例。如果您正苦于以下问题:Java ListBuffer.add方法的具体用法?Java ListBuffer.add怎么用?Java ListBuffer.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sun.tools.javac.util.ListBuffer的用法示例。


在下文中一共展示了ListBuffer.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getPathEntries

import com.sun.tools.javac.util.ListBuffer; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:29,代码来源:Paths.java

示例2: processTypeParams

import com.sun.tools.javac.util.ListBuffer; //导入方法依赖的package包/类
List<JCTypeParameter> processTypeParams(String typeParams) {

        if (typeParams == null || typeParams.length() == 0)
            return List.<JCTypeParameter>nil(); // empty

        String[] typeVarsArr = typeParams.split(",");
        ListBuffer<JCTypeParameter> typeParamsDecls = new ListBuffer<>();

        for (String typeVar : typeVarsArr) {
            typeParamsDecls.add(
                make.TypeParameter(names.fromString(typeVar),
                                    List.<JCExpression>nil()));
        }

        return typeParamsDecls.toList();
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:PackageGenerator.java

示例3: visitClassDef

import com.sun.tools.javac.util.ListBuffer; //导入方法依赖的package包/类
@Override
public void visitClassDef(JCClassDecl tree) {
    if ((tree.mods.flags & (INTERFACE | ENUM)) == 0 &&
            !tree.getMembers().stream()
            .anyMatch(t -> t.getKind() == Tree.Kind.METHOD &&
            ((MethodTree) t).getName() == tree.name.table.names.init)) {
        // Generate a default constructor, since
        // this is a regular class and there are no constructors
        ListBuffer<JCTree> ndefs = new ListBuffer<>();
        ndefs.addAll(tree.defs);
        ndefs.add(make.MethodDef(make.Modifiers(PUBLIC),
                tree.name.table.names.init,
                null, List.nil(), List.nil(), List.nil(),
                resolutionExceptionBlock(), null));
        tree.defs = ndefs.toList();
    }
    super.visitClassDef(tree);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:Corraller.java

示例4: toList

import com.sun.tools.javac.util.ListBuffer; //导入方法依赖的package包/类
<T> ListBuffer<T> toList(Iterable<? extends T> items) {
    ListBuffer<T> list = new ListBuffer<>();
    if (items != null) {
        for (T item : items) {
            list.add(item);
        }
    }
    return list;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:Arguments.java

示例5: save

import com.sun.tools.javac.util.ListBuffer; //导入方法依赖的package包/类
/**
 * Save the state of this inference context
 */
public List<Type> save() {
    ListBuffer<Type> buf = new ListBuffer<>();
    for (Type t : undetvars) {
        buf.add(((UndetVar)t).dup(infer.types));
    }
    return buf.toList();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:InferenceContext.java

示例6: getComments

import com.sun.tools.javac.util.ListBuffer; //导入方法依赖的package包/类
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();
    }
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:14,代码来源:Tokens.java

示例7: addPendingText

import com.sun.tools.javac.util.ListBuffer; //导入方法依赖的package包/类
protected void addPendingText(ListBuffer<DCTree> list, int textEnd) {
    if (textStart != -1) {
        if (textStart <= textEnd) {
            list.add(m.at(textStart).newTextTree(newString(textStart, textEnd + 1)));
        }
        textStart = -1;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:DocCommentParser.java

示例8: processAnnoDecl

import com.sun.tools.javac.util.ListBuffer; //导入方法依赖的package包/类
JCAnnotation processAnnoDecl(Element annoDeclNode) {
    String annoId = annoDeclNode.getAttribute("id");

    ListBuffer<JCExpression> args = new ListBuffer<>();
    String className = "";

    NodeList nodes = annoDeclNode.getChildNodes();
    for (int i = 0; i < nodes.getLength(); i++) {
        Node node = nodes.item(i);

        if (!(node instanceof Element))
            continue;

        switch (((Element)node).getTagName()) {
            case "class":
                className = ((Element)node).getTextContent();
                break;
            case "arg":
                String argName = ((Element)node).getAttribute("name");
                String argValue = ((Element)node).getAttribute("value");

                JCExpression arg;
                if (argName.length() == 0)
                    arg = make.Ident(names.fromString(argValue));
                else
                    arg = make.Assign(
                              make.Ident(names.fromString(argName)),
                              make.Ident(names.fromString(argValue)));

                args.add(arg);
                break;
        }
    }

    return make.Annotation(
               make.Ident(names.fromString(className)),
               args.toList());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:39,代码来源:PackageGenerator.java

示例9: freeVarsIn

import com.sun.tools.javac.util.ListBuffer; //导入方法依赖的package包/类
/**
 * Returns a list of free variables in a given type
 */
final List<Type> freeVarsIn(Type t) {
    ListBuffer<Type> buf = new ListBuffer<>();
    for (Type iv : inferenceVars()) {
        if (t.contains(iv)) {
            buf.add(iv);
        }
    }
    return buf.toList();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:InferenceContext.java

示例10: addPendingText

import com.sun.tools.javac.util.ListBuffer; //导入方法依赖的package包/类
protected void addPendingText(ListBuffer<DCTree> list, int textEnd) {
    if (textStart != -1) {
        if (textStart <= textEnd) {
            list.add(m.at(textStart).Text(newString(textStart, textEnd + 1)));
        }
        textStart = -1;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:9,代码来源:DocCommentParser.java

示例11: entity

import com.sun.tools.javac.util.ListBuffer; //导入方法依赖的package包/类
protected void entity(ListBuffer<DCTree> list) {
    newline = false;
    addPendingText(list, bp - 1);
    list.add(entity());
    if (textStart == -1) {
        textStart = bp;
        lastNonWhite = -1;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:DocCommentParser.java

示例12: processSerialFields

import com.sun.tools.javac.util.ListBuffer; //导入方法依赖的package包/类
JCTree processSerialFields(Element sfNode) {
    String baseName = sfNode.getAttribute("basename");
    String[] fieldTypes = sfNode.getTextContent().split(",");

    ListBuffer<JCExpression> serialFields = new ListBuffer<>();
    HashMap<String, Integer> scope = new HashMap<>();

    for (String fType : fieldTypes) {
        String fieldName = baseName + getUniqIndex(scope, baseName);
        serialFields.add(
            make.NewClass(
                null,
                null,
                make.Type(getTypeByName("ObjectStreamField")),
                List.from(
                    new JCTree.JCExpression[] {
                        make.Literal(fieldName),
                        make.Ident(names.fromString(fType + ".class"))
                    }),
                null));
    }

    JCTree sfDecl = make.VarDef(
                        make.Modifiers(
                            Flags.PRIVATE | Flags.STATIC | Flags.FINAL),
                        names.fromString("serialPersistentFields"),
                        make.TypeArray(
                            make.Type(getTypeByName("ObjectStreamField"))),
                        make.NewArray(
                            null,
                            List.<JCExpression>nil(),
                            serialFields.toList()));

    return sfDecl;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:36,代码来源:PackageGenerator.java

示例13: blockTags

import com.sun.tools.javac.util.ListBuffer; //导入方法依赖的package包/类
/**
 * Read a series of block tags, including their content.
 * Standard tags parse their content appropriately.
 * Non-standard tags are represented by {@link UnknownBlockTag}.
 */
protected List<DCTree> blockTags() {
    ListBuffer<DCTree> tags = new ListBuffer<>();
    while (ch == '@')
        tags.add(blockTag());
    return tags.toList();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:DocCommentParser.java

示例14: htmlAttrs

import com.sun.tools.javac.util.ListBuffer; //导入方法依赖的package包/类
/**
 * Read a series of HTML attributes, terminated by {@literal > }.
 * Each attribute is of the form {@literal identifier[=value] }.
 * "value" may be unquoted, single-quoted, or double-quoted.
 */
protected List<DCTree> htmlAttrs() {
    ListBuffer<DCTree> attrs = new ListBuffer<>();
    skipWhitespace();

    loop:
    while (isIdentifierStart(ch)) {
        int namePos = bp;
        Name name = readAttributeName();
        skipWhitespace();
        List<DCTree> value = null;
        ValueKind vkind = ValueKind.EMPTY;
        if (ch == '=') {
            ListBuffer<DCTree> v = new ListBuffer<>();
            nextChar();
            skipWhitespace();
            if (ch == '\'' || ch == '"') {
                vkind = (ch == '\'') ? ValueKind.SINGLE : ValueKind.DOUBLE;
                char quote = ch;
                nextChar();
                textStart = bp;
                while (bp < buflen && ch != quote) {
                    if (newline && ch == '@') {
                        attrs.add(erroneous("dc.unterminated.string", namePos));
                        // No point trying to read more.
                        // In fact, all attrs get discarded by the caller
                        // and superseded by a malformed.html node because
                        // the html tag itself is not terminated correctly.
                        break loop;
                    }
                    attrValueChar(v);
                }
                addPendingText(v, bp - 1);
                nextChar();
            } else {
                vkind = ValueKind.UNQUOTED;
                textStart = bp;
                while (bp < buflen && !isUnquotedAttrValueTerminator(ch)) {
                    attrValueChar(v);
                }
                addPendingText(v, bp - 1);
            }
            skipWhitespace();
            value = v.toList();
        }
        DCAttribute attr = m.at(namePos).newAttributeTree(name, vkind, value);
        attrs.add(attr);
    }

    return attrs.toList();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:56,代码来源:DocCommentParser.java

示例15: blockContent

import com.sun.tools.javac.util.ListBuffer; //导入方法依赖的package包/类
/**
 * Read block content, consisting of text, html and inline tags.
 * Terminated by the end of input, or the beginning of the next block tag:
 * i.e. @ as the first non-whitespace character on a line.
 */
@SuppressWarnings("fallthrough")
protected List<DCTree> blockContent() {
    ListBuffer<DCTree> trees = new ListBuffer<DCTree>();
    textStart = -1;

    loop:
    while (bp < buflen) {
        switch (ch) {
            case '\n': case '\r': case '\f':
                newline = true;
                // fallthrough

            case ' ': case '\t':
                nextChar();
                break;

            case '&':
                entity(trees);
                break;

            case '<':
                newline = false;
                addPendingText(trees, bp - 1);
                trees.add(html());
                if (textStart == -1) {
                    textStart = bp;
                    lastNonWhite = -1;
                }
                break;

            case '>':
                newline = false;
                addPendingText(trees, bp - 1);
                trees.add(m.at(bp).Erroneous(newString(bp, bp+1), diagSource, "dc.bad.gt"));
                nextChar();
                if (textStart == -1) {
                    textStart = bp;
                    lastNonWhite = -1;
                }
                break;

            case '{':
                inlineTag(trees);
                break;

            case '@':
                if (newline) {
                    addPendingText(trees, lastNonWhite);
                    break loop;
                }
                // fallthrough

            default:
                newline = false;
                if (textStart == -1)
                    textStart = bp;
                lastNonWhite = bp;
                nextChar();
        }
    }

    if (lastNonWhite != -1)
        addPendingText(trees, lastNonWhite);

    return trees.toList();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:72,代码来源:DocCommentParser.java


注:本文中的com.sun.tools.javac.util.ListBuffer.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。