diff --git a/core/org.eclipse.cdt.core.tests/ChangeLog b/core/org.eclipse.cdt.core.tests/ChangeLog index 76725892083..72e58eef948 100644 --- a/core/org.eclipse.cdt.core.tests/ChangeLog +++ b/core/org.eclipse.cdt.core.tests/ChangeLog @@ -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 Refactor of the ICPatEntry to IPathEntry diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CPathEntryTest.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CPathEntryTest.java index ca49d5d6cf4..f7050a0ef32 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CPathEntryTest.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CPathEntryTest.java @@ -54,7 +54,7 @@ public class CPathEntryTest extends TestCase { int flags = delta.getFlags(); int kind = delta.getKind(); if (kind == ICElementDelta.CHANGED ) { - if ((flags & ICElementDelta.F_ADDED_TO_PATHENTRY) != 0) { + if ((flags & ICElementDelta.F_ADDED_PATHENTRY_INCLUDE) != 0) { count++; } } @@ -141,8 +141,8 @@ public class CPathEntryTest extends TestCase { IPathEntry[] entries = testProject.getResolvedPathEntries(); assertTrue("No cpathentries", entries.length == 0); entries = new IPathEntry[3]; - entries[0] = CoreModel.newIncludeEntry(new Path("/cpathtest"), new Path("/usr/include"), true); - entries[1] = CoreModel.newIncludeEntry(new Path("/cpaththest/foo.c"), 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[2] = CoreModel.newLibraryEntry(new Path("/usr/lib/libc.so.1"), null, null, null); testProject.setRawPathEntries(entries, new NullProgressMonitor()); entries = testProject.getResolvedPathEntries(); @@ -163,7 +163,7 @@ public class CPathEntryTest extends TestCase { } CProjectHelper.addSourceContainer(testProject, "foo"); 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[2] = CoreModel.newLibraryEntry(new Path("/usr/lib/libc.so.1"), null, null, null); CElementListener listener = new CElementListener(); @@ -190,8 +190,8 @@ public class CPathEntryTest extends TestCase { public IPathEntry[] getPathEntries() { IPathEntry[] entries = new IPathEntry[3]; - entries[0] = CoreModel.newIncludeEntry(new Path("/cpathtest"), new Path("/usr/include"), true); - entries[1] = CoreModel.newIncludeEntry(new Path("/cpaththest/foo.c"), new Path("/usr/include"), true); + entries[0] = CoreModel.newIncludeEntry(new Path(""), 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); return entries; } diff --git a/core/org.eclipse.cdt.core/ChangeLog b/core/org.eclipse.cdt.core/ChangeLog index 9e491a73394..7f5d1ff8af3 100644 --- a/core/org.eclipse.cdt.core/ChangeLog +++ b/core/org.eclipse.cdt.core/ChangeLog @@ -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 Fixed CModelManager.isValidTranslationUnitName() regression. diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java index 2daf802dc64..98385bd117e 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java @@ -312,7 +312,7 @@ public class CoreModel { *

* * @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 * */ @@ -335,7 +335,7 @@ public class CoreModel { *

* * @param path - * the absolute workspace-relative path of a source folder + * the project-relative path of a source folder * @param exclusionPatterns * the possibly empty list of exclusion patterns represented as * relative paths @@ -361,7 +361,7 @@ public class CoreModel { *

* * @param path - * the absolute workspace-relative path of a source folder + * the project-relative path of a source folder * @param exclusionPatterns * the possibly empty list of exclusion patterns represented as * relative paths @@ -406,7 +406,7 @@ public class CoreModel { * Creates and returns a new entry of kind CDT_INCLUDE * * @param path - * the affected worksapce-relative resource path + * the affected project-relative resource path * @param includePath * the absolute path of the include * @return IIncludeEntry @@ -415,11 +415,23 @@ public class CoreModel { return newIncludeEntry(resourcePath, includePath, false); } + /** + * Creates and returns a new entry of kind CDT_INCLUDE + * + * @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 CDT_INCLUDE * * @param path - * the affected workspace-relative resource path + * the affected project-relative resource path * @param includePath * the absolute path of the include * @param isSystemInclude @@ -435,7 +447,7 @@ public class CoreModel { * Creates and returns a new entry of kind CDT_INCLUDE * * @param path - * the affected workspace-relative resource path + * the affected project-relative resource path * @param includePath * the absolute path of the include * @param isSystemInclude diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ICElementDelta.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ICElementDelta.java index 1f3a74ea60f..dd89fa68952 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ICElementDelta.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ICElementDelta.java @@ -87,48 +87,88 @@ public interface ICElementDelta { * Change flag indicating that the underlying IProject has been * opened. */ - public int F_OPENED = 0x0200; + public int F_OPENED = 0x0040; /** * Change flag indicating that the underlying IProject has been * 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. */ - public int F_SOURCEATTACHED = 0x1000; + public int F_SOURCEATTACHED = 0x100000; /** * 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 * to the members level was done to determine if there were structural changes to * 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. diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CElementDelta.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CElementDelta.java index 299212c29e7..73b354e6e40 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CElementDelta.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CElementDelta.java @@ -670,16 +670,40 @@ public class CElementDelta implements ICElementDelta { buffer.append("MODIFIERS CHANGED"); //$NON-NLS-1$ prev = true; } - if ((changeFlags & ICElementDelta.F_ADDED_TO_PATHENTRY) != 0) { + if ((changeFlags & ICElementDelta.F_ADDED_PATHENTRY_INCLUDE) != 0) { if (prev) buffer.append(" | "); //$NON-NLS-1$ - buffer.append("ADDED TO PATHENTRY"); //$NON-NLS-1$ + buffer.append("ADDED TO PATHENTRY INCLUDE"); //$NON-NLS-1$ prev = true; } - if ((changeFlags & ICElementDelta.F_REMOVED_FROM_PATHENTRY) != 0) { + if ((changeFlags & ICElementDelta.F_ADDED_PATHENTRY_MACRO) != 0) { if (prev) 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; } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IncludeEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IncludeEntry.java index df42df0536d..d0bf9fb90f7 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IncludeEntry.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IncludeEntry.java @@ -14,7 +14,6 @@ package org.eclipse.cdt.internal.core.model; import org.eclipse.cdt.core.model.IIncludeEntry; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; 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, IPath[] exclusionPatterns) { - super(IIncludeEntry.CDT_INCLUDE, isRecursive, exclusionPatterns, false); - this.resourcePath = resourcePath == null ? new Path("/") : resourcePath; + super(IIncludeEntry.CDT_INCLUDE, isRecursive, exclusionPatterns, resourcePath == null); + this.resourcePath = resourcePath; this.includePath = includePath; this.isSystemInclude = isSystemInclude; } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryManager.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryManager.java index 272f33cd381..e2d9b54bc7e 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryManager.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryManager.java @@ -425,7 +425,7 @@ public class PathEntryManager { // Was it deleted. if (!found) { ICElementDelta delta = - makePathEntryDelta(cproject, oldEntries[i], ICElementDelta.F_REMOVED_FROM_PATHENTRY); + makePathEntryDelta(cproject, oldEntries[i], true); if (delta != null) { list.add(delta); } @@ -447,7 +447,7 @@ public class PathEntryManager { // is it new? if (!found) { ICElementDelta delta = - makePathEntryDelta(cproject, newEntries[i], ICElementDelta.F_ADDED_TO_PATHENTRY); + makePathEntryDelta(cproject, newEntries[i], false); if (delta != null) { list.add(delta); } @@ -462,32 +462,39 @@ public class PathEntryManager { /** * 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(); ICElement celement = null; + int flag = 0; if (kind == IPathEntry.CDT_SOURCE) { ISourceEntry source = (ISourceEntry) entry; IPath path = source.getSourcePath(); celement = CoreModel.getDefault().create(path); + flag = (removed) ? ICElementDelta.F_REMOVED_PATHENTRY_SOURCE : ICElementDelta.F_ADDED_PATHENTRY_SOURCE; } else if (kind == IPathEntry.CDT_LIBRARY) { //ILibraryEntry lib = (ILibraryEntry) entry; //IPath path = lib.getLibraryPath(); celement = cproject; + flag = (removed) ? ICElementDelta.F_REMOVED_PATHENTRY_LIBRARY : ICElementDelta.F_ADDED_PATHENTRY_LIBRARY; } else if (kind == IPathEntry.CDT_PROJECT) { //IProjectEntry pentry = (IProjectEntry) entry; //IPath path = pentry.getProjectPath(); celement = cproject; + flag = (removed) ? ICElementDelta.F_REMOVED_PATHENTRY_PROJECT : ICElementDelta.F_ADDED_PATHENTRY_PROJECT; } else if (kind == IPathEntry.CDT_INCLUDE) { IIncludeEntry include = (IIncludeEntry) entry; IPath path = include.getResourcePath(); celement = CoreModel.getDefault().create(path); + flag = (removed) ? ICElementDelta.F_REMOVED_PATHENTRY_INCLUDE : ICElementDelta.F_ADDED_PATHENTRY_INCLUDE; } else if (kind == IPathEntry.CDT_MACRO) { IMacroEntry macro = (IMacroEntry) entry; IPath path = macro.getResourcePath(); celement = CoreModel.getDefault().create(path); + flag = (removed) ? ICElementDelta.F_REMOVED_PATHENTRY_MACRO : ICElementDelta.F_ADDED_PATHENTRY_MACRO; } else if (kind == IPathEntry.CDT_CONTAINER) { - IContainerEntry container = (IContainerEntry) entry; - celement = cproject; + //IContainerEntry container = (IContainerEntry) entry; + //celement = cproject; + // SHOULD NOT BE HERE Container are resolved. } if (celement == null) { celement = cproject;