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

Bug 338349

Summary: CodanCReconciler does not find resources consistenly
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, jamesblackburn+eclipse
Version: 8.0   
Target Milestone: 8.0   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Proposed patch eclipse.sprigogin: iplog-

Description Alex Ruiz CLA 2011-02-27 14:23:46 EST
Build Identifier: 20110204-0611

org.eclipse.cdt.codan.internal.ui.cxx.CodanCReconciler uses org.eclipse.core.resources.IWorkspaceRoot to find an IResource from a java.net.URI. It works for normal file systems, but not for the customized file system we use. The problem is that Codan does not run checkers in "run in editor" mode in our projects.

The solution is to use org.eclipse.cdt.internal.core.resources.ResourceLookup#findFilesForLocationURI(URI) instead. I have tested it with regular projects and our own and it works.

Reproducible: Always

Steps to Reproduce:
It is not possible to reproduce this bug outside my workplace, because of the customizations of our development environment.
Comment 1 Alex Ruiz CLA 2011-02-28 12:28:41 EST
Created attachment 189970 [details]
Proposed patch

Patch with the proposed solution.
Comment 2 James Blackburn CLA 2011-02-28 12:40:35 EST
> String filePath = ast.getFilePath();
> URI uri = new File(filePath).toURI();
> IFile[] resources = ResourceLookup.findFilesForLocationURI(uri);

That still looks weird. How does this cope with non-file URI paths? Does this stuff support generic EFS resources at all?
Comment 3 Alex Ruiz CLA 2011-02-28 19:05:24 EST
Probably Alena is the best to answer this question :)

AFAIK, codan only works with files (at least that is the default behavior in IChecker#enabledInContext(IResource)


(In reply to comment #2)
> > String filePath = ast.getFilePath();
> > URI uri = new File(filePath).toURI();
> > IFile[] resources = ResourceLookup.findFilesForLocationURI(uri);
> 
> That still looks weird. How does this cope with non-file URI paths? Does this
> stuff support generic EFS resources at all?
Comment 4 Sergey Prigogin CLA 2011-03-25 17:49:45 EDT
Fixed in HEAD > 20110325.