mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 10:16:03 +02:00
2005-02-24 Alain Magloire
Part of 79596 * model/org/eclipse/cdt/internal/core/model/PathEntryManager.java * plugin.properties
This commit is contained in:
parent
98c8876390
commit
cb3e02121c
3 changed files with 125 additions and 44 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2005-02-24 Alain Magloire
|
||||||
|
Part of 79596
|
||||||
|
* model/org/eclipse/cdt/internal/core/model/PathEntryManager.java
|
||||||
|
* plugin.properties
|
||||||
|
|
||||||
2005-02-21 Alain Magloire
|
2005-02-21 Alain Magloire
|
||||||
Adapt the ResolverModel code to the IContentTypeManager.
|
Adapt the ResolverModel code to the IContentTypeManager.
|
||||||
* src/orgeclipse/cdt/core/internal/filetype/ResolverModel.java
|
* src/orgeclipse/cdt/core/internal/filetype/ResolverModel.java
|
||||||
|
|
|
@ -176,10 +176,11 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
ICProject cproject = cunit.getCProject();
|
ICProject cproject = cunit.getCProject();
|
||||||
IPath resPath = cunit.getPath();
|
IPath resPath = cunit.getPath();
|
||||||
// Do this first so the containers get inialized.
|
// Do this first so the containers get inialized.
|
||||||
IPathEntry[] entries = getResolvedPathEntries(cproject);
|
ArrayList resolvedListEntries = getResolvedPathEntries(cproject, false);
|
||||||
for (int i = 0; i < entries.length; ++i) {
|
for (int i = 0; i < resolvedListEntries.size(); ++i) {
|
||||||
if (entries[i].getEntryKind() == IPathEntry.CDT_INCLUDE) {
|
IPathEntry entry = (IPathEntry)resolvedListEntries.get(i);
|
||||||
includeList.add(entries[i]);
|
if (entry.getEntryKind() == IPathEntry.CDT_INCLUDE) {
|
||||||
|
includeList.add(entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
IPathEntryContainer[] containers = getPathEntryContainers(cproject);
|
IPathEntryContainer[] containers = getPathEntryContainers(cproject);
|
||||||
|
@ -214,8 +215,8 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
|
|
||||||
// Since the include that comes from a project contribution are not
|
// Since the include that comes from a project contribution are not
|
||||||
// tied to a resource they are added last.
|
// tied to a resource they are added last.
|
||||||
for (int i = 0; i < entries.length; i++) {
|
for (int i = 0; i < resolvedListEntries.size(); i++) {
|
||||||
IPathEntry entry = entries[i];
|
IPathEntry entry = (IPathEntry)resolvedListEntries.get(i);
|
||||||
if (entry != null && entry.getEntryKind() == IPathEntry.CDT_PROJECT) {
|
if (entry != null && entry.getEntryKind() == IPathEntry.CDT_PROJECT) {
|
||||||
IResource res = cproject.getCModel().getWorkspace().getRoot().findMember(entry.getPath());
|
IResource res = cproject.getCModel().getWorkspace().getRoot().findMember(entry.getPath());
|
||||||
if (res != null && res.getType() == IResource.PROJECT) {
|
if (res != null && res.getType() == IResource.PROJECT) {
|
||||||
|
@ -251,10 +252,11 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
ICProject cproject = cunit.getCProject();
|
ICProject cproject = cunit.getCProject();
|
||||||
IPath resPath = cunit.getPath();
|
IPath resPath = cunit.getPath();
|
||||||
// Do this first so the containers get inialized.
|
// Do this first so the containers get inialized.
|
||||||
IPathEntry[] entries = getResolvedPathEntries(cproject);
|
ArrayList resolvedListEntries = getResolvedPathEntries(cproject, false);
|
||||||
for (int i = 0; i < entries.length; ++i) {
|
for (int i = 0; i < resolvedListEntries.size(); ++i) {
|
||||||
if (entries[i].getEntryKind() == IPathEntry.CDT_MACRO) {
|
IPathEntry entry = (IPathEntry)resolvedListEntries.get(i);
|
||||||
macroList.add(entries[i]);
|
if (entry.getEntryKind() == IPathEntry.CDT_MACRO) {
|
||||||
|
macroList.add(entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
IPathEntryContainer[] containers = getPathEntryContainers(cproject);
|
IPathEntryContainer[] containers = getPathEntryContainers(cproject);
|
||||||
|
@ -289,8 +291,8 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the Project contributions last.
|
// Add the Project contributions last.
|
||||||
for (int i = 0; i < entries.length; i++) {
|
for (int i = 0; i < resolvedListEntries.size(); i++) {
|
||||||
IPathEntry entry = entries[i];
|
IPathEntry entry = (IPathEntry)resolvedListEntries.get(i);
|
||||||
if (entry != null && entry.getEntryKind() == IPathEntry.CDT_PROJECT) {
|
if (entry != null && entry.getEntryKind() == IPathEntry.CDT_PROJECT) {
|
||||||
IResource res = cproject.getCModel().getWorkspace().getRoot().findMember(entry.getPath());
|
IResource res = cproject.getCModel().getWorkspace().getRoot().findMember(entry.getPath());
|
||||||
if (res != null && res.getType() == IResource.PROJECT) {
|
if (res != null && res.getType() == IResource.PROJECT) {
|
||||||
|
@ -318,12 +320,88 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IPathEntry[] getResolvedPathEntries(ICProject cproject) throws CModelException {
|
/**
|
||||||
boolean markers = cproject.getProject().getWorkspace().isTreeLocked();
|
* Return the cached entries, if no cache null.
|
||||||
return getResolvedPathEntries(cproject, !markers);
|
* @param cproject
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected IPathEntry[] getCachedResolvedPathEntries(ICProject cproject) {
|
||||||
|
ArrayList resolvedListEntries = (ArrayList)resolvedMap.get(cproject);
|
||||||
|
if (resolvedListEntries != null) {
|
||||||
|
try {
|
||||||
|
return getCachedResolvedPathEntries(resolvedListEntries, cproject);
|
||||||
|
} catch (CModelException e) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IPathEntry[] getResolvedPathEntries(ICProject cproject, boolean generateMarkers) throws CModelException {
|
protected IPathEntry[] removeCachedResovedPathEntries(ICProject cproject) {
|
||||||
|
ArrayList resolvedListEntries = (ArrayList)resolvedMap.remove(cproject);
|
||||||
|
if (resolvedListEntries != null) {
|
||||||
|
try {
|
||||||
|
return getCachedResolvedPathEntries(resolvedListEntries, cproject);
|
||||||
|
} catch (CModelException e) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private IPathEntry[] getCachedResolvedPathEntries(ArrayList resolvedListEntries, ICProject cproject) throws CModelException {
|
||||||
|
IPathEntry[] entries = (IPathEntry[])resolvedListEntries.toArray(NO_PATHENTRIES);
|
||||||
|
boolean hasContainerExtension = false;
|
||||||
|
for (int i = 0; i < entries.length; i++) {
|
||||||
|
if (entries[i].getEntryKind() == IPathEntry.CDT_CONTAINER) {
|
||||||
|
IContainerEntry centry = (IContainerEntry)entries[i];
|
||||||
|
IPathEntryContainer container = getPathEntryContainer(centry, cproject);
|
||||||
|
if (container instanceof IPathEntryContainerExtension) {
|
||||||
|
hasContainerExtension = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (hasContainerExtension) {
|
||||||
|
IPath projectPath = cproject.getPath();
|
||||||
|
ArrayList listEntries = new ArrayList(entries.length);
|
||||||
|
for (int i = 0; i < entries.length; ++i) {
|
||||||
|
if (entries[i].getEntryKind() == IPathEntry.CDT_CONTAINER) {
|
||||||
|
IContainerEntry centry = (IContainerEntry)entries[i];
|
||||||
|
IPathEntryContainer container = getPathEntryContainer(centry, cproject);
|
||||||
|
if (container != null) {
|
||||||
|
IPathEntry[] containerEntries = container.getPathEntries();
|
||||||
|
if (containerEntries != null) {
|
||||||
|
for (int j = 0; j < containerEntries.length; j++) {
|
||||||
|
IPathEntry newEntry = cloneEntry(projectPath, containerEntries[j]);
|
||||||
|
listEntries.add(newEntry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
listEntries.add(entries[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
entries = (IPathEntry[])listEntries.toArray(NO_PATHENTRIES);
|
||||||
|
}
|
||||||
|
return entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IPathEntry[] getResolvedPathEntries(ICProject cproject) throws CModelException {
|
||||||
|
boolean markers = cproject.getProject().getWorkspace().isTreeLocked();
|
||||||
|
ArrayList resolvedListEntries = getResolvedPathEntries(cproject, !markers);
|
||||||
|
return getCachedResolvedPathEntries(resolvedListEntries, cproject);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method will not expand container extending IPathEntryContainerExtension
|
||||||
|
*
|
||||||
|
* @param cproject
|
||||||
|
* @param generateMarkers
|
||||||
|
* @return
|
||||||
|
* @throws CModelException
|
||||||
|
*/
|
||||||
|
private ArrayList getResolvedPathEntries(ICProject cproject, boolean generateMarkers) throws CModelException {
|
||||||
ArrayList resolvedEntries = (ArrayList)resolvedMap.get(cproject);
|
ArrayList resolvedEntries = (ArrayList)resolvedMap.get(cproject);
|
||||||
if (resolvedEntries == null) {
|
if (resolvedEntries == null) {
|
||||||
IPath projectPath = cproject.getPath();
|
IPath projectPath = cproject.getPath();
|
||||||
|
@ -336,6 +414,9 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
IContainerEntry centry = (IContainerEntry)entry;
|
IContainerEntry centry = (IContainerEntry)entry;
|
||||||
IPathEntryContainer container = getPathEntryContainer(centry, cproject);
|
IPathEntryContainer container = getPathEntryContainer(centry, cproject);
|
||||||
if (container != null) {
|
if (container != null) {
|
||||||
|
// For backward compatibility we need to expand and cache container that
|
||||||
|
// are not IPathEntryContainerExtension.
|
||||||
|
if (!(container instanceof IPathEntryContainerExtension)) {
|
||||||
IPathEntry[] containerEntries = container.getPathEntries();
|
IPathEntry[] containerEntries = container.getPathEntries();
|
||||||
if (containerEntries != null) {
|
if (containerEntries != null) {
|
||||||
for (int j = 0; j < containerEntries.length; j++) {
|
for (int j = 0; j < containerEntries.length; j++) {
|
||||||
|
@ -343,6 +424,9 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
resolvedEntries.add(newEntry);
|
resolvedEntries.add(newEntry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
resolvedEntries.add(cloneEntry(projectPath, entry));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
IPathEntry clone = cloneEntry(projectPath, entry);
|
IPathEntry clone = cloneEntry(projectPath, entry);
|
||||||
|
@ -373,7 +457,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
|
|
||||||
resolvedMap.put(cproject, resolvedEntries);
|
resolvedMap.put(cproject, resolvedEntries);
|
||||||
}
|
}
|
||||||
return (IPathEntry[])resolvedEntries.toArray(NO_PATHENTRIES);
|
return resolvedEntries;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IPathEntry getExpandedPathEntry(IPathEntry entry, ICProject cproject) throws CModelException {
|
private IPathEntry getExpandedPathEntry(IPathEntry entry, ICProject cproject) throws CModelException {
|
||||||
|
@ -562,11 +646,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
|
|
||||||
public void setRawPathEntries(ICProject cproject, IPathEntry[] newEntries, IProgressMonitor monitor) throws CModelException {
|
public void setRawPathEntries(ICProject cproject, IPathEntry[] newEntries, IProgressMonitor monitor) throws CModelException {
|
||||||
try {
|
try {
|
||||||
IPathEntry[] oldResolvedEntries = null;
|
IPathEntry[] oldResolvedEntries = getCachedResolvedPathEntries(cproject);
|
||||||
ArrayList listEntries = (ArrayList)resolvedMap.get(cproject);
|
|
||||||
if (listEntries != null) {
|
|
||||||
oldResolvedEntries = (IPathEntry[])listEntries.toArray(NO_PATHENTRIES);
|
|
||||||
}
|
|
||||||
SetPathEntriesOperation op = new SetPathEntriesOperation(cproject, oldResolvedEntries, newEntries);
|
SetPathEntriesOperation op = new SetPathEntriesOperation(cproject, oldResolvedEntries, newEntries);
|
||||||
CModelManager.getDefault().runOperation(op, monitor);
|
CModelManager.getDefault().runOperation(op, monitor);
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
|
@ -662,12 +742,13 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
remaining++;
|
remaining++;
|
||||||
ArrayList listEntries = (ArrayList)resolvedMap.remove(affectedProject);
|
oldResolvedEntries[i] = removeCachedResovedPathEntries(affectedProject);
|
||||||
if (listEntries != null) {
|
// ArrayList listEntries = (ArrayList)resolvedMap.remove(affectedProject);
|
||||||
oldResolvedEntries[i] = (IPathEntry[])listEntries.toArray(NO_PATHENTRIES);
|
// if (listEntries != null) {
|
||||||
} else {
|
// oldResolvedEntries[i] = (IPathEntry[])listEntries.toArray(NO_PATHENTRIES);
|
||||||
oldResolvedEntries[i] = null;
|
// } else {
|
||||||
}
|
// oldResolvedEntries[i] = null;
|
||||||
|
// }
|
||||||
containerPut(affectedProject, containerPath, newContainer);
|
containerPut(affectedProject, containerPath, newContainer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -722,7 +803,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
Map projectContainers = (Map)Containers.get(cproject);
|
Map projectContainers = (Map)Containers.get(cproject);
|
||||||
if (projectContainers != null) {
|
if (projectContainers != null) {
|
||||||
Collection collection = projectContainers.values();
|
Collection collection = projectContainers.values();
|
||||||
pcs = (IPathEntryContainer[]) collection.toArray(new IPathEntryContainer[collection.size()]);
|
pcs = (IPathEntryContainer[]) collection.toArray(NO_PATHENTRYCONTAINERS);
|
||||||
}
|
}
|
||||||
return pcs;
|
return pcs;
|
||||||
}
|
}
|
||||||
|
@ -1120,9 +1201,8 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
*/
|
*/
|
||||||
public void run(IProgressMonitor monitor) throws CoreException {
|
public void run(IProgressMonitor monitor) throws CoreException {
|
||||||
for(int i = 0; i < cProjects.length; i++) {
|
for(int i = 0; i < cProjects.length; i++) {
|
||||||
ArrayList resolvedList = (ArrayList)resolvedMap.get(cProjects[i]);
|
IPathEntry[] entries = getCachedResolvedPathEntries(cProjects[i]);
|
||||||
if (resolvedList != null) {
|
if (entries != null) {
|
||||||
IPathEntry[] entries = (IPathEntry[])resolvedList.toArray(new IPathEntry[resolvedList.size()]);
|
|
||||||
IProject project = cProjects[i].getProject();
|
IProject project = cProjects[i].getProject();
|
||||||
flushPathEntryProblemMarkers(project);
|
flushPathEntryProblemMarkers(project);
|
||||||
ICModelStatus status = validatePathEntry(cProjects[i], entries);
|
ICModelStatus status = validatePathEntry(cProjects[i], entries);
|
||||||
|
@ -1380,11 +1460,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
if (project.isAccessible()) {
|
if (project.isAccessible()) {
|
||||||
try {
|
try {
|
||||||
// Clear the old cache entries.
|
// Clear the old cache entries.
|
||||||
IPathEntry[] oldResolvedEntries = null;
|
IPathEntry[] oldResolvedEntries = removeCachedResovedPathEntries(cproject);
|
||||||
ArrayList listEntries = (ArrayList)resolvedMap.remove(cproject);
|
|
||||||
if (listEntries != null) {
|
|
||||||
oldResolvedEntries = (IPathEntry[])listEntries.toArray(NO_PATHENTRIES);
|
|
||||||
}
|
|
||||||
IPathEntry[] newResolvedEntries = getResolvedPathEntries(cproject);
|
IPathEntry[] newResolvedEntries = getResolvedPathEntries(cproject);
|
||||||
ICElementDelta[] deltas = generatePathEntryDeltas(cproject, oldResolvedEntries, newResolvedEntries);
|
ICElementDelta[] deltas = generatePathEntryDeltas(cproject, oldResolvedEntries, newResolvedEntries);
|
||||||
if (deltas.length > 0) {
|
if (deltas.length > 0) {
|
||||||
|
|
|
@ -63,7 +63,7 @@ DefaultCodeFormatter.name=Default Formatter
|
||||||
DefaultCodeFormatter.name=Default Formatter
|
DefaultCodeFormatter.name=Default Formatter
|
||||||
|
|
||||||
cSourceName=C Source File
|
cSourceName=C Source File
|
||||||
cHeaderName=C/C++ Header File
|
cHeaderName=C Header File
|
||||||
cxxSourceName=C++ Source File
|
cxxSourceName=C++ Source File
|
||||||
cxxHeaderName=C++ Header File
|
cxxHeaderName=C++ Header File
|
||||||
asmHeaderName=Machine Assembly Source File
|
asmSourceName=Assembly Source File
|
||||||
|
|
Loading…
Add table
Reference in a new issue