Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » modified abstract syntax tree needs to be reflected back to original source file(Exception is generated while using FileBuffere.getTextFileBufferManagar() method. )
modified abstract syntax tree needs to be reflected back to original source file [message #712761] Sun, 07 August 2011 18:12
sagar  is currently offline sagar Friend
Messages: 12
Registered: August 2011
Junior Member
I am parsing a source java file which has methods with contracts writting using COFOJA.
I am creating abstract syntax tree of source file, then I modify the method code using JDT, and ASTRewrite. I can see the changes being made in the Document document object. But when I try to reflect these changes back to the original source file, as per the instructions in the article I get exception. Article link :

Kindly refer "Write it down" section. It says
ITextFileBufferManager bufferManager = FileBuffers.getTextFileBufferManager(); // get the buffer manager

Above declaration throws the exception in my case.

Exception in thread "main" java.lang.ExceptionInInitializerError
at ASTModifier.main(
Caused by: java.lang.IllegalStateException: Workspace is closed.
at org.eclipse.core.resources.ResourcesPlugin.getWorkspace(

Article doesn't say much about other things, but I got a link online:

It says: "In brief, this is caused by simply adding dependent jar files to regular java project.
To use JDT, you need to have the program running as a plug-in (or at least, an OSGi-enabled application) rather than using it as a jar. "

Now, I am using JDT, and doing everything in simple project. As per the above link, Do i need to create plugin to make FileBuffer declaration work and to get rid off the exception?

Sorry for a big message. To explain it properly , I had to write all the things.

(Source file attached: ---> input file to be parsed --> main file to be executed --- > to traverse the nodes of ast )

Thanks again

Previous Topic:Is eclipse.ini the only place where jdk for Eclipse itself is specified?
Next Topic:swing app in intranet
Goto Forum:

Current Time: Sun Apr 22 22:06:27 GMT 2018

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

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