Argus Codewatch consists of 5 projects:
Code checks are in arguscodewatch > src > net.sourceforge.arguscodewatch.builders.
Quick fixes are in net.sourceforge.arguscodewatch.quickfixes
net.sourceforge.arguscodewatch.exsd contains utility classes to handle plugin.xml.
In net.sourceforge.arguscodewatch.preferences, classes can be found that build the Argus Codewatch preference page.
Code checks extend CodewatchVisitor. This class can be found in arguscodewatch > src > net.sourceforge.arguscodewatch.
Quick fixes extend CodewatchCompletionProposal. It can also be found in net.sourceforge.arguscodewatch.
ArgusProjectBuilder.java in net.sourceforge.arguscodewatch.builders is defined as a builder in plugin.xml. This builder calls a method that runs Argus Codewatch code checks on the given resource:
At the moment of this writing, incremental is not used, so the resource is checked completely. Monitor might be null to hide the building process. As is done when checking code real-time.
Argus Codewatch uses a job that is scheduled with some delay when the resource is changed. Currently an IElementChangedListener is defined which attaches a IBufferChangedListener to the resource. The IElementChangedListener then calls the IBufferChangedListener.bufferChanged(BufferChangedEvent event) to activate the job once. (Then, the IBufferChangedListener takes over IElementChangedListener's task to start the job)
Actually, ResourceBufferListener implements IBufferChangedListener. In its constructor, it defines a job, sets a rule (a lock) and hides it by calling Job.setSystem(true). In bufferChanged() method, the job is cancelled if it was waiting and then rescheduled. This way, the job is always rescheduled any time the resource is changed. This means, that any time the user is modifying the resource, the job should wait some milliseconds. If a BufferChangedEvent is triggered because the resource is modified, this means the user is still typing code and thus modifying the resource, and therefore the job should not start, but should be rescheduled to start after some milliseconds.
When the Eclipse shuts down, a BufferChangedEvent is fired and calls indirectly ArgusProjectBuilder.checkResource(). More or less at the same time, CodewatchPlugin.stop() is called. It sets plugin to null. However code checks might need plugin. Therefore checkResource() should not execute the code checks if CodewatchPlugin.plugin is null. That's why CodewatchPlugin.plugin is locked when it is assigned null or is going to be accessed.
Note: read the Eclipse article "On the Job: The Eclipse Jobs API" for more information.