Summary: | ASTParser fails on enums when setSource(char[] source) is used | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | David Schuler <schulerdavid> | ||||||||
Component: | Core | Assignee: | Olivier Thomann <Olivier_Thomann> | ||||||||
Status: | VERIFIED FIXED | QA Contact: | |||||||||
Severity: | normal | ||||||||||
Priority: | P3 | CC: | markus.kell.r, Olivier_Thomann | ||||||||
Version: | 3.6 | Keywords: | Documentation | ||||||||
Target Milestone: | 3.6 RC4 | ||||||||||
Hardware: | Macintosh | ||||||||||
OS: | Mac OS X - Carbon (unsup.) | ||||||||||
Whiteboard: | |||||||||||
Attachments: |
|
Description
David Schuler
2010-05-28 05:43:50 EDT
Created attachment 170322 [details]
JUnit test to reproduce the error.
It is clearly explained in the ASTParser documentation that compiler options are set to the JavaCore.getOptions() value if setSource(char[]) is used. Therefore you need to explicitly set the compiler options in order to parse the source. The default values are clearly explain in the JavaCore class. Closing as INVALID. You are right. It is documented. What led me to the impression that it is a bug, was that I followed the code snippet in the Javadoc of the class. I thought that that this code is sufficient to parse Java Code that uses 1.5 features. In addition the constant JLS3 reinforced this impression. When I used the parser it even handled foreach loops correctly (producing error messages though as I found out later). When I stumbled across the enums, it took me quite some time to figure out the reason for the failure. To save others from this pitfall, maybe the code snippet could be updated, or it could be mentioned explicitly in the Javadocs of setSource(char[]) that the default source (1.3) will be used. (In reply to comment #3) > To save others from this pitfall, maybe the code snippet could be updated, or > it could be mentioned explicitly in the Javadocs of setSource(char[]) that the > default source (1.3) will be used. Good suggestion. Will do. Thanks. Created attachment 170559 [details]
Proposed doc change
Let me know if this clarifies the problem you had.
I also updated the documentation of the setSource(char[]) method. Yes, this clarifies the problem. Thanks. Verified for 3.6RC3 Created attachment 170625 [details]
refer to JavaCore#setComplianceOptions(..)
The advice in the Javadocs of ASTParser and setSource(char[]) is quite lengthy and only mentions some of the compliance options. It would be better to replace this with a reference to JavaCore#setComplianceOptions(String, Map).
The patch also fixes two other typos.
. Thanks Markus. Released for RC4. |