コード例 #1
0
    String getOutput(
        OutputKind outKind,
        ErrorKind errKind,
        MultilinePolicy policy,
        IndentKind summaryIndent,
        IndentKind detailsIndent,
        IndentKind multiIndent) {
      String constIndent =
          (errKind == ErrorKind.DOUBLE)
              ? summaryIndent.string + detailsIndent.string
              : summaryIndent.string;
      constIndent += multiIndent.string;

      String errMsg1 = errKind.getOutput(outKind, summaryIndent, detailsIndent, constIndent);
      String errMsg2 =
          errKind.getOutput(outKind, summaryIndent, detailsIndent, constIndent + constIndent);

      errMsg1 = errMsg1.replaceAll("compiler.err", "compiler.misc");
      errMsg1 = errMsg1.replaceAll("error message", "subdiagnostic");
      errMsg2 = errMsg2.replaceAll("compiler.err", "compiler.misc");
      errMsg2 = errMsg2.replaceAll("error message", "subdiagnostic");

      String template =
          outKind == OutputKind.RAW
              ? rawTemplates[policy.index][index]
              : basicTemplates[policy.index][index];

      template = template.replaceAll("E", errMsg1);
      return template.replaceAll("Q", errMsg2);
    }
コード例 #2
0
  void checkOutput(String msg) {
    boolean shouldPrintSource =
        posKind == PositionKind.POS
            && xdiagsSource != XDiagsSource.NO_SOURCE
            && (xdiagsSource == XDiagsSource.SOURCE || outputKind == OutputKind.BASIC);
    String errorLine =
        posKind.getOutput(outputKind)
            + errorKind.getOutput(outputKind, summaryIndent, detailsIndent);
    if (xdiagsCompact != XDiagsCompact.COMPACT)
      errorLine +=
          multiKind.getOutput(
              outputKind, errorKind, multiPolicy, summaryIndent, detailsIndent, subdiagsIndent);
    String[] lines = errorLine.split("\n");
    if (xdiagsCompact == XDiagsCompact.COMPACT) {
      errorLine = lines[0];
      lines = new String[] {errorLine};
    }
    if (shouldPrintSource) {
      if (sourceLineKind.isAfterSummary()) {
        String sep = "\n";
        if (lines.length == 1) {
          errorLine += "\n";
          sep = "";
        }
        errorLine =
            errorLine.replaceFirst(
                "\n",
                Matcher.quoteReplacement(
                    xdiagsSource.getOutput(caretKind, sourceIndent, outputKind) + sep));
      } else errorLine += xdiagsSource.getOutput(caretKind, sourceIndent, outputKind);
    }

    if (!msg.equals(errorLine)) {
      printInfo(msg, errorLine);
      throw new AssertionError("errors were found");
    }
  }