Skip to main content


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 :

http://www.eclipse.org/articles/article.php?file=Article-JavaCodeManipulation_AST/index.html

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(ASTModifier.java:205)
Caused by: java.lang.IllegalStateException: Workspace is closed.
at org.eclipse.core.resources.ResourcesPlugin.getWorkspace(ResourcesPlugin.java:340)


Article doesn't say much about other things, but I got a link online:
http://www.programcreek.com/2011/05/java-lang-illegalstateexception-workspace-is-closed/#comment-1939

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.



thanks.
(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 )

Thanks again

Regards
sagar
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: Tue Apr 16 16:07:16 GMT 2024

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

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

Back to the top