### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/core/compiler/IProblem.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java,v retrieving revision 1.172 diff -u -r1.172 IProblem.java --- compiler/org/eclipse/jdt/core/compiler/IProblem.java 6 Mar 2006 08:13:41 -0000 1.172 +++ compiler/org/eclipse/jdt/core/compiler/IProblem.java 8 Mar 2006 21:07:28 -0000 @@ -1090,6 +1090,11 @@ */ /** @since 3.1 */ int CorruptedSignature = Internal + 700; + /** + * Corrupted source + */ + /** @since 3.1 */ + int CannotReadSource = Internal + 701; /** * Autoboxing Index: compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties,v retrieving revision 1.199 diff -u -r1.199 messages.properties --- compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties 6 Mar 2006 14:39:32 -0000 1.199 +++ compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties 8 Mar 2006 21:07:45 -0000 @@ -525,6 +525,9 @@ ### CORRUPTED BINARIES 700 = The class file {0} contains a signature ''{1}'' ill-formed at position {2} +### CORRUPTED SOURCES +701 = Cannot read source from {0} due to internal exception {1} + ### AUTOBOXING 720 = The expression of type {0} is boxed into {1} 721 = The expression of type {0} is unboxed into {1} Index: compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java,v retrieving revision 1.303 diff -u -r1.303 ProblemReporter.java --- compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 6 Mar 2006 14:41:06 -0000 1.303 +++ compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 8 Mar 2006 21:07:44 -0000 @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.jdt.internal.compiler.problem; +import java.io.PrintWriter; +import java.io.StringWriter; import java.text.MessageFormat; import org.eclipse.jdt.core.compiler.CategorizedProblem; @@ -815,6 +817,20 @@ constructorCall.sourceStart, constructorCall.sourceEnd); } +public void cannotReadSource(CompilationUnitDeclaration unit, Throwable e) { + String fileName = new String(unit.compilationResult.fileName); + StringWriter stringWriter = new StringWriter(); + PrintWriter writer = new PrintWriter(stringWriter); + e.printStackTrace(writer); + String exceptionTrace = stringWriter.toString(); + String[] arguments = new String[]{ fileName, exceptionTrace, }; + this.handle( + IProblem.CannotReadSource, + arguments, + arguments, + 0, + 0); +} public void cannotReferToNonFinalOuterLocal(LocalVariableBinding local, ASTNode location) { String[] arguments =new String[]{ new String(local.readableName())}; this.handle( Index: compiler/org/eclipse/jdt/internal/compiler/problem/AbortCompilationUnit.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/AbortCompilationUnit.java,v retrieving revision 1.10 diff -u -r1.10 AbortCompilationUnit.java --- compiler/org/eclipse/jdt/internal/compiler/problem/AbortCompilationUnit.java 17 Feb 2006 16:09:55 -0000 1.10 +++ compiler/org/eclipse/jdt/internal/compiler/problem/AbortCompilationUnit.java 8 Mar 2006 21:07:38 -0000 @@ -26,4 +26,8 @@ public AbortCompilationUnit(CompilationResult compilationResult, CategorizedProblem problem) { super(compilationResult, problem); } + +public AbortCompilationUnit(CompilationResult compilationResult, Throwable exception) { + super(compilationResult, exception); +} } Index: compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java,v retrieving revision 1.342 diff -u -r1.342 Parser.java --- compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java 8 Mar 2006 10:50:41 -0000 1.342 +++ compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java 8 Mar 2006 21:07:36 -0000 @@ -38,6 +38,7 @@ import org.eclipse.jdt.internal.compiler.lookup.TypeIds; import org.eclipse.jdt.internal.compiler.parser.diagnose.DiagnoseParser; import org.eclipse.jdt.internal.compiler.problem.AbortCompilation; +import org.eclipse.jdt.internal.compiler.problem.AbortCompilationUnit; import org.eclipse.jdt.internal.compiler.problem.ProblemReporter; import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities; import org.eclipse.jdt.internal.compiler.util.Messages; @@ -7704,8 +7705,7 @@ try { this.diet = true; parsedUnit = parse(sourceUnit, compilationResult); - } - finally { + } finally { this.diet = old; } return parsedUnit; @@ -9033,9 +9033,24 @@ initialize(true); goForCompilationUnit(); + /* unit creation */ + this.referenceContext = + this.compilationUnit = + new CompilationUnitDeclaration( + this.problemReporter, + compilationResult, + 0); + /* scanners initialization */ - char[] contents = sourceUnit.getContents(); + char[] contents; + try { + contents = sourceUnit.getContents(); + } catch(AbortCompilationUnit e) { + this.problemReporter().cannotReadSource(this.compilationUnit, e.exception); + contents = CharOperation.NO_CHAR; // pretend empty from thereon + } this.scanner.setSource(contents); + this.compilationUnit.sourceEnd = this.scanner.source.length - 1; if (end != -1) this.scanner.resetTo(start, end); if (this.javadocParser != null && this.javadocParser.checkDocComment) { this.javadocParser.scanner.setSource(contents); @@ -9043,13 +9058,6 @@ this.javadocParser.scanner.resetTo(start, end); } } - /* unit creation */ - this.referenceContext = - this.compilationUnit = - new CompilationUnitDeclaration( - this.problemReporter, - compilationResult, - this.scanner.source.length); /* run automaton */ parse(); } finally { Index: batch/org/eclipse/jdt/internal/compiler/batch/CompilationUnit.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/CompilationUnit.java,v retrieving revision 1.28 diff -u -r1.28 CompilationUnit.java --- batch/org/eclipse/jdt/internal/compiler/batch/CompilationUnit.java 11 Feb 2006 02:06:25 -0000 1.28 +++ batch/org/eclipse/jdt/internal/compiler/batch/CompilationUnit.java 8 Mar 2006 21:07:27 -0000 @@ -15,6 +15,7 @@ import org.eclipse.jdt.core.compiler.CharOperation; import org.eclipse.jdt.internal.compiler.env.ICompilationUnit; +import org.eclipse.jdt.internal.compiler.problem.AbortCompilationUnit; import org.eclipse.jdt.internal.compiler.util.Util; public class CompilationUnit implements ICompilationUnit { @@ -56,9 +57,9 @@ try { return Util.getFileCharContent(new File(new String(this.fileName)), this.encoding); } catch (IOException e) { - // assume no content then + this.contents = CharOperation.NO_CHAR; // assume no source if asked again + throw new AbortCompilationUnit(null, e); } - return CharOperation.NO_CHAR; } /** * @see org.eclipse.jdt.internal.compiler.env.IDependent#getFileName()