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 108853 Details for
Bug 242292
call to createAST(..) throws IllegalStateException when parser source is not char[]
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed fix
patch_242292.txt (text/plain), 5.01 KB, created by
Olivier Thomann
on 2008-07-31 10:25:56 EDT
(
hide
)
Description:
Proposed fix
Filename:
MIME Type:
Creator:
Olivier Thomann
Created:
2008-07-31 10:25:56 EDT
Size:
5.01 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: dom/org/eclipse/jdt/core/dom/ASTParser.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTParser.java,v >retrieving revision 1.82 >diff -u -r1.82 ASTParser.java >--- dom/org/eclipse/jdt/core/dom/ASTParser.java 27 Jun 2008 16:03:46 -0000 1.82 >+++ dom/org/eclipse/jdt/core/dom/ASTParser.java 31 Jul 2008 13:50:43 -0000 >@@ -538,7 +538,7 @@ > * > * @param offset the index of the first character to parse > * @param length the number of characters to parse, or -1 if >- * the remainder of the source string is >+ * the remainder of the source string is to be parsed > */ > public void setSourceRange(int offset, int length) { > if (offset < 0 || length < -1) { >@@ -745,22 +745,22 @@ > } > > /** >- * Creates bindings for a batch of Java elements. These elements are either >- * enclosed in {@link ICompilationUnit}s or in {@link IClassFile}s. >- * <p> >- * All enclosing compilation units and class files must >- * come from the same Java project, which must be set beforehand >- * with <code>setProject</code>. >- * </p> >- * <p> >- * All elements must exist. If one doesn't exist, an <code>IllegalStateException</code> >- * is thrown. >- * </p> >- * <p> >- * The returned array has the same size as the given elements array. At a given position >- * it contains the binding of the corresponding Java element, or <code>null</code> >- * if no binding could be created. >- * </p> >+ * Creates bindings for a batch of Java elements. These elements are either >+ * enclosed in {@link ICompilationUnit}s or in {@link IClassFile}s. >+ * <p> >+ * All enclosing compilation units and class files must >+ * come from the same Java project, which must be set beforehand >+ * with <code>setProject</code>. >+ * </p> >+ * <p> >+ * All elements must exist. If one doesn't exist, an <code>IllegalStateException</code> >+ * is thrown. >+ * </p> >+ * <p> >+ * The returned array has the same size as the given elements array. At a given position >+ * it contains the binding of the corresponding Java element, or <code>null</code> >+ * if no binding could be created. >+ * </p> > * <p> > * Note also the following parser parameters are used, regardless of what > * may have been specified: >@@ -771,18 +771,18 @@ > * <li>The {@linkplain #setFocalPosition(int) focal position} is not set</li> > * </ul> > * </p> >- * <p> >- * A successful call to this method returns all settings to their >- * default values so the object is ready to be reused. >- * </p> >- * >- * @param elements the Java elements to create bindings for >- * @return the bindings for the given Java elements, possibly containing <code>null</code>s >- * if some bindings could not be created >+ * <p> >+ * A successful call to this method returns all settings to their >+ * default values so the object is ready to be reused. >+ * </p> >+ * >+ * @param elements the Java elements to create bindings for >+ * @return the bindings for the given Java elements, possibly containing <code>null</code>s >+ * if some bindings could not be created > * @exception IllegalStateException if the settings provided > * are insufficient, contradictory, or otherwise unsupported > * @since 3.1 >- */ >+ */ > public IBinding[] createBindings(IJavaElement[] elements, IProgressMonitor monitor) { > try { > if (this.project == null) >@@ -803,9 +803,36 @@ > case K_CLASS_BODY_DECLARATIONS : > case K_EXPRESSION : > case K_STATEMENTS : >+ if (this.rawSource == null) { >+ if (this.typeRoot != null) { >+ // get the source from the type root >+ if (this.typeRoot instanceof ICompilationUnit) { >+ org.eclipse.jdt.internal.compiler.env.ICompilationUnit sourceUnit = (org.eclipse.jdt.internal.compiler.env.ICompilationUnit) this.typeRoot; >+ this.rawSource = sourceUnit.getContents(); >+ } else if (this.typeRoot instanceof IClassFile) { >+ try { >+ String sourceString = this.typeRoot.getSource(); >+ if (sourceString != null) { >+ this.rawSource = sourceString.toCharArray(); >+ } >+ } catch(JavaModelException e) { >+ // an error occured accessing the java element >+ StringWriter stringWriter = new StringWriter(); >+ PrintWriter writer = null; >+ try { >+ writer = new PrintWriter(stringWriter); >+ e.printStackTrace(writer); >+ } finally { >+ if (writer != null) writer.close(); >+ } >+ throw new IllegalStateException(String.valueOf(stringWriter.getBuffer())); >+ } >+ } >+ } >+ } > if (this.rawSource != null) { > if (this.sourceOffset + this.sourceLength > this.rawSource.length) { >- throw new IllegalStateException(); >+ throw new IllegalStateException(); > } > return internalCreateASTForKind(); > }
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 242292
: 108853