diff --git a/core/org.eclipse.cdt.core/ChangeLog b/core/org.eclipse.cdt.core/ChangeLog index c3f37671f50..300a39b85de 100644 --- a/core/org.eclipse.cdt.core/ChangeLog +++ b/core/org.eclipse.cdt.core/ChangeLog @@ -1,3 +1,11 @@ +2004-06-07 Alain Magloire + + Fix for PR 65633 + * model/org/eclipse/cdt/internal/core/model/CProject.java + * 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-07 Hoda Amer Fix for PR 65369 : [CModel] Duplicate namespace declarations in views when namespace defined twice in a file diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CProject.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CProject.java index 8141349c693..7a47c7ae283 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CProject.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CProject.java @@ -134,37 +134,60 @@ public class CProject extends Openable implements ICProject { } public IIncludeReference[] getIncludeReferences() throws CModelException { - IPathEntry[] entries = getResolvedPathEntries(); - ArrayList list = new ArrayList(entries.length); - for (int i = 0; i < entries.length; i++) { - if (entries[i].getEntryKind() == IPathEntry.CDT_INCLUDE) { - IIncludeEntry entry = (IIncludeEntry) entries[i]; - IIncludeReference inc = new IncludeReference(this, entry); - if (inc != null) { - list.add(inc); + CProjectInfo pinfo = (CProjectInfo)CModelManager.getDefault().peekAtInfo(this); + IIncludeReference[] incRefs = null; + if (pinfo != null) { + incRefs = pinfo.incReferences; + } + if (incRefs == null) { + IPathEntry[] entries = getResolvedPathEntries(); + ArrayList list = new ArrayList(entries.length); + for (int i = 0; i < entries.length; i++) { + if (entries[i].getEntryKind() == IPathEntry.CDT_INCLUDE) { + IIncludeEntry entry = (IIncludeEntry) entries[i]; + IIncludeReference inc = new IncludeReference(this, entry); + if (inc != null) { + list.add(inc); + } } } + incRefs = (IIncludeReference[]) list.toArray(new IIncludeReference[0]); + if (pinfo != null) { + pinfo.incReferences = incRefs; + } } - return (IIncludeReference[]) list.toArray(new IIncludeReference[0]); + return incRefs; } public ILibraryReference[] getLibraryReferences() throws CModelException { - BinaryParserConfig[] binConfigs = CModelManager.getDefault().getBinaryParser(getProject()); - IPathEntry[] entries = getResolvedPathEntries(); - ArrayList list = new ArrayList(entries.length); - for (int i = 0; i < entries.length; i++) { - if (entries[i].getEntryKind() == IPathEntry.CDT_LIBRARY) { - ILibraryEntry entry = (ILibraryEntry) entries[i]; - ILibraryReference lib = getLibraryReference(this, binConfigs, entry); - if (lib != null) { - list.add(lib); + CProjectInfo pinfo = (CProjectInfo)CModelManager.getDefault().peekAtInfo(this); + ILibraryReference[] libRefs = null; + if (pinfo != null) { + libRefs = pinfo.libReferences; + } + + if (libRefs == null) { + BinaryParserConfig[] binConfigs = CModelManager.getDefault().getBinaryParser(getProject()); + IPathEntry[] entries = getResolvedPathEntries(); + ArrayList list = new ArrayList(entries.length); + for (int i = 0; i < entries.length; i++) { + if (entries[i].getEntryKind() == IPathEntry.CDT_LIBRARY) { + ILibraryEntry entry = (ILibraryEntry) entries[i]; + ILibraryReference lib = getLibraryReference(this, binConfigs, entry); + if (lib != null) { + list.add(lib); + } } } + libRefs = (ILibraryReference[]) list.toArray(new ILibraryReference[0]); + if (pinfo != null) { + pinfo.libReferences = libRefs; + } } - return (ILibraryReference[]) list.toArray(new ILibraryReference[0]); + return libRefs; } - public static ILibraryReference getLibraryReference(ICProject cproject, BinaryParserConfig[] binConfigs, ILibraryEntry entry) { + private static ILibraryReference getLibraryReference(ICProject cproject, BinaryParserConfig[] binConfigs, ILibraryEntry entry) { if (binConfigs == null) { binConfigs = CModelManager.getDefault().getBinaryParser(cproject.getProject()); } 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 b1e6247a776..c49735c6228 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 @@ -87,11 +87,12 @@ public class IncludeEntry extends APathEntry implements IIncludeEntry { if (p.isAbsolute()) { return p; } - IResource res = ResourcesPlugin.getWorkspace().getRoot().findMember(p); + IPath resPath = getPath(); + IResource res = ResourcesPlugin.getWorkspace().getRoot().findMember(resPath); if (res != null) { IPath location = res.getLocation(); if (location != null) { - return location; + 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 9e34570794a..7672b75f3b3 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 @@ -139,11 +139,12 @@ public class LibraryEntry extends APathEntry implements ILibraryEntry { if (p.isAbsolute()) { return p; } - IResource res = ResourcesPlugin.getWorkspace().getRoot().findMember(p); + IPath resPath = getPath(); + IResource res = ResourcesPlugin.getWorkspace().getRoot().findMember(resPath); if (res != null) { IPath location = res.getLocation(); if (location != null) { - return location; + p = location.append(p); } } return p; @@ -156,6 +157,7 @@ public class LibraryEntry extends APathEntry implements ILibraryEntry { public IPath getLibraryPath() { return libraryPath; } + /* (non-Javadoc) * @see java.lang.Object#toString() */ 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 dccb52d3107..f32e3746972 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 @@ -201,6 +201,14 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange IIncludeEntry refEntry = (IIncludeEntry)entries[i]; 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 (refRes != null) { + newBasePath = refRes.getLocation(); + } + } return CoreModel.newIncludeEntry(includeEntry.getPath(), newBasePath, includePath); } @@ -288,8 +296,18 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange for (int i = 0; i < entries.length; i++) { if (entries[i].getEntryKind() == IPathEntry.CDT_LIBRARY) { ILibraryEntry refEntry = (ILibraryEntry)entries[i]; - if (refEntry.getPath().equals(libraryPath)) { - return CoreModel.newLibraryEntry(entry.getPath(), refEntry.getBasePath(), + 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 (refRes != null) { + newBasePath = refRes.getLocation(); + } + } + + return CoreModel.newLibraryEntry(entry.getPath(), newBasePath, refEntry.getLibraryPath(), refEntry.getSourceAttachmentPath(), refEntry.getSourceAttachmentRootPath(), refEntry.getSourceAttachmentPrefixMapping(), false); @@ -449,6 +467,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange IPathEntry[] newEntries = getResolvedPathEntries(affectedProject); ICElementDelta[] deltas = generatePathEntryDeltas(affectedProject, oldResolvedEntries[i], newEntries); if (deltas.length > 0) { + affectedProject.close(); shouldFire = true; for (int j = 0; j < deltas.length; j++) { mgr.registerCModelDelta(deltas[j]);