test/tools/javac/Diagnostics/6769027/T6769027.java

Sat, 07 Nov 2020 10:30:02 +0800

author
aoqi
date
Sat, 07 Nov 2020 10:30:02 +0800
changeset 3938
93012e2a5d1d
parent 2525
2eb010b6cb22
permissions
-rw-r--r--

Added tag mips-jdk8u275-b01 for changeset eb6ee6a5f2fe

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation.
aoqi@0 8 *
aoqi@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 12 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 13 * accompanied this code).
aoqi@0 14 *
aoqi@0 15 * You should have received a copy of the GNU General Public License version
aoqi@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 18 *
aoqi@0 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 20 * or visit www.oracle.com if you need additional information or have any
aoqi@0 21 * questions.
aoqi@0 22 */
aoqi@0 23
aoqi@0 24 /**
aoqi@0 25 * @test
aoqi@0 26 * @bug 6769027 8006694
aoqi@0 27 * @summary Source line should be displayed immediately after the first diagnostic line
aoqi@0 28 * temporarily workaround combo tests are causing time out in several platforms
aoqi@0 29 * @author Maurizio Cimadamore
aoqi@0 30 * @library ../../lib
aoqi@0 31 * @build JavacTestingAbstractThreadedTest
aoqi@0 32 * @run main/othervm T6769027
aoqi@0 33 */
aoqi@0 34
aoqi@0 35 // use /othervm to avoid jtreg timeout issues (CODETOOLS-7900047)
aoqi@0 36 // see JDK-8006746
aoqi@0 37
aoqi@0 38 import java.net.URI;
aoqi@0 39 import java.util.regex.Matcher;
aoqi@0 40 import javax.tools.*;
aoqi@0 41 import com.sun.tools.javac.util.*;
aoqi@0 42
aoqi@0 43 public class T6769027
aoqi@0 44 extends JavacTestingAbstractThreadedTest
aoqi@0 45 implements Runnable {
aoqi@0 46
aoqi@0 47 enum OutputKind {
aoqi@0 48 RAW("rawDiagnostics","rawDiagnostics"),
aoqi@0 49 BASIC("","");
aoqi@0 50
aoqi@0 51 String key;
aoqi@0 52 String value;
aoqi@0 53
aoqi@0 54 void init(Options opts) {
aoqi@0 55 opts.put(key, value);
aoqi@0 56 }
aoqi@0 57
aoqi@0 58 OutputKind(String key, String value) {
aoqi@0 59 this.key = key;
aoqi@0 60 this.value = value;
aoqi@0 61 }
aoqi@0 62 }
aoqi@0 63
aoqi@0 64 enum CaretKind {
aoqi@0 65 DEFAULT("", ""),
aoqi@0 66 SHOW("showCaret","true"),
aoqi@0 67 HIDE("showCaret","false");
aoqi@0 68
aoqi@0 69 String key;
aoqi@0 70 String value;
aoqi@0 71
aoqi@0 72 void init(Options opts) {
aoqi@0 73 opts.put(key, value);
aoqi@0 74 }
aoqi@0 75
aoqi@0 76 CaretKind(String key, String value) {
aoqi@0 77 this.key = key;
aoqi@0 78 this.value = value;
aoqi@0 79 }
aoqi@0 80
aoqi@0 81 boolean isEnabled() {
aoqi@0 82 return this == DEFAULT || this == SHOW;
aoqi@0 83 }
aoqi@0 84 }
aoqi@0 85
aoqi@0 86 enum SourceLineKind {
aoqi@0 87 DEFAULT("", ""),
aoqi@0 88 AFTER_SUMMARY("sourcePosition", "top"),
aoqi@0 89 BOTTOM("sourcePosition", "bottom");
aoqi@0 90
aoqi@0 91 String key;
aoqi@0 92 String value;
aoqi@0 93
aoqi@0 94 void init(Options opts) {
aoqi@0 95 opts.put(key, value);
aoqi@0 96 }
aoqi@0 97
aoqi@0 98 SourceLineKind(String key, String value) {
aoqi@0 99 this.key = key;
aoqi@0 100 this.value = value;
aoqi@0 101 }
aoqi@0 102
aoqi@0 103 boolean isAfterSummary() {
aoqi@0 104 return this == DEFAULT || this == AFTER_SUMMARY;
aoqi@0 105 }
aoqi@0 106 }
aoqi@0 107
aoqi@0 108 enum XDiagsSource {
aoqi@0 109 DEFAULT(""),
aoqi@0 110 SOURCE("source"),
aoqi@0 111 NO_SOURCE("-source");
aoqi@0 112
aoqi@0 113 String flag;
aoqi@0 114
aoqi@0 115 void init(Options opts) {
aoqi@0 116 if (this != DEFAULT) {
aoqi@0 117 String flags = opts.get("diags");
aoqi@0 118 flags = flags == null ? flag : flags + "," + flag;
aoqi@0 119 opts.put("diags", flags);
aoqi@0 120 }
aoqi@0 121 }
aoqi@0 122
aoqi@0 123 XDiagsSource(String flag) {
aoqi@0 124 this.flag = flag;
aoqi@0 125 }
aoqi@0 126
aoqi@0 127 String getOutput(CaretKind caretKind, IndentKind indent, OutputKind outKind) {
aoqi@0 128 String spaces = (outKind == OutputKind.BASIC) ? indent.string : "";
aoqi@0 129 return "\n" + spaces + "This is a source line" +
aoqi@0 130 (caretKind.isEnabled() ? "\n" + spaces + " ^" : "");
aoqi@0 131 }
aoqi@0 132 }
aoqi@0 133
aoqi@0 134 enum XDiagsCompact {
aoqi@0 135 DEFAULT(""),
aoqi@0 136 COMPACT("short"),
aoqi@0 137 NO_COMPACT("-short");
aoqi@0 138
aoqi@0 139 String flag;
aoqi@0 140
aoqi@0 141 void init(Options opts) {
aoqi@0 142 if (this != DEFAULT) {
aoqi@0 143 String flags = opts.get("diags");
aoqi@0 144 flags = flags == null ? flag : flags + "," + flag;
aoqi@0 145 opts.put("diags", flags);
aoqi@0 146 }
aoqi@0 147 }
aoqi@0 148
aoqi@0 149 XDiagsCompact(String flag) {
aoqi@0 150 this.flag = flag;
aoqi@0 151 }
aoqi@0 152 }
aoqi@0 153
aoqi@0 154 enum ErrorKind {
aoqi@0 155 SINGLE("single",
aoqi@0 156 "compiler.err.single: Hello!",
aoqi@0 157 "KXThis is a test error message Hello!"),
aoqi@0 158 DOUBLE("double",
aoqi@0 159 "compiler.err.double: Hello!",
aoqi@0 160 "KXThis is a test error message.\n" +
aoqi@0 161 "KXYThis is another line of the above error message Hello!");
aoqi@0 162
aoqi@0 163 String key;
aoqi@0 164 String rawOutput;
aoqi@0 165 String nonRawOutput;
aoqi@0 166
aoqi@0 167 String key() {
aoqi@0 168 return key;
aoqi@0 169 }
aoqi@0 170
aoqi@0 171 ErrorKind(String key, String rawOutput, String nonRawOutput) {
aoqi@0 172 this.key = key;
aoqi@0 173 this.rawOutput = rawOutput;
aoqi@0 174 this.nonRawOutput = nonRawOutput;
aoqi@0 175 }
aoqi@0 176
aoqi@0 177 String getOutput(OutputKind outKind, IndentKind summaryIndent, IndentKind detailsIndent) {
aoqi@0 178 return outKind == OutputKind.RAW ?
aoqi@0 179 rawOutput :
aoqi@0 180 nonRawOutput.replace("X", summaryIndent.string).replace("Y", detailsIndent.string).replace("K", "");
aoqi@0 181 }
aoqi@0 182
aoqi@0 183 String getOutput(OutputKind outKind, IndentKind summaryIndent, IndentKind detailsIndent, String indent) {
aoqi@0 184 return outKind == OutputKind.RAW ?
aoqi@0 185 rawOutput :
aoqi@0 186 nonRawOutput.replace("X", summaryIndent.string).replace("Y", detailsIndent.string).replace("K", indent);
aoqi@0 187 }
aoqi@0 188 }
aoqi@0 189
aoqi@0 190 enum MultilineKind {
aoqi@0 191 NONE(0),
aoqi@0 192 DOUBLE(1),
aoqi@0 193 NESTED(2),
aoqi@0 194 DOUBLE_NESTED(3);
aoqi@0 195
aoqi@0 196 static String[][] rawTemplates = {
aoqi@0 197 {"", ",{(E),(E)}", ",{(E,{(E)})}", ",{(E,{(E)}),(E,{(E)})}"}, //ENABLED
aoqi@0 198 {"", "", "", "",""}, //DISABLED
aoqi@0 199 {"", ",{(E)}", ",{(E,{(E)})}", ",{(E,{(E)})}"}, //LIMIT_LENGTH
aoqi@0 200 {"", ",{(E),(E)}", ",{(E)}", ",{(E),(E)}"}, //LIMIT_DEPTH
aoqi@0 201 {"", ",{(E)}", ",{(E)}", ",{(E)}"}}; //LIMIT_BOTH
aoqi@0 202
aoqi@0 203 static String[][] basicTemplates = {
aoqi@0 204 {"", "\nE\nE", "\nE\nQ", "\nE\nQ\nE\nQ"}, //ENABLED
aoqi@0 205 {"", "", "", "",""}, //DISABLED
aoqi@0 206 {"", "\nE", "\nE\nQ", "\nE\nQ"}, //LIMIT_LENGTH
aoqi@0 207 {"", "\nE\nE", "\nE", "\nE\nE"}, //LIMIT_DEPTH
aoqi@0 208 {"", "\nE", "\nE", "\nE"}}; //LIMIT_BOTH
aoqi@0 209
aoqi@0 210
aoqi@0 211 int index;
aoqi@0 212
aoqi@0 213 MultilineKind (int index) {
aoqi@0 214 this.index = index;
aoqi@0 215 }
aoqi@0 216
aoqi@0 217 boolean isDouble() {
aoqi@0 218 return this == DOUBLE || this == DOUBLE_NESTED;
aoqi@0 219 }
aoqi@0 220
aoqi@0 221 boolean isNested() {
aoqi@0 222 return this == NESTED || this == DOUBLE_NESTED;
aoqi@0 223 }
aoqi@0 224
aoqi@0 225 String getOutput(OutputKind outKind, ErrorKind errKind, MultilinePolicy policy,
aoqi@0 226 IndentKind summaryIndent, IndentKind detailsIndent, IndentKind multiIndent) {
aoqi@0 227 String constIndent = (errKind == ErrorKind.DOUBLE) ?
aoqi@0 228 summaryIndent.string + detailsIndent.string :
aoqi@0 229 summaryIndent.string;
aoqi@0 230 constIndent += multiIndent.string;
aoqi@0 231
aoqi@0 232 String errMsg1 = errKind.getOutput(outKind, summaryIndent, detailsIndent, constIndent);
aoqi@0 233 String errMsg2 = errKind.getOutput(outKind, summaryIndent, detailsIndent, constIndent + constIndent);
aoqi@0 234
aoqi@0 235 errMsg1 = errMsg1.replaceAll("compiler.err", "compiler.misc");
aoqi@0 236 errMsg1 = errMsg1.replaceAll("error message", "subdiagnostic");
aoqi@0 237 errMsg2 = errMsg2.replaceAll("compiler.err", "compiler.misc");
aoqi@0 238 errMsg2 = errMsg2.replaceAll("error message", "subdiagnostic");
aoqi@0 239
aoqi@0 240 String template = outKind == OutputKind.RAW ?
aoqi@0 241 rawTemplates[policy.index][index] :
aoqi@0 242 basicTemplates[policy.index][index];
aoqi@0 243
aoqi@0 244 template = template.replaceAll("E", errMsg1);
aoqi@0 245 return template.replaceAll("Q", errMsg2);
aoqi@0 246 }
aoqi@0 247 }
aoqi@0 248
aoqi@0 249 enum MultilinePolicy {
aoqi@0 250 ENABLED(0, "multilinePolicy", "enabled"),
aoqi@0 251 DISABLED(1, "multilinePolicy", "disabled"),
aoqi@0 252 LIMIT_LENGTH(2, "multilinePolicy", "limit:1:*"),
aoqi@0 253 LIMIT_DEPTH(3, "multilinePolicy", "limit:*:1"),
aoqi@0 254 LIMIT_BOTH(4, "multilinePolicy", "limit:1:1");
aoqi@0 255
aoqi@0 256 String name;
aoqi@0 257 String value;
aoqi@0 258 int index;
aoqi@0 259
aoqi@0 260 MultilinePolicy(int index, String name, String value) {
aoqi@0 261 this.name = name;
aoqi@0 262 this.value = value;
aoqi@0 263 this.index = index;
aoqi@0 264 }
aoqi@0 265
aoqi@0 266 void init(Options options) {
aoqi@0 267 options.put(name, value);
aoqi@0 268 }
aoqi@0 269 }
aoqi@0 270
aoqi@0 271 enum PositionKind {
aoqi@0 272 NOPOS(Position.NOPOS, "- ", "error: "),
aoqi@0 273 POS(5, "Test.java:1:6: ", "/Test.java:1: error: ");
aoqi@0 274
aoqi@0 275 int pos;
aoqi@0 276 String rawOutput;
aoqi@0 277 String nonRawOutput;
aoqi@0 278
aoqi@0 279 PositionKind(int pos, String rawOutput, String nonRawOutput) {
aoqi@0 280 this.pos = pos;
aoqi@0 281 this.rawOutput = rawOutput;
aoqi@0 282 this.nonRawOutput = nonRawOutput;
aoqi@0 283 }
aoqi@0 284
aoqi@0 285 JCDiagnostic.DiagnosticPosition pos() {
aoqi@0 286 return new JCDiagnostic.SimpleDiagnosticPosition(pos);
aoqi@0 287 }
aoqi@0 288
aoqi@0 289 String getOutput(OutputKind outputKind) {
aoqi@0 290 return outputKind == OutputKind.RAW ?
aoqi@0 291 rawOutput :
aoqi@0 292 nonRawOutput;
aoqi@0 293 }
aoqi@0 294 }
aoqi@0 295
aoqi@0 296 static class MyFileObject extends SimpleJavaFileObject {
aoqi@0 297 private String text;
aoqi@0 298 public MyFileObject(String text) {
aoqi@0 299 super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
aoqi@0 300 this.text = text;
aoqi@0 301 }
aoqi@0 302 @Override
aoqi@0 303 public CharSequence getCharContent(boolean ignoreEncodingErrors) {
aoqi@0 304 return text;
aoqi@0 305 }
aoqi@0 306 }
aoqi@0 307
aoqi@0 308 enum IndentKind {
aoqi@0 309 NONE(""),
aoqi@0 310 CUSTOM(" ");
aoqi@0 311
aoqi@0 312 String string;
aoqi@0 313
aoqi@0 314 IndentKind(String indent) {
aoqi@0 315 string = indent;
aoqi@0 316 }
aoqi@0 317 }
aoqi@0 318
aoqi@0 319 class MyLog extends Log {
aoqi@0 320 MyLog(Context ctx) {
aoqi@0 321 super(ctx);
aoqi@0 322 }
aoqi@0 323
aoqi@0 324 @Override
aoqi@0 325 protected java.io.PrintWriter getWriterForDiagnosticType(JCDiagnostic.DiagnosticType dt) {
aoqi@0 326 return outWriter;
aoqi@0 327 }
aoqi@0 328
aoqi@0 329 @Override
aoqi@0 330 protected boolean shouldReport(JavaFileObject jfo, int pos) {
aoqi@0 331 return true;
aoqi@0 332 }
aoqi@0 333 }
aoqi@0 334
aoqi@0 335 OutputKind outputKind;
aoqi@0 336 ErrorKind errorKind;
aoqi@0 337 MultilineKind multiKind;
aoqi@0 338 MultilinePolicy multiPolicy;
aoqi@0 339 PositionKind posKind;
aoqi@0 340 XDiagsSource xdiagsSource;
aoqi@0 341 XDiagsCompact xdiagsCompact;
aoqi@0 342 CaretKind caretKind;
aoqi@0 343 SourceLineKind sourceLineKind;
aoqi@0 344 IndentKind summaryIndent;
aoqi@0 345 IndentKind detailsIndent;
aoqi@0 346 IndentKind sourceIndent;
aoqi@0 347 IndentKind subdiagsIndent;
aoqi@0 348
aoqi@0 349 T6769027(OutputKind outputKind, ErrorKind errorKind, MultilineKind multiKind,
aoqi@0 350 MultilinePolicy multiPolicy, PositionKind posKind, XDiagsSource xdiagsSource,
aoqi@0 351 XDiagsCompact xdiagsCompact, CaretKind caretKind, SourceLineKind sourceLineKind,
aoqi@0 352 IndentKind summaryIndent, IndentKind detailsIndent, IndentKind sourceIndent,
aoqi@0 353 IndentKind subdiagsIndent) {
aoqi@0 354 this.outputKind = outputKind;
aoqi@0 355 this.errorKind = errorKind;
aoqi@0 356 this.multiKind = multiKind;
aoqi@0 357 this.multiPolicy = multiPolicy;
aoqi@0 358 this.posKind = posKind;
aoqi@0 359 this.xdiagsSource = xdiagsSource;
aoqi@0 360 this.xdiagsCompact = xdiagsCompact;
aoqi@0 361 this.caretKind = caretKind;
aoqi@0 362 this.sourceLineKind = sourceLineKind;
aoqi@0 363 this.summaryIndent = summaryIndent;
aoqi@0 364 this.detailsIndent = detailsIndent;
aoqi@0 365 this.sourceIndent = sourceIndent;
aoqi@0 366 this.subdiagsIndent = subdiagsIndent;
aoqi@0 367 }
aoqi@0 368
aoqi@0 369 @Override
aoqi@0 370 public void run() {
aoqi@0 371 Context ctx = new Context();
aoqi@0 372 Options options = Options.instance(ctx);
aoqi@0 373 outputKind.init(options);
aoqi@0 374 multiPolicy.init(options);
aoqi@0 375 xdiagsSource.init(options);
aoqi@0 376 xdiagsCompact.init(options);
aoqi@0 377 caretKind.init(options);
aoqi@0 378 sourceLineKind.init(options);
aoqi@0 379 String indentString = "";
aoqi@0 380 indentString = (summaryIndent == IndentKind.CUSTOM) ? "3" : "0";
aoqi@0 381 indentString += (detailsIndent == IndentKind.CUSTOM) ? "|3" : "|0";
aoqi@0 382 indentString += (sourceIndent == IndentKind.CUSTOM) ? "|3" : "|0";
aoqi@0 383 indentString += (subdiagsIndent == IndentKind.CUSTOM) ? "|3" : "|0";
aoqi@0 384 options.put("diagsIndentation", indentString);
aoqi@0 385 MyLog log = new MyLog(ctx);
aoqi@0 386 JavacMessages messages = JavacMessages.instance(ctx);
aoqi@0 387 messages.add("tester");
aoqi@0 388 JCDiagnostic.Factory diags = JCDiagnostic.Factory.instance(ctx);
aoqi@0 389 log.useSource(new MyFileObject("This is a source line"));
aoqi@0 390 JCDiagnostic d = diags.error(log.currentSource(),
aoqi@0 391 posKind.pos(),
aoqi@0 392 errorKind.key(), "Hello!");
aoqi@0 393 if (multiKind != MultilineKind.NONE) {
aoqi@0 394 JCDiagnostic sub = diags.fragment(errorKind.key(), "Hello!");
aoqi@0 395 if (multiKind.isNested())
aoqi@0 396 sub = new JCDiagnostic.MultilineDiagnostic(sub, List.of(sub));
aoqi@0 397 List<JCDiagnostic> subdiags = multiKind.isDouble() ?
aoqi@0 398 List.of(sub, sub) :
aoqi@0 399 List.of(sub);
aoqi@0 400 d = new JCDiagnostic.MultilineDiagnostic(d, subdiags);
aoqi@0 401 }
aoqi@0 402 String diag = log.getDiagnosticFormatter().format(d, messages.getCurrentLocale());
aoqi@0 403 checkOutput(diag);
aoqi@0 404 }
aoqi@0 405
aoqi@0 406 public static void main(String[] args) throws Exception {
aoqi@0 407 for (OutputKind outputKind : OutputKind.values()) {
aoqi@0 408 for (ErrorKind errKind : ErrorKind.values()) {
aoqi@0 409 for (MultilineKind multiKind : MultilineKind.values()) {
aoqi@0 410 for (MultilinePolicy multiPolicy : MultilinePolicy.values()) {
aoqi@0 411 for (PositionKind posKind : PositionKind.values()) {
aoqi@0 412 for (XDiagsSource xdiagsSource : XDiagsSource.values()) {
aoqi@0 413 for (XDiagsCompact xdiagsCompact : XDiagsCompact.values()) {
aoqi@0 414 for (CaretKind caretKind : CaretKind.values()) {
aoqi@0 415 for (SourceLineKind sourceLineKind : SourceLineKind.values()) {
aoqi@0 416 for (IndentKind summaryIndent : IndentKind.values()) {
aoqi@0 417 for (IndentKind detailsIndent : IndentKind.values()) {
aoqi@0 418 for (IndentKind sourceIndent : IndentKind.values()) {
aoqi@0 419 for (IndentKind subdiagsIndent : IndentKind.values()) {
aoqi@0 420 pool.execute(new T6769027(outputKind,
aoqi@0 421 errKind,
aoqi@0 422 multiKind,
aoqi@0 423 multiPolicy,
aoqi@0 424 posKind,
aoqi@0 425 xdiagsSource,
aoqi@0 426 xdiagsCompact,
aoqi@0 427 caretKind,
aoqi@0 428 sourceLineKind,
aoqi@0 429 summaryIndent,
aoqi@0 430 detailsIndent,
aoqi@0 431 sourceIndent,
aoqi@0 432 subdiagsIndent));
aoqi@0 433 }
aoqi@0 434 }
aoqi@0 435 }
aoqi@0 436 }
aoqi@0 437 }
aoqi@0 438 }
aoqi@0 439 }
aoqi@0 440 }
aoqi@0 441 }
aoqi@0 442 }
aoqi@0 443 }
aoqi@0 444 }
aoqi@0 445 }
aoqi@0 446
aoqi@0 447 checkAfterExec(false);
aoqi@0 448 }
aoqi@0 449
aoqi@0 450 void printInfo(String msg, String errorLine) {
aoqi@0 451 String sep = "*********************************************************";
aoqi@0 452 String desc = "raw=" + outputKind + " pos=" + posKind + " key=" + errorKind.key() +
aoqi@0 453 " multiline=" + multiKind +" multiPolicy=" + multiPolicy.value +
aoqi@0 454 " diags= " + java.util.Arrays.asList(xdiagsSource.flag, xdiagsCompact.flag) +
aoqi@0 455 " caret=" + caretKind + " sourcePosition=" + sourceLineKind +
aoqi@0 456 " summaryIndent=" + summaryIndent + " detailsIndent=" + detailsIndent +
aoqi@0 457 " sourceIndent=" + sourceIndent + " subdiagsIndent=" + subdiagsIndent;
aoqi@0 458 errWriter.println(sep);
aoqi@0 459 errWriter.println(desc);
aoqi@0 460 errWriter.println(sep);
aoqi@0 461 errWriter.println(msg);
aoqi@0 462 errWriter.println("Diagnostic formatting problem - expected diagnostic...\n" + errorLine);
aoqi@0 463 }
aoqi@0 464
aoqi@0 465 void checkOutput(String msg) {
aoqi@0 466 boolean shouldPrintSource = posKind == PositionKind.POS &&
aoqi@0 467 xdiagsSource != XDiagsSource.NO_SOURCE &&
aoqi@0 468 (xdiagsSource == XDiagsSource.SOURCE ||
aoqi@0 469 outputKind == OutputKind.BASIC);
aoqi@0 470 String errorLine = posKind.getOutput(outputKind) +
aoqi@0 471 errorKind.getOutput(outputKind, summaryIndent, detailsIndent);
aoqi@0 472 if (xdiagsCompact != XDiagsCompact.COMPACT)
aoqi@0 473 errorLine += multiKind.getOutput(outputKind, errorKind, multiPolicy,
aoqi@0 474 summaryIndent, detailsIndent, subdiagsIndent);
aoqi@0 475 String[] lines = errorLine.split("\n");
aoqi@0 476 if (xdiagsCompact == XDiagsCompact.COMPACT) {
aoqi@0 477 errorLine = lines[0];
aoqi@0 478 lines = new String[] {errorLine};
aoqi@0 479 }
aoqi@0 480 if (shouldPrintSource) {
aoqi@0 481 if (sourceLineKind.isAfterSummary()) {
aoqi@0 482 String sep = "\n";
aoqi@0 483 if (lines.length == 1) {
aoqi@0 484 errorLine += "\n";
aoqi@0 485 sep = "";
aoqi@0 486 }
aoqi@0 487 errorLine = errorLine.replaceFirst("\n",
aoqi@0 488 Matcher.quoteReplacement(xdiagsSource.getOutput(caretKind, sourceIndent, outputKind) + sep));
aoqi@0 489 }
aoqi@0 490 else
aoqi@0 491 errorLine += xdiagsSource.getOutput(caretKind, sourceIndent, outputKind);
aoqi@0 492 }
aoqi@0 493
aoqi@0 494 if (!msg.equals(errorLine)) {
aoqi@0 495 // printInfo(msg, errorLine);
aoqi@0 496 errCount.incrementAndGet();
aoqi@0 497 }
aoqi@0 498 }
aoqi@0 499
aoqi@0 500 }

mercurial