From c11d57b594a6c62640b4f130d1e44abd63556693 Mon Sep 17 00:00:00 2001 From: Alain Magloire Date: Wed, 28 Apr 2004 01:24:04 +0000 Subject: [PATCH] Work in progress on the IPathEntry --- .../org/eclipse/cdt/core/model/CoreModel.java | 2 +- .../internal/core/model/PathEntryManager.java | 54 ++++++++++++++++++- 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java index ef6da752e3b..3cf0222db24 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java @@ -672,7 +672,7 @@ public class CoreModel { * @see #setPathEntryContainer(IPath, ICProject[], IPathEntryContainer, * IProgressMonitor) */ - public IPathEntryContainer getPathEntryContainer(IPath containerPath, ICProject project) throws CModelException { + public static IPathEntryContainer getPathEntryContainer(IPath containerPath, ICProject project) throws CModelException { return pathEntryManager.getPathEntryContainer(containerPath, project); } 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 edf529261ec..c8f0657f3f1 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 @@ -37,6 +37,7 @@ import org.eclipse.cdt.core.resources.IPathEntryStore; import org.eclipse.cdt.core.resources.IPathEntryStoreListener; import org.eclipse.cdt.core.resources.PathEntryStoreChangedEvent; import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IWorkspaceRunnable; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IConfigurationElement; @@ -184,7 +185,10 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange } } } else { - list.add(entry); + IPathEntry e = getExpandedPathEntry(entry, cproject); + if (e != null) { + list.add(entry); + } } } entries = new IPathEntry[list.size()]; @@ -194,6 +198,54 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange return entries; } + private IPathEntry getExpandedPathEntry(IPathEntry entry, ICProject cproject) throws CModelException { + switch(entry.getEntryKind()) { + case IPathEntry.CDT_INCLUDE: { + IIncludeEntry includeEntry = (IIncludeEntry)entry; + IPath includePath = includeEntry.getIncludePath(); + IPath refPath = includeEntry.getBaseReference(); + if (refPath != null && !refPath.isEmpty()) { + if (refPath.isAbsolute()) { + IResource res = cproject.getCModel().getWorkspace().getRoot().findMember(refPath); + if (res != null && res.getType() == IResource.PROJECT) { + ICProject refCProject = CoreModel.getDefault().create((IProject)res); + if (refCProject != null) { + IPathEntry[] entries = getResolvedPathEntries(refCProject); + for (int i = 0; i < entries.length; i++) { + if (entries[i].getEntryKind() == IPathEntry.CDT_INCLUDE) { + IIncludeEntry refEntry = (IIncludeEntry)entries[i]; + if (refEntry.getIncludePath().equals(includePath)) { + IPath newBasePath = refEntry.getBasePath(); + return CoreModel.newIncludeEntry(includeEntry.getPath(), newBasePath, includePath); + } + } + } + } + } + } else { // Container ref + IPathEntryContainer container = getPathEntryContainer(refPath, cproject); + if (container != null) { + IPathEntry[] entries = container.getPathEntries(); + for (int i = 0; i < entries.length; i++) { + if (entries[i].getEntryKind() == IPathEntry.CDT_INCLUDE) { + IIncludeEntry refEntry = (IIncludeEntry)entries[i]; + if (refEntry.getIncludePath().equals(includePath)) { + IPath newBasePath = refEntry.getBasePath(); + return CoreModel.newIncludeEntry(includeEntry.getPath(), newBasePath, includePath); + } + } + } + } + } + } + break; + } + case IPathEntry.CDT_MACRO: + break; + } + return entry; + } + public void setRawPathEntries(ICProject cproject, IPathEntry[] newEntries, IProgressMonitor monitor) throws CModelException { try { IPathEntry[] oldResolvedEntries = (IPathEntry[]) resolvedMap.get(cproject);