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


Java List.nonEmpty方法代码示例

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


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

示例1: rollback

import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
/** Restore the state of this inference context to the previous known checkpoint.
*  Consider that the number of saved undetermined variables can be different to the current
*  amount. This is because new captured variables could have been added.
*/
public void rollback(List<Type> saved_undet) {
    Assert.check(saved_undet != null);
    //restore bounds (note: we need to preserve the old instances)
    ListBuffer<Type> newUndetVars = new ListBuffer<>();
    ListBuffer<Type> newInferenceVars = new ListBuffer<>();
    while (saved_undet.nonEmpty() && undetvars.nonEmpty()) {
        UndetVar uv = (UndetVar)undetvars.head;
        UndetVar uv_saved = (UndetVar)saved_undet.head;
        if (uv.qtype == uv_saved.qtype) {
            uv_saved.dupTo(uv, types);
            undetvars = undetvars.tail;
            saved_undet = saved_undet.tail;
            newUndetVars.add(uv);
            newInferenceVars.add(uv.qtype);
        } else {
            undetvars = undetvars.tail;
        }
    }
    undetvars = newUndetVars.toList();
    inferencevars = newInferenceVars.toList();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:InferenceContext.java

示例2: printAnnotations

import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
private void printAnnotations(List<JCAnnotation> annotations) {
    if (annotations.isEmpty()) return ;

    if (printAnnotationsFormatted(annotations)) {
        if (!printingMethodParams)
            toColExactly(out.leftMargin);
        else
            out.needSpace();
        return ;
    }
    
    while (annotations.nonEmpty()) {
 printNoParenExpr(annotations.head);
        if (annotations.tail != null && annotations.tail.nonEmpty()) {
            switch(cs.wrapAnnotations()) {
            case WRAP_IF_LONG:
                int rm = cs.getRightMargin();
                if (widthEstimator.estimateWidth(annotations.tail.head, rm - out.col) + out.col + 1 <= rm) {
                    print(' ');
                    break;
                }
            case WRAP_ALWAYS:
                newline();
                toColExactly(out.leftMargin);
                break;
            case WRAP_NEVER:
                print(' ');
                break;
            }
        } else {
            if (!printingMethodParams)
                toColExactly(out.leftMargin);
        }
        annotations = annotations.tail;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:37,代码来源:VeryPretty.java

示例3: sideCast

import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
private boolean sideCast(Type from, Type to, Warner warn) {
    // We are casting from type $from$ to type $to$, which are
    // non-final unrelated types.  This method
    // tries to reject a cast by transferring type parameters
    // from $to$ to $from$ by common superinterfaces.
    boolean reverse = false;
    Type target = to;
    if ((to.tsym.flags() & INTERFACE) == 0) {
        Assert.check((from.tsym.flags() & INTERFACE) != 0);
        reverse = true;
        to = from;
        from = target;
    }
    List<Type> commonSupers = superClosure(to, erasure(from));
    boolean giveWarning = commonSupers.isEmpty();
    // The arguments to the supers could be unified here to
    // get a more accurate analysis
    while (commonSupers.nonEmpty()) {
        Type t1 = asSuper(from, commonSupers.head.tsym);
        Type t2 = commonSupers.head; // same as asSuper(to, commonSupers.head.tsym);
        if (disjointTypes(t1.getTypeArguments(), t2.getTypeArguments()))
            return false;
        giveWarning = giveWarning || (reverse ? giveWarning(t2, t1) : giveWarning(t1, t2));
        commonSupers = commonSupers.tail;
    }
    if (giveWarning && !isReifiable(reverse ? from : to))
        warn.warn(LintCategory.UNCHECKED);
    if (!allowCovariantReturns)
        // reject if there is a common method signature with
        // incompatible return types.
        chk.checkCompatibleAbstracts(warn.pos(), from, to);
    return true;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:34,代码来源:Types.java

示例4: checkClassType

import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
/** Check that type is a class or interface type.
 *  @param pos           Position to be used for error reporting.
 *  @param t             The type to be checked.
 *  @param noBounds    True if type bounds are illegal here.
 */
Type checkClassType(DiagnosticPosition pos, Type t, boolean noBounds) {
    t = checkClassType(pos, t);
    if (noBounds && t.isParameterized()) {
        List<Type> args = t.getTypeArguments();
        while (args.nonEmpty()) {
            if (args.head.tag == WILDCARD)
                return typeTagError(pos,
                                    diags.fragment("type.req.exact"),
                                    args.head);
            args = args.tail;
        }
    }
    return t;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:20,代码来源:Check.java

示例5: checkClassType

import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
/** Check that type is a class or interface type.
 *  @param pos           Position to be used for error reporting.
 *  @param t             The type to be checked.
 *  @param noBounds    True if type bounds are illegal here.
 */
Type checkClassType(DiagnosticPosition pos, Type t, boolean noBounds) {
    t = checkClassType(pos, t);
    if (noBounds && t.isParameterized()) {
        List<Type> args = t.getTypeArguments();
        while (args.nonEmpty()) {
            if (args.head.hasTag(WILDCARD))
                return typeTagError(pos,
                                    diags.fragment(Fragments.TypeReqExact),
                                    args.head);
            args = args.tail;
        }
    }
    return t;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:Check.java

示例6: cspCases

import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
/**
 * Visitor method: compute source positions for
 * a list of case blocks of switch statements.
 */
public SourceRange cspCases(List<JCCase> trees) {
    if ((trees == null) || !(trees.nonEmpty())) return null;
    SourceRange list_sr = new SourceRange();
    for (List<JCCase> l = trees; l.nonEmpty(); l = l.tail) {
        list_sr.mergeWith(csp(l.head));
    }
    positions.put(trees, list_sr);
    return list_sr;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:14,代码来源:CRTable.java

示例7: apply

import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
@Override
void apply(InferenceContext inferenceContext, Warner warn) {
    List<Type> boundList = uv.getBounds(InferenceBound.UPPER).stream()
            .collect(types.closureCollector(true, types::isSameType));
    for (Type b2 : boundList) {
        if (t == b2) continue;
            /* This wildcard check is temporary workaround. This code may need to be
             * revisited once spec bug JDK-7034922 is fixed.
             */
        if (t != b2 && !t.hasTag(WILDCARD) && !b2.hasTag(WILDCARD)) {
            for (Pair<Type, Type> commonSupers : getParameterizedSupers(t, b2)) {
                List<Type> allParamsSuperBound1 = commonSupers.fst.allparams();
                List<Type> allParamsSuperBound2 = commonSupers.snd.allparams();
                while (allParamsSuperBound1.nonEmpty() && allParamsSuperBound2.nonEmpty()) {
                    //traverse the list of all params comparing them
                    if (!allParamsSuperBound1.head.hasTag(WILDCARD) &&
                            !allParamsSuperBound2.head.hasTag(WILDCARD)) {
                        if (!isSameType(inferenceContext.asUndetVar(allParamsSuperBound1.head),
                                inferenceContext.asUndetVar(allParamsSuperBound2.head))) {
                            reportBoundError(uv, InferenceBound.UPPER);
                        }
                    }
                    allParamsSuperBound1 = allParamsSuperBound1.tail;
                    allParamsSuperBound2 = allParamsSuperBound2.tail;
                }
                Assert.check(allParamsSuperBound1.isEmpty() && allParamsSuperBound2.isEmpty());
            }
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:31,代码来源:Infer.java

示例8: addVars

import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
/** Add any variables defined in stats to the switch scope. */
private static void addVars(List<JCStatement> stats, WriteableScope switchScope) {
    for (;stats.nonEmpty(); stats = stats.tail) {
        JCTree stat = stats.head;
        if (stat.hasTag(VARDEF))
            switchScope.enter(((JCVariableDecl) stat).sym);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:Attr.java

示例9: checkBridges

import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
/**
 * Check that every bridge in the generated classfile has a matching bridge
 * annotation in the bridge map
 */
protected void checkBridges(JavaFileObject jfo) {
    try (InputStream is = jfo.openInputStream()) {
        ClassFile cf = ClassFile.read(is);
        System.err.println("checking: " + cf.getName());

        List<Bridge> bridgeList = bridgesMap.get(cf.getName());
        if (bridgeList == null) {
            //no bridges - nothing to check;
            bridgeList = List.nil();
        }

        for (Method m : cf.methods) {
            if (m.access_flags.is(AccessFlags.ACC_SYNTHETIC | AccessFlags.ACC_BRIDGE)) {
                //this is a bridge - see if there's a match in the bridge list
                Bridge match = null;
                for (Bridge b : bridgeList) {
                    if (b.value().equals(descriptor(m, cf.constant_pool))) {
                        match = b;
                        break;
                    }
                }
                if (match == null) {
                    error("No annotation for bridge method: " + descriptor(m, cf.constant_pool));
                } else {
                    bridgeList = drop(bridgeList, match);
                }
            }
        }
        if (bridgeList.nonEmpty()) {
            error("Redundant bridge annotation found: " + bridgeList.head.value());
        }
    } catch (Exception e) {
        e.printStackTrace();
        throw new Error("error reading " + jfo.toUri() +": " + e);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:41,代码来源:BridgeHarness.java

示例10: mostSpecificSignature

import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
String mostSpecificSignature(Result<Iterable<? extends Element>> result) {
    List<Diagnostic<? extends JavaFileObject>> rsDiag =
            result.diagnosticsForKey("compiler.note.verbose.resolve.multi");
    if (rsDiag.nonEmpty()) {
        ClientCodeWrapper.DiagnosticSourceUnwrapper dsu =
                    (ClientCodeWrapper.DiagnosticSourceUnwrapper)rsDiag.head;
        JCDiagnostic.MultilineDiagnostic mdiag =
            (JCDiagnostic.MultilineDiagnostic)dsu.d;
        int mostSpecificIndex = (Integer)mdiag.getArgs()[2];
        return mdiag.getSubdiagnostics().get(mostSpecificIndex).getArgs()[1].toString();
    } else {
        return null;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:StructuralMostSpecificTest.java

示例11: instantiateExpr

import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
/** Try to instantiate expression type `that' to given type `to'.
 *  If a maximal instantiation exists which makes this type
 *  a subtype of type `to', return the instantiated type.
 *  If no instantiation exists, or if several incomparable
 *  best instantiations exist throw a NoInstanceException.
 */
public Type instantiateExpr(ForAll that,
                            Type to,
                            Warner warn) throws InferenceException {
    List<Type> undetvars = Type.map(that.tvars, fromTypeVarFun);
    for (List<Type> l = undetvars; l.nonEmpty(); l = l.tail) {
        UndetVar uv = (UndetVar) l.head;
        TypeVar tv = (TypeVar)uv.qtype;
        ListBuffer<Type> hibounds = new ListBuffer<Type>();
        for (Type t : that.getConstraints(tv, ConstraintKind.EXTENDS)) {
            hibounds.append(types.subst(t, that.tvars, undetvars));
        }

        List<Type> inst = that.getConstraints(tv, ConstraintKind.EQUAL);
        if (inst.nonEmpty() && inst.head.tag != BOT) {
            uv.inst = inst.head;
        }
        uv.hibounds = hibounds.toList();
    }
    Type qtype1 = types.subst(that.qtype, that.tvars, undetvars);
    if (!types.isSubtype(qtype1,
            qtype1.tag == UNDETVAR ? types.boxedTypeOrType(to) : to)) {
        throw unambiguousNoInstanceException
            .setMessage("infer.no.conforming.instance.exists",
                        that.tvars, that.qtype, to);
    }
    for (List<Type> l = undetvars; l.nonEmpty(); l = l.tail)
        maximizeInst((UndetVar) l.head, warn);
    // System.out.println(" = " + qtype1.map(getInstFun));//DEBUG

    // check bounds
    List<Type> targs = Type.map(undetvars, getInstFun);
    if (Type.containsAny(targs, that.tvars)) {
        //replace uninferred type-vars
        targs = types.subst(targs,
                that.tvars,
                instantiateAsUninferredVars(undetvars, that.tvars));
    }
    return chk.checkType(warn.pos(), that.inst(targs, types), to);
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:46,代码来源:Infer.java

示例12: containsType

import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
boolean containsType(List<Type> ts, List<Type> ss) {
    while (ts.nonEmpty() && ss.nonEmpty()
           && containsType(ts.head, ss.head)) {
        ts = ts.tail;
        ss = ss.tail;
    }
    return ts.isEmpty() && ss.isEmpty();
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:9,代码来源:Types.java

示例13: csp

import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
/** Visitor method: compute source positions for a list of nodes.
 */
public SourceRange csp(List<? extends JCTree> trees) {
    if ((trees == null) || !(trees.nonEmpty())) return null;
    SourceRange list_sr = new SourceRange();
    for (List<? extends JCTree> l = trees; l.nonEmpty(); l = l.tail) {
        list_sr.mergeWith(csp(l.head));
    }
    positions.put(trees, list_sr);
    return list_sr;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:CRTable.java

示例14: check

import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
void check(Result<?> res) {
    DiagnosticKind diag = null;
    boolean altMetafactory = false;
    for (DiagnosticKind dk : DiagnosticKind.values()) {
        List<Diagnostic<? extends JavaFileObject>> jcDiag = res.diagnosticsForKey(dk.code);
        if (jcDiag.nonEmpty()) {
            diag = dk;
            ClientCodeWrapper.DiagnosticSourceUnwrapper dsu =
                    (ClientCodeWrapper.DiagnosticSourceUnwrapper)jcDiag.head;
            altMetafactory = (Boolean)dsu.d.getArgs()[0];
            break;
        }
    }

    if (diag == null) {
        fail("No diagnostic found; " + res.compilationInfo());
    }

    boolean error = diag.lambda !=
            (ek == ExprKind.LAMBDA);

    error |= diag.bridge !=
            (ek == ExprKind.MREF2);

    error |= altMetafactory !=
            (tk == TargetKind.SERIALIZABLE);

    if (error) {
        fail("Bad stat diagnostic found for source\n" +
                "lambda = " + diag.lambda + "\n" +
                "bridge = " + diag.bridge + "\n" +
                "altMF = " + altMetafactory + "\n" +
                res.compilationInfo());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:36,代码来源:TestLambdaToMethodStats.java

示例15: print

import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
String print(List<? extends JCTree> list, String sep) {
    StringBuilder sb = new StringBuilder();
    if (list.nonEmpty()) {
        sb.append(print(list.head));
        for (List<? extends JCTree> l = list.tail; l.nonEmpty(); l = l.tail) {
            sb.append(sep);
            sb.append(print(l.head));
        }
    }
    return sb.toString();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:TestProcessor.java


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