1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 17:05:26 +02:00

Support for delta in the ICElementDelta hierarchy for

IPathEntry deltas.
This commit is contained in:
Alain Magloire 2004-02-24 05:03:30 +00:00
parent f25407a2dc
commit 5872a87f8c
8 changed files with 135 additions and 37 deletions

View file

@ -1,3 +1,9 @@
2004-02-23 Alain Magloire
Adjust the test for IPathEntry deltas.
* model/org/eclipse/cdt/core/model/test/CPathEntryTest.java
2004-02-21 Alain Magloire 2004-02-21 Alain Magloire
Refactor of the ICPatEntry to IPathEntry Refactor of the ICPatEntry to IPathEntry

View file

@ -54,7 +54,7 @@ public class CPathEntryTest extends TestCase {
int flags = delta.getFlags(); int flags = delta.getFlags();
int kind = delta.getKind(); int kind = delta.getKind();
if (kind == ICElementDelta.CHANGED ) { if (kind == ICElementDelta.CHANGED ) {
if ((flags & ICElementDelta.F_ADDED_TO_PATHENTRY) != 0) { if ((flags & ICElementDelta.F_ADDED_PATHENTRY_INCLUDE) != 0) {
count++; count++;
} }
} }
@ -141,8 +141,8 @@ public class CPathEntryTest extends TestCase {
IPathEntry[] entries = testProject.getResolvedPathEntries(); IPathEntry[] entries = testProject.getResolvedPathEntries();
assertTrue("No cpathentries", entries.length == 0); assertTrue("No cpathentries", entries.length == 0);
entries = new IPathEntry[3]; entries = new IPathEntry[3];
entries[0] = CoreModel.newIncludeEntry(new Path("/cpathtest"), new Path("/usr/include"), true); entries[0] = CoreModel.newIncludeEntry(new Path(""), new Path("/usr/include"), true);
entries[1] = CoreModel.newIncludeEntry(new Path("/cpaththest/foo.c"), new Path("/usr/include"), true); entries[1] = CoreModel.newIncludeEntry(new Path("cpaththest/foo.c"), new Path("/usr/include"), true);
entries[2] = CoreModel.newLibraryEntry(new Path("/usr/lib/libc.so.1"), null, null, null); entries[2] = CoreModel.newLibraryEntry(new Path("/usr/lib/libc.so.1"), null, null, null);
testProject.setRawPathEntries(entries, new NullProgressMonitor()); testProject.setRawPathEntries(entries, new NullProgressMonitor());
entries = testProject.getResolvedPathEntries(); entries = testProject.getResolvedPathEntries();
@ -163,7 +163,7 @@ public class CPathEntryTest extends TestCase {
} }
CProjectHelper.addSourceContainer(testProject, "foo"); CProjectHelper.addSourceContainer(testProject, "foo");
IPathEntry[] entries = new IPathEntry[3]; IPathEntry[] entries = new IPathEntry[3];
entries[0] = CoreModel.newIncludeEntry(new Path("/cpathtest"), new Path("/usr/include"), true); entries[0] = CoreModel.newIncludeEntry(new Path(""), new Path("/usr/include"), true);
entries[1] = CoreModel.newIncludeEntry(new Path("foo"), new Path("/usr/include"), true); entries[1] = CoreModel.newIncludeEntry(new Path("foo"), new Path("/usr/include"), true);
entries[2] = CoreModel.newLibraryEntry(new Path("/usr/lib/libc.so.1"), null, null, null); entries[2] = CoreModel.newLibraryEntry(new Path("/usr/lib/libc.so.1"), null, null, null);
CElementListener listener = new CElementListener(); CElementListener listener = new CElementListener();
@ -190,8 +190,8 @@ public class CPathEntryTest extends TestCase {
public IPathEntry[] getPathEntries() { public IPathEntry[] getPathEntries() {
IPathEntry[] entries = new IPathEntry[3]; IPathEntry[] entries = new IPathEntry[3];
entries[0] = CoreModel.newIncludeEntry(new Path("/cpathtest"), new Path("/usr/include"), true); entries[0] = CoreModel.newIncludeEntry(new Path(""), new Path("/usr/include"), true);
entries[1] = CoreModel.newIncludeEntry(new Path("/cpaththest/foo.c"), new Path("/usr/include"), true); entries[1] = CoreModel.newIncludeEntry(new Path("foo.c"), new Path("/usr/include"), true);
entries[2] = CoreModel.newLibraryEntry(new Path("/usr/lib/libc.so.1"), null, null, null); entries[2] = CoreModel.newLibraryEntry(new Path("/usr/lib/libc.so.1"), null, null, null);
return entries; return entries;
} }

View file

@ -1,3 +1,13 @@
2004-02-23 Alain Magloire
Support for IPathEntry deltas in the ICElementDelta
* model/org/eclipse/cdt/core/model/CoreModel.java
* model/org/eclipse/cdt/core/model/ICElementDelta.java
* model/org/eclipse/cdt/internal/core/model/CElementDelta.java
* model/org/eclipse/cdt/internal/core/model/IncludeEntry.java
* model/org/eclipse/cdt/internal/core/model/PathEntryManager.java
2004-02-22 John Camelon 2004-02-22 John Camelon
Fixed CModelManager.isValidTranslationUnitName() regression. Fixed CModelManager.isValidTranslationUnitName() regression.

View file

@ -312,7 +312,7 @@ public class CoreModel {
* </p> * </p>
* *
* @param path * @param path
* the absolute workspace-relative path of a source folder * the project-relative path of a source folder
* @return a new source entry with not exclusion patterns * @return a new source entry with not exclusion patterns
* *
*/ */
@ -335,7 +335,7 @@ public class CoreModel {
* </p> * </p>
* *
* @param path * @param path
* the absolute workspace-relative path of a source folder * the project-relative path of a source folder
* @param exclusionPatterns * @param exclusionPatterns
* the possibly empty list of exclusion patterns represented as * the possibly empty list of exclusion patterns represented as
* relative paths * relative paths
@ -361,7 +361,7 @@ public class CoreModel {
* </p> * </p>
* *
* @param path * @param path
* the absolute workspace-relative path of a source folder * the project-relative path of a source folder
* @param exclusionPatterns * @param exclusionPatterns
* the possibly empty list of exclusion patterns represented as * the possibly empty list of exclusion patterns represented as
* relative paths * relative paths
@ -406,7 +406,7 @@ public class CoreModel {
* Creates and returns a new entry of kind <code>CDT_INCLUDE</code> * Creates and returns a new entry of kind <code>CDT_INCLUDE</code>
* *
* @param path * @param path
* the affected worksapce-relative resource path * the affected project-relative resource path
* @param includePath * @param includePath
* the absolute path of the include * the absolute path of the include
* @return IIncludeEntry * @return IIncludeEntry
@ -415,11 +415,23 @@ public class CoreModel {
return newIncludeEntry(resourcePath, includePath, false); return newIncludeEntry(resourcePath, includePath, false);
} }
/**
* Creates and returns a new entry of kind <code>CDT_INCLUDE</code>
*
* @param includePath
* the absolute path of the include
* @return IIncludeEntry
*/
public static IIncludeEntry newIncludeEntry(IPath includePath) {
return newIncludeEntry(null, includePath, false);
}
/**
/** /**
* Creates and returns a new entry of kind <code>CDT_INCLUDE</code> * Creates and returns a new entry of kind <code>CDT_INCLUDE</code>
* *
* @param path * @param path
* the affected workspace-relative resource path * the affected project-relative resource path
* @param includePath * @param includePath
* the absolute path of the include * the absolute path of the include
* @param isSystemInclude * @param isSystemInclude
@ -435,7 +447,7 @@ public class CoreModel {
* Creates and returns a new entry of kind <code>CDT_INCLUDE</code> * Creates and returns a new entry of kind <code>CDT_INCLUDE</code>
* *
* @param path * @param path
* the affected workspace-relative resource path * the affected project-relative resource path
* @param includePath * @param includePath
* the absolute path of the include * the absolute path of the include
* @param isSystemInclude * @param isSystemInclude

View file

@ -87,48 +87,88 @@ public interface ICElementDelta {
* Change flag indicating that the underlying <code>IProject</code> has been * Change flag indicating that the underlying <code>IProject</code> has been
* opened. * opened.
*/ */
public int F_OPENED = 0x0200; public int F_OPENED = 0x0040;
/** /**
* Change flag indicating that the underlying <code>IProject</code> has been * Change flag indicating that the underlying <code>IProject</code> has been
* closed. * closed.
*/ */
public int F_CLOSED = 0x0400; public int F_CLOSED = 0x0080;
/** /**
* Change in the binary Parser. * A pathEntry Source changed for this resource.
*/ */
public int F_BINARY_PARSER_CHANGED = 0x0800; public int F_ADDED_PATHENTRY_SOURCE = 0x0100;
/** /**
* A cpathEntry was added for this resource. * A pathEntry Macro was added for this resource.
*/ */
public int F_ADDED_TO_PATHENTRY = 0x0040; public int F_ADDED_PATHENTRY_MACRO = 0x0200;
/** /**
* A cpathEtnry was remove for this resource. * A pathEntry Include was added for this resourc.
*/ */
public int F_REMOVED_FROM_PATHENTRY = 0x0080; public int F_ADDED_PATHENTRY_INCLUDE = 0x0400;
//public int F_CLASSPATH_REORDER = 0x0100; /**
//public int F_SUPER_TYPES = 0x0800; * A pathEntry Library was added for this resourc.
*/
public int F_ADDED_PATHENTRY_LIBRARY = 0x0800;
/**
* A pathEntry Project was added to the project.
*/
public int F_ADDED_PATHENTRY_PROJECT = 0x01000;
/**
* A pathEtnry Source was remove for this resource.
*/
public int F_REMOVED_PATHENTRY_SOURCE = 0x02000;
/**
* A pathEtnry Macro was remove for this resource.
*/
public int F_REMOVED_PATHENTRY_MACRO = 0x04000;
/**
* A pathEtnry Include was remove for this resource.
*/
public int F_REMOVED_PATHENTRY_INCLUDE = 0x08000;
/**
* A pathEtnry Library was remove for this resource.
*/
public int F_REMOVED_PATHENTRY_LIBRARY = 0x010000;
/**
* A pathEtnry Project was remove for this resource.
*/
public int F_REMOVED_PATHENTRY_PROJECT = 0x020000;
//public int F_PATHENTRY_REORDER = 0x040000;
//public int F_SUPER_TYPES = 0x080000;
/** /**
* Change flag indicating that a source jar has been attached to a binary jar. * Change flag indicating that a source jar has been attached to a binary jar.
*/ */
public int F_SOURCEATTACHED = 0x1000; public int F_SOURCEATTACHED = 0x100000;
/** /**
* Change flag indicating that a source jar has been detached to a binary jar. * Change flag indicating that a source jar has been detached to a binary jar.
*/ */
public int F_SOURCEDETACHED = 0x2000; public int F_SOURCEDETACHED = 0x200000;
/** /**
* Change flag indicating that this is a fine-grained delta, i.e. an analysis down * Change flag indicating that this is a fine-grained delta, i.e. an analysis down
* to the members level was done to determine if there were structural changes to * to the members level was done to determine if there were structural changes to
* members. * members.
*/ */
public int F_FINE_GRAINED = 0x4000; public int F_FINE_GRAINED = 0x400000;
/**
* Change in the binary Parser.
*/
public int F_BINARY_PARSER_CHANGED = 0x800000;
/** /**
* Returns deltas for the children that have been added. * Returns deltas for the children that have been added.

View file

@ -670,16 +670,40 @@ public class CElementDelta implements ICElementDelta {
buffer.append("MODIFIERS CHANGED"); //$NON-NLS-1$ buffer.append("MODIFIERS CHANGED"); //$NON-NLS-1$
prev = true; prev = true;
} }
if ((changeFlags & ICElementDelta.F_ADDED_TO_PATHENTRY) != 0) { if ((changeFlags & ICElementDelta.F_ADDED_PATHENTRY_INCLUDE) != 0) {
if (prev) if (prev)
buffer.append(" | "); //$NON-NLS-1$ buffer.append(" | "); //$NON-NLS-1$
buffer.append("ADDED TO PATHENTRY"); //$NON-NLS-1$ buffer.append("ADDED TO PATHENTRY INCLUDE"); //$NON-NLS-1$
prev = true; prev = true;
} }
if ((changeFlags & ICElementDelta.F_REMOVED_FROM_PATHENTRY) != 0) { if ((changeFlags & ICElementDelta.F_ADDED_PATHENTRY_MACRO) != 0) {
if (prev) if (prev)
buffer.append(" | "); //$NON-NLS-1$ buffer.append(" | "); //$NON-NLS-1$
buffer.append("REMOVED FROM PATHENTRY"); //$NON-NLS-1$ buffer.append("ADDED TO PATHENTRY MACRO"); //$NON-NLS-1$
prev = true;
}
if ((changeFlags & ICElementDelta.F_ADDED_PATHENTRY_LIBRARY) != 0) {
if (prev)
buffer.append(" | "); //$NON-NLS-1$
buffer.append("ADDED TO PATHENTRY LIBRARY"); //$NON-NLS-1$
prev = true;
}
if ((changeFlags & ICElementDelta.F_REMOVED_PATHENTRY_INCLUDE) != 0) {
if (prev)
buffer.append(" | "); //$NON-NLS-1$
buffer.append("REMOVED FROM PATHENTRY INCLUDE"); //$NON-NLS-1$
prev = true;
}
if ((changeFlags & ICElementDelta.F_REMOVED_PATHENTRY_MACRO) != 0) {
if (prev)
buffer.append(" | "); //$NON-NLS-1$
buffer.append("REMOVED FROM PATHENTRY MACRO"); //$NON-NLS-1$
prev = true;
}
if ((changeFlags & ICElementDelta.F_REMOVED_PATHENTRY_LIBRARY) != 0) {
if (prev)
buffer.append(" | "); //$NON-NLS-1$
buffer.append("REMOVED FROM PATHENTRY LIBRARY"); //$NON-NLS-1$
prev = true; prev = true;
} }

View file

@ -14,7 +14,6 @@ package org.eclipse.cdt.internal.core.model;
import org.eclipse.cdt.core.model.IIncludeEntry; import org.eclipse.cdt.core.model.IIncludeEntry;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
public class IncludeEntry extends APathEntry implements IIncludeEntry { public class IncludeEntry extends APathEntry implements IIncludeEntry {
@ -24,8 +23,8 @@ public class IncludeEntry extends APathEntry implements IIncludeEntry {
public IncludeEntry(IPath resourcePath, IPath includePath, boolean isSystemInclude, boolean isRecursive, public IncludeEntry(IPath resourcePath, IPath includePath, boolean isSystemInclude, boolean isRecursive,
IPath[] exclusionPatterns) { IPath[] exclusionPatterns) {
super(IIncludeEntry.CDT_INCLUDE, isRecursive, exclusionPatterns, false); super(IIncludeEntry.CDT_INCLUDE, isRecursive, exclusionPatterns, resourcePath == null);
this.resourcePath = resourcePath == null ? new Path("/") : resourcePath; this.resourcePath = resourcePath;
this.includePath = includePath; this.includePath = includePath;
this.isSystemInclude = isSystemInclude; this.isSystemInclude = isSystemInclude;
} }

View file

@ -425,7 +425,7 @@ public class PathEntryManager {
// Was it deleted. // Was it deleted.
if (!found) { if (!found) {
ICElementDelta delta = ICElementDelta delta =
makePathEntryDelta(cproject, oldEntries[i], ICElementDelta.F_REMOVED_FROM_PATHENTRY); makePathEntryDelta(cproject, oldEntries[i], true);
if (delta != null) { if (delta != null) {
list.add(delta); list.add(delta);
} }
@ -447,7 +447,7 @@ public class PathEntryManager {
// is it new? // is it new?
if (!found) { if (!found) {
ICElementDelta delta = ICElementDelta delta =
makePathEntryDelta(cproject, newEntries[i], ICElementDelta.F_ADDED_TO_PATHENTRY); makePathEntryDelta(cproject, newEntries[i], false);
if (delta != null) { if (delta != null) {
list.add(delta); list.add(delta);
} }
@ -462,32 +462,39 @@ public class PathEntryManager {
/** /**
* return a delta, with the specified change flag. * return a delta, with the specified change flag.
*/ */
protected ICElementDelta makePathEntryDelta(ICProject cproject, IPathEntry entry, int flag) { protected ICElementDelta makePathEntryDelta(ICProject cproject, IPathEntry entry, boolean removed) {
int kind = entry.getEntryKind(); int kind = entry.getEntryKind();
ICElement celement = null; ICElement celement = null;
int flag = 0;
if (kind == IPathEntry.CDT_SOURCE) { if (kind == IPathEntry.CDT_SOURCE) {
ISourceEntry source = (ISourceEntry) entry; ISourceEntry source = (ISourceEntry) entry;
IPath path = source.getSourcePath(); IPath path = source.getSourcePath();
celement = CoreModel.getDefault().create(path); celement = CoreModel.getDefault().create(path);
flag = (removed) ? ICElementDelta.F_REMOVED_PATHENTRY_SOURCE : ICElementDelta.F_ADDED_PATHENTRY_SOURCE;
} else if (kind == IPathEntry.CDT_LIBRARY) { } else if (kind == IPathEntry.CDT_LIBRARY) {
//ILibraryEntry lib = (ILibraryEntry) entry; //ILibraryEntry lib = (ILibraryEntry) entry;
//IPath path = lib.getLibraryPath(); //IPath path = lib.getLibraryPath();
celement = cproject; celement = cproject;
flag = (removed) ? ICElementDelta.F_REMOVED_PATHENTRY_LIBRARY : ICElementDelta.F_ADDED_PATHENTRY_LIBRARY;
} else if (kind == IPathEntry.CDT_PROJECT) { } else if (kind == IPathEntry.CDT_PROJECT) {
//IProjectEntry pentry = (IProjectEntry) entry; //IProjectEntry pentry = (IProjectEntry) entry;
//IPath path = pentry.getProjectPath(); //IPath path = pentry.getProjectPath();
celement = cproject; celement = cproject;
flag = (removed) ? ICElementDelta.F_REMOVED_PATHENTRY_PROJECT : ICElementDelta.F_ADDED_PATHENTRY_PROJECT;
} else if (kind == IPathEntry.CDT_INCLUDE) { } else if (kind == IPathEntry.CDT_INCLUDE) {
IIncludeEntry include = (IIncludeEntry) entry; IIncludeEntry include = (IIncludeEntry) entry;
IPath path = include.getResourcePath(); IPath path = include.getResourcePath();
celement = CoreModel.getDefault().create(path); celement = CoreModel.getDefault().create(path);
flag = (removed) ? ICElementDelta.F_REMOVED_PATHENTRY_INCLUDE : ICElementDelta.F_ADDED_PATHENTRY_INCLUDE;
} else if (kind == IPathEntry.CDT_MACRO) { } else if (kind == IPathEntry.CDT_MACRO) {
IMacroEntry macro = (IMacroEntry) entry; IMacroEntry macro = (IMacroEntry) entry;
IPath path = macro.getResourcePath(); IPath path = macro.getResourcePath();
celement = CoreModel.getDefault().create(path); celement = CoreModel.getDefault().create(path);
flag = (removed) ? ICElementDelta.F_REMOVED_PATHENTRY_MACRO : ICElementDelta.F_ADDED_PATHENTRY_MACRO;
} else if (kind == IPathEntry.CDT_CONTAINER) { } else if (kind == IPathEntry.CDT_CONTAINER) {
IContainerEntry container = (IContainerEntry) entry; //IContainerEntry container = (IContainerEntry) entry;
celement = cproject; //celement = cproject;
// SHOULD NOT BE HERE Container are resolved.
} }
if (celement == null) { if (celement == null) {
celement = cproject; celement = cproject;