Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » How to listen to a compilation error as soon as it happens
How to listen to a compilation error as soon as it happens [message #825644] Wed, 21 March 2012 00:20 Go to next message
Sukanya Ratanotayanon is currently offline Sukanya Ratanotayanon
Messages: 3
Registered: March 2012
Junior Member
Hi, I would like to ask whether there is an event that I can listen to so that I know that a compilation occur. I'd tried listening to the marker change event but I will get the notification only after a user save the file. I saw that in Java editor, it can show quickfix and do the underlying as soon as the error occur. So this must be possible. I'd appreciate any suggestions.

Thanks a lot.
Re: How to listen to a compilation error as soon as it happens [message #825791 is a reply to message #825644] Wed, 21 March 2012 05:08 Go to previous messageGo to next message
Satyam Kandula is currently offline Satyam Kandula
Messages: 444
Registered: July 2009
Senior Member
There is a reconcile operation that happens while somebody works on the editor without saving. One can add themselves as a CompilationParticipant and override reconcile to get called during the reconcile. In this function you could get hold to the AST of the program which will have the problems set.
Re: How to listen to a compilation error as soon as it happens [message #826667 is a reply to message #825791] Thu, 22 March 2012 07:07 Go to previous messageGo to next message
Sukanya Ratanotayanon is currently offline Sukanya Ratanotayanon
Messages: 3
Registered: March 2012
Junior Member
Hi Satyam,

Thank you very much for your reply. I have tried extending the compilationParticipant extension point. I created a listener that extends the CompilationParticipant class and override reconcile method as you suggested. However, the reconcile method in my listener has never been called. Do you have any idea what might be the problem? My extension point is as below. In my reconcile method, I just do the System.out.println so that I know that it is called.

<extension
id="testlistener"
name="CompilerListener"
point="org.eclipse.jdt.core.compilationParticipant">
<compilationParticipant
class="test.views.CompileListener"
id="testlistener"
modifiesEnvironment="true">
</compilationParticipant>
</extension>
Re: How to listen to a compilation error as soon as it happens [message #826709 is a reply to message #826667] Thu, 22 March 2012 08:07 Go to previous message
Sukanya Ratanotayanon is currently offline Sukanya Ratanotayanon
Messages: 3
Registered: March 2012
Junior Member
Never mind my last post. I did not know that I have to override isActive to return true for the project that I want to listen. Now it works fine.

Thank you very much.
Previous Topic:Upgrading from JAVA 6 to 7
Next Topic:Deleted.
Goto Forum:
  


Current Time: Thu Aug 28 01:37:39 EDT 2014

Powered by FUDForum. Page generated in 0.02298 seconds