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:
parent
91bf21d039
commit
6eff3a3a90
4 changed files with 422 additions and 368 deletions
|
@ -10,7 +10,6 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.model;
|
package org.eclipse.cdt.internal.core.model;
|
||||||
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.ICModelStatus;
|
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 {
|
public class CModelStatus extends Status implements ICModelStatus, ICModelStatusConstants, IResourceStatus {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The elements related to the failure, or <code>null</code>
|
* The elements related to the failure, or <code>null</code> if no
|
||||||
* if no elements are involved.
|
* elements are involved.
|
||||||
*/
|
*/
|
||||||
protected ICElement[] fElements;
|
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>
|
* The path related to the failure, or <code>null</code> if no path is
|
||||||
* if no path is involved.
|
* involved.
|
||||||
*/
|
*/
|
||||||
protected IPath fPath;
|
protected IPath fPath;
|
||||||
/**
|
/**
|
||||||
|
@ -74,8 +74,7 @@ public class CModelStatus extends Status implements ICModelStatus, ICModelStatus
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs an C model status with the given corresponding
|
* Constructs an C model status with the given corresponding elements.
|
||||||
* elements.
|
|
||||||
*/
|
*/
|
||||||
public CModelStatus(int code, ICElement[] elements) {
|
public CModelStatus(int code, ICElement[] elements) {
|
||||||
super(ERROR, CCorePlugin.PLUGIN_ID, code, DEFAULT_STRING, null);
|
super(ERROR, CCorePlugin.PLUGIN_ID, code, DEFAULT_STRING, null);
|
||||||
|
@ -107,16 +106,15 @@ public class CModelStatus extends Status implements ICModelStatus, ICModelStatus
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs an C model status with the given corresponding
|
* Constructs an C model status with the given corresponding element.
|
||||||
* element.
|
|
||||||
*/
|
*/
|
||||||
public CModelStatus(int code, ICElement element) {
|
public CModelStatus(int code, ICElement element) {
|
||||||
this(code, new ICElement[]{element});
|
this(code, new ICElement[]{element});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs an C model status with the given corresponding
|
* Constructs an C model status with the given corresponding element and
|
||||||
* element and string
|
* string
|
||||||
*/
|
*/
|
||||||
public CModelStatus(int code, ICElement element, String string) {
|
public CModelStatus(int code, ICElement element, String string) {
|
||||||
this(code, new ICElement[]{element});
|
this(code, new ICElement[]{element});
|
||||||
|
@ -184,7 +182,6 @@ public class CModelStatus extends Status implements ICModelStatus, ICModelStatus
|
||||||
case CORE_EXCEPTION :
|
case CORE_EXCEPTION :
|
||||||
return CoreModelMessages.getFormattedString("status.coreException"); //$NON-NLS-1$
|
return CoreModelMessages.getFormattedString("status.coreException"); //$NON-NLS-1$
|
||||||
|
|
||||||
|
|
||||||
case DEVICE_PATH :
|
case DEVICE_PATH :
|
||||||
return CoreModelMessages.getFormattedString("status.cannotUseDeviceOnPath", getPath().toString()); //$NON-NLS-1$
|
return CoreModelMessages.getFormattedString("status.cannotUseDeviceOnPath", getPath().toString()); //$NON-NLS-1$
|
||||||
|
|
||||||
|
@ -220,10 +217,11 @@ public class CModelStatus extends Status implements ICModelStatus, ICModelStatus
|
||||||
return CoreModelMessages.getFormattedString("status.invalidName", getString()); //$NON-NLS-1$
|
return CoreModelMessages.getFormattedString("status.invalidName", getString()); //$NON-NLS-1$
|
||||||
|
|
||||||
case INVALID_PATH :
|
case INVALID_PATH :
|
||||||
if (fString != null) {
|
String path = getPath() == null ? "null" : getPath().toString(); //$NON-NLS-1$
|
||||||
return fString;
|
return CoreModelMessages.getFormattedString("status.invalidPath", new Object[]{path, getString()}); //$NON-NLS-1$
|
||||||
}
|
|
||||||
return CoreModelMessages.getFormattedString("status.invalidPath", getPath() == null ? "null" : getPath().toString()); //$NON-NLS-1$ //$NON-NLS-2$
|
case INVALID_PATHENTRY :
|
||||||
|
return CoreModelMessages.getFormattedString("status.invalidPathEntry", getString()); //$NON-NLS-1$
|
||||||
|
|
||||||
case INVALID_PROJECT :
|
case INVALID_PROJECT :
|
||||||
return CoreModelMessages.getFormattedString("status.invalidProject", getString()); //$NON-NLS-1$
|
return CoreModelMessages.getFormattedString("status.invalidProject", getString()); //$NON-NLS-1$
|
||||||
|
@ -267,7 +265,8 @@ public class CModelStatus extends Status implements ICModelStatus, ICModelStatus
|
||||||
return CoreModelMessages.getFormattedString("operation.needString"); //$NON-NLS-1$
|
return CoreModelMessages.getFormattedString("operation.needString"); //$NON-NLS-1$
|
||||||
|
|
||||||
case PATH_OUTSIDE_PROJECT :
|
case PATH_OUTSIDE_PROJECT :
|
||||||
return CoreModelMessages.getFormattedString("operation.pathOutsideProject", new String[]{getString(), getFirstElementName()}); //$NON-NLS-1$
|
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$
|
return CoreModelMessages.getFormattedString("status.readOnly", getFirstElementName()); //$NON-NLS-1$
|
||||||
|
@ -282,18 +281,15 @@ public class CModelStatus extends Status implements ICModelStatus, ICModelStatus
|
||||||
return CoreModelMessages.getFormattedString("status.noLocalContents", getPath().toString()); //$NON-NLS-1$
|
return CoreModelMessages.getFormattedString("status.noLocalContents", getPath().toString()); //$NON-NLS-1$
|
||||||
|
|
||||||
case INVALID_CONTAINER_ENTRY :
|
case INVALID_CONTAINER_ENTRY :
|
||||||
return CoreModelMessages.getFormattedString("pathentry.invalidContainer", new String[] {getString(), getFirstElementName()}); //$NON-NLS-1$
|
return CoreModelMessages.getFormattedString(
|
||||||
|
"pathentry.invalidContainer", new String[]{getString(), getFirstElementName()}); //$NON-NLS-1$
|
||||||
|
|
||||||
case VARIABLE_PATH_UNBOUND :
|
case VARIABLE_PATH_UNBOUND :
|
||||||
return CoreModelMessages.getFormattedString("pathentry.unboundVariablePath",
|
return CoreModelMessages.getFormattedString("pathentry.unboundVariablePath", //$NON-NLS-1$
|
||||||
new String[] {getPath().makeRelative().toString(), getFirstElementName()}); //$NON-NLS-1$
|
new String[]{getPath().makeRelative().toString(), getFirstElementName()});
|
||||||
|
|
||||||
case PATHENTRY_CYCLE :
|
case PATHENTRY_CYCLE :
|
||||||
return CoreModelMessages.getFormattedString("pathentry.cycle", getFirstElementName()); //$NON-NLS-1$
|
return CoreModelMessages.getFormattedString("pathentry.cycle", getFirstElementName()); //$NON-NLS-1$
|
||||||
|
|
||||||
//case DISABLED_CP_EXCLUSION_PATTERNS:
|
|
||||||
//case DISABLED_CP_MULTIPLE_OUTPUT_LOCATIONS:
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return getString();
|
return getString();
|
||||||
}
|
}
|
||||||
|
@ -318,7 +314,8 @@ public class CModelStatus extends Status implements ICModelStatus, ICModelStatus
|
||||||
* @see IStatus
|
* @see IStatus
|
||||||
*/
|
*/
|
||||||
public int getSeverity() {
|
public int getSeverity() {
|
||||||
if (fChildren == fgEmptyChildren) return super.getSeverity();
|
if (fChildren == fgEmptyChildren)
|
||||||
|
return super.getSeverity();
|
||||||
int severity = -1;
|
int severity = -1;
|
||||||
for (int i = 0, max = fChildren.length; i < max; i++) {
|
for (int i = 0, max = fChildren.length; i < max; i++) {
|
||||||
int childrenSeverity = fChildren[i].getSeverity();
|
int childrenSeverity = fChildren[i].getSeverity();
|
||||||
|
@ -392,8 +389,8 @@ public class CModelStatus extends Status implements ICModelStatus, ICModelStatus
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and returns a new <code>ICModelStatus</code> that is a
|
* Creates and returns a new <code>ICModelStatus</code> that is a a
|
||||||
* a multi-status status.
|
* multi-status status.
|
||||||
*
|
*
|
||||||
* @see IStatus#.isMultiStatus()
|
* @see IStatus#.isMultiStatus()
|
||||||
*/
|
*/
|
||||||
|
@ -404,8 +401,8 @@ public class CModelStatus extends Status implements ICModelStatus, ICModelStatus
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and returns a new <code>ICModelStatus</code> that is a
|
* Creates and returns a new <code>ICModelStatus</code> that is a a
|
||||||
* a multi-status status.
|
* multi-status status.
|
||||||
*
|
*
|
||||||
* @see IStatus#.isMultiStatus()
|
* @see IStatus#.isMultiStatus()
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -58,6 +58,7 @@ status.invalidName = Invalid name specified: {0}.
|
||||||
status.invalidPackage = Invalid package: {0}.
|
status.invalidPackage = Invalid package: {0}.
|
||||||
status.invalidPath = Invalid path: ''{0}''.
|
status.invalidPath = Invalid path: ''{0}''.
|
||||||
status.invalidProject = Invalid project: {0}.
|
status.invalidProject = Invalid project: {0}.
|
||||||
|
status.invalidPathEntry = Invalid project path: {0}.
|
||||||
status.invalidResource = Invalid resource: {0}.
|
status.invalidResource = Invalid resource: {0}.
|
||||||
status.invalidResourceType = Invalid resource type for {0}.
|
status.invalidResourceType = Invalid resource type for {0}.
|
||||||
status.invalidSibling = Invalid sibling: {0}.
|
status.invalidSibling = Invalid sibling: {0}.
|
||||||
|
@ -68,3 +69,11 @@ status.readOnly = {0} is read-only.
|
||||||
status.targetException = Target exception.
|
status.targetException = Target exception.
|
||||||
status.updateConflict = Update conflict.
|
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
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2000, 2004 QNX Software Systems and others.
|
* Copyright (c) 2000, 2004 QNX Software Systems and others. All rights
|
||||||
* All rights reserved. This program and the accompanying materials
|
* reserved. This program and the accompanying materials are made available
|
||||||
* are made available under the terms of the Common Public License v1.0
|
* under the terms of the Common Public License v1.0 which accompanies this
|
||||||
* which accompanies this distribution, and is available at
|
* distribution, and is available at http://www.eclipse.org/legal/cpl-v10.html
|
||||||
* http://www.eclipse.org/legal/cpl-v10.html
|
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors: QNX Software Systems - Initial API and implementation
|
||||||
* QNX Software Systems - Initial API and implementation
|
******************************************************************************/
|
||||||
*******************************************************************************/
|
|
||||||
package org.eclipse.cdt.internal.core.model;
|
package org.eclipse.cdt.internal.core.model;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.IPathEntry;
|
import org.eclipse.cdt.core.model.IPathEntry;
|
||||||
|
@ -26,21 +24,27 @@ public class PathEntry implements IPathEntry {
|
||||||
this.isExported = isExported;
|
this.isExported = isExported;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see org.eclipse.cdt.core.IPathEntry#getEntryKind()
|
* @see org.eclipse.cdt.core.IPathEntry#getEntryKind()
|
||||||
*/
|
*/
|
||||||
public IPath getPath() {
|
public IPath getPath() {
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see org.eclipse.cdt.core.IPathEntry#getEntryKind()
|
* @see org.eclipse.cdt.core.IPathEntry#getEntryKind()
|
||||||
*/
|
*/
|
||||||
public int getEntryKind() {
|
public int getEntryKind() {
|
||||||
return entryKind;
|
return entryKind;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see org.eclipse.cdt.core.IPathEntry#isExported()
|
* @see org.eclipse.cdt.core.IPathEntry#isExported()
|
||||||
*/
|
*/
|
||||||
public boolean isExported() {
|
public boolean isExported() {
|
||||||
|
@ -122,31 +126,28 @@ public class PathEntry implements IPathEntry {
|
||||||
buffer.append(path.toString()).append(' ');
|
buffer.append(path.toString()).append(' ');
|
||||||
}
|
}
|
||||||
buffer.append('[');
|
buffer.append('[');
|
||||||
switch (getEntryKind()) {
|
buffer.append(getKindString());
|
||||||
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(']');
|
buffer.append(']');
|
||||||
return buffer.toString();
|
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$
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -17,6 +17,7 @@ import java.util.HashMap;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
import java.util.List;
|
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;
|
||||||
import org.eclipse.cdt.core.ICExtensionReference;
|
import org.eclipse.cdt.core.ICExtensionReference;
|
||||||
|
@ -50,6 +51,7 @@ import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.resources.IWorkspace;
|
import org.eclipse.core.resources.IWorkspace;
|
||||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||||
import org.eclipse.core.resources.IWorkspaceRunnable;
|
import org.eclipse.core.resources.IWorkspaceRunnable;
|
||||||
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IConfigurationElement;
|
import org.eclipse.core.runtime.IConfigurationElement;
|
||||||
import org.eclipse.core.runtime.IExtension;
|
import org.eclipse.core.runtime.IExtension;
|
||||||
|
@ -76,19 +78,20 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
|
|
||||||
static String CONTAINER_INITIALIZER_EXTPOINT_ID = "PathEntryContainerInitializer"; //$NON-NLS-1$
|
static String CONTAINER_INITIALIZER_EXTPOINT_ID = "PathEntryContainerInitializer"; //$NON-NLS-1$
|
||||||
/**
|
/**
|
||||||
* An empty array of strings indicating that a project doesn't have any prerequesite projects.
|
* An empty array of strings indicating that a project doesn't have any
|
||||||
|
* prerequesite projects.
|
||||||
*/
|
*/
|
||||||
static final String[] NO_PREREQUISITES = new String[0];
|
static final String[] NO_PREREQUISITES = new String[0];
|
||||||
/**
|
/**
|
||||||
* pathentry containers pool
|
* pathentry containers pool accessing the Container is done synch with the
|
||||||
* accessing the Container is done synch with the class
|
* class
|
||||||
*/
|
*/
|
||||||
private static HashMap Containers = new HashMap(5);
|
private static HashMap Containers = new HashMap(5);
|
||||||
|
|
||||||
static final IPathEntry[] NO_PATHENTRIES = new IPathEntry[0];
|
static final IPathEntry[] NO_PATHENTRIES = new IPathEntry[0];
|
||||||
|
|
||||||
// Synchronized the access of the cache entries.
|
// Synchronized the access of the cache entries.
|
||||||
private Map resolvedMap = new Hashtable();
|
protected Map resolvedMap = new Hashtable();
|
||||||
|
|
||||||
// Accessing the map is synch with the class
|
// Accessing the map is synch with the class
|
||||||
private Map storeMap = new HashMap();
|
private Map storeMap = new HashMap();
|
||||||
|
@ -109,21 +112,27 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
runInitializer = init;
|
runInitializer = init;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see org.eclipse.cdt.core.model.IPathEntryContainer#getPathEntries()
|
* @see org.eclipse.cdt.core.model.IPathEntryContainer#getPathEntries()
|
||||||
*/
|
*/
|
||||||
public IPathEntry[] getPathEntries() {
|
public IPathEntry[] getPathEntries() {
|
||||||
return NO_PATHENTRIES;
|
return NO_PATHENTRIES;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see org.eclipse.cdt.core.model.IPathEntryContainer#getDescription()
|
* @see org.eclipse.cdt.core.model.IPathEntryContainer#getDescription()
|
||||||
*/
|
*/
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return new String("Lock container"); //$NON-NLS-1$
|
return new String("Lock container"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see org.eclipse.cdt.core.model.IPathEntryContainer#getPath()
|
* @see org.eclipse.cdt.core.model.IPathEntryContainer#getPath()
|
||||||
*/
|
*/
|
||||||
public IPath getPath() {
|
public IPath getPath() {
|
||||||
|
@ -220,14 +229,18 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
IIncludeEntry refEntry = (IIncludeEntry)entries[i];
|
IIncludeEntry refEntry = (IIncludeEntry)entries[i];
|
||||||
if (refEntry.getIncludePath().equals(includePath)) {
|
if (refEntry.getIncludePath().equals(includePath)) {
|
||||||
IPath newBasePath = refEntry.getBasePath();
|
IPath newBasePath = refEntry.getBasePath();
|
||||||
// If the includePath is relative give a new basepath if none
|
// If the includePath is
|
||||||
|
// relative give a new basepath
|
||||||
|
// if none
|
||||||
if (!newBasePath.isAbsolute() && !includePath.isAbsolute()) {
|
if (!newBasePath.isAbsolute() && !includePath.isAbsolute()) {
|
||||||
IResource refRes;
|
IResource refRes;
|
||||||
if (!newBasePath.isEmpty()) {
|
if (!newBasePath.isEmpty()) {
|
||||||
refRes = cproject.getCModel().getWorkspace().getRoot().findMember(newBasePath);
|
refRes = cproject.getCModel().getWorkspace().getRoot().findMember(
|
||||||
|
newBasePath);
|
||||||
} else {
|
} else {
|
||||||
IPath refResPath = refEntry.getPath();
|
IPath refResPath = refEntry.getPath();
|
||||||
refRes = cproject.getCModel().getWorkspace().getRoot().findMember(refResPath);
|
refRes = cproject.getCModel().getWorkspace().getRoot().findMember(
|
||||||
|
refResPath);
|
||||||
}
|
}
|
||||||
if (refRes != null) {
|
if (refRes != null) {
|
||||||
if (refRes.getType() == IResource.FILE) {
|
if (refRes.getType() == IResource.FILE) {
|
||||||
|
@ -236,8 +249,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
newBasePath = refRes.getLocation().append(newBasePath);
|
newBasePath = refRes.getLocation().append(newBasePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return CoreModel.newIncludeEntry(includeEntry.getPath(),
|
return CoreModel.newIncludeEntry(includeEntry.getPath(), newBasePath, includePath);
|
||||||
newBasePath, includePath);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -325,14 +337,18 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
ILibraryEntry refEntry = (ILibraryEntry)entries[i];
|
ILibraryEntry refEntry = (ILibraryEntry)entries[i];
|
||||||
if (refEntry.getLibraryPath().equals(libraryPath)) {
|
if (refEntry.getLibraryPath().equals(libraryPath)) {
|
||||||
IPath newBasePath = refEntry.getBasePath();
|
IPath newBasePath = refEntry.getBasePath();
|
||||||
// If the libraryPath is relative give a new basepath if none
|
// If the libraryPath is
|
||||||
|
// relative give a new basepath
|
||||||
|
// if none
|
||||||
if (!newBasePath.isAbsolute() && !libraryPath.isAbsolute()) {
|
if (!newBasePath.isAbsolute() && !libraryPath.isAbsolute()) {
|
||||||
IResource refRes;
|
IResource refRes;
|
||||||
if (!newBasePath.isEmpty()) {
|
if (!newBasePath.isEmpty()) {
|
||||||
refRes = cproject.getCModel().getWorkspace().getRoot().findMember(newBasePath);
|
refRes = cproject.getCModel().getWorkspace().getRoot().findMember(
|
||||||
|
newBasePath);
|
||||||
} else {
|
} else {
|
||||||
IPath refResPath = refEntry.getPath();
|
IPath refResPath = refEntry.getPath();
|
||||||
refRes = cproject.getCModel().getWorkspace().getRoot().findMember(refResPath);
|
refRes = cproject.getCModel().getWorkspace().getRoot().findMember(
|
||||||
|
refResPath);
|
||||||
}
|
}
|
||||||
if (refRes != null) {
|
if (refRes != null) {
|
||||||
if (refRes.getType() == IResource.FILE) {
|
if (refRes.getType() == IResource.FILE) {
|
||||||
|
@ -465,7 +481,8 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!found) {
|
if (!found) {
|
||||||
// filter out this project - does not reference the container path
|
// filter out this project - does not reference the container
|
||||||
|
// path
|
||||||
modifiedProjects[i] = null;
|
modifiedProjects[i] = null;
|
||||||
// Still add it to the cache
|
// Still add it to the cache
|
||||||
containerPut(affectedProject, containerPath, newContainer);
|
containerPut(affectedProject, containerPath, newContainer);
|
||||||
|
@ -492,8 +509,10 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
}
|
}
|
||||||
// trigger model refresh
|
// trigger model refresh
|
||||||
try {
|
try {
|
||||||
//final boolean canChangeResources = !ResourcesPlugin.getWorkspace().isTreeLocked();
|
//final boolean canChangeResources =
|
||||||
|
// !ResourcesPlugin.getWorkspace().isTreeLocked();
|
||||||
CoreModel.run(new IWorkspaceRunnable() {
|
CoreModel.run(new IWorkspaceRunnable() {
|
||||||
|
|
||||||
public void run(IProgressMonitor progressMonitor) throws CoreException {
|
public void run(IProgressMonitor progressMonitor) throws CoreException {
|
||||||
|
|
||||||
boolean shouldFire = false;
|
boolean shouldFire = false;
|
||||||
|
@ -577,7 +596,8 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (!ok[0]) {
|
if (!ok[0]) {
|
||||||
containerPut(project, containerPath, null); // flush and notify
|
containerPut(project, containerPath, null); // flush and
|
||||||
|
// notify
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// retrieve new value
|
// retrieve new value
|
||||||
|
@ -587,23 +607,27 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method finding the container initializer registered for a given container ID or <code>null</code> if none was found
|
* Helper method finding the container initializer registered for a given
|
||||||
* while iterating over the contributions to extension point to the extension point
|
* container ID or <code>null</code> if none was found while iterating
|
||||||
|
* over the contributions to extension point to the extension point
|
||||||
* "org.eclipse.cdt.core.PathEntryContainerInitializer".
|
* "org.eclipse.cdt.core.PathEntryContainerInitializer".
|
||||||
* <p>
|
* <p>
|
||||||
* A containerID is the first segment of any container path, used to identify the registered container initializer.
|
* A containerID is the first segment of any container path, used to
|
||||||
|
* identify the registered container initializer.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param containerID -
|
* @param containerID -
|
||||||
* a containerID identifying a registered initializer
|
* a containerID identifying a registered initializer
|
||||||
* @return PathEntryContainerInitializer - the registered container initializer or <code>null</code> if none was found.
|
* @return PathEntryContainerInitializer - the registered container
|
||||||
|
* initializer or <code>null</code> if none was found.
|
||||||
*/
|
*/
|
||||||
public PathEntryContainerInitializer getPathEntryContainerInitializer(String containerID) {
|
public PathEntryContainerInitializer getPathEntryContainerInitializer(String containerID) {
|
||||||
Plugin core = CCorePlugin.getDefault();
|
Plugin core = CCorePlugin.getDefault();
|
||||||
if (core == null) {
|
if (core == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID, CONTAINER_INITIALIZER_EXTPOINT_ID);
|
IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID,
|
||||||
|
CONTAINER_INITIALIZER_EXTPOINT_ID);
|
||||||
if (extension != null) {
|
if (extension != null) {
|
||||||
IExtension[] extensions = extension.getExtensions();
|
IExtension[] extensions = extension.getExtensions();
|
||||||
for (int i = 0; i < extensions.length; i++) {
|
for (int i = 0; i < extensions.length; i++) {
|
||||||
|
@ -706,7 +730,8 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
|
|
||||||
// Do not do this for container, the path is the ID.
|
// Do not do this for container, the path is the ID.
|
||||||
if (kind != IPathEntry.CDT_CONTAINER) {
|
if (kind != IPathEntry.CDT_CONTAINER) {
|
||||||
// translate to project relative from absolute (unless a device path)
|
// translate to project relative from absolute (unless a device
|
||||||
|
// path)
|
||||||
if (resourcePath.isAbsolute()) {
|
if (resourcePath.isAbsolute()) {
|
||||||
if (projectPath != null && projectPath.isPrefixOf(resourcePath)) {
|
if (projectPath != null && projectPath.isPrefixOf(resourcePath)) {
|
||||||
if (resourcePath.segment(0).equals(projectPath.segment(0))) {
|
if (resourcePath.segment(0).equals(projectPath.segment(0))) {
|
||||||
|
@ -746,9 +771,9 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
}
|
}
|
||||||
IPath baseRef = library.getBaseReference();
|
IPath baseRef = library.getBaseReference();
|
||||||
if (baseRef == null || baseRef.isEmpty()) {
|
if (baseRef == null || baseRef.isEmpty()) {
|
||||||
entry = CoreModel.newLibraryEntry(resourcePath, library.getBasePath(),
|
entry = CoreModel.newLibraryEntry(resourcePath, library.getBasePath(), library.getLibraryPath(),
|
||||||
library.getLibraryPath(), sourcePath, library.getSourceAttachmentRootPath(),
|
sourcePath, library.getSourceAttachmentRootPath(), library.getSourceAttachmentPrefixMapping(),
|
||||||
library.getSourceAttachmentPrefixMapping(), library.isExported());
|
library.isExported());
|
||||||
} else {
|
} else {
|
||||||
entry = CoreModel.newLibraryRefEntry(resourcePath, baseRef, library.getLibraryPath());
|
entry = CoreModel.newLibraryRefEntry(resourcePath, baseRef, library.getLibraryPath());
|
||||||
}
|
}
|
||||||
|
@ -799,27 +824,69 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void generateMarkers(final ICProject finalCProject, final IPathEntry[] finalEntries) {
|
public void generateMarkers(final ICProject cProject, final IPathEntry[] entries) {
|
||||||
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)
|
||||||
*/
|
*/
|
||||||
protected IStatus run(IProgressMonitor monitor) {
|
protected IStatus run(IProgressMonitor monitor) {
|
||||||
IProject project = finalCProject.getProject();
|
IProject project = cProject.getProject();
|
||||||
flushPathEntryProblemMarkers(project);
|
flushPathEntryProblemMarkers(project);
|
||||||
ICModelStatus status = validatePathEntry(finalCProject, finalEntries);
|
ICModelStatus status = validatePathEntry(cProject, entries);
|
||||||
if (!status.isOK()) {
|
if (!status.isOK()) {
|
||||||
createPathEntryProblemMarker(project, status);
|
createPathEntryProblemMarker(project, status);
|
||||||
}
|
}
|
||||||
for (int j = 0; j < finalEntries.length; j++) {
|
for (int j = 0; j < entries.length; j++) {
|
||||||
status = validatePathEntry(finalCProject, finalEntries[j], true, false);
|
status = validatePathEntry(cProject, entries[j], true, false);
|
||||||
if (!status.isOK()) {
|
if (!status.isOK()) {
|
||||||
createPathEntryProblemMarker(project, status);
|
createPathEntryProblemMarker(project, status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Status.OK_STATUS;
|
return Status.OK_STATUS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
markerTask.setRule(CCorePlugin.getWorkspace().getRoot());
|
||||||
|
markerTask.schedule();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateMarkers(final ICProject[] cProjects) {
|
||||||
|
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)
|
||||||
|
*/
|
||||||
|
protected IStatus run(IProgressMonitor monitor) {
|
||||||
|
for(int i = 0; i < cProjects.length; i++) {
|
||||||
|
ArrayList resolvedList = (ArrayList)resolvedMap.get(cProjects[i]);
|
||||||
|
if (resolvedList != null) {
|
||||||
|
IPathEntry[] entries = (IPathEntry[])resolvedList.toArray(new IPathEntry[resolvedList.size()]);
|
||||||
|
IProject project = cProjects[i].getProject();
|
||||||
|
flushPathEntryProblemMarkers(project);
|
||||||
|
ICModelStatus status = validatePathEntry(cProjects[i], entries);
|
||||||
|
if (!status.isOK()) {
|
||||||
|
createPathEntryProblemMarker(project, status);
|
||||||
|
}
|
||||||
|
for (int j = 0; j < entries.length; j++) {
|
||||||
|
status = validatePathEntry(cProjects[i], entries[j], true, false);
|
||||||
|
if (!status.isOK()) {
|
||||||
|
createPathEntryProblemMarker(project, status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Status.OK_STATUS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
markerTask.setRule(CCorePlugin.getWorkspace().getRoot());
|
||||||
markerTask.schedule();
|
markerTask.schedule();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -953,7 +1020,8 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
ArrayList containerIDList = new ArrayList(5);
|
ArrayList containerIDList = new ArrayList(5);
|
||||||
IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID, CONTAINER_INITIALIZER_EXTPOINT_ID);
|
IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID,
|
||||||
|
CONTAINER_INITIALIZER_EXTPOINT_ID);
|
||||||
if (extension != null) {
|
if (extension != null) {
|
||||||
IExtension[] extensions = extension.getExtensions();
|
IExtension[] extensions = extension.getExtensions();
|
||||||
for (int i = 0; i < extensions.length; i++) {
|
for (int i = 0; i < extensions.length; i++) {
|
||||||
|
@ -1024,7 +1092,9 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
return store;
|
return store;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see org.eclipse.cdt.core.resources.IPathEntryStoreListener#pathEntryStoreChanged(org.eclipse.cdt.core.resources.PathEntryChangedEvent)
|
* @see org.eclipse.cdt.core.resources.IPathEntryStoreListener#pathEntryStoreChanged(org.eclipse.cdt.core.resources.PathEntryChangedEvent)
|
||||||
*/
|
*/
|
||||||
public void pathEntryStoreChanged(PathEntryStoreChangedEvent event) {
|
public void pathEntryStoreChanged(PathEntryStoreChangedEvent event) {
|
||||||
|
@ -1067,27 +1137,31 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see org.eclipse.cdt.core.model.IElementChangedListener#elementChanged(org.eclipse.cdt.core.model.ElementChangedEvent)
|
* @see org.eclipse.cdt.core.model.IElementChangedListener#elementChanged(org.eclipse.cdt.core.model.ElementChangedEvent)
|
||||||
*/
|
*/
|
||||||
public void elementChanged(ElementChangedEvent event) {
|
public void elementChanged(ElementChangedEvent event) {
|
||||||
try {
|
try {
|
||||||
processDelta(event.getDelta());
|
if (processDelta(event.getDelta()) == true) {
|
||||||
|
ICProject[] projects = (ICProject [])resolvedMap.keySet().toArray(new ICProject[0]);
|
||||||
|
updateMarkers(projects);
|
||||||
|
}
|
||||||
} catch (CModelException e) {
|
} catch (CModelException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void processDelta(ICElementDelta delta) throws CModelException {
|
protected boolean processDelta(ICElementDelta delta) throws CModelException {
|
||||||
int kind = delta.getKind();
|
int kind = delta.getKind();
|
||||||
int flags= delta.getFlags();
|
|
||||||
ICElement element = delta.getElement();
|
ICElement element = delta.getElement();
|
||||||
|
int type = element.getElementType();
|
||||||
|
|
||||||
//System.out.println("Processing " + element);
|
// handle open, closing and removing of projects
|
||||||
|
if ( type == ICElement.C_PROJECT) {
|
||||||
// handle closing and removing of projects
|
|
||||||
if (((flags & ICElementDelta.F_CLOSED) != 0) || (kind == ICElementDelta.REMOVED)) {
|
|
||||||
if (element.getElementType() == ICElement.C_PROJECT) {
|
|
||||||
ICProject cproject = (ICProject)element;
|
ICProject cproject = (ICProject)element;
|
||||||
|
if ((kind == ICElementDelta.REMOVED || kind == ICElementDelta.ADDED)) {
|
||||||
|
if (kind == ICElementDelta.REMOVED) {
|
||||||
IProject project = cproject.getProject();
|
IProject project = cproject.getProject();
|
||||||
IPathEntryStore store = null;
|
IPathEntryStore store = null;
|
||||||
try {
|
try {
|
||||||
|
@ -1103,25 +1177,21 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
containerRemove(cproject);
|
containerRemove(cproject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
} else if (kind == ICElementDelta.CHANGED) {
|
return true;
|
||||||
// We should update the pathentry markers if the project change.
|
|
||||||
if (element.getElementType() == ICElement.C_PROJECT) {
|
|
||||||
ICProject cproject = (ICProject)element;
|
|
||||||
ArrayList resolvedList = (ArrayList)resolvedMap.get(cproject);
|
|
||||||
if (resolvedList != null) {
|
|
||||||
IPathEntry[] entries = (IPathEntry[]) resolvedList.toArray(new IPathEntry[resolvedList.size()]);
|
|
||||||
generateMarkers(cproject, entries);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
// project change, traverse children.
|
||||||
|
} else if (kind == ICElementDelta.ADDED || kind == ICElementDelta.REMOVED) {
|
||||||
|
return true; // add/remove we validate all paths
|
||||||
}
|
}
|
||||||
ICElementDelta[] affectedChildren = delta.getAffectedChildren();
|
ICElementDelta[] affectedChildren = delta.getAffectedChildren();
|
||||||
for (int i = 0; i < affectedChildren.length; i++) {
|
for (int i = 0; i < affectedChildren.length; i++) {
|
||||||
processDelta(affectedChildren[i]);
|
if (processDelta(affectedChildren[i]) == true) {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
protected IPathEntry cloneEntry(IPath rpath, IPathEntry entry) {
|
protected IPathEntry cloneEntry(IPath rpath, IPathEntry entry) {
|
||||||
|
|
||||||
|
@ -1182,7 +1252,6 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
}
|
}
|
||||||
if (entry != otherEntry && otherEntry.equals(entry)) {
|
if (entry != otherEntry && otherEntry.equals(entry)) {
|
||||||
StringBuffer errMesg = new StringBuffer(CCorePlugin.getResourceString("CoreModel.PathEntry.DuplicateEntry")); //$NON-NLS-1$
|
StringBuffer errMesg = new StringBuffer(CCorePlugin.getResourceString("CoreModel.PathEntry.DuplicateEntry")); //$NON-NLS-1$
|
||||||
errMesg.append(':').append(entry.toString());
|
|
||||||
return new CModelStatus(ICModelStatusConstants.INVALID_PATHENTRY, errMesg.toString());
|
return new CModelStatus(ICModelStatusConstants.INVALID_PATHENTRY, errMesg.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1194,7 +1263,6 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
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) {
|
||||||
StringBuffer errMesg = new StringBuffer(CCorePlugin.getResourceString("CoreModel.PathEntry.DuplicateEntry")); //$NON-NLS-1$
|
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());
|
cmodelStatus[i] = new CModelStatus(ICModelStatusConstants.INVALID_PATHENTRY, errMesg.toString());
|
||||||
}
|
}
|
||||||
return CModelStatus.newMultiStatus(ICModelStatusConstants.INVALID_PATHENTRY, cmodelStatus);
|
return CModelStatus.newMultiStatus(ICModelStatusConstants.INVALID_PATHENTRY, cmodelStatus);
|
||||||
|
@ -1206,13 +1274,13 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
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) {
|
||||||
StringBuffer errMesg = new StringBuffer(CCorePlugin.getResourceString("CoreModel.PathEntry.DuplicateEntry")); //$NON-NLS-1$
|
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());
|
cmodelStatus[i] = new CModelStatus(ICModelStatusConstants.NAME_COLLISION, errMesg.toString());
|
||||||
}
|
}
|
||||||
return CModelStatus.newMultiStatus(ICModelStatusConstants.INVALID_PATHENTRY, cmodelStatus);
|
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];
|
||||||
if (entry == null) {
|
if (entry == null) {
|
||||||
|
@ -1235,17 +1303,17 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
|
|
||||||
String exclusionPattern = entryPath.removeFirstSegments(otherPath.segmentCount()).segment(0);
|
String exclusionPattern = entryPath.removeFirstSegments(otherPath.segmentCount()).segment(0);
|
||||||
if (CoreModelUtil.isExcluded(entryPath, exclusionPatterns)) {
|
if (CoreModelUtil.isExcluded(entryPath, exclusionPatterns)) {
|
||||||
StringBuffer errMesg = new StringBuffer(CCorePlugin.getResourceString("CoreModel.PathEntry.NestedEntry")); //$NON-NLS-1$
|
StringBuffer errMesg = new StringBuffer(
|
||||||
errMesg.append(':').append(entry.toString());
|
CCorePlugin.getResourceString("CoreModel.PathEntry.NestedEntry")); //$NON-NLS-1$
|
||||||
return new CModelStatus(ICModelStatusConstants.INVALID_PATHENTRY, errMesg.toString());
|
return new CModelStatus(ICModelStatusConstants.INVALID_PATHENTRY, errMesg.toString());
|
||||||
} else if (otherKind == IPathEntry.CDT_SOURCE) {
|
} else if (otherKind == IPathEntry.CDT_SOURCE) {
|
||||||
exclusionPattern += '/';
|
exclusionPattern += '/';
|
||||||
StringBuffer errMesg = new StringBuffer(CCorePlugin.getResourceString("CoreModel.PathEntry.NestedEntry")); //$NON-NLS-1$
|
StringBuffer errMesg = new StringBuffer(
|
||||||
errMesg.append(':').append(entry.toString());
|
CCorePlugin.getResourceString("CoreModel.PathEntry.NestedEntry")); //$NON-NLS-1$
|
||||||
return new CModelStatus(ICModelStatusConstants.INVALID_PATHENTRY, errMesg.toString());
|
return new CModelStatus(ICModelStatusConstants.INVALID_PATHENTRY, errMesg.toString());
|
||||||
} else {
|
} else {
|
||||||
StringBuffer errMesg = new StringBuffer(CCorePlugin.getResourceString("CoreModel.PathEntry.NestedEntry")); //$NON-NLS-1$
|
StringBuffer errMesg = new StringBuffer(
|
||||||
errMesg.append(':').append(entry.toString());
|
CCorePlugin.getResourceString("CoreModel.PathEntry.NestedEntry")); //$NON-NLS-1$
|
||||||
return new CModelStatus(ICModelStatusConstants.INVALID_PATHENTRY, errMesg.toString()); //$NON-NLS-1$
|
return new CModelStatus(ICModelStatusConstants.INVALID_PATHENTRY, errMesg.toString()); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1257,86 +1325,67 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
return CModelStatus.VERIFIED_OK;
|
return CModelStatus.VERIFIED_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICModelStatus validatePathEntry(ICProject cProject, IPathEntry entry, boolean checkSourceAttachment, boolean recurseInContainers){
|
public ICModelStatus validatePathEntry(ICProject cProject, IPathEntry entry, boolean checkSourceAttachment,
|
||||||
|
boolean recurseInContainers) {
|
||||||
IProject project = cProject.getProject();
|
IProject project = cProject.getProject();
|
||||||
StringBuffer sb = new StringBuffer();
|
IPath path = entry.getPath();
|
||||||
sb.append(CCorePlugin.getResourceString("CoreModel.PathEntry.InvalidPathEntry")); //$NON-NLS-1$
|
if (entry.getEntryKind() != IPathEntry.CDT_PROJECT) {
|
||||||
sb.append(':').append(entry.toString());
|
if (!isValidWorkspacePath(project, path)) {
|
||||||
String entryMesg = sb.toString();
|
return new CModelStatus(
|
||||||
|
ICModelStatusConstants.INVALID_PATHENTRY,
|
||||||
|
CoreModelMessages.getString("PathEntryManager.0") + path.toOSString() + " for " + ((PathEntry)entry).getKindString()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch (entry.getEntryKind()) {
|
switch (entry.getEntryKind()) {
|
||||||
case IPathEntry.CDT_INCLUDE : {
|
case IPathEntry.CDT_INCLUDE : {
|
||||||
IIncludeEntry include = (IIncludeEntry)entry;
|
IIncludeEntry include = (IIncludeEntry)entry;
|
||||||
IPath path = include.getPath();
|
|
||||||
if (!isValidWorkspacePath(project, path)) {
|
|
||||||
return new CModelStatus(ICModelStatusConstants.INVALID_PATHENTRY, entryMesg); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
IPath includePath = include.getFullIncludePath();
|
IPath includePath = include.getFullIncludePath();
|
||||||
if (!isValidExternalPath(includePath)) {
|
if (!isValidExternalPath(includePath)) {
|
||||||
return new CModelStatus(ICModelStatusConstants.INVALID_PATHENTRY, entryMesg); //$NON-NLS-1$
|
return new CModelStatus(ICModelStatusConstants.INVALID_PATHENTRY,
|
||||||
|
CoreModelMessages.getString("PathEntryManager.2") + " (" + includePath.toOSString() + ")"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
|
||||||
|
}
|
||||||
|
if (!isValidBasePath(include.getBasePath())) {
|
||||||
|
return new CModelStatus(ICModelStatusConstants.INVALID_PATHENTRY,
|
||||||
|
CoreModelMessages.getString("PathEntryManager.1") + " (" + includePath.toOSString() + ")"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IPathEntry.CDT_LIBRARY : {
|
case IPathEntry.CDT_LIBRARY : {
|
||||||
ILibraryEntry library = (ILibraryEntry)entry;
|
ILibraryEntry library = (ILibraryEntry)entry;
|
||||||
IPath path = library.getPath();
|
|
||||||
if (!isValidWorkspacePath(project, path)) {
|
|
||||||
return new CModelStatus(ICModelStatusConstants.INVALID_PATHENTRY, entryMesg); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
if (checkSourceAttachment) {
|
if (checkSourceAttachment) {
|
||||||
IPath sourceAttach = library.getSourceAttachmentPath();
|
IPath sourceAttach = library.getSourceAttachmentPath();
|
||||||
if (sourceAttach != null) {
|
if (sourceAttach != null) {
|
||||||
if (!sourceAttach.isAbsolute()) {
|
if (!sourceAttach.isAbsolute()) {
|
||||||
if (!isValidWorkspacePath(project, sourceAttach)) {
|
if (!isValidWorkspacePath(project, sourceAttach) || !isValidExternalPath(sourceAttach)) {
|
||||||
return new CModelStatus(ICModelStatusConstants.INVALID_PATHENTRY, entryMesg);
|
return new CModelStatus(ICModelStatusConstants.INVALID_PATHENTRY,
|
||||||
|
CoreModelMessages.getString("PathEntryManager.3") + " (" + sourceAttach.toOSString() + ")"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
|
||||||
}
|
}
|
||||||
} else if (!isValidExternalPath(sourceAttach)) {
|
|
||||||
return new CModelStatus(ICModelStatusConstants.INVALID_PATHENTRY, entryMesg);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
IPath libraryPath = library.getFullLibraryPath();
|
IPath libraryPath = library.getFullLibraryPath();
|
||||||
if (!isValidExternalPath(libraryPath)) {
|
if (!isValidExternalPath(libraryPath)) {
|
||||||
return new CModelStatus(ICModelStatusConstants.INVALID_PATHENTRY, entryMesg); //$NON-NLS-1$
|
return new CModelStatus(ICModelStatusConstants.INVALID_PATHENTRY,
|
||||||
|
CoreModelMessages.getString("PathEntryManager.4") + " (" + libraryPath.toOSString() + ")"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
|
||||||
}
|
}
|
||||||
break;
|
if (!isValidBasePath(library.getBasePath())) {
|
||||||
}
|
return new CModelStatus(ICModelStatusConstants.INVALID_PATHENTRY,
|
||||||
case IPathEntry.CDT_MACRO: {
|
CoreModelMessages.getString("PathEntryManager.7") + " (" + libraryPath.toOSString() + ")"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
|
||||||
IMacroEntry macro = (IMacroEntry)entry;
|
|
||||||
IPath path = macro.getPath();
|
|
||||||
if (!isValidWorkspacePath(project, path)) {
|
|
||||||
return new CModelStatus(ICModelStatusConstants.INVALID_PATHENTRY, entryMesg); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case IPathEntry.CDT_OUTPUT: {
|
|
||||||
IOutputEntry out = (IOutputEntry)entry;
|
|
||||||
IPath path = out.getPath();
|
|
||||||
if (!isValidWorkspacePath(project, path)) {
|
|
||||||
return new CModelStatus(ICModelStatusConstants.INVALID_PATHENTRY, entryMesg); //$NON-NLS-1$
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IPathEntry.CDT_PROJECT : {
|
case IPathEntry.CDT_PROJECT : {
|
||||||
IProjectEntry projEntry = (IProjectEntry)entry;
|
IProjectEntry projEntry = (IProjectEntry)entry;
|
||||||
IPath path = projEntry.getPath();
|
path = projEntry.getPath();
|
||||||
if (path != null && path.isAbsolute() && !path.isEmpty()) {
|
|
||||||
IProject reqProject = project.getWorkspace().getRoot().getProject(path.segment(0));
|
IProject reqProject = project.getWorkspace().getRoot().getProject(path.segment(0));
|
||||||
if (!reqProject.exists() || !(CoreModel.hasCNature(reqProject) || CoreModel.hasCCNature(reqProject))) {
|
if (!reqProject.isAccessible()) {
|
||||||
return new CModelStatus(ICModelStatusConstants.INVALID_PATHENTRY, entryMesg); //$NON-NLS-1$
|
return new CModelStatus(ICModelStatusConstants.INVALID_PATHENTRY,
|
||||||
|
CoreModelMessages.getString("PathEntryManager.5")); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
if (!reqProject.isOpen()){
|
if (! (CoreModel.hasCNature(reqProject) || CoreModel.hasCCNature(reqProject))) {
|
||||||
return new CModelStatus(ICModelStatusConstants.INVALID_PATHENTRY, entryMesg); //$NON-NLS-1$
|
return new CModelStatus(ICModelStatusConstants.INVALID_PATHENTRY,
|
||||||
}
|
CoreModelMessages.getString("PathEntryManager.6")); //$NON-NLS-1$
|
||||||
} else {
|
|
||||||
return new CModelStatus(ICModelStatusConstants.INVALID_PATHENTRY, entryMesg); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case IPathEntry.CDT_SOURCE: {
|
|
||||||
ISourceEntry source = (ISourceEntry)entry;
|
|
||||||
IPath path = source.getPath();
|
|
||||||
if (!isValidWorkspacePath(project, path)) {
|
|
||||||
return new CModelStatus(ICModelStatusConstants.INVALID_PATHENTRY, entryMesg); //$NON-NLS-1$
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1385,6 +1434,16 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isValidBasePath(IPath path) {
|
||||||
|
if (!path.isEmpty() && !path.isAbsolute()) {
|
||||||
|
IResource res = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
|
||||||
|
if (res == null || !res.isAccessible()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private List checkForDuplication(List pathEntries, int type) {
|
private List checkForDuplication(List pathEntries, int type) {
|
||||||
List duplicate = new ArrayList(pathEntries.size());
|
List duplicate = new ArrayList(pathEntries.size());
|
||||||
for (int i = 0; i < pathEntries.size(); ++i) {
|
for (int i = 0; i < pathEntries.size(); ++i) {
|
||||||
|
@ -1431,20 +1490,10 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
|
|
||||||
try {
|
try {
|
||||||
marker = project.createMarker(ICModelMarker.PATHENTRY_PROBLEM_MARKER);
|
marker = project.createMarker(ICModelMarker.PATHENTRY_PROBLEM_MARKER);
|
||||||
marker.setAttributes(
|
marker.setAttributes(new String[]{IMarker.MESSAGE, IMarker.SEVERITY, IMarker.LOCATION,
|
||||||
new String[] {
|
ICModelMarker.PATHENTRY_FILE_FORMAT,}, new Object[]{status.getMessage(), new Integer(severity), "pathentry",//$NON-NLS-1$
|
||||||
IMarker.MESSAGE,
|
|
||||||
IMarker.SEVERITY,
|
|
||||||
IMarker.LOCATION,
|
|
||||||
ICModelMarker.PATHENTRY_FILE_FORMAT,
|
|
||||||
},
|
|
||||||
new Object[] {
|
|
||||||
status.getMessage(),
|
|
||||||
new Integer(severity),
|
|
||||||
"pathentry",//$NON-NLS-1$
|
|
||||||
"false",//$NON-NLS-1$
|
"false",//$NON-NLS-1$
|
||||||
}
|
});
|
||||||
);
|
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
// could not create marker: cannot do much
|
// could not create marker: cannot do much
|
||||||
//e.printStackTrace();
|
//e.printStackTrace();
|
||||||
|
@ -1470,6 +1519,4 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue