Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 338467

Summary: Codan calls "before" and "after" even for checkers that are not supposed to run in a launch mode
Product: [Tools] CDT Reporter: Alex Ruiz <alruiz>
Component: cdt-codanAssignee: Sergey Prigogin <eclipse.sprigogin>
Status: RESOLVED FIXED QA Contact: Elena Laskavaia <elaskavaia.cdt>
Severity: normal    
Priority: P3 CC: alruiz, cdtdoug, eclipse.sprigogin
Version: 8.0   
Target Milestone: 8.0   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Proposed patch
none
Improved version of patch submitted earlier eclipse.sprigogin: iplog+

Description Alex Ruiz CLA 2011-02-28 15:54:39 EST
Build Identifier: 20110204-0611

When processing an IResource (method processResource(IResource, IProgressMonitor, Object, CheckerLaunchMode)) CodanBuilder currently checks:
1. that the checker is enabled for a context (i.e. the IResource)
2. asks the CheckersRegistry if a checker is enabled for a launch mode

The problem is #2. This check only verifies that the IProblems a checker provides are enabled for a particular launch mode, without checking that the checker itself supports such launch mode.

For example, an IProblem may be enabled for "run in editor," but if the checker that defines return 'false' in "runWithEditor" or if the checker is not an instance of IRunnableEditorChecker, the checker should not be considered for processing the resource.

My use case is the following:
1. I have a custom Checker that is not supposed to "run in editor" (it does not implement IRunnableEditorChecker.
2. I enable the problems from my checker to "run in editor"
3. When I change a C++ file, my checker is not called, by the markers it provided the previous time are removed, because CodanBuilder called the checker's "before" and "after" methods.

The solution is to check first if the checker is enabled for a launch mode, and then check if the problems the checker defines are also enabled for a launch mode.

Reproducible: Always

Steps to Reproduce:
This is not possible to reproduce outside my environment, since my checker is tightly tied to proprietary infrastructure. I'm attaching a patch with a solution though.
Comment 1 Alex Ruiz CLA 2011-02-28 15:55:38 EST
Created attachment 189996 [details]
Proposed patch

Patch with a proposed solution.
Comment 2 Alex Ruiz CLA 2011-03-04 18:14:19 EST
Created attachment 190458 [details]
Improved version of patch submitted earlier

Removed double-check for launch mode support in checker. Renamed method "isCheckerEnabledForLaunchMode" to "checkerSupportsLaunchMode".
Comment 3 Sergey Prigogin CLA 2011-03-04 18:26:26 EST
Patch committed.
Comment 4 CDT Genie CLA 2011-03-04 19:23:08 EST
*** cdt cvs genie on behalf of sprigogin ***
Bug 338467 - Codan calls &quot;before&quot; and &quot;after&quot; even for checkers that are not supposed to run in a launch mode. Patch by Alex Ruiz.

[*] CodanBuilder.java 1.18 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodanBuilder.java?root=Tools_Project&r1=1.17&r2=1.18