| Which AST parse level should I be using? [message #268851] |
Thu, 26 August 2004 11:35  |
Eclipse User |
|
|
|
I know that I create a parse with the following code:
ASTParser p = ASTParser.newParser(AST.JLS3);
p.setSource(unit);
CompilationUnit u = (CompilationUnit) p.createAST(null);
This, of course, fails because 1.5 parsing is not yet supported. The
question is, how do I choose the correct parse level? Once 1.5 parsing is
supported, shouldn't there be a setting somewhere that allows me to NOT do
1.5 level compilation? Shouldn't I be getting the current parse level from a
more static location? Has that location already been implemented and I just
haven't found it? Is my code up above totally screwed?
Jim Adams
|
|
|
|
|
| Re: Which AST parse level should I be using? [message #269058 is a reply to message #269030] |
Fri, 27 August 2004 13:47   |
Eclipse User |
|
|
|
The code, as given, does not solve the problem. This still fails with an
exception because Java 1.5 is not supported. I am looking for something that
will allow my code to work even when 1.5 is supported. I have always heard
that you shouldn't use exceptions to handle code flow but it seems that that
is what I am being forced into.
"Jim Adams" <Jim.Adams@sas.com> wrote in message
news:cgnl07$9rj$1@eclipse.org...
> Does that allow for a fallback to level 2? Or do I really not even need to
> do the options.put()? Will I get whatever was set on the project? Isn't
that
> enough?
>
> "Olivier Thomann" <olivier_thomannNOSPAM@ca.ibm.com> wrote in message
> news:cgl101$96j$1@eclipse.org...
> > Jim Adams wrote:
> > > I know that I create a parse with the following code:
> > > ASTParser p = ASTParser.newParser(AST.JLS3);
> > > p.setSource(unit);
> > > CompilationUnit u = (CompilationUnit) p.createAST(null);
> > >
> > > This, of course, fails because 1.5 parsing is not yet supported. The
> > > question is, how do I choose the correct parse level? Once 1.5 parsing
> is
> > > supported, shouldn't there be a setting somewhere that allows me to
NOT
> do
> > > 1.5 level compilation? Shouldn't I be getting the current parse level
> from a
> > > more static location? Has that location already been implemented and I
> just
> > > haven't found it? Is my code up above totally screwed?
> > You should use setCompilerOptions(Map options) on the ASTParser.
> > You can do something like:
> > ASTParser astParser = ASTParser.newParser(AST.JLS3);
> > astParser.setSource(unit);
> > Map options = unit.getJavaProject().getOptions(true);
> > options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5);
> > options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM,
> > JavaCore.VERSION_1_5);
> > astParser.setCompilerOptions(options);
> > astParser.setResolveBindings(false);
> > CompilationUnit u = (CompilationUnit) astParser.createAST(null);
> >
> > HTH,
> > --
> > Olivier
>
>
|
|
|
|
|
| Re: Which AST parse level should I be using? [message #269304 is a reply to message #269100] |
Mon, 30 August 2004 15:15  |
Eclipse User |
|
|
|
Bug 72899 was added to address this issue.
"Olivier Thomann" <olivier_thomannNOSPAM@ca.ibm.com> wrote in message
news:cgoako$a3k$1@eclipse.org...
> Jim Adams wrote:
> > The code, as given, does not solve the problem. This still fails with an
> > exception because Java 1.5 is not supported. I am looking for something
that
> > will allow my code to work even when 1.5 is supported. I have always
heard
> > that you shouldn't use exceptions to handle code flow but it seems that
that
> > is what I am being forced into.
> Could you please create a bug report against JDT/Core with your test case?
> I am assuming that you are using one of the 3.1 integration build,
> otherwise it won't work for sure. Most of the 1.5 support is not
> included in 3.0.
> --
> Olivier
|
|
|
Powered by
FUDForum. Page generated in 0.05868 seconds