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

Bug 353831

Summary: LanguageManager.getLanguageForFile(IFile...) cannot handle EFS resources
Product: [Tools] CDT Reporter: Andrew Gvozdev <angvoz.dev>
Component: cdt-coreAssignee: Andrew Gvozdev <angvoz.dev>
Status: RESOLVED FIXED QA Contact: Doug Schaefer <cdtdoug>
Severity: normal    
Priority: P3    
Version: 8.0   
Target Milestone: 8.1.0   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
suggested patch cdtdoug: iplog-

Description Andrew Gvozdev CLA 2011-08-03 18:31:51 EDT
LanguageManager.getLanguageForFile(IFile file...) assumes resources on local filesystem and cannot handle EFS resources due to code

  IContentType contentType= CContentTypes.getContentType(project, file.getLocation().toString());

That causes NPE as file.getLocation() returns null for EFS resources.
Comment 1 Andrew Gvozdev CLA 2011-08-03 18:56:21 EDT
Created attachment 200864 [details]
suggested patch

I am unsure which way to fix the issue is the correct one. Being not too much experienced in intricacies of determining languages or content types it feels that the attached patch is the "safest" one. Or should I just use file.getName() for filename?

Maybe there is a better way to figure out language ID for IFile? I've looked but haven't found one.
Comment 2 Andrew Gvozdev CLA 2011-08-08 15:23:06 EDT
OK, nobody objects. Committed on master.
Comment 3 CDT Genie CLA 2011-08-08 16:23:01 EDT
*** cdt git genie on behalf of Andrew Gvozdev ***

    bug 353831: LanguageManager.getLanguageForFile(IFile...) cannot handle
    EFS resources

[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=be1435ad0aa79768bb03030a333084bed1ea2929