|modified abstract syntax tree needs to be reflected back to original source file [message #712761]
||Sun, 07 August 2011 14:12
Registered: August 2011
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
Caused by: java.lang.IllegalStateException: Workspace is closed.
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: Input2.java ---> input file to be parsed
ASTModifier.java --> main file to be executed
MyVisitor.java --- > to traverse the nodes of ast )
Powered by FUDForum
. Page generated in 0.01472 seconds