當前位置: 首頁>>代碼示例>>Java>>正文


Java List.of方法代碼示例

本文整理匯總了Java中com.sun.tools.javac.util.List.of方法的典型用法代碼示例。如果您正苦於以下問題:Java List.of方法的具體用法?Java List.of怎麽用?Java List.of使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.sun.tools.javac.util.List的用法示例。


在下文中一共展示了List.of方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: fallbackDescriptorType

import com.sun.tools.javac.util.List; //導入方法依賴的package包/類
private Type fallbackDescriptorType(JCExpression tree) {
    switch (tree.getTag()) {
        case LAMBDA:
            JCLambda lambda = (JCLambda)tree;
            List<Type> argtypes = List.nil();
            for (JCVariableDecl param : lambda.params) {
                argtypes = param.vartype != null ?
                        argtypes.append(param.vartype.type) :
                        argtypes.append(syms.errType);
            }
            return new MethodType(argtypes, Type.recoveryType,
                    List.of(syms.throwableType), syms.methodClass);
        case REFERENCE:
            return new MethodType(List.nil(), Type.recoveryType,
                    List.of(syms.throwableType), syms.methodClass);
        default:
            Assert.error("Cannot get here!");
    }
    return null;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:21,代碼來源:Attr.java

示例2: enterUnop

import com.sun.tools.javac.util.List; //導入方法依賴的package包/類
/** Enter a unary operation into symbol table.
 *  @param name     The name of the operator.
 *  @param arg      The type of the operand.
 *  @param res      The operation's result type.
 *  @param opcode   The operation's bytecode instruction.
 */
private OperatorSymbol enterUnop(String name,
                                 Type arg,
                                 Type res,
                                 int opcode) {
    OperatorSymbol sym =
        new OperatorSymbol(makeOperatorName(name),
                           new MethodType(List.of(arg),
                                          res,
                                          List.<Type>nil(),
                                          methodClass),
                           opcode,
                           predefClass);
    predefClass.members().enter(sym);
    return sym;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:22,代碼來源:Symtab.java

示例3: enterUnop

import com.sun.tools.javac.util.List; //導入方法依賴的package包/類
/** Enter a unary operation into symbol table.
 *  @param name     The name of the operator.
 *  @param arg      The type of the operand.
 *  @param res      The operation's result type.
 *  @param opcode   The operation's bytecode instruction.
 */
private OperatorSymbol enterUnop(String name,
                                 Type arg,
                                 Type res,
                                 int opcode) {
    OperatorSymbol sym =
        new OperatorSymbol(names.fromString(name),
                           new MethodType(List.of(arg),
                                          res,
                                          List.<Type>nil(),
                                          methodClass),
                           opcode,
                           predefClass);
    predefClass.members().enter(sym);
    return sym;
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:22,代碼來源:Symtab.java

示例4: classOrInterfaceOrEnumDeclaration

import com.sun.tools.javac.util.List; //導入方法依賴的package包/類
/** ClassOrInterfaceOrEnumDeclaration = ModifiersOpt
 *           (ClassDeclaration | InterfaceDeclaration | EnumDeclaration)
 *  @param mods     Any modifiers starting the class or interface declaration
 *  @param dc       The documentation comment for the class, or null.
 */
protected JCStatement classOrInterfaceOrEnumDeclaration(JCModifiers mods, Comment dc) {
    if (token.kind == CLASS) {
        return classDeclaration(mods, dc);
    } else if (token.kind == INTERFACE) {
        return interfaceDeclaration(mods, dc);
    } else if (token.kind == ENUM) {
        return enumDeclaration(mods, dc);
    } else {
        int pos = token.pos;
        List<JCTree> errs;
        if (LAX_IDENTIFIER.accepts(token.kind)) {
            errs = List.of(mods, toP(F.at(pos).Ident(ident())));
            setErrorEndPos(token.pos);
        } else {
            errs = List.of(mods);
        }
        final JCErroneous erroneousTree;
        if (parseModuleInfo) {
            erroneousTree = syntaxError(pos, errs, "expected.module.or.open");
        } else {
            erroneousTree = syntaxError(pos, errs, "expected3", CLASS, INTERFACE, ENUM);
        }
        return toP(F.Exec(erroneousTree));
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:31,代碼來源:JavacParser.java

示例5: appendScope

import com.sun.tools.javac.util.List; //導入方法依賴的package包/類
private Scope appendScope(Scope newScope) {
    List<Scope> existingScopes = this.subScopes.reverse();
    subScopes = List.of(existingScopes.head);
    subScopes = subScopes.prepend(newScope);
    for (Scope s : existingScopes.tail) {
        subScopes = subScopes.prepend(s);
    }
    return newScope;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:10,代碼來源:Scope.java

示例6: makeTwrFinallyClause

import com.sun.tools.javac.util.List; //導入方法依賴的package包/類
private JCBlock makeTwrFinallyClause(Symbol primaryException, JCExpression resource) {
    // primaryException.addSuppressed(catchException);
    VarSymbol catchException =
        new VarSymbol(SYNTHETIC, make.paramName(2),
                      syms.throwableType,
                      currentMethodSym);
    JCStatement addSuppressionStatement =
        make.Exec(makeCall(make.Ident(primaryException),
                           names.addSuppressed,
                           List.<JCExpression>of(make.Ident(catchException))));

    // try { resource.close(); } catch (e) { primaryException.addSuppressed(e); }
    JCBlock tryBlock =
        make.Block(0L, List.<JCStatement>of(makeResourceCloseInvocation(resource)));
    JCVariableDecl catchExceptionDecl = make.VarDef(catchException, null);
    JCBlock catchBlock = make.Block(0L, List.<JCStatement>of(addSuppressionStatement));
    List<JCCatch> catchClauses = List.<JCCatch>of(make.Catch(catchExceptionDecl, catchBlock));
    JCTry tryTree = make.Try(tryBlock, catchClauses, null);
    tryTree.finallyCanCompleteNormally = true;

    // if (primaryException != null) {try...} else resourceClose;
    JCIf closeIfStatement = make.If(makeNonNullCheck(make.Ident(primaryException)),
                                    tryTree,
                                    makeResourceCloseInvocation(resource));

    // if (#resource != null) { if (primaryException ...  }
    return make.Block(0L,
                      List.<JCStatement>of(make.If(makeNonNullCheck(resource),
                                                   closeIfStatement,
                                                   null)));
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:32,代碼來源:Lower.java

示例7: typeArguments

import com.sun.tools.javac.util.List; //導入方法依賴的package包/類
/**
 *  {@literal
 *  TypeArguments  = "<" TypeArgument {"," TypeArgument} ">"
 *  }
 */
List<JCExpression> typeArguments(boolean diamondAllowed) {
    if (token.kind == LT) {
        nextToken();
        if (token.kind == GT && diamondAllowed) {
            checkDiamond();
            mode |= DIAMOND;
            nextToken();
            return List.nil();
        } else {
            ListBuffer<JCExpression> args = new ListBuffer<>();
            args.append(((mode & EXPR) == 0) ? typeArgument() : parseType());
            while (token.kind == COMMA) {
                nextToken();
                args.append(((mode & EXPR) == 0) ? typeArgument() : parseType());
            }
            switch (token.kind) {

            case GTGTGTEQ: case GTGTEQ: case GTEQ:
            case GTGTGT: case GTGT:
                token = S.split();
                break;
            case GT:
                nextToken();
                break;
            default:
                args.append(syntaxError(token.pos, "expected", GT));
                break;
            }
            return args.toList();
        }
    } else {
        return List.<JCExpression>of(syntaxError(token.pos, "expected", LT));
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:40,代碼來源:JavacParser.java

示例8: visitTypeVar

import com.sun.tools.javac.util.List; //導入方法依賴的package包/類
@Override
public List<Type> visitTypeVar(TypeVar t, Void ignored) {
    if (t.bound.isCompound())
        return interfaces(t.bound);

    if (t.bound.isInterface())
        return List.of(t.bound);

    return List.nil();
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:11,代碼來源:Types.java

示例9: getLocation

import com.sun.tools.javac.util.List; //導入方法依賴的package包/類
public Iterable<? extends File> getLocation(Location location) {
    nullCheck(location);
    paths.lazy();
    if (location == CLASS_OUTPUT) {
        return (getClassOutDir() == null ? null : List.of(getClassOutDir()));
    } else if (location == SOURCE_OUTPUT) {
        return (getSourceOutDir() == null ? null : List.of(getSourceOutDir()));
    } else
        return paths.getPathForLocation(location);
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:11,代碼來源:JavacFileManager.java

示例10: makeTwrFinallyClause

import com.sun.tools.javac.util.List; //導入方法依賴的package包/類
private JCBlock makeTwrFinallyClause(Symbol primaryException, JCExpression resource) {
    // primaryException.addSuppressed(catchException);
    VarSymbol catchException =
        new VarSymbol(0, make.paramName(2),
                      syms.throwableType,
                      currentMethodSym);
    JCStatement addSuppressionStatement =
        make.Exec(makeCall(make.Ident(primaryException),
                           names.addSuppressed,
                           List.<JCExpression>of(make.Ident(catchException))));

    // try { resource.close(); } catch (e) { primaryException.addSuppressed(e); }
    JCBlock tryBlock =
        make.Block(0L, List.<JCStatement>of(makeResourceCloseInvocation(resource)));
    JCVariableDecl catchExceptionDecl = make.VarDef(catchException, null);
    JCBlock catchBlock = make.Block(0L, List.<JCStatement>of(addSuppressionStatement));
    List<JCCatch> catchClauses = List.<JCCatch>of(make.Catch(catchExceptionDecl, catchBlock));
    JCTry tryTree = make.Try(tryBlock, catchClauses, null);

    // if (primaryException != null) {try...} else resourceClose;
    JCIf closeIfStatement = make.If(makeNonNullCheck(make.Ident(primaryException)),
                                    tryTree,
                                    makeResourceCloseInvocation(resource));

    // if (#resource != null) { if (primaryException ...  }
    return make.Block(0L,
                      List.<JCStatement>of(make.If(makeNonNullCheck(resource),
                                                   closeIfStatement,
                                                   null)));
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:31,代碼來源:Lower.java

示例11: visitArrayForeachLoop

import com.sun.tools.javac.util.List; //導入方法依賴的package包/類
/**
 * A statement of the form
 *
 * <pre>
 *     for ( T v : arrayexpr ) stmt;
 * </pre>
 *
 * (where arrayexpr is of an array type) gets translated to
 *
 * <pre>{@code
 *     for ( { arraytype #arr = arrayexpr;
 *             int #len = array.length;
 *             int #i = 0; };
 *           #i < #len; i$++ ) {
 *         T v = arr$[#i];
 *         stmt;
 *     }
 * }</pre>
 *
 * where #arr, #len, and #i are freshly named synthetic local variables.
 */
private void visitArrayForeachLoop(JCEnhancedForLoop tree) {
    make_at(tree.expr.pos());
    VarSymbol arraycache = new VarSymbol(SYNTHETIC,
                                         names.fromString("arr" + target.syntheticNameChar()),
                                         tree.expr.type,
                                         currentMethodSym);
    JCStatement arraycachedef = make.VarDef(arraycache, tree.expr);
    VarSymbol lencache = new VarSymbol(SYNTHETIC,
                                       names.fromString("len" + target.syntheticNameChar()),
                                       syms.intType,
                                       currentMethodSym);
    JCStatement lencachedef = make.
        VarDef(lencache, make.Select(make.Ident(arraycache), syms.lengthVar));
    VarSymbol index = new VarSymbol(SYNTHETIC,
                                    names.fromString("i" + target.syntheticNameChar()),
                                    syms.intType,
                                    currentMethodSym);

    JCVariableDecl indexdef = make.VarDef(index, make.Literal(INT, 0));
    indexdef.init.type = indexdef.type = syms.intType.constType(0);

    List<JCStatement> loopinit = List.of(arraycachedef, lencachedef, indexdef);
    JCBinary cond = makeBinary(LT, make.Ident(index), make.Ident(lencache));

    JCExpressionStatement step = make.Exec(makeUnary(PREINC, make.Ident(index)));

    Type elemtype = types.elemtype(tree.expr.type);
    JCExpression loopvarinit = make.Indexed(make.Ident(arraycache),
                                            make.Ident(index)).setType(elemtype);
    JCVariableDecl loopvardef = (JCVariableDecl)make.VarDef(tree.var.mods,
                                          tree.var.name,
                                          tree.var.vartype,
                                          loopvarinit).setType(tree.var.type);
    loopvardef.sym = tree.var.sym;
    JCBlock body = make.
        Block(0, List.of(loopvardef, tree.body));

    result = translate(make.
                       ForLoop(loopinit,
                               cond,
                               List.of(step),
                               body));
    patchTargets(body, tree, result);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:66,代碼來源:Lower.java

示例12: getSuperBounds

import com.sun.tools.javac.util.List; //導入方法依賴的package包/類
private static List<Type> getSuperBounds(Type.WildcardType wild) {
    return wild.isExtendsBound()
            ? List.nil()
            : List.of(wild.type);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:6,代碼來源:WildcardTypeImpl.java

示例13: getCloseable

import com.sun.tools.javac.util.List; //導入方法依賴的package包/類
@Override
public List<TestAcloseable> getCloseable() {
	return List.of(_ASSERT_NOT_NULL, _ASSERT_NOT_NULL_2, _ASSERT_NOT_NULL_3);
}
 
開發者ID:prestongarno,項目名稱:trywithres-compat,代碼行數:5,代碼來源:MultipleResources.java

示例14: getCloseable

import com.sun.tools.javac.util.List; //導入方法依賴的package包/類
@Override
public List<TestAcloseable> getCloseable() {
	return List.of(this._ASSERT_NOT_NULL);
}
 
開發者ID:prestongarno,項目名稱:trywithres-compat,代碼行數:5,代碼來源:TestInceptionTryCatch.java

示例15: addComment

import com.sun.tools.javac.util.List; //導入方法依賴的package包/類
List<Comment> addComment(List<Comment> comments, Comment comment) {
    return comments == null ?
            List.of(comment) :
            comments.prepend(comment);
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:6,代碼來源:JavaTokenizer.java


注:本文中的com.sun.tools.javac.util.List.of方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。