1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Fix for PR 65633

This commit is contained in:
Alain Magloire 2004-06-08 03:02:01 +00:00
parent 74c63e682b
commit eea5bdc2c8
5 changed files with 79 additions and 26 deletions

View file

@ -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 2004-06-07 Hoda Amer
Fix for PR 65369 : [CModel] Duplicate namespace declarations in views when namespace defined twice in a file Fix for PR 65369 : [CModel] Duplicate namespace declarations in views when namespace defined twice in a file

View file

@ -134,37 +134,60 @@ public class CProject extends Openable implements ICProject {
} }
public IIncludeReference[] getIncludeReferences() throws CModelException { public IIncludeReference[] getIncludeReferences() throws CModelException {
IPathEntry[] entries = getResolvedPathEntries(); CProjectInfo pinfo = (CProjectInfo)CModelManager.getDefault().peekAtInfo(this);
ArrayList list = new ArrayList(entries.length); IIncludeReference[] incRefs = null;
for (int i = 0; i < entries.length; i++) { if (pinfo != null) {
if (entries[i].getEntryKind() == IPathEntry.CDT_INCLUDE) { incRefs = pinfo.incReferences;
IIncludeEntry entry = (IIncludeEntry) entries[i]; }
IIncludeReference inc = new IncludeReference(this, entry); if (incRefs == null) {
if (inc != null) { IPathEntry[] entries = getResolvedPathEntries();
list.add(inc); 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 { public ILibraryReference[] getLibraryReferences() throws CModelException {
BinaryParserConfig[] binConfigs = CModelManager.getDefault().getBinaryParser(getProject()); CProjectInfo pinfo = (CProjectInfo)CModelManager.getDefault().peekAtInfo(this);
IPathEntry[] entries = getResolvedPathEntries(); ILibraryReference[] libRefs = null;
ArrayList list = new ArrayList(entries.length); if (pinfo != null) {
for (int i = 0; i < entries.length; i++) { libRefs = pinfo.libReferences;
if (entries[i].getEntryKind() == IPathEntry.CDT_LIBRARY) { }
ILibraryEntry entry = (ILibraryEntry) entries[i];
ILibraryReference lib = getLibraryReference(this, binConfigs, entry); if (libRefs == null) {
if (lib != null) { BinaryParserConfig[] binConfigs = CModelManager.getDefault().getBinaryParser(getProject());
list.add(lib); 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) { if (binConfigs == null) {
binConfigs = CModelManager.getDefault().getBinaryParser(cproject.getProject()); binConfigs = CModelManager.getDefault().getBinaryParser(cproject.getProject());
} }

View file

@ -87,11 +87,12 @@ public class IncludeEntry extends APathEntry implements IIncludeEntry {
if (p.isAbsolute()) { if (p.isAbsolute()) {
return p; return p;
} }
IResource res = ResourcesPlugin.getWorkspace().getRoot().findMember(p); IPath resPath = getPath();
IResource res = ResourcesPlugin.getWorkspace().getRoot().findMember(resPath);
if (res != null) { if (res != null) {
IPath location = res.getLocation(); IPath location = res.getLocation();
if (location != null) { if (location != null) {
return location; p = location.append(p);
} }
} }
return p; return p;

View file

@ -139,11 +139,12 @@ public class LibraryEntry extends APathEntry implements ILibraryEntry {
if (p.isAbsolute()) { if (p.isAbsolute()) {
return p; return p;
} }
IResource res = ResourcesPlugin.getWorkspace().getRoot().findMember(p); IPath resPath = getPath();
IResource res = ResourcesPlugin.getWorkspace().getRoot().findMember(resPath);
if (res != null) { if (res != null) {
IPath location = res.getLocation(); IPath location = res.getLocation();
if (location != null) { if (location != null) {
return location; p = location.append(p);
} }
} }
return p; return p;
@ -156,6 +157,7 @@ public class LibraryEntry extends APathEntry implements ILibraryEntry {
public IPath getLibraryPath() { public IPath getLibraryPath() {
return libraryPath; return libraryPath;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see java.lang.Object#toString() * @see java.lang.Object#toString()
*/ */

View file

@ -201,6 +201,14 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
IIncludeEntry refEntry = (IIncludeEntry)entries[i]; IIncludeEntry refEntry = (IIncludeEntry)entries[i];
if (refEntry.getIncludePath().equals(includePath)) { if (refEntry.getIncludePath().equals(includePath)) {
IPath newBasePath = refEntry.getBasePath(); 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(), return CoreModel.newIncludeEntry(includeEntry.getPath(),
newBasePath, includePath); newBasePath, includePath);
} }
@ -288,8 +296,18 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
for (int i = 0; i < entries.length; i++) { for (int i = 0; i < entries.length; i++) {
if (entries[i].getEntryKind() == IPathEntry.CDT_LIBRARY) { if (entries[i].getEntryKind() == IPathEntry.CDT_LIBRARY) {
ILibraryEntry refEntry = (ILibraryEntry)entries[i]; ILibraryEntry refEntry = (ILibraryEntry)entries[i];
if (refEntry.getPath().equals(libraryPath)) { if (refEntry.getLibraryPath().equals(libraryPath)) {
return CoreModel.newLibraryEntry(entry.getPath(), refEntry.getBasePath(), 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.getLibraryPath(), refEntry.getSourceAttachmentPath(),
refEntry.getSourceAttachmentRootPath(), refEntry.getSourceAttachmentRootPath(),
refEntry.getSourceAttachmentPrefixMapping(), false); refEntry.getSourceAttachmentPrefixMapping(), false);
@ -449,6 +467,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
IPathEntry[] newEntries = getResolvedPathEntries(affectedProject); IPathEntry[] newEntries = getResolvedPathEntries(affectedProject);
ICElementDelta[] deltas = generatePathEntryDeltas(affectedProject, oldResolvedEntries[i], newEntries); ICElementDelta[] deltas = generatePathEntryDeltas(affectedProject, oldResolvedEntries[i], newEntries);
if (deltas.length > 0) { if (deltas.length > 0) {
affectedProject.close();
shouldFire = true; shouldFire = true;
for (int j = 0; j < deltas.length; j++) { for (int j = 0; j < deltas.length; j++) {
mgr.registerCModelDelta(deltas[j]); mgr.registerCModelDelta(deltas[j]);