| Summary: | CModelUtil.getSourceFolder returns non-source folders | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Product: | [Tools] CDT | Reporter: | Mohamed Hussein <mohamed_hussein> | ||||||||
| Component: | cdt-core | Assignee: | Nobody - feel free to take it <nobody> | ||||||||
| Status: | RESOLVED FIXED | QA Contact: | Doug Schaefer <cdtdoug> | ||||||||
| Severity: | normal | ||||||||||
| Priority: | P3 | CC: | marc.khouzam, nobody | ||||||||
| Version: | 7.0 | ||||||||||
| Target Milestone: | 8.1.0 | ||||||||||
| Hardware: | All | ||||||||||
| OS: | All | ||||||||||
| Whiteboard: | |||||||||||
| Attachments: |
|
||||||||||
The patch you've provided isn't in a format I can work with. It has to be generated from egit and in a format so I can Apply patch with it. Created attachment 199610 [details]
Patch to make getSourceFolder only returns source folders only
git format patch
Created attachment 201201 [details]
Modified patch.
Mohamed, I modified your patch a little bit. I'll commit it if my modifications are OK with you. (In reply to comment #4) > Mohamed, I modified your patch a little bit. I'll commit it if my modifications > are OK with you. Hi Mikhail, Your change performs the same function, so I am ok with using it instead of mine. Minor point: I understand you want to minimize the code changes, but I guess you can also move foundSourceRoot = (curr instanceof ISourceRoot); Inside the if condition and change it to =true (In reply to comment #5) > Minor point: > I understand you want to minimize the code changes, but I guess you can also > move > foundSourceRoot = (curr instanceof ISourceRoot); > Inside the if condition and change it to =true It's not my intention to minimize the code changes, I just want to simplify the old code. I don't think we need 'foundSourceRoot' flag, we can simply check 'curr instanceof ISourceRoot' directly in the while condition. Applied to the HEAD branch. *** cdt git genie on behalf of Mohamed Hussein ***
Bug 351422 - CModelUtil.getSourceFolder returns non-source folders.
[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=e0b1937020793057ce96ee45591a9c35d1fe8704
|
Created attachment 199245 [details] Patch to make getSourceFolder only returns source folders The method org.eclipse.cdt.internal.corext.util.CModelUtil.getSourceFolder(ICElement) will return the passed folder even if it is not a source folder. The Java doc of the method says: /** * Returns the source folder of <code>ICElement</code>. If the given * element is already a source folder, the element itself is returned. */ public static ICContainer getSourceFolder(ICElement element) { Though inside the method it allows returning the first folder using the check: if (curr instanceof ICContainer && folder == null) { folder = (ICContainer)curr; } Changing the condition to if (curr instanceof ISourceRoot) { ensures that the method always returns source folders only.