Bug 93948 - [DOM] Eclipse compiler dependencies
Summary: [DOM] Eclipse compiler dependencies
Status: RESOLVED DUPLICATE of bug 87852
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC All
: P3 major (vote)
Target Milestone: 3.2 M6   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-05-06 12:24 EDT by Eugene Kuleshov CLA
Modified: 2006-03-13 12:07 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eugene Kuleshov CLA 2005-05-06 12:24:48 EDT
In 3.0, Eclipse compiler that could be called from an Ant task had no
dependencies on other Eclipse plugins. It was enough to have only 
org.eclipse.jdt.core plugin in a classpath.

I've tried to run the following snippet on the latest 3.1 build

  ASTParser parser = ASTParser.newParser( AST.JLS3);
  parser.setKind(ASTParser.K_COMPILATION_UNIT);
  parser.setSource( source.toCharArray());
  CompilationUnit node = (CompilationUnit) parser.createAST(null);  

and it require at least following plugins and still does not work.

org.eclipse.core.resources_3.1.0.jar
org.eclipse.core.runtime_3.1.0.jar
org.eclipse.osgi_3.1.0.jar

Note that Eclipse compiler is being used for Tomkat and all those dependency may
became a big issue.

I believe that compiler should be better isolated from an Eclipse core.
Comment 1 Philipe Mulet CLA 2005-05-06 15:41:34 EDT
This isn't the compiler, but rather the DOM AST API which isn't meant to be
separated from Eclipse platform.

The batch compiler is and will remain extractible for other to use outside of
Eclipse. 
Comment 2 Eugene Kuleshov CLA 2005-05-06 15:44:29 EDT
Hmm, is there are way to use Eclipse AST outside platform? 

There are number of projects that may benefit from this. For example dynamic
scripting, batch code analysis and transformation, etc.
Comment 3 Philipe Mulet CLA 2005-05-09 05:09:33 EDT
No, the DOM AST is currently Eclipse-based. Note that you can use Eclipse in a
batch mode (headless), so there shouldn't be any problem in using the DOM AST as
you want to.
Comment 4 Eugene Kuleshov CLA 2005-05-09 11:20:02 EDT
Philippe, the big problem with headless Eclipse is that it will require the
entire platform runtime, which is huge, comparing to just jdt.core plugin.
Comment 5 Philipe Mulet CLA 2005-05-09 15:41:53 EDT
Well, we are talking only about 12-13 extra plugins, and most of them are pretty
small. 

Definitely not for 3.1
Comment 6 Eugene Kuleshov CLA 2005-09-25 16:08:59 EDT
Philippe, is it possible to resolve this in 3.2?
Comment 7 Martin Smolny CLA 2006-03-08 13:52:19 EST
I also need a resolution for this issue. In particular, I need to use AST
independent from a running Eclipse platform.

As it looks to me, the whole AST is independent from a running Eclipse platform - except for the call to JavaCore.getOptions() in ASTParser; this introduces the dependency.

What about the following idea:
in class org.eclipse.jdt.core.dom.ASTParser

instead:
    this.compilerOptions = JavaCore.getOptions();
just use
    if (InternalPlatform.isRunning()) {
        this.compilerOptions = JavaCore.getOptions();
    } else {
        this.compilerOptions = new HashMap();
    }
This is needed in two places (initializeDefaults() and setCompilerOptions()).

This fix does not change the current behaviour for Eclipse,
but enables also non-Eclipse environments to work with the
powerful AST parser (again).
As this fix is really easy and low risk, a fix also in 3.1 would be great.
Comment 8 Olivier Thomann CLA 2006-03-08 13:56:44 EST
this.compilerOptions = new HashMap(); should better be a good default.
If an empty map is provided, I doubt that you will get the expected result. So I would better work on some default map that would match the existing default.

