當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。