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

- improved path marker messages to be more informative

- improved validation method.
This commit is contained in:
David Inglis 2004-08-26 18:54:05 +00:00
parent 91bf21d039
commit 6eff3a3a90
4 changed files with 422 additions and 368 deletions

View file

@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.model;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICModelStatus;
@ -29,14 +28,15 @@ import org.eclipse.core.runtime.Status;
public class CModelStatus extends Status implements ICModelStatus, ICModelStatusConstants, IResourceStatus {
/**
* The elements related to the failure, or <code>null</code>
* if no elements are involved.
* The elements related to the failure, or <code>null</code> if no
* elements are involved.
*/
protected ICElement[] fElements;
protected final static ICElement[] EmptyElement = new ICElement[] {};
protected final static ICElement[] EmptyElement = new ICElement[]{};
/**
* The path related to the failure, or <code>null</code>
* if no path is involved.
* The path related to the failure, or <code>null</code> if no path is
* involved.
*/
protected IPath fPath;
/**
@ -49,9 +49,9 @@ public class CModelStatus extends Status implements ICModelStatus, ICModelStatus
/**
* Empty children
*/
protected final static IStatus[] fgEmptyChildren = new IStatus[] {};
protected IStatus[] fChildren= fgEmptyChildren;
protected final static String DEFAULT_STRING= "CModelStatus"; //$NON-NLS-1$;
protected final static IStatus[] fgEmptyChildren = new IStatus[]{};
protected IStatus[] fChildren = fgEmptyChildren;
protected final static String DEFAULT_STRING = "CModelStatus"; //$NON-NLS-1$;
/**
* Singleton OK object
@ -74,13 +74,12 @@ public class CModelStatus extends Status implements ICModelStatus, ICModelStatus
}
/**
* Constructs an C model status with the given corresponding
* elements.
* Constructs an C model status with the given corresponding elements.
*/
public CModelStatus(int code, ICElement[] elements) {
super(ERROR, CCorePlugin.PLUGIN_ID, code, DEFAULT_STRING, null);
fElements = elements;
fPath= Path.EMPTY;
fPath = Path.EMPTY;
}
/**
@ -93,9 +92,9 @@ public class CModelStatus extends Status implements ICModelStatus, ICModelStatus
public CModelStatus(int severity, int code, String string) {
super(severity, CCorePlugin.PLUGIN_ID, code, DEFAULT_STRING, null);
fElements = CElement.NO_ELEMENTS;
fPath= Path.EMPTY;
fPath = Path.EMPTY;
fString = string;
}
}
/**
* Constructs an C model status with no corresponding elements.
@ -103,30 +102,29 @@ public class CModelStatus extends Status implements ICModelStatus, ICModelStatus
public CModelStatus(int code, IPath path) {
super(ERROR, CCorePlugin.PLUGIN_ID, code, DEFAULT_STRING, null);
fElements = CElement.NO_ELEMENTS;
fPath= path;
fPath = path;
}
/**
* Constructs an C model status with the given corresponding
* element.
* Constructs an C model status with the given corresponding element.
*/
public CModelStatus(int code, ICElement element) {
this(code, new ICElement[]{element});
}
/**
* Constructs an C model status with the given corresponding
* element and string
* Constructs an C model status with the given corresponding element and
* string
*/
public CModelStatus(int code, ICElement element, String string) {
this(code, new ICElement[]{element});
fString= string;
fString = string;
}
public CModelStatus(int code, ICElement element, IPath path) {
this(code, new ICElement[]{element});
fPath = path;
}
}
/**
* Constructs an C model status with no corresponding elements.
@ -146,7 +144,7 @@ public class CModelStatus extends Status implements ICModelStatus, ICModelStatus
protected int getBits() {
int severity = 1 << (getCode() % 100 / 33);
int category = 1 << ((getCode() / 100) + 3);
int category = 1 << ( (getCode() / 100) + 3);
return severity | category;
}
@ -184,66 +182,66 @@ public class CModelStatus extends Status implements ICModelStatus, ICModelStatus
case CORE_EXCEPTION :
return CoreModelMessages.getFormattedString("status.coreException"); //$NON-NLS-1$
case DEVICE_PATH:
case DEVICE_PATH :
return CoreModelMessages.getFormattedString("status.cannotUseDeviceOnPath", getPath().toString()); //$NON-NLS-1$
case PARSER_EXCEPTION:
case PARSER_EXCEPTION :
return CoreModelMessages.getFormattedString("status.ParserError"); //$NON-NLS-1$
case ELEMENT_DOES_NOT_EXIST:
case ELEMENT_DOES_NOT_EXIST :
return CoreModelMessages.getFormattedString("element.doesNotExist", getFirstElementName()); //$NON-NLS-1$
case EVALUATION_ERROR:
case EVALUATION_ERROR :
return CoreModelMessages.getFormattedString("status.evaluationError", getString()); //$NON-NLS-1$
case INDEX_OUT_OF_BOUNDS:
case INDEX_OUT_OF_BOUNDS :
return CoreModelMessages.getFormattedString("status.indexOutOfBounds"); //$NON-NLS-1$
case INVALID_CONTENTS:
case INVALID_CONTENTS :
return CoreModelMessages.getFormattedString("status.invalidContents"); //$NON-NLS-1$
case INVALID_DESTINATION:
case INVALID_DESTINATION :
return CoreModelMessages.getFormattedString("status.invalidDestination", getFirstElementName()); //$NON-NLS-1$
case INVALID_ELEMENT_TYPES:
StringBuffer buff= new StringBuffer(CoreModelMessages.getFormattedString("operation.notSupported")); //$NON-NLS-1$
case INVALID_ELEMENT_TYPES :
StringBuffer buff = new StringBuffer(CoreModelMessages.getFormattedString("operation.notSupported")); //$NON-NLS-1$
for (int i = 0; i < fElements.length; i++) {
if (i > 0) {
buff.append(", "); //$NON-NLS-1$
}
buff.append((fElements[i]).toString());
buff.append( (fElements[i]).toString());
}
return buff.toString();
case INVALID_NAME:
case INVALID_NAME :
return CoreModelMessages.getFormattedString("status.invalidName", getString()); //$NON-NLS-1$
case INVALID_PATH:
if (fString != null) {
return fString;
}
return CoreModelMessages.getFormattedString("status.invalidPath", getPath() == null ? "null" : getPath().toString()); //$NON-NLS-1$ //$NON-NLS-2$
case INVALID_PATH :
String path = getPath() == null ? "null" : getPath().toString(); //$NON-NLS-1$
return CoreModelMessages.getFormattedString("status.invalidPath", new Object[]{path, getString()}); //$NON-NLS-1$
case INVALID_PROJECT:
case INVALID_PATHENTRY :
return CoreModelMessages.getFormattedString("status.invalidPathEntry", getString()); //$NON-NLS-1$
case INVALID_PROJECT :
return CoreModelMessages.getFormattedString("status.invalidProject", getString()); //$NON-NLS-1$
case INVALID_RESOURCE:
case INVALID_RESOURCE :
return CoreModelMessages.getFormattedString("status.invalidResource", getString()); //$NON-NLS-1$
case INVALID_RESOURCE_TYPE:
case INVALID_RESOURCE_TYPE :
return CoreModelMessages.getFormattedString("status.invalidResourceType", getString()); //$NON-NLS-1$
case INVALID_SIBLING:
case INVALID_SIBLING :
if (fString != null) {
return CoreModelMessages.getFormattedString("status.invalidSibling", getString()); //$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$
case NAME_COLLISION:
case NAME_COLLISION :
StringBuffer sb = new StringBuffer();
if (fElements != null && fElements.length > 0) {
ICElement element = fElements[0];
@ -254,46 +252,44 @@ public class CModelStatus extends Status implements ICModelStatus, ICModelStatus
}
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$
case NULL_NAME:
case NULL_NAME :
return CoreModelMessages.getFormattedString("operation.needName"); //$NON-NLS-1$
case NULL_PATH:
case NULL_PATH :
return CoreModelMessages.getFormattedString("operation.needPath"); //$NON-NLS-1$
case NULL_STRING:
case NULL_STRING :
return CoreModelMessages.getFormattedString("operation.needString"); //$NON-NLS-1$
case PATH_OUTSIDE_PROJECT:
return CoreModelMessages.getFormattedString("operation.pathOutsideProject", new String[]{getString(), getFirstElementName()}); //$NON-NLS-1$
case PATH_OUTSIDE_PROJECT :
return CoreModelMessages.getFormattedString(
"operation.pathOutsideProject", new String[]{getString(), getFirstElementName()}); //$NON-NLS-1$
case READ_ONLY:
case READ_ONLY :
return CoreModelMessages.getFormattedString("status.readOnly", getFirstElementName()); //$NON-NLS-1$
case RELATIVE_PATH:
case RELATIVE_PATH :
return CoreModelMessages.getFormattedString("operation.needAbsolutePath", getPath().toString()); //$NON-NLS-1$
case UPDATE_CONFLICT:
case UPDATE_CONFLICT :
return CoreModelMessages.getFormattedString("status.updateConflict"); //$NON-NLS-1$
case NO_LOCAL_CONTENTS :
return CoreModelMessages.getFormattedString("status.noLocalContents", getPath().toString()); //$NON-NLS-1$
case INVALID_CONTAINER_ENTRY:
return CoreModelMessages.getFormattedString("pathentry.invalidContainer", new String[] {getString(), getFirstElementName()}); //$NON-NLS-1$
case INVALID_CONTAINER_ENTRY :
return CoreModelMessages.getFormattedString(
"pathentry.invalidContainer", new String[]{getString(), getFirstElementName()}); //$NON-NLS-1$
case VARIABLE_PATH_UNBOUND:
return CoreModelMessages.getFormattedString("pathentry.unboundVariablePath",
new String[] {getPath().makeRelative().toString(), getFirstElementName()}); //$NON-NLS-1$
case PATHENTRY_CYCLE:
return CoreModelMessages.getFormattedString("pathentry.cycle", getFirstElementName()); //$NON-NLS-1$
//case DISABLED_CP_EXCLUSION_PATTERNS:
//case DISABLED_CP_MULTIPLE_OUTPUT_LOCATIONS:
case VARIABLE_PATH_UNBOUND :
return CoreModelMessages.getFormattedString("pathentry.unboundVariablePath", //$NON-NLS-1$
new String[]{getPath().makeRelative().toString(), getFirstElementName()});
case PATHENTRY_CYCLE :
return CoreModelMessages.getFormattedString("pathentry.cycle", getFirstElementName()); //$NON-NLS-1$
}
return getString();
}
@ -318,7 +314,8 @@ public class CModelStatus extends Status implements ICModelStatus, ICModelStatus
* @see IStatus
*/
public int getSeverity() {
if (fChildren == fgEmptyChildren) return super.getSeverity();
if (fChildren == fgEmptyChildren)
return super.getSeverity();
int severity = -1;
for (int i = 0, max = fChildren.length; i < max; i++) {
int childrenSeverity = fChildren[i].getSeverity();
@ -362,7 +359,7 @@ public class CModelStatus extends Status implements ICModelStatus, ICModelStatus
/**
* @see ICModelStatus
*/
*/
public boolean isOK() {
return getCode() == OK;
}
@ -371,11 +368,11 @@ public class CModelStatus extends Status implements ICModelStatus, ICModelStatus
* @see IStatus#matches
*/
public boolean matches(int mask) {
if (! isMultiStatus()) {
if (!isMultiStatus()) {
return matches(this, mask);
}
for (int i = 0, max = fChildren.length; i < max; i++) {
if (matches((CModelStatus) fChildren[i], mask))
if (matches((CModelStatus)fChildren[i], mask))
return true;
}
return false;
@ -388,13 +385,13 @@ public class CModelStatus extends Status implements ICModelStatus, ICModelStatus
int severityMask = mask & 0x7;
int categoryMask = mask & ~0x7;
int bits = status.getBits();
return ((severityMask == 0) || (bits & severityMask) != 0) && ((categoryMask == 0) || (bits & categoryMask) != 0);
return ( (severityMask == 0) || (bits & severityMask) != 0) && ( (categoryMask == 0) || (bits & categoryMask) != 0);
}
/**
* Creates and returns a new <code>ICModelStatus</code> that is a
* a multi-status status.
*
* Creates and returns a new <code>ICModelStatus</code> that is a a
* multi-status status.
*
* @see IStatus#.isMultiStatus()
*/
public static ICModelStatus newMultiStatus(ICModelStatus[] children) {
@ -404,9 +401,9 @@ public class CModelStatus extends Status implements ICModelStatus, ICModelStatus
}
/**
* Creates and returns a new <code>ICModelStatus</code> that is a
* a multi-status status.
*
* 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) {
@ -420,7 +417,7 @@ public class CModelStatus extends Status implements ICModelStatus, ICModelStatus
* purposes.
*/
public String toString() {
if (this == VERIFIED_OK){
if (this == VERIFIED_OK) {
return "CModelStatus[OK]"; //$NON-NLS-1$
}
StringBuffer buffer = new StringBuffer();
@ -429,4 +426,4 @@ public class CModelStatus extends Status implements ICModelStatus, ICModelStatus
buffer.append("]"); //$NON-NLS-1$
return buffer.toString();
}
}
}

View file

@ -58,6 +58,7 @@ status.invalidName = Invalid name specified: {0}.
status.invalidPackage = Invalid package: {0}.
status.invalidPath = Invalid path: ''{0}''.
status.invalidProject = Invalid project: {0}.
status.invalidPathEntry = Invalid project path: {0}.
status.invalidResource = Invalid resource: {0}.
status.invalidResourceType = Invalid resource type for {0}.
status.invalidSibling = Invalid sibling: {0}.
@ -68,3 +69,11 @@ status.readOnly = {0} is read-only.
status.targetException = Target exception.
status.updateConflict = Update conflict.
PathEntryManager.0=Missing project folder or file:
PathEntryManager.2=Include path not found
PathEntryManager.3=Source attachment not found
PathEntryManager.4=Library not found
PathEntryManager.5=Referenced project is not accessible
PathEntryManager.6=Referenced project is not a C/C++ project
PathEntryManager.1=Workspace include path in accessible
PathEntryManager.7=Workspace library path in accessible

View file

@ -1,13 +1,11 @@
/*******************************************************************************
* Copyright (c) 2000, 2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
* Copyright (c) 2000, 2004 QNX Software Systems and others. All rights
* reserved. This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0 which accompanies this
* distribution, and is available at http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
*******************************************************************************/
* Contributors: QNX Software Systems - Initial API and implementation
******************************************************************************/
package org.eclipse.cdt.internal.core.model;
import org.eclipse.cdt.core.model.IPathEntry;
@ -26,21 +24,27 @@ public class PathEntry implements IPathEntry {
this.isExported = isExported;
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.IPathEntry#getEntryKind()
*/
public IPath getPath() {
return path;
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.IPathEntry#getEntryKind()
*/
public int getEntryKind() {
return entryKind;
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.IPathEntry#isExported()
*/
public boolean isExported() {
@ -106,7 +110,7 @@ public class PathEntry implements IPathEntry {
return "mac"; //$NON-NLS-1$
case IPathEntry.CDT_CONTAINER :
return "con"; //$NON-NLS-1$
case IPathEntry.CDT_OUTPUT:
case IPathEntry.CDT_OUTPUT :
return "out"; //$NON-NLS-1$
default :
return "unknown"; //$NON-NLS-1$
@ -122,31 +126,28 @@ public class PathEntry implements IPathEntry {
buffer.append(path.toString()).append(' ');
}
buffer.append('[');
switch (getEntryKind()) {
case IPathEntry.CDT_LIBRARY :
buffer.append("CDT_LIBRARY"); //$NON-NLS-1$
break;
case IPathEntry.CDT_PROJECT :
buffer.append("CDT_PROJECT"); //$NON-NLS-1$
break;
case IPathEntry.CDT_SOURCE :
buffer.append("CDT_SOURCE"); //$NON-NLS-1$
break;
case IPathEntry.CDT_OUTPUT :
buffer.append("CDT_OUTPUT"); //$NON-NLS-1$
break;
case IPathEntry.CDT_INCLUDE :
buffer.append("CDT_INCLUDE"); //$NON-NLS-1$
break;
case IPathEntry.CDT_MACRO :
buffer.append("CDT_MACRO"); //$NON-NLS-1$
break;
case IPathEntry.CDT_CONTAINER :
buffer.append("CDT_CONTAINER"); //$NON-NLS-1$
break;
}
buffer.append(getKindString());
buffer.append(']');
return buffer.toString();
}
}
String getKindString() {
switch (getEntryKind()) {
case IPathEntry.CDT_LIBRARY :
return ("Library path"); //$NON-NLS-1$
case IPathEntry.CDT_PROJECT :
return ("Project path"); //$NON-NLS-1$
case IPathEntry.CDT_SOURCE :
return ("Source path"); //$NON-NLS-1$
case IPathEntry.CDT_OUTPUT :
return ("Output path"); //$NON-NLS-1$
case IPathEntry.CDT_INCLUDE :
return ("Include path"); //$NON-NLS-1$
case IPathEntry.CDT_MACRO :
return ("Symbol definition"); //$NON-NLS-1$
case IPathEntry.CDT_CONTAINER :
return ("Contributed paths"); //$NON-NLS-1$
}
return ("Unknown"); //$NON-NLS-1$
}
}