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
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 {
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());
}

View file

@ -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;

View file

@ -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()
*/

View file

@ -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]);