diff --git a/core/org.eclipse.cdt.core/ChangeLog b/core/org.eclipse.cdt.core/ChangeLog index b60b3de45e9..ff2f6d35753 100644 --- a/core/org.eclipse.cdt.core/ChangeLog +++ b/core/org.eclipse.cdt.core/ChangeLog @@ -1,3 +1,12 @@ +2004-06-11 Alain Magloire + + The IncludeEntry LibraryEntry getFullIncludePath() + was returning the wrong values sometimes. + + * model/org/eclipse/cdt/internal/core/model/IncludeEntry.java + * model/org/eclipse/cdt/internal/core/model/LibraryEntry.java + * model/org/eclipse/cdt/internal/core/model/PathEntryManager.java + 2004-06-10 Hoda Amer Fix for PR 65970: [Outline View] Contents of Includes displayed in Outline for STRUCTURAL_PARSE mode diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IncludeEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IncludeEntry.java index c49735c6228..f9bc7594935 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IncludeEntry.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IncludeEntry.java @@ -83,16 +83,33 @@ public class IncludeEntry extends APathEntry implements IIncludeEntry { * @see org.eclipse.cdt.core.model.IIncludeEntry#getFullIncludePath() */ public IPath getFullIncludePath() { - IPath p = (!basePath.isEmpty()) ? basePath.append(includePath) : includePath; - if (p.isAbsolute()) { + IPath p; + IPath inc = getIncludePath(); + if (!basePath.isEmpty()) { + IPath loc = basePath; + if (!loc.isAbsolute()) { + IResource res = ResourcesPlugin.getWorkspace().getRoot().findMember(loc); + if (res != null) { + loc = res.getLocation(); + } + } + p = loc.append(inc); return p; } - IPath resPath = getPath(); - IResource res = ResourcesPlugin.getWorkspace().getRoot().findMember(resPath); - if (res != null) { - IPath location = res.getLocation(); - if (location != null) { - p = location.append(p); + + p = inc; + + if (!p.isAbsolute()) { + IPath resPath = getPath(); + IResource res = ResourcesPlugin.getWorkspace().getRoot().findMember(resPath); + if (res != null) { + if (res.getType() == IResource.FILE) { + res = res.getParent(); + } + IPath location = res.getLocation(); + if (location != null) { + p = location.append(p); + } } } return p; diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/LibraryEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/LibraryEntry.java index 7672b75f3b3..bd3d4a3c6ec 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/LibraryEntry.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/LibraryEntry.java @@ -134,21 +134,35 @@ public class LibraryEntry extends APathEntry implements ILibraryEntry { } public IPath getFullLibraryPath() { + IPath p; IPath lib = getLibraryPath(); - IPath p = (!basePath.isEmpty()) ? basePath.append(lib) : lib; - if (p.isAbsolute()) { + if (!basePath.isEmpty()) { + IPath loc = basePath; + if (!loc.isAbsolute()) { + IResource res = ResourcesPlugin.getWorkspace().getRoot().findMember(loc); + if (res != null) { + loc = res.getLocation(); + } + } + p = loc.append(lib); return p; + } else { + p = lib; } - IPath resPath = getPath(); - IResource res = ResourcesPlugin.getWorkspace().getRoot().findMember(resPath); - if (res != null) { - IPath location = res.getLocation(); - if (location != null) { - p = location.append(p); + if (!p.isAbsolute()) { + IPath resPath = getPath(); + IResource res = ResourcesPlugin.getWorkspace().getRoot().findMember(resPath); + if (res != null) { + if (res.getType() == IResource.FILE) { + res = res.getParent(); + } + IPath location = res.getLocation(); + if (location != null) { + p = location.append(p); + } } } return p; - } /* (non-Javadoc) diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryManager.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryManager.java index 95daa4a38e5..51f9c06d80c 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryManager.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryManager.java @@ -223,11 +223,19 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange if (refEntry.getIncludePath().equals(includePath)) { IPath newBasePath = refEntry.getBasePath(); // If the includePath is relative give a new basepath if none - if (newBasePath.isEmpty() && !includePath.isAbsolute()) { - IPath refResPath = refEntry.getPath(); - IResource refRes = cproject.getCModel().getWorkspace().getRoot().findMember(refResPath); + if (!newBasePath.isAbsolute() && !includePath.isAbsolute()) { + IResource refRes; + if (!newBasePath.isEmpty()) { + refRes = cproject.getCModel().getWorkspace().getRoot().findMember(newBasePath); + } else { + IPath refResPath = refEntry.getPath(); + refRes = cproject.getCModel().getWorkspace().getRoot().findMember(refResPath); + } if (refRes != null) { - newBasePath = refRes.getLocation(); + if (refRes.getType() == IResource.FILE) { + refRes = refRes.getParent(); + } + newBasePath = refRes.getLocation().append(newBasePath); } } return CoreModel.newIncludeEntry(includeEntry.getPath(), @@ -320,11 +328,19 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange if (refEntry.getLibraryPath().equals(libraryPath)) { IPath newBasePath = refEntry.getBasePath(); // If the libraryPath is relative give a new basepath if none - if (newBasePath.isEmpty() && !libraryPath.isAbsolute()) { - IPath refResPath = refEntry.getPath(); - IResource refRes = cproject.getCModel().getWorkspace().getRoot().findMember(refResPath); + if (!newBasePath.isAbsolute() && !libraryPath.isAbsolute()) { + IResource refRes; + if (!newBasePath.isEmpty()) { + refRes = cproject.getCModel().getWorkspace().getRoot().findMember(newBasePath); + } else { + IPath refResPath = refEntry.getPath(); + refRes = cproject.getCModel().getWorkspace().getRoot().findMember(refResPath); + } if (refRes != null) { - newBasePath = refRes.getLocation(); + if (refRes.getType() == IResource.FILE) { + refRes = refRes.getParent(); + } + newBasePath = refRes.getLocation().append(newBasePath); } }