Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Use JDT Api in Java Project (not plug-in project)(Is it possible to use the JDT methods to get and modify an ICompilationUnit object without the project being an eclipse plug-in project.)
Use JDT Api in Java Project (not plug-in project) [message #836852] Wed, 04 April 2012 21:04 Go to next message
Eclipse UserFriend
My is to be able to
* take source code,
* add instructions to instrument the code for testing purposes, and
* compile and use the instrumented code at runtime.

From what I have been reading in the JDT Programmers Guide, it appears that JDT can do much of job. The problem I am running into at this point is how to create a usable instance of ICompilationUnit. Documentation includes example lines such as the following:
ICompilationUnit unit = ..; // get some compilation unit

From what I understand of the JavaModel structure, an ICompilationUnit is an element of the workspace hierarchy, but attempts to access that hierarchy such as the following seems fail.
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();


The answer I have found on the internet so far is that the project must be a plug-in project. Currently the project is not designed as a plug-in but as a standard Java Project.

So finally the question:
Is is possible to get, and/or create, an ICompilationUnit object, or other object useful for purpose, in a standard Java Project?



My level of expertise:
* General OO Programming: Solid understanding of basics
* Java Programming: Fairly inexperienced. More familiar with C#. Some experience with other other c-ish languages as well.
* Eclipse program structure, api, and plugins: Little to none.
Re: Use JDT Api in Java Project (not plug-in project) [message #837079 is a reply to message #836852] Thu, 05 April 2012 04:46 Go to previous messageGo to next message
Eclipse UserFriend
You cannot use ICompilationUnit in a standard Java project. It has to be an Eclipse Plugin.
Re: Use JDT Api in Java Project (not plug-in project) [message #837306 is a reply to message #836852] Thu, 05 April 2012 10:03 Go to previous message
Eclipse UserFriend
If you are wanting to inspect the AST of your source you could instead use org.eclipse.jdt.core.dom.CompilationUnit which you can create using an org.eclipse.jdt.core.dom.ASTParser

Satyam might have some links to better examples of doing this.
Previous Topic:Eclipse Start Up
Next Topic:link with editor package explorer background color
Goto Forum:
  


Current Time: Fri Jul 25 02:21:54 EDT 2025

Powered by FUDForum. Page generated in 0.04576 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top