But I agree that changing this should not affect a running Eclipse instance and we should target 3.2.
Comment 9 Eugene Kuleshov CLA 2006-03-08 13:59:27 EST
(In reply to comment #8)
> this.compilerOptions = new HashMap(); should better be a good default.
> If an empty map is provided, I doubt that you will get the expected result. So
> I would better work on some default map that would match the existing default.

Ideally it would be handy to have some pluggable options provider, so platform would hook up existing JavaCore.getOptions() and external tool could use their own mechanisms. But defaults will do for a short term...
Comment 10 Martin Smolny CLA 2006-03-08 14:04:26 EST
> Ideally it would be handy to have some pluggable options provider, so platform
> would hook up existing JavaCore.getOptions() and external tool could use their
> own mechanisms. But defaults will do for a short term...

I'm not sure if we make it too pluggable here. Any platform or exploiter may set its options by ASTParser.setCompilerOptions() to whatever it like; this should be enough configurability. Therefore, I could also accept the empty HashMap as default (for my code, this patch worked), but a specific default map is also good for me.
Comment 11 Eugene Kuleshov CLA 2006-03-08 14:27:35 EST
(In reply to comment #10)
> I'm not sure if we make it too pluggable here. Any platform or exploiter may
> set its options by ASTParser.setCompilerOptions() to whatever it like; this
> should be enough configurability. Therefore, I could also accept the empty
> HashMap as default (for my code, this patch worked), but a specific default map
> is also good for me.

I am not very familiar with the code, so I am wondering why platform/jdt can't initialize ASTParser.setCompilerOptions() externally then?
Comment 12 Philipe Mulet CLA 2006-03-09 04:13:30 EST
Changing existing behavior may break some clients; so I would rather only consider supporting cases the platform is not running, and then rely on client to specify its options using #setCompilerOptions(...).

One other piece of missing information when no project is available is: no classpath. Shouldn't we also have a #setClasspath(...) likewise ?
This would allow to resolve bindings, and we could restrain classpath to simple explicit folders or libraries. But maybe this is more than what is needed currently, and could be addressed beyond 3.2, as we froze our API already (M5).

Tagging for 3.2M6, as there seems to be some consensus ahead.
Comment 13 Olivier Thomann CLA 2006-03-09 10:59:10 EST

*** This bug has been marked as a duplicate of 87852 ***
Comment 14 Olivier Thomann CLA 2006-03-09 20:07:58 EST
This will allow the AST to be created, but no binding will be available.
Is this ok?
Comment 15 Philipe Mulet CLA 2006-03-10 03:46:14 EST
If bindings are required, then another bug should be filled. This bug is about providing equivalent functionality as in 3.0, which is AST no binding.
Comment 16 Martin Smolny CLA 2006-03-10 04:30:10 EST
(In reply to comment #15)
> If bindings are required, then another bug should be filled. This bug is about
> providing equivalent functionality as in 3.0, which is AST no binding.
> 
That's also my opinion.
Comment 17 Olivier Thomann CLA 2006-03-13 11:50:14 EST
(In reply to comment #7) 
> As it looks to me, the whole AST is independent from a running Eclipse platform
> - except for the call to JavaCore.getOptions() in ASTParser; this introduces
> the dependency.
I prefer to put the patch inside JavaCore.getOptions().

>     if (InternalPlatform.isRunning()) {
>         this.compilerOptions = JavaCore.getOptions();
>     } else {
>         this.compilerOptions = new HashMap();
>     }
InternalPlatform cannot be used since it is internal.
I would say we either check getPlugin() == null or:
Platform.isRunning()

Would you test it if I release that change for tomorrow's integration build?
Comment 18 Martin Smolny CLA 2006-03-13 12:07:46 EST
(In reply to comment #17)
> InternalPlatform cannot be used since it is internal.
> I would say we either check getPlugin() == null or:
> Platform.isRunning()
> 
> Would you test it if I release that change for tomorrow's integration build?
> 
Yes, I'll test it. Thanks.