View | Details | Raw Unified | Return to bug 256735 | Differences between
and this patch

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/util/Util.java (+38 lines)
Lines 18-23 Link Here
18
import java.io.IOException;
18
import java.io.IOException;
19
import java.io.InputStream;
19
import java.io.InputStream;
20
import java.io.InputStreamReader;
20
import java.io.InputStreamReader;
21
import java.io.PrintWriter;
22
import java.io.StringWriter;
21
import java.io.UnsupportedEncodingException;
23
import java.io.UnsupportedEncodingException;
22
import java.util.StringTokenizer;
24
import java.util.StringTokenizer;
23
import java.util.zip.ZipEntry;
25
import java.util.zip.ZipEntry;
Lines 427-432 Link Here
427
		return contents;
429
		return contents;
428
	}
430
	}
429
431
432
	/**
433
	 * Returns a one line summary for an exception (extracted from its stacktrace: name + first frame)
434
	 * @param exception
435
	 * @return one line summary for an exception
436
	 */
437
	public static String getExceptionSummary(Throwable exception) {
438
		StringWriter stringWriter = new StringWriter();
439
		exception.printStackTrace(new PrintWriter(stringWriter));
440
		StringBuffer buffer = stringWriter.getBuffer();		
441
		StringBuffer exceptionBuffer = new StringBuffer(50);
442
		exceptionBuffer.append(exception.toString());
443
		// only keep leading frame portion of the trace (i.e. line no. 2 from the stacktrace)
444
		lookupLine2: for (int i = 0, lineSep = 0, max = buffer.length(), line2Start = 0; i < max; i++) {
445
			switch (buffer.charAt(i)) {
446
				case '\n':
447
				case '\r' :
448
					if (line2Start > 0) {
449
						exceptionBuffer.append(' ').append(buffer.substring(line2Start, i));
450
						break lookupLine2;
451
					}						
452
					lineSep++;
453
					break;
454
				case ' ' :
455
				case '\t' :
456
					break;
457
				default :
458
					if (lineSep > 0) {
459
						line2Start = i;
460
						lineSep = 0;
461
					}
462
					break;
463
			}
464
		}
465
		return exceptionBuffer.toString();
466
	}
467
	
430
	public static int getLineNumber(int position, int[] lineEnds, int g, int d) {
468
	public static int getLineNumber(int position, int[] lineEnds, int g, int d) {
431
		if (lineEnds == null)
469
		if (lineEnds == null)
432
			return 1;
470
			return 1;
(-)compiler/org/eclipse/jdt/internal/compiler/messages.properties (-1 / +1 lines)
Lines 20-26 Link Here
20
compilation_done       = [completed  {2} - #{0}/{1}]
20
compilation_done       = [completed  {2} - #{0}/{1}]
21
compilation_units      = [{0} units compiled]
21
compilation_units      = [{0} units compiled]
22
compilation_unit       = [{0} unit compiled]
22
compilation_unit       = [{0} unit compiled]
23
compilation_internalError = Internal compiler error
23
compilation_internalError = Internal compiler error: {0}
24
compilation_beginningToCompile=Beginning to compile
24
compilation_beginningToCompile=Beginning to compile
25
compilation_processing=Processing {0}
25
compilation_processing=Processing {0}
26
26
(-)compiler/org/eclipse/jdt/internal/compiler/Compiler.java (-8 / +3 lines)
Lines 557-571 Link Here
557
		boolean needToPrint = true;
557
		boolean needToPrint = true;
558
		if (result != null) {
558
		if (result != null) {
559
			/* create and record a compilation problem */
559
			/* create and record a compilation problem */
560
			StringWriter stringWriter = new StringWriter();
560
			// only keep leading portion of the trace
561
			PrintWriter writer = new PrintWriter(stringWriter);
562
			internalException.printStackTrace(writer);
563
			StringBuffer buffer = stringWriter.getBuffer();
564
565
			String[] pbArguments = new String[] {
561
			String[] pbArguments = new String[] {
566
				Messages.compilation_internalError
562
				Messages.bind(Messages.compilation_internalError, Util.getExceptionSummary(internalException)),
567
					+ "\n"  //$NON-NLS-1$
563
			};
568
					+ buffer.toString()};
569
564
570
			result
565
			result
571
				.record(
566
				.record(

Return to bug 256735