Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 353831 - LanguageManager.getLanguageForFile(IFile...) cannot handle EFS resources
Summary: LanguageManager.getLanguageForFile(IFile...) cannot handle EFS resources
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-core (show other bugs)
Version: 8.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 8.1.0   Edit
Assignee: Andrew Gvozdev CLA
QA Contact: Doug Schaefer CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-03 18:31 EDT by Andrew Gvozdev CLA
Modified: 2012-05-22 20:39 EDT (History)
0 users

See Also:


Attachments
suggested patch (1.37 KB, patch)
2011-08-03 18:56 EDT, Andrew Gvozdev CLA
cdtdoug: iplog-
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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