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
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$
public CProject(ICElement parent, IProject project) {
super(parent, project, CElement.C_PROJECT);
super(parent, project, ICElement.C_PROJECT);
}
public IBinaryContainer getBinaryContainer() throws CModelException {
@ -493,10 +493,12 @@ public class CProject extends Openable implements ICProject {
if (pinfo.sourceRoots != null) {
roots = pinfo.sourceRoots;
} 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 {
roots = (ISourceRoot[])computeSourceRoots().toArray(new ISourceRoot[computeSourceRoots().size()]);
List list = computeSourceRoots();
roots = (ISourceRoot[])list.toArray(new ISourceRoot[list.size()]);
}
return roots;
}

View file

@ -148,12 +148,11 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
}
public IPathEntry[] getResolvedPathEntries(ICProject cproject, boolean generateMarkers) throws CModelException {
ArrayList listEntries = (ArrayList)resolvedMap.get(cproject);
IPathEntry[] resolvedEntries;
if (listEntries == null) {
ArrayList resolvedEntries = (ArrayList)resolvedMap.get(cproject);
if (resolvedEntries == null) {
IPath projectPath = cproject.getPath();
IPathEntry[] rawEntries = getRawPathEntries(cproject);
listEntries = new ArrayList();
resolvedEntries = new ArrayList();
for (int i = 0; i < rawEntries.length; i++) {
IPathEntry entry = rawEntries[i];
// Expand the containers.
@ -165,7 +164,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
if (containerEntries != null) {
for (int j = 0; j < containerEntries.length; 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 e = getExpandedPathEntry(clone, cproject);
if (e != null) {
listEntries.add(e);
resolvedEntries.add(e);
}
}
}
listEntries.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()]);
}
resolvedEntries.trimToSize();
if (generateMarkers) {
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$
/* (non-Javadoc)
* @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();
}
resolvedMap.put(cproject, listEntries);
} else {
resolvedEntries = (IPathEntry[])listEntries.toArray(NO_PATHENTRIES);
// Check for duplication in the sources
List dups = checkForDuplication(resolvedEntries, IPathEntry.CDT_SOURCE);
if (dups.size() > 0) {
resolvedEntries.removeAll(dups);
}
// Check for duplication in the outputs
dups = checkForDuplication(resolvedEntries, IPathEntry.CDT_OUTPUT);
if (dups.size() > 0) {
resolvedEntries.removeAll(dups);
}
resolvedMap.put(cproject, resolvedEntries);
}
return resolvedEntries;
return (IPathEntry[])resolvedEntries.toArray(NO_PATHENTRIES);
}
private IPathEntry getExpandedPathEntry(IPathEntry entry, ICProject cproject) throws CModelException {
@ -1182,7 +1174,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
}
// check duplication of sources
List dups = checkForSourceDuplication(entries);
List dups = checkForDuplication(Arrays.asList(entries), IPathEntry.CDT_SOURCE);
if (dups.size() > 0) {
ICModelStatus[] cmodelStatus = new ICModelStatus[dups.size()];
for (int i = 0; i < dups.size(); ++i) {
@ -1194,7 +1186,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
}
// check duplication of Outputs
dups = checkForOutputDuplication(entries);
dups = checkForDuplication(Arrays.asList(entries), IPathEntry.CDT_OUTPUT);
if (dups.size() > 0) {
ICModelStatus[] cmodelStatus = new ICModelStatus[dups.size()];
for (int i = 0; i < dups.size(); ++i) {
@ -1378,42 +1370,19 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
return false;
}
private List checkForSourceDuplication(IPathEntry[] pathEntries) {
List duplicate = new ArrayList(pathEntries.length);
for (int i = 0; i < pathEntries.length; ++i) {
if (pathEntries[i].getEntryKind() == IPathEntry.CDT_SOURCE) {
ISourceEntry sourceEntry = (ISourceEntry)pathEntries[i];
for (int j = 0; j < pathEntries.length; ++j) {
if (pathEntries[j].getEntryKind() == IPathEntry.CDT_SOURCE) {
ISourceEntry otherSource = (ISourceEntry)pathEntries[j];
if (!sourceEntry.equals(otherSource)) {
if (!duplicate.contains(sourceEntry)) {
if (sourceEntry.getPath().equals(otherSource.getPath())) {
private List checkForDuplication(List pathEntries, int type) {
List duplicate = new ArrayList(pathEntries.size());
for (int i = 0; i < pathEntries.size(); ++i) {
IPathEntry pathEntry = (IPathEntry)pathEntries.get(i);
if (pathEntry.getEntryKind() == type) {
for (int j = 0; j < pathEntries.size(); ++j) {
IPathEntry otherEntry = (IPathEntry)pathEntries.get(j);
if (otherEntry.getEntryKind() == type) {
if (!pathEntry.equals(otherEntry)) {
if (!duplicate.contains(pathEntry)) {
if (pathEntry.getPath().equals(otherEntry.getPath())) {
// duplication of sources
duplicate.add(otherSource);
}
}
}
}
}
}
}
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);
duplicate.add(otherEntry);
}
}
}