Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 35938 Details for
Bug 130980
[compiler] When the contents of the unit cannot be retrieved, the compiler should report an error
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Better patch
130980.txt (text/plain), 8.95 KB, created by
Philipe Mulet
on 2006-03-08 17:03:26 EST
(
hide
)
Description:
Better patch
Filename:
MIME Type:
Creator:
Philipe Mulet
Created:
2006-03-08 17:03:26 EST
Size:
8.95 KB
patch
obsolete
>### 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 22:03:46 -0000 >@@ -1090,6 +1090,13 @@ > */ > /** @since 3.1 */ > int CorruptedSignature = Internal + 700; >+ /** >+ * Corrupted source >+ */ >+ /** @since 3.2 */ >+ int InvalidEncoding = Internal + 701; >+ /** @since 3.2 */ >+ int CannotReadSource = Internal + 702; > > /** > * 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 22:04:03 -0000 >@@ -525,6 +525,10 @@ > ### CORRUPTED BINARIES > 700 = The class file {0} contains a signature ''{1}'' ill-formed at position {2} > >+### CORRUPTED SOURCES >+701 = Cannot read the source from {0}; either the file uses a different encoding than {1} or it is corrupted >+702 = Cannot read the 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 22:04:03 -0000 >@@ -10,6 +10,9 @@ > *******************************************************************************/ > package org.eclipse.jdt.internal.compiler.problem; > >+import java.io.CharConversionException; >+import java.io.PrintWriter; >+import java.io.StringWriter; > import java.text.MessageFormat; > > import org.eclipse.jdt.core.compiler.CategorizedProblem; >@@ -815,6 +818,35 @@ > constructorCall.sourceStart, > constructorCall.sourceEnd); > } >+public void cannotReadSource(CompilationUnitDeclaration unit, AbortCompilationUnit abortException) { >+ String fileName = new String(unit.compilationResult.fileName); >+ if (abortException.exception instanceof CharConversionException) { >+ // specific encoding issue >+ String encoding = abortException.encoding; >+ if (encoding == null) { >+ encoding = System.getProperty("file.encoding"); //$NON-NLS-1$ >+ } >+ String[] arguments = new String[]{ fileName, encoding, }; >+ this.handle( >+ IProblem.InvalidEncoding, >+ arguments, >+ arguments, >+ 0, >+ 0); >+ return; >+ } >+ StringWriter stringWriter = new StringWriter(); >+ PrintWriter writer = new PrintWriter(stringWriter); >+ abortException.exception.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 22:03:57 -0000 >@@ -10,6 +10,8 @@ > *******************************************************************************/ > package org.eclipse.jdt.internal.compiler.problem; > >+import java.io.IOException; >+ > import org.eclipse.jdt.core.compiler.CategorizedProblem; > import org.eclipse.jdt.internal.compiler.CompilationResult; > >@@ -23,7 +25,17 @@ > > private static final long serialVersionUID = -4253893529982226734L; // backward compatible > >+ public String encoding; >+ > public AbortCompilationUnit(CompilationResult compilationResult, CategorizedProblem problem) { > super(compilationResult, problem); > } >+ >+/** >+ * Used to surface encoding issues when reading sources >+ */ >+public AbortCompilationUnit(CompilationResult compilationResult, IOException exception, String encoding) { >+ super(compilationResult, exception); >+ this.encoding = encoding; >+} > } >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 22:03:54 -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 abortException) { >+ this.problemReporter().cannotReadSource(this.compilationUnit, abortException); >+ 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 22:03:45 -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, this.encoding); > } >- return CharOperation.NO_CHAR; > } > /** > * @see org.eclipse.jdt.internal.compiler.env.IDependent#getFileName()
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 130980
:
35936
| 35938