mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-31 21:05:37 +02:00
2004-08-24 Alain Magloire
Fix for PR 72078 * model/org/eclipse/cdt/internal/core/model/CModelStatus.java * model/org/eclipse/cdt/internal/core/model/PathEntryManager.java
This commit is contained in:
parent
76f927a165
commit
e0f8a9bbeb
3 changed files with 142 additions and 32 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2004-08-24 Alain Magloire
|
||||||
|
|
||||||
|
Fix for PR 72078
|
||||||
|
* model/org/eclipse/cdt/internal/core/model/CModelStatus.java
|
||||||
|
* model/org/eclipse/cdt/internal/core/model/PathEntryManager.java
|
||||||
|
|
||||||
2004-08-23 Chris Wiebe
|
2004-08-23 Chris Wiebe
|
||||||
|
|
||||||
fix for 68210 - add missing cpp header names
|
fix for 68210 - add missing cpp header names
|
||||||
|
|
|
@ -169,6 +169,16 @@ public class CModelStatus extends Status implements ICModelStatus, ICModelStatus
|
||||||
*/
|
*/
|
||||||
public String getMessage() {
|
public String getMessage() {
|
||||||
Throwable exception = getException();
|
Throwable exception = getException();
|
||||||
|
if (isMultiStatus()) {
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
IStatus[] children = getChildren();
|
||||||
|
if (children != null && children.length > 0) {
|
||||||
|
for (int i = 0; i < children.length; ++i) {
|
||||||
|
sb.append(children[i].getMessage()).append(',');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
if (exception == null) {
|
if (exception == null) {
|
||||||
switch (getCode()) {
|
switch (getCode()) {
|
||||||
case CORE_EXCEPTION :
|
case CORE_EXCEPTION :
|
||||||
|
@ -212,9 +222,8 @@ public class CModelStatus extends Status implements ICModelStatus, ICModelStatus
|
||||||
case INVALID_PATH:
|
case INVALID_PATH:
|
||||||
if (fString != null) {
|
if (fString != null) {
|
||||||
return fString;
|
return fString;
|
||||||
} else {
|
|
||||||
return CoreModelMessages.getFormattedString("status.invalidPath", getPath() == null ? "null" : getPath().toString()); //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
}
|
}
|
||||||
|
return CoreModelMessages.getFormattedString("status.invalidPath", getPath() == null ? "null" : getPath().toString()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
|
||||||
case INVALID_PROJECT:
|
case INVALID_PROJECT:
|
||||||
return CoreModelMessages.getFormattedString("status.invalidProject", getString()); //$NON-NLS-1$
|
return CoreModelMessages.getFormattedString("status.invalidProject", getString()); //$NON-NLS-1$
|
||||||
|
@ -228,9 +237,8 @@ public class CModelStatus extends Status implements ICModelStatus, ICModelStatus
|
||||||
case INVALID_SIBLING:
|
case INVALID_SIBLING:
|
||||||
if (fString != null) {
|
if (fString != null) {
|
||||||
return CoreModelMessages.getFormattedString("status.invalidSibling", getString()); //$NON-NLS-1$
|
return CoreModelMessages.getFormattedString("status.invalidSibling", getString()); //$NON-NLS-1$
|
||||||
} else {
|
|
||||||
return CoreModelMessages.getFormattedString("status.invalidSibling", getFirstElementName()); //$NON-NLS-1$
|
|
||||||
}
|
}
|
||||||
|
return CoreModelMessages.getFormattedString("status.invalidSibling", getFirstElementName()); //$NON-NLS-1$
|
||||||
|
|
||||||
case IO_EXCEPTION:
|
case IO_EXCEPTION:
|
||||||
return CoreModelMessages.getFormattedString("status.IOException"); //$NON-NLS-1$
|
return CoreModelMessages.getFormattedString("status.IOException"); //$NON-NLS-1$
|
||||||
|
@ -243,9 +251,8 @@ public class CModelStatus extends Status implements ICModelStatus, ICModelStatus
|
||||||
}
|
}
|
||||||
if (fString != null) {
|
if (fString != null) {
|
||||||
return fString;
|
return fString;
|
||||||
} else {
|
|
||||||
return CoreModelMessages.getFormattedString("status.nameCollision", sb.toString()); //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
}
|
}
|
||||||
|
return CoreModelMessages.getFormattedString("status.nameCollision", sb.toString()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
|
||||||
case NO_ELEMENTS_TO_PROCESS:
|
case NO_ELEMENTS_TO_PROCESS:
|
||||||
return CoreModelMessages.getFormattedString("operation.needElements"); //$NON-NLS-1$
|
return CoreModelMessages.getFormattedString("operation.needElements"); //$NON-NLS-1$
|
||||||
|
@ -289,14 +296,12 @@ public class CModelStatus extends Status implements ICModelStatus, ICModelStatus
|
||||||
|
|
||||||
}
|
}
|
||||||
return getString();
|
return getString();
|
||||||
} else {
|
|
||||||
String message = exception.getMessage();
|
|
||||||
if (message != null) {
|
|
||||||
return message;
|
|
||||||
} else {
|
|
||||||
return exception.toString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
String message = exception.getMessage();
|
||||||
|
if (message != null) {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
return exception.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -368,13 +373,12 @@ public class CModelStatus extends Status implements ICModelStatus, ICModelStatus
|
||||||
public boolean matches(int mask) {
|
public boolean matches(int mask) {
|
||||||
if (! isMultiStatus()) {
|
if (! isMultiStatus()) {
|
||||||
return matches(this, mask);
|
return matches(this, mask);
|
||||||
} else {
|
|
||||||
for (int i = 0, max = fChildren.length; i < max; i++) {
|
|
||||||
if (matches((CModelStatus) fChildren[i], mask))
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
for (int i = 0, max = fChildren.length; i < max; i++) {
|
||||||
|
if (matches((CModelStatus) fChildren[i], mask))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -399,6 +403,18 @@ public class CModelStatus extends Status implements ICModelStatus, ICModelStatus
|
||||||
return jms;
|
return jms;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates and returns a new <code>ICModelStatus</code> that is a
|
||||||
|
* a multi-status status.
|
||||||
|
*
|
||||||
|
* @see IStatus#.isMultiStatus()
|
||||||
|
*/
|
||||||
|
public static ICModelStatus newMultiStatus(int code, ICModelStatus[] children) {
|
||||||
|
CModelStatus jms = new CModelStatus(code);
|
||||||
|
jms.fChildren = children;
|
||||||
|
return jms;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a printable representation of this exception for debugging
|
* Returns a printable representation of this exception for debugging
|
||||||
* purposes.
|
* purposes.
|
||||||
|
|
|
@ -12,8 +12,10 @@ package org.eclipse.cdt.internal.core.model;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.ICDescriptor;
|
import org.eclipse.cdt.core.ICDescriptor;
|
||||||
|
@ -176,7 +178,25 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
listEntries.trimToSize();
|
listEntries.trimToSize();
|
||||||
|
|
||||||
resolvedEntries = (IPathEntry[])listEntries.toArray(NO_PATHENTRIES);
|
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[])listEntries.toArray(NO_PATHENTRIES);
|
||||||
|
@ -197,7 +217,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
createPathEntryProblemMarker(project, status);
|
createPathEntryProblemMarker(project, status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return CModelStatus.OK_STATUS;
|
return Status.OK_STATUS;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
markerTask.schedule();
|
markerTask.schedule();
|
||||||
|
@ -1161,6 +1181,30 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check duplication of sources
|
||||||
|
List dups = checkForSourceDuplication(entries);
|
||||||
|
if (dups.size() > 0) {
|
||||||
|
ICModelStatus[] cmodelStatus = new ICModelStatus[dups.size()];
|
||||||
|
for (int i = 0; i < dups.size(); ++i) {
|
||||||
|
StringBuffer errMesg = new StringBuffer(CCorePlugin.getResourceString("CoreModel.PathEntry.DuplicateEntry")); //$NON-NLS-1$
|
||||||
|
errMesg.append(':').append(dups.get(i).toString());
|
||||||
|
cmodelStatus[i] = new CModelStatus(ICModelStatusConstants.INVALID_PATHENTRY, errMesg.toString());
|
||||||
|
}
|
||||||
|
return CModelStatus.newMultiStatus(ICModelStatusConstants.INVALID_PATHENTRY, cmodelStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
// check duplication of Outputs
|
||||||
|
dups = checkForOutputDuplication(entries);
|
||||||
|
if (dups.size() > 0) {
|
||||||
|
ICModelStatus[] cmodelStatus = new ICModelStatus[dups.size()];
|
||||||
|
for (int i = 0; i < dups.size(); ++i) {
|
||||||
|
StringBuffer errMesg = new StringBuffer(CCorePlugin.getResourceString("CoreModel.PathEntry.DuplicateEntry")); //$NON-NLS-1$
|
||||||
|
errMesg.append(':').append(dups.get(i).toString());
|
||||||
|
cmodelStatus[i] = new CModelStatus(ICModelStatusConstants.NAME_COLLISION, errMesg.toString());
|
||||||
|
}
|
||||||
|
return CModelStatus.newMultiStatus(ICModelStatusConstants.INVALID_PATHENTRY, cmodelStatus);
|
||||||
|
}
|
||||||
|
|
||||||
// allow nesting source entries in each other as long as the outer entry excludes the inner one
|
// allow nesting source entries in each other as long as the outer entry excludes the inner one
|
||||||
for (int i = 0; i < entries.length; i++) {
|
for (int i = 0; i < entries.length; i++) {
|
||||||
IPathEntry entry = entries[i];
|
IPathEntry entry = entries[i];
|
||||||
|
@ -1187,17 +1231,15 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
StringBuffer errMesg = new StringBuffer(CCorePlugin.getResourceString("CoreModel.PathEntry.NestedEntry")); //$NON-NLS-1$
|
StringBuffer errMesg = new StringBuffer(CCorePlugin.getResourceString("CoreModel.PathEntry.NestedEntry")); //$NON-NLS-1$
|
||||||
errMesg.append(':').append(entry.toString());
|
errMesg.append(':').append(entry.toString());
|
||||||
return new CModelStatus(ICModelStatusConstants.INVALID_PATHENTRY, errMesg.toString());
|
return new CModelStatus(ICModelStatusConstants.INVALID_PATHENTRY, errMesg.toString());
|
||||||
|
} else if (otherKind == IPathEntry.CDT_SOURCE) {
|
||||||
|
exclusionPattern += '/';
|
||||||
|
StringBuffer errMesg = new StringBuffer(CCorePlugin.getResourceString("CoreModel.PathEntry.NestedEntry")); //$NON-NLS-1$
|
||||||
|
errMesg.append(':').append(entry.toString());
|
||||||
|
return new CModelStatus(ICModelStatusConstants.INVALID_PATHENTRY, errMesg.toString());
|
||||||
} else {
|
} else {
|
||||||
if (otherKind == IPathEntry.CDT_SOURCE) {
|
StringBuffer errMesg = new StringBuffer(CCorePlugin.getResourceString("CoreModel.PathEntry.NestedEntry")); //$NON-NLS-1$
|
||||||
exclusionPattern += '/';
|
errMesg.append(':').append(entry.toString());
|
||||||
StringBuffer errMesg = new StringBuffer(CCorePlugin.getResourceString("CoreModel.PathEntry.NestedEntry")); //$NON-NLS-1$
|
return new CModelStatus(ICModelStatusConstants.INVALID_PATHENTRY, errMesg.toString()); //$NON-NLS-1$
|
||||||
errMesg.append(':').append(entry.toString());
|
|
||||||
return new CModelStatus(ICModelStatusConstants.INVALID_PATHENTRY, errMesg.toString());
|
|
||||||
} else {
|
|
||||||
StringBuffer errMesg = new StringBuffer(CCorePlugin.getResourceString("CoreModel.PathEntry.NestedEntry")); //$NON-NLS-1$
|
|
||||||
errMesg.append(':').append(entry.toString());
|
|
||||||
return new CModelStatus(ICModelStatusConstants.INVALID_PATHENTRY, errMesg.toString()); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1336,6 +1378,52 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
return false;
|
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())) {
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return duplicate;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Record a new marker denoting a classpath problem
|
* Record a new marker denoting a classpath problem
|
||||||
*/
|
*/
|
||||||
|
@ -1351,7 +1439,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
case ICModelStatusConstants.INVALID_PATH:
|
case ICModelStatusConstants.INVALID_PATH:
|
||||||
severity = IMarker.SEVERITY_WARNING;
|
severity = IMarker.SEVERITY_WARNING;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
severity = IMarker.SEVERITY_ERROR;
|
severity = IMarker.SEVERITY_ERROR;
|
||||||
break;
|
break;
|
||||||
|
@ -1367,7 +1455,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
ICModelMarker.PATHENTRY_FILE_FORMAT,
|
ICModelMarker.PATHENTRY_FILE_FORMAT,
|
||||||
},
|
},
|
||||||
new Object[] {
|
new Object[] {
|
||||||
status.getString(),
|
status.getMessage(),
|
||||||
new Integer(severity),
|
new Integer(severity),
|
||||||
"pathentry",//$NON-NLS-1$
|
"pathentry",//$NON-NLS-1$
|
||||||
"false",//$NON-NLS-1$
|
"false",//$NON-NLS-1$
|
||||||
|
|
Loading…
Add table
Reference in a new issue