mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fix C model corruption by resource to items mapping
This commit is contained in:
parent
2a14adcbbc
commit
d65887df09
1 changed files with 7 additions and 10 deletions
|
@ -186,18 +186,15 @@ public class ResourceToItemsMapper {
|
|||
private static IResource getCorrespondingResource(Object element) {
|
||||
if (element instanceof ICElement) {
|
||||
ICElement elem= (ICElement) element;
|
||||
if (elem.exists()) {
|
||||
IResource res= elem.getResource();
|
||||
if (res == null) {
|
||||
ITranslationUnit cu= (ITranslationUnit) elem.getAncestor(ICElement.C_UNIT);
|
||||
if (cu != null) {
|
||||
// elements in compilation units are mapped to the underlying resource of the original cu
|
||||
res= cu.getResource();
|
||||
}
|
||||
IResource res= elem.getResource();
|
||||
if (res == null) {
|
||||
ITranslationUnit cu= (ITranslationUnit) elem.getAncestor(ICElement.C_UNIT);
|
||||
if (cu != null) {
|
||||
// elements in compilation units are mapped to the underlying resource of the original cu
|
||||
res= cu.getResource();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
return null;
|
||||
return res;
|
||||
} else if (element instanceof IResource) {
|
||||
return (IResource) element;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue