Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlain Magloire2003-10-27 03:12:03 +0000
committerAlain Magloire2003-10-27 03:12:03 +0000
commit7d41a65e943dea963f2f8ec0ccdde8e06288e1c8 (patch)
tree3ad0bfadd3801080b485b216d86ca8322f054336
parentf61ea0d8410ba4c1d4a964b1f687a8a9350f9257 (diff)
downloadorg.eclipse.cdt-7d41a65e943dea963f2f8ec0ccdde8e06288e1c8.tar.gz
org.eclipse.cdt-7d41a65e943dea963f2f8ec0ccdde8e06288e1c8.tar.xz
org.eclipse.cdt-7d41a65e943dea963f2f8ec0ccdde8e06288e1c8.zip
added method for implementing firing events when
cpathentry is modified.
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ICElementDelta.java12
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ICProject.java15
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ACPathEntry.java31
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CPathEntry.java19
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CProject.java23
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ContainerEntry.java20
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IncludeEntry.java32
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/LibraryEntry.java31
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MacroEntry.java29
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ProjectEntry.java20
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/SetCPathEntriesOperation.java77
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/SourceEntry.java29
12 files changed, 316 insertions, 22 deletions
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 277e0cf0fe6..b8edc907642 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
@@ -100,8 +100,16 @@ public interface ICElementDelta {
*/
public int F_BINARY_PARSER_CHANGED = 0x0800;
- //public int F_ADDED_TO_CLASSPATH = 0x0040;
- //public int F_REMOVED_FROM_CLASSPATH = 0x0080;
+ /**
+ * A cpathEntry was added for this resource.
+ */
+ public int F_ADDED_TO_CPATHENTRY = 0x0040;
+
+ /**
+ * A cpathEtnry was remove for this resource.
+ */
+ public int F_REMOVED_FROM_CPATHENTRY = 0x0080;
+
//public int F_CLASSPATH_REORDER = 0x0100;
//public int F_SUPER_TYPES = 0x0800;
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ICProject.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ICProject.java
index b11ef9368c9..32fb5e79942 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ICProject.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ICProject.java
@@ -131,7 +131,18 @@ public interface ICProject extends ICContainer {
* @exception CModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource
*/
- ICPathEntry[] getCPathEntries() throws CModelException;
+ ICPathEntry[] getResolvedCPathEntries() throws CModelException;
+
+ /**
+ * Returns the list of entries for the project. This corresponds to the exact set
+ * of entries which were assigned using <code>setCPathEntries</code>.
+ * <p>
+ *
+ * @return the list of entries for the project.
+ * @exception CModelException if this element does not exist or if an
+ * exception occurs while accessing its corresponding resource
+ */
+ ICPathEntry[] getRawCPathEntries() throws CModelException;
/**
* Sets the entries for this project.
@@ -144,6 +155,6 @@ public interface ICProject extends ICContainer {
* <li> The entries are being modified during resource change event notification (CORE_EXCEPTION)
* </ul>
*/
- void setCPathEntries(ICPathEntry[] entries, IProgressMonitor monitor) throws CModelException;
+ void setRawCPathEntries(ICPathEntry[] entries, IProgressMonitor monitor) throws CModelException;
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ACPathEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ACPathEntry.java
index 78410049aac..dffe125b56b 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ACPathEntry.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ACPathEntry.java
@@ -41,5 +41,34 @@ public abstract class ACPathEntry extends CPathEntry {
public boolean isRecursive() {
return isRecursive;
}
-
+
+ public boolean equals(Object obj) {
+ if (obj instanceof ACPathEntry) {
+ ACPathEntry otherEntry = (ACPathEntry)obj;
+ if (!super.equals(otherEntry)) {
+ return false;
+ }
+ if (isRecursive != otherEntry.isRecursive()) {
+ return false;
+ }
+ IPath[] otherExcludes = otherEntry.getExclusionPatterns();
+ if (exclusionPatterns != otherExcludes) {
+ int excludeLength = (exclusionPatterns == null) ? 0 : exclusionPatterns.length;
+ if (otherExcludes.length != excludeLength) {
+ return false;
+ }
+ for (int i = 0; i < excludeLength; i++) {
+ // compare toStrings instead of IPaths
+ // since IPath.equals is specified to ignore trailing separators
+ String myPattern = exclusionPatterns[i].toString();
+ if (!myPattern.equals(otherExcludes[i].toString())) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+ return super.equals(obj);
+ }
+
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CPathEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CPathEntry.java
index 51512920b57..2003955ece0 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CPathEntry.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CPathEntry.java
@@ -39,15 +39,18 @@ public class CPathEntry implements ICPathEntry {
return isExported;
}
- public boolean equals(ICPathEntry otherEntry) {
- return entryKind == otherEntry.getEntryKind();
- }
-
- public boolean equals(Object object) {
- if (object instanceof ICPathEntry) {
- return equals((ICPathEntry) object);
+ public boolean equals(Object obj) {
+ if (obj instanceof ICPathEntry) {
+ ICPathEntry otherEntry = (ICPathEntry)obj;
+ if (entryKind != otherEntry.getEntryKind()) {
+ return false;
+ }
+ if (isExported != otherEntry.isExported()) {
+ return false;
+ }
+ return true;
}
- return super.equals(object);
+ return super.equals(obj);
}
/**
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CProject.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CProject.java
index 896b0406f37..d9882bf2974 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CProject.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CProject.java
@@ -115,7 +115,7 @@ public class CProject extends CContainer implements ICProject {
binParser = CCorePlugin.getDefault().getBinaryParser(getProject());
} catch (CoreException e) {
}
- ICPathEntry[] entries = getCPathEntries();
+ ICPathEntry[] entries = getResolvedCPathEntries();
for (int i = 0; i < entries.length; i++) {
if (entries[i].getEntryKind() == ICPathEntry.CDT_LIBRARY) {
ILibraryEntry entry = (ILibraryEntry) entries[i];
@@ -145,7 +145,7 @@ public class CProject extends CContainer implements ICProject {
* @see ICProject#getRequiredProjectNames()
*/
public String[] getRequiredProjectNames() throws CModelException {
- return projectPrerequisites(getCPathEntries());
+ return projectPrerequisites(getResolvedCPathEntries());
}
public String[] projectPrerequisites(ICPathEntry[] entries) throws CModelException {
@@ -336,9 +336,17 @@ public class CProject extends CContainer implements ICProject {
static String VALUE_TRUE = "true"; //$NON-NLS-1$
/* (non-Javadoc)
- * @see org.eclipse.cdt.core.model.ICProject#getCPathEntries()
+ * @see org.eclipse.cdt.core.model.ICProject#getResolvedCPathEntries()
*/
- public ICPathEntry[] getCPathEntries() throws CModelException {
+ public ICPathEntry[] getResolvedCPathEntries() throws CModelException {
+ // Not implemented
+ return getRawCPathEntries();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.model.ICProject#getRawCPathEntries()
+ */
+ public ICPathEntry[] getRawCPathEntries() throws CModelException {
ArrayList pathEntries = new ArrayList();
try {
ICDescriptor cdesc = CCorePlugin.getDefault().getCProjectDescription(getProject());
@@ -359,11 +367,11 @@ public class CProject extends CContainer implements ICProject {
}
/* (non-Javadoc)
- * @see org.eclipse.cdt.core.model.ICProject#setCPathEntries(org.eclipse.cdt.core.model.ICPathEntry[], org.eclipse.core.runtime.IProgressMonitor)
+ * @see org.eclipse.cdt.core.model.ICProject#setRawCPathEntries(org.eclipse.cdt.core.model.ICPathEntry[], org.eclipse.core.runtime.IProgressMonitor)
*/
- public void setCPathEntries(ICPathEntry[] newEntries, IProgressMonitor monitor) throws CModelException {
+ public void setRawCPathEntries(ICPathEntry[] newEntries, IProgressMonitor monitor) throws CModelException {
try {
- SetCPathEntriesOperation op = new SetCPathEntriesOperation(this, getCPathEntries(), newEntries);
+ SetCPathEntriesOperation op = new SetCPathEntriesOperation(this, getRawCPathEntries(), newEntries);
runOperation(op, monitor);
} catch (CoreException e) {
throw new CModelException(e);
@@ -568,5 +576,4 @@ public class CProject extends CContainer implements ICProject {
}
}
}
-
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ContainerEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ContainerEntry.java
index e34fb365f3f..eae95703cf0 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ContainerEntry.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ContainerEntry.java
@@ -31,4 +31,24 @@ public class ContainerEntry extends CPathEntry implements IContainerEntry {
return id;
}
+ public boolean equals(Object obj) {
+ if (obj instanceof IContainerEntry) {
+ IContainerEntry container = (IContainerEntry)obj;
+ if (!super.equals(container)) {
+ return false;
+ }
+ if (id == null) {
+ if (container.getId() != null) {
+ return false;
+ }
+ } else {
+ if (!id.equals(container.getId())) {
+ return false;
+ }
+ }
+ return true;
+ }
+ return super.equals(obj);
+ }
+
}
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 58bca6a6b60..0072ee5ede2 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
@@ -52,5 +52,37 @@ public class IncludeEntry extends ACPathEntry implements IIncludeEntry {
public boolean isSystemInclude() {
return isSystemInclude;
}
+
+ public boolean equals(Object obj) {
+ if (obj instanceof IIncludeEntry) {
+ IIncludeEntry otherEntry = (IIncludeEntry)obj;
+ if (!super.equals(otherEntry)) {
+ return false;
+ }
+ if (resourcePath == null) {
+ if (otherEntry.getResourcePath() != null) {
+ return false;
+ }
+ } else {
+ if (!resourcePath.toString().equals(otherEntry.getResourcePath().toString())) {
+ return false;
+ }
+ }
+ if (includePath == null) {
+ if (otherEntry.getIncludePath() != null) {
+ return false;
+ }
+ } else {
+ if (!includePath.toString().equals(otherEntry.getIncludePath().toString())) {
+ return false;
+ }
+ }
+ if (isSystemInclude != otherEntry.isSystemInclude()) {
+ return false;
+ }
+ return true;
+ }
+ return super.equals(obj);
+ }
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/LibraryEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/LibraryEntry.java
index 46c055097b6..6e418ef0d0f 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/LibraryEntry.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/LibraryEntry.java
@@ -86,4 +86,35 @@ public class LibraryEntry extends CPathEntry implements ILibraryEntry {
return sourceAttachmentPrefixMapping;
}
+
+ public boolean equals(Object obj) {
+ if (obj instanceof ILibraryEntry) {
+ ILibraryEntry otherEntry = (ILibraryEntry)obj;
+ if (!super.equals(obj)) {
+ return false;
+ }
+ IPath otherPath = otherEntry.getSourceAttachmentPath();
+ if (sourceAttachmentPath == null) {
+ if (otherPath != null) {
+ return false;
+ }
+ } else {
+ if (!sourceAttachmentPath.equals(otherPath)) {
+ return false;
+ }
+ }
+ otherPath = otherEntry.getSourceAttachmentRootPath();
+ if (sourceAttachmentRootPath == null) {
+ if (otherPath != null) {
+ return false;
+ }
+ } else {
+ if (!sourceAttachmentRootPath.equals(otherPath)) {
+ return false;
+ }
+ }
+ return true;
+ }
+ return super.equals(obj);
+ }
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MacroEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MacroEntry.java
index 48662fd1c49..95d4d48bc25 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MacroEntry.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MacroEntry.java
@@ -54,4 +54,33 @@ public class MacroEntry extends ACPathEntry implements IMacroEntry {
return macroName;
}
+ public boolean equals(Object obj) {
+ if (obj instanceof IMacroEntry) {
+ IMacroEntry otherEntry = (IMacroEntry)obj;
+ if (!super.equals(otherEntry)) {
+ return false;
+ }
+ if (macroName == null) {
+ if (otherEntry.getMacroName() != null) {
+ return false;
+ }
+ } else {
+ if (!macroName.equals(otherEntry.getMacroName())) {
+ return false;
+ }
+ }
+ if (macroValue == null) {
+ if (otherEntry.getMacroValue() != null) {
+ return false;
+ }
+ } else {
+ if (!macroValue.equals(otherEntry.getMacroValue())) {
+ return false;
+ }
+ }
+ return true;
+ }
+ return super.equals(obj);
+ }
+
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ProjectEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ProjectEntry.java
index 4fa1e47bebb..48a1f3ff17d 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ProjectEntry.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ProjectEntry.java
@@ -33,4 +33,24 @@ public class ProjectEntry extends CPathEntry implements IProjectEntry {
return projectPath;
}
+ public boolean equals(Object obj) {
+ if (obj instanceof IProjectEntry) {
+ IProjectEntry otherEntry = (IProjectEntry)obj;
+ if (!super.equals(otherEntry)) {
+ return false;
+ }
+ if (projectPath == null) {
+ if (otherEntry.getProjectPath() != null) {
+ return false;
+ }
+ } else {
+ if (!projectPath.toString().equals(otherEntry.getProjectPath().toString())) {
+ return false;
+ }
+ }
+ return true;
+ }
+ return super.equals(obj);
+ }
+
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/SetCPathEntriesOperation.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/SetCPathEntriesOperation.java
index 6b838f5ffe3..1a354a18bc4 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/SetCPathEntriesOperation.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/SetCPathEntriesOperation.java
@@ -20,11 +20,19 @@ import java.util.Iterator;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.ICDescriptor;
import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICElementDelta;
import org.eclipse.cdt.core.model.ICPathEntry;
+import org.eclipse.cdt.core.model.IContainerEntry;
+import org.eclipse.cdt.core.model.IIncludeEntry;
+import org.eclipse.cdt.core.model.IMacroEntry;
+import org.eclipse.cdt.core.model.ISourceEntry;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -138,7 +146,74 @@ public class SetCPathEntriesOperation extends CModelOperation {
}
private void generateCPathEntryDeltas() {
+ CModelManager manager = CModelManager.getDefault();
+ boolean needToUpdateDependents = false;
+ CElementDelta delta = new CElementDelta(getCModel());
+ boolean hasDelta = false;
+
+ // Check the removed entries.
+ for (int i = 0; i < oldEntries.length; i++) {
+ boolean found = false;
+ for (int j = 0; j < newEntries.length; j++) {
+ if (oldEntries[i].equals(newEntries[j])) {
+ found = true;
+ break;
+ }
+ }
+ // Was it deleted.
+ if (!found) {
+ addCPathEntryDeltas(oldEntries[i], ICElementDelta.F_REMOVED_FROM_CPATHENTRY, delta);
+ }
+ }
+ // Check the new entries.
+ for (int i = 0; i < newEntries.length; i++) {
+ boolean found = false;
+ for (int j = 0; j < oldEntries.length; j++) {
+ if (newEntries[i].equals(oldEntries[j])) {
+ found = true;
+ break;
+ }
+ }
+ // is it new?
+ if (!found) {
+ addCPathEntryDeltas(newEntries[i], ICElementDelta.F_ADDED_TO_CPATHENTRY, delta);
+ }
+ }
}
-
+ /**
+ * Adds deltas, with the specified change flag.
+ */
+ protected void addCPathEntryDeltas(ICPathEntry entry, int flag, CElementDelta delta) {
+
+ int kind = entry.getEntryKind();
+ ICElement celement = null;
+ if (kind == ICPathEntry.CDT_SOURCE) {
+ ISourceEntry source = (ISourceEntry) entry;
+ IPath path = source.getSourcePath();
+ celement = CoreModel.getDefault().create(path);
+ } else if (kind == ICPathEntry.CDT_LIBRARY) {
+ //ILibraryEntry lib = (ILibraryEntry) entry;
+ //IPath path = lib.getLibraryPath();
+ celement = project;
+ } else if (kind == ICPathEntry.CDT_PROJECT) {
+ //IProjectEntry pentry = (IProjectEntry) entry;
+ //IPath path = pentry.getProjectPath();
+ celement = project;
+ } else if (kind == ICPathEntry.CDT_INCLUDE) {
+ IIncludeEntry include = (IIncludeEntry) entry;
+ IPath path = include.getResourcePath();
+ celement = CoreModel.getDefault().create(path);
+ } else if (kind == ICPathEntry.CDT_MACRO) {
+ IMacroEntry macro = (IMacroEntry) entry;
+ IPath path = macro.getResourcePath();
+ celement = CoreModel.getDefault().create(path);
+ } else if (kind == ICPathEntry.CDT_CONTAINER) {
+ IContainerEntry container = (IContainerEntry) entry;
+ celement = project;
+ }
+ if (celement != null) {
+ delta.changed(celement, flag);
+ }
+ }
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/SourceEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/SourceEntry.java
index 9dc82ab1741..2e317eb1dad 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/SourceEntry.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/SourceEntry.java
@@ -44,4 +44,33 @@ public class SourceEntry extends ACPathEntry implements ISourceEntry {
return outputLocation;
}
+ public boolean equals (Object obj) {
+ if (obj instanceof ISourceEntry) {
+ ISourceEntry otherEntry = (ISourceEntry)obj;
+ if (!super.equals(otherEntry)) {
+ return false;
+ }
+ if (sourcePath == null) {
+ if (otherEntry.getSourcePath() != null) {
+ return false;
+ }
+ } else {
+ if (!sourcePath.toString().equals(otherEntry.getSourcePath().toString())) {
+ return false;
+ }
+ }
+ if (outputLocation == null) {
+ if (otherEntry.getOutputLocation() != null) {
+ return false;
+ }
+ } else {
+ if (!outputLocation.toString().equals(otherEntry.getOutputLocation().toString())) {
+ return false;
+ }
+ }
+ return true;
+ }
+ return super.equals(obj);
+ }
+
}

Back to the top