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

2004-08-25 Alain Magloire

Fix for PR 72078
	* model/org/eclipse/cdt/internal/core/mode/CProject.java
	* model/org/eclipse/cdt/internal/core/mode/PathEntryManager.java
This commit is contained in:
Alain Magloire 2004-08-25 14:25:44 +00:00
parent 6a973b377a
commit 4377ae355f
3 changed files with 48 additions and 71 deletions

View file

@ -1,3 +1,9 @@
2004-08-25 Alain Magloire
Fix for PR 72078
* model/org/eclipse/cdt/internal/core/mode/CProject.java
* model/org/eclipse/cdt/internal/core/mode/PathEntryManager.java
2004-08-24 Alain Magloire 2004-08-24 Alain Magloire
Fix for PR 72078 Fix for PR 72078

View file

@ -55,7 +55,7 @@ public class CProject extends Openable implements ICProject {
private static final String CUSTOM_DEFAULT_OPTION_VALUE = "#\r\n\r#custom-non-empty-default-value#\r\n\r#"; //$NON-NLS-1$ private static final String CUSTOM_DEFAULT_OPTION_VALUE = "#\r\n\r#custom-non-empty-default-value#\r\n\r#"; //$NON-NLS-1$
public CProject(ICElement parent, IProject project) { public CProject(ICElement parent, IProject project) {
super(parent, project, CElement.C_PROJECT); super(parent, project, ICElement.C_PROJECT);
} }
public IBinaryContainer getBinaryContainer() throws CModelException { public IBinaryContainer getBinaryContainer() throws CModelException {
@ -493,10 +493,12 @@ public class CProject extends Openable implements ICProject {
if (pinfo.sourceRoots != null) { if (pinfo.sourceRoots != null) {
roots = pinfo.sourceRoots; roots = pinfo.sourceRoots;
} else { } else {
roots = pinfo.sourceRoots = (ISourceRoot[])computeSourceRoots().toArray(new ISourceRoot[computeSourceRoots().size()]); List list = computeSourceRoots();
roots = pinfo.sourceRoots = (ISourceRoot[])list.toArray(new ISourceRoot[list.size()]);
} }
} else { } else {
roots = (ISourceRoot[])computeSourceRoots().toArray(new ISourceRoot[computeSourceRoots().size()]); List list = computeSourceRoots();
roots = (ISourceRoot[])list.toArray(new ISourceRoot[list.size()]);
} }
return roots; return roots;
} }

View file

@ -148,12 +148,11 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
} }
public IPathEntry[] getResolvedPathEntries(ICProject cproject, boolean generateMarkers) throws CModelException { public IPathEntry[] getResolvedPathEntries(ICProject cproject, boolean generateMarkers) throws CModelException {
ArrayList listEntries = (ArrayList)resolvedMap.get(cproject); ArrayList resolvedEntries = (ArrayList)resolvedMap.get(cproject);
IPathEntry[] resolvedEntries; if (resolvedEntries == null) {
if (listEntries == null) {
IPath projectPath = cproject.getPath(); IPath projectPath = cproject.getPath();
IPathEntry[] rawEntries = getRawPathEntries(cproject); IPathEntry[] rawEntries = getRawPathEntries(cproject);
listEntries = new ArrayList(); resolvedEntries = new ArrayList();
for (int i = 0; i < rawEntries.length; i++) { for (int i = 0; i < rawEntries.length; i++) {
IPathEntry entry = rawEntries[i]; IPathEntry entry = rawEntries[i];
// Expand the containers. // Expand the containers.
@ -165,7 +164,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
if (containerEntries != null) { if (containerEntries != null) {
for (int j = 0; j < containerEntries.length; j++) { for (int j = 0; j < containerEntries.length; j++) {
IPathEntry newEntry = cloneEntry(projectPath, containerEntries[j]); IPathEntry newEntry = cloneEntry(projectPath, containerEntries[j]);
listEntries.add(newEntry); resolvedEntries.add(newEntry);
} }
} }
} }
@ -173,33 +172,15 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
IPathEntry clone = cloneEntry(projectPath, entry); IPathEntry clone = cloneEntry(projectPath, entry);
IPathEntry e = getExpandedPathEntry(clone, cproject); IPathEntry e = getExpandedPathEntry(clone, cproject);
if (e != null) { if (e != null) {
listEntries.add(e); resolvedEntries.add(e);
} }
} }
} }
listEntries.trimToSize(); resolvedEntries.trimToSize();
resolvedEntries = (IPathEntry[])listEntries.toArray(NO_PATHENTRIES);
// Check for duplication in the sources
List dups = checkForSourceDuplication(resolvedEntries);
if (dups.size() > 0) {
List newList = new ArrayList(Arrays.asList(resolvedEntries));
newList.removeAll(dups);
resolvedEntries = (IPathEntry[]) newList.toArray(new IPathEntry[newList.size()]);
}
// Check for duplication in the outputs
dups = checkForOutputDuplication(resolvedEntries);
if (dups.size() > 0) {
List newList = new ArrayList(Arrays.asList(resolvedEntries));
newList.removeAll(dups);
resolvedEntries = (IPathEntry[]) newList.toArray(new IPathEntry[newList.size()]);
}
if (generateMarkers) { if (generateMarkers) {
final ICProject finalCProject = cproject; final ICProject finalCProject = cproject;
final IPathEntry[] finalEntries = (IPathEntry[])listEntries.toArray(NO_PATHENTRIES); final IPathEntry[] finalEntries = (IPathEntry[])resolvedEntries.toArray(NO_PATHENTRIES);
Job markerTask = new Job("PathEntry Marker Job") { //$NON-NLS-1$ Job markerTask = new Job("PathEntry Marker Job") { //$NON-NLS-1$
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor) * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
@ -222,11 +203,22 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
}; };
markerTask.schedule(); markerTask.schedule();
} }
resolvedMap.put(cproject, listEntries);
} else { // Check for duplication in the sources
resolvedEntries = (IPathEntry[])listEntries.toArray(NO_PATHENTRIES); List dups = checkForDuplication(resolvedEntries, IPathEntry.CDT_SOURCE);
if (dups.size() > 0) {
resolvedEntries.removeAll(dups);
} }
return resolvedEntries;
// Check for duplication in the outputs
dups = checkForDuplication(resolvedEntries, IPathEntry.CDT_OUTPUT);
if (dups.size() > 0) {
resolvedEntries.removeAll(dups);
}
resolvedMap.put(cproject, resolvedEntries);
}
return (IPathEntry[])resolvedEntries.toArray(NO_PATHENTRIES);
} }
private IPathEntry getExpandedPathEntry(IPathEntry entry, ICProject cproject) throws CModelException { private IPathEntry getExpandedPathEntry(IPathEntry entry, ICProject cproject) throws CModelException {
@ -1182,7 +1174,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
} }
// check duplication of sources // check duplication of sources
List dups = checkForSourceDuplication(entries); List dups = checkForDuplication(Arrays.asList(entries), IPathEntry.CDT_SOURCE);
if (dups.size() > 0) { if (dups.size() > 0) {
ICModelStatus[] cmodelStatus = new ICModelStatus[dups.size()]; ICModelStatus[] cmodelStatus = new ICModelStatus[dups.size()];
for (int i = 0; i < dups.size(); ++i) { for (int i = 0; i < dups.size(); ++i) {
@ -1194,7 +1186,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
} }
// check duplication of Outputs // check duplication of Outputs
dups = checkForOutputDuplication(entries); dups = checkForDuplication(Arrays.asList(entries), IPathEntry.CDT_OUTPUT);
if (dups.size() > 0) { if (dups.size() > 0) {
ICModelStatus[] cmodelStatus = new ICModelStatus[dups.size()]; ICModelStatus[] cmodelStatus = new ICModelStatus[dups.size()];
for (int i = 0; i < dups.size(); ++i) { for (int i = 0; i < dups.size(); ++i) {
@ -1378,42 +1370,19 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
return false; return false;
} }
private List checkForSourceDuplication(IPathEntry[] pathEntries) { private List checkForDuplication(List pathEntries, int type) {
List duplicate = new ArrayList(pathEntries.length); List duplicate = new ArrayList(pathEntries.size());
for (int i = 0; i < pathEntries.length; ++i) { for (int i = 0; i < pathEntries.size(); ++i) {
if (pathEntries[i].getEntryKind() == IPathEntry.CDT_SOURCE) { IPathEntry pathEntry = (IPathEntry)pathEntries.get(i);
ISourceEntry sourceEntry = (ISourceEntry)pathEntries[i]; if (pathEntry.getEntryKind() == type) {
for (int j = 0; j < pathEntries.length; ++j) { for (int j = 0; j < pathEntries.size(); ++j) {
if (pathEntries[j].getEntryKind() == IPathEntry.CDT_SOURCE) { IPathEntry otherEntry = (IPathEntry)pathEntries.get(j);
ISourceEntry otherSource = (ISourceEntry)pathEntries[j]; if (otherEntry.getEntryKind() == type) {
if (!sourceEntry.equals(otherSource)) { if (!pathEntry.equals(otherEntry)) {
if (!duplicate.contains(sourceEntry)) { if (!duplicate.contains(pathEntry)) {
if (sourceEntry.getPath().equals(otherSource.getPath())) { if (pathEntry.getPath().equals(otherEntry.getPath())) {
// duplication of sources // duplication of sources
duplicate.add(otherSource); duplicate.add(otherEntry);
}
}
}
}
}
}
}
return duplicate;
}
private List checkForOutputDuplication(IPathEntry[] pathEntries) {
List duplicate = new ArrayList(pathEntries.length);
for (int i = 0; i < pathEntries.length; ++i) {
if (pathEntries[i].getEntryKind() == IPathEntry.CDT_OUTPUT) {
IOutputEntry outputEntry = (IOutputEntry)pathEntries[i];
for (int j = 0; j < pathEntries.length; ++j) {
if (pathEntries[j].getEntryKind() == IPathEntry.CDT_OUTPUT) {
IOutputEntry otherOutput = (IOutputEntry)pathEntries[j];
if (!outputEntry.equals(otherOutput)) {
if (!duplicate.contains(outputEntry)) {
if (outputEntry.getPath().equals(otherOutput.getPath())) {
// duplication of outputs
duplicate.add(otherOutput);
} }
} }
} }