mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
fixed NPE on reorder
This commit is contained in:
parent
8dde2f9a0e
commit
8b8959e099
2 changed files with 56 additions and 47 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2004-03-26 David Inglis
|
||||||
|
|
||||||
|
Fixed NPE on path reorder
|
||||||
|
|
||||||
|
* model/org/eclipse/cdt/internal/core/model/PathEntryManager.java
|
||||||
|
|
||||||
2004-03-26 David Inglis
|
2004-03-26 David Inglis
|
||||||
|
|
||||||
Refactor to move exclusion matching methods out into public class.
|
Refactor to move exclusion matching methods out into public class.
|
||||||
|
|
|
@ -59,6 +59,7 @@ import org.w3c.dom.NodeList;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class PathEntryManager implements ICDescriptorListener {
|
public class PathEntryManager implements ICDescriptorListener {
|
||||||
|
|
||||||
static String CONTAINER_INITIALIZER_EXTPOINT_ID = "pathEntryContainerInitializer"; //$NON-NLS-1$
|
static String CONTAINER_INITIALIZER_EXTPOINT_ID = "pathEntryContainerInitializer"; //$NON-NLS-1$
|
||||||
static String PATH_ENTRY = "pathentry"; //$NON-NLS-1$
|
static String PATH_ENTRY = "pathentry"; //$NON-NLS-1$
|
||||||
static String PATH_ENTRY_ID = "org.eclipse.cdt.core.pathentry"; //$NON-NLS-1$
|
static String PATH_ENTRY_ID = "org.eclipse.cdt.core.pathentry"; //$NON-NLS-1$
|
||||||
|
@ -76,8 +77,7 @@ public class PathEntryManager implements ICDescriptorListener {
|
||||||
static String VALUE_TRUE = "true"; //$NON-NLS-1$
|
static String VALUE_TRUE = "true"; //$NON-NLS-1$
|
||||||
final static IPathEntry[] EMPTY = {};
|
final static IPathEntry[] EMPTY = {};
|
||||||
/**
|
/**
|
||||||
* An empty array of strings indicating that a project doesn't have any
|
* An empty array of strings indicating that a project doesn't have any prerequesite projects.
|
||||||
* prerequesite projects.
|
|
||||||
*/
|
*/
|
||||||
static final String[] NO_PREREQUISITES = new String[0];
|
static final String[] NO_PREREQUISITES = new String[0];
|
||||||
/**
|
/**
|
||||||
|
@ -168,7 +168,7 @@ public class PathEntryManager implements ICDescriptorListener {
|
||||||
boolean foundSource = false;
|
boolean foundSource = false;
|
||||||
boolean foundOutput = false;
|
boolean foundOutput = false;
|
||||||
for (int i = 0; i < pathEntries.size(); i++) {
|
for (int i = 0; i < pathEntries.size(); i++) {
|
||||||
IPathEntry rawEntry = (IPathEntry)pathEntries.get(i);
|
IPathEntry rawEntry = (IPathEntry) pathEntries.get(i);
|
||||||
if (rawEntry.getEntryKind() == IPathEntry.CDT_SOURCE) {
|
if (rawEntry.getEntryKind() == IPathEntry.CDT_SOURCE) {
|
||||||
foundSource = true;
|
foundSource = true;
|
||||||
}
|
}
|
||||||
|
@ -239,6 +239,7 @@ public class PathEntryManager implements ICDescriptorListener {
|
||||||
// trigger model refresh
|
// trigger model refresh
|
||||||
try {
|
try {
|
||||||
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;
|
||||||
CModelManager mgr = CModelManager.getDefault();
|
CModelManager mgr = CModelManager.getDefault();
|
||||||
|
@ -292,6 +293,7 @@ public class PathEntryManager implements ICDescriptorListener {
|
||||||
// initializer would be
|
// initializer would be
|
||||||
// causing some grief
|
// causing some grief
|
||||||
Platform.run(new ISafeRunnable() {
|
Platform.run(new ISafeRunnable() {
|
||||||
|
|
||||||
public void handleException(Throwable exception) {
|
public void handleException(Throwable exception) {
|
||||||
//Util.log(exception, "Exception occurred in
|
//Util.log(exception, "Exception occurred in
|
||||||
// container initializer: "+initializer);
|
// container initializer: "+initializer);
|
||||||
|
@ -317,19 +319,16 @@ public class PathEntryManager implements ICDescriptorListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method finding the container initializer registered for a given
|
* Helper method finding the container initializer registered for a given container ID or <code>null</code> if none was found
|
||||||
* container ID or <code>null</code> if none was found while iterating
|
* while iterating over the contributions to extension point to the extension point
|
||||||
* 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
|
* A containerID is the first segment of any container path, used to identify the registered container initializer.
|
||||||
* 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
|
* @return PathEntryContainerInitializer - the registered container initializer or <code>null</code> if none was found.
|
||||||
* 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();
|
||||||
|
@ -491,39 +490,41 @@ public class PathEntryManager implements ICDescriptorListener {
|
||||||
* return a delta, with the specified change flag.
|
* return a delta, with the specified change flag.
|
||||||
*/
|
*/
|
||||||
protected ICElementDelta makePathEntryDelta(ICProject cproject, IPathEntry entry, boolean removed) {
|
protected ICElementDelta makePathEntryDelta(ICProject cproject, IPathEntry entry, boolean removed) {
|
||||||
int kind = entry.getEntryKind();
|
|
||||||
ICElement celement = null;
|
ICElement celement = null;
|
||||||
int flag = ICElementDelta.F_PATHENTRY_REORDER;
|
int flag = ICElementDelta.F_PATHENTRY_REORDER;
|
||||||
if (entry == null) {
|
if (entry == null) {
|
||||||
celement = cproject;
|
celement = cproject;
|
||||||
flag = ICElementDelta.F_PATHENTRY_REORDER;
|
flag = ICElementDelta.F_PATHENTRY_REORDER;
|
||||||
} else if (kind == IPathEntry.CDT_SOURCE) {
|
} else {
|
||||||
ISourceEntry source = (ISourceEntry) entry;
|
int kind = entry.getEntryKind();
|
||||||
IPath path = source.getPath();
|
if (kind == IPathEntry.CDT_SOURCE) {
|
||||||
celement = CoreModel.getDefault().create(path);
|
ISourceEntry source = (ISourceEntry) entry;
|
||||||
flag = (removed) ? ICElementDelta.F_REMOVED_PATHENTRY_SOURCE : ICElementDelta.F_ADDED_PATHENTRY_SOURCE;
|
IPath path = source.getPath();
|
||||||
} else if (kind == IPathEntry.CDT_LIBRARY) {
|
celement = CoreModel.getDefault().create(path);
|
||||||
ILibraryEntry lib = (ILibraryEntry) entry;
|
flag = (removed) ? ICElementDelta.F_REMOVED_PATHENTRY_SOURCE : ICElementDelta.F_ADDED_PATHENTRY_SOURCE;
|
||||||
celement = CProject.getLibraryReference(cproject, null, lib);
|
} else if (kind == IPathEntry.CDT_LIBRARY) {
|
||||||
flag = (removed) ? ICElementDelta.F_ADDED_PATHENTRY_LIBRARY : ICElementDelta.F_REMOVED_PATHENTRY_LIBRARY;
|
ILibraryEntry lib = (ILibraryEntry) entry;
|
||||||
} else if (kind == IPathEntry.CDT_PROJECT) {
|
celement = CProject.getLibraryReference(cproject, null, lib);
|
||||||
//IProjectEntry pentry = (IProjectEntry) entry;
|
flag = (removed) ? ICElementDelta.F_ADDED_PATHENTRY_LIBRARY : ICElementDelta.F_REMOVED_PATHENTRY_LIBRARY;
|
||||||
celement = cproject;
|
} else if (kind == IPathEntry.CDT_PROJECT) {
|
||||||
flag = ICElementDelta.F_CHANGED_PATHENTRY_PROJECT;
|
//IProjectEntry pentry = (IProjectEntry) entry;
|
||||||
} else if (kind == IPathEntry.CDT_INCLUDE) {
|
celement = cproject;
|
||||||
IIncludeEntry include = (IIncludeEntry) entry;
|
flag = ICElementDelta.F_CHANGED_PATHENTRY_PROJECT;
|
||||||
IPath path = include.getPath();
|
} else if (kind == IPathEntry.CDT_INCLUDE) {
|
||||||
celement = CoreModel.getDefault().create(path);
|
IIncludeEntry include = (IIncludeEntry) entry;
|
||||||
flag = ICElementDelta.F_CHANGED_PATHENTRY_INCLUDE;
|
IPath path = include.getPath();
|
||||||
} else if (kind == IPathEntry.CDT_MACRO) {
|
celement = CoreModel.getDefault().create(path);
|
||||||
IMacroEntry macro = (IMacroEntry) entry;
|
flag = ICElementDelta.F_CHANGED_PATHENTRY_INCLUDE;
|
||||||
IPath path = macro.getPath();
|
} else if (kind == IPathEntry.CDT_MACRO) {
|
||||||
celement = CoreModel.getDefault().create(path);
|
IMacroEntry macro = (IMacroEntry) entry;
|
||||||
flag = ICElementDelta.F_CHANGED_PATHENTRY_MACRO;
|
IPath path = macro.getPath();
|
||||||
} else if (kind == IPathEntry.CDT_CONTAINER) {
|
celement = CoreModel.getDefault().create(path);
|
||||||
//IContainerEntry container = (IContainerEntry) entry;
|
flag = ICElementDelta.F_CHANGED_PATHENTRY_MACRO;
|
||||||
//celement = cproject;
|
} else if (kind == IPathEntry.CDT_CONTAINER) {
|
||||||
// SHOULD NOT BE HERE Container are resolved.
|
//IContainerEntry container = (IContainerEntry) entry;
|
||||||
|
//celement = cproject;
|
||||||
|
// SHOULD NOT BE HERE Container are resolved.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (celement == null) {
|
if (celement == null) {
|
||||||
celement = cproject;
|
celement = cproject;
|
||||||
|
@ -574,12 +575,12 @@ public class PathEntryManager implements ICDescriptorListener {
|
||||||
path = projectPath.append(path);
|
path = projectPath.append(path);
|
||||||
}
|
}
|
||||||
// source attachment info (optional)
|
// source attachment info (optional)
|
||||||
IPath sourceAttachmentPath = element.hasAttribute(ATTRIBUTE_SOURCEPATH) ? new Path(element
|
IPath sourceAttachmentPath = element.hasAttribute(ATTRIBUTE_SOURCEPATH) ? new Path(
|
||||||
.getAttribute(ATTRIBUTE_SOURCEPATH)) : null;
|
element.getAttribute(ATTRIBUTE_SOURCEPATH)) : null;
|
||||||
IPath sourceAttachmentRootPath = element.hasAttribute(ATTRIBUTE_ROOTPATH) ? new Path(element
|
IPath sourceAttachmentRootPath = element.hasAttribute(ATTRIBUTE_ROOTPATH) ? new Path(
|
||||||
.getAttribute(ATTRIBUTE_ROOTPATH)) : null;
|
element.getAttribute(ATTRIBUTE_ROOTPATH)) : null;
|
||||||
IPath sourceAttachmentPrefixMapping = element.hasAttribute(ATTRIBUTE_PREFIXMAPPING) ? new Path(element
|
IPath sourceAttachmentPrefixMapping = element.hasAttribute(ATTRIBUTE_PREFIXMAPPING) ? new Path(
|
||||||
.getAttribute(ATTRIBUTE_PREFIXMAPPING)) : null;
|
element.getAttribute(ATTRIBUTE_PREFIXMAPPING)) : null;
|
||||||
// exclusion patterns (optional)
|
// exclusion patterns (optional)
|
||||||
String exclusion = element.getAttribute(ATTRIBUTE_EXCLUDING);
|
String exclusion = element.getAttribute(ATTRIBUTE_EXCLUDING);
|
||||||
IPath[] exclusionPatterns = APathEntry.NO_EXCLUSION_PATTERNS;
|
IPath[] exclusionPatterns = APathEntry.NO_EXCLUSION_PATTERNS;
|
||||||
|
@ -725,7 +726,9 @@ public class PathEntryManager implements ICDescriptorListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see org.eclipse.cdt.core.ICDescriptorListener#descriptorChanged(org.eclipse.cdt.core.CDescriptorEvent)
|
* @see org.eclipse.cdt.core.ICDescriptorListener#descriptorChanged(org.eclipse.cdt.core.CDescriptorEvent)
|
||||||
*/
|
*/
|
||||||
public void descriptorChanged(CDescriptorEvent event) {
|
public void descriptorChanged(CDescriptorEvent event) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue