--- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CLibraryFileEntry.java Thu Jul 30 12:03:02 2009 -0500
+++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CLibraryFileEntry.java Thu Jul 30 14:23:38 2009 -0500
@@ -93,6 +93,18 @@
}
@Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((fSourceAttachmentPath == null) ? 0 : fSourceAttachmentPath.hashCode());
+ result = prime * result
+ + ((fSourceAttachmentPrefixMapping == null) ? 0 : fSourceAttachmentPrefixMapping.hashCode());
+ result = prime * result
+ + ((fSourceAttachmentRootPath == null) ? 0 : fSourceAttachmentRootPath.hashCode());
+ return result;
+ }
+
+ @Override
public boolean equals(Object other) {
if(other == this)
return true;
--- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/APathEntry.java Thu Jul 30 12:03:02 2009 -0500
+++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/APathEntry.java Thu Jul 30 14:23:38 2009 -0500
@@ -81,6 +81,16 @@
}
@Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((basePath == null) ? 0 : basePath.hashCode());
+ result = prime * result + ((baseRef == null) ? 0 : baseRef.hashCode());
+ result = prime * result + Arrays.hashCode(exclusionPatterns);
+ return result;
+ }
+
+ @Override
public boolean equals(Object obj) {
if (obj instanceof APathEntry) {
APathEntry otherEntry = (APathEntry)obj;
@@ -125,16 +135,6 @@
return super.equals(obj);
}
- @Override
- public int hashCode() {
- int hashCode = Arrays.hashCode(exclusionPatterns);
- if (basePath != null)
- hashCode += basePath.hashCode();
- if (baseRef != null)
- hashCode += baseRef.hashCode();
- return hashCode + super.hashCode();
- }
-
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@@ -150,4 +150,5 @@
}
return sb.toString();
}
+
}
--- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IncludeEntry.java Thu Jul 30 12:03:02 2009 -0500
+++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IncludeEntry.java Thu Jul 30 14:23:38 2009 -0500
@@ -49,6 +49,16 @@
return isSystemInclude;
}
+@Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result
+ + ((includePath == null) ? 0 : includePath.hashCode());
+ result = prime * result + (isSystemInclude ? 1231 : 1237);
+ return result;
+ }
+
@Override
public boolean equals(Object obj) {
if (obj instanceof IIncludeEntry) {
--- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IncludeFileEntry.java Thu Jul 30 12:03:02 2009 -0500
+++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IncludeFileEntry.java Thu Jul 30 14:23:38 2009 -0500
@@ -41,6 +41,16 @@
}
@Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result
+ + ((includeFilePath == null) ? 0 : includeFilePath.hashCode());
+ return result;
+ }
+
+
+ @Override
public boolean equals(Object obj) {
if (obj instanceof IIncludeFileEntry) {
IIncludeFileEntry otherEntry = (IIncludeFileEntry) obj;
--- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/LibraryEntry.java Thu Jul 30 12:03:02 2009 -0500
+++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/LibraryEntry.java Thu Jul 30 14:23:38 2009 -0500
@@ -133,6 +133,17 @@
return super.equals(obj);
}
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((libraryPath == null) ? 0 : libraryPath.hashCode());
+ result = prime * result + ((sourceAttachmentPath == null) ? 0 : sourceAttachmentPath.hashCode());
+ result = prime * result
+ + ((sourceAttachmentRootPath == null) ? 0 : sourceAttachmentRootPath.hashCode());
+ return result;
+ }
+
public IPath getFullLibraryPath() {
IPath p;
IPath lib = getLibraryPath();
--- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MacroEntry.java Thu Jul 30 12:03:02 2009 -0500
+++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MacroEntry.java Thu Jul 30 14:23:38 2009 -0500
@@ -45,6 +45,17 @@
}
@Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result
+ + ((macroName == null) ? 0 : macroName.hashCode());
+ result = prime * result
+ + ((macroValue == null) ? 0 : macroValue.hashCode());
+ return result;
+ }
+
+ @Override
public boolean equals(Object obj) {
if (obj instanceof IMacroEntry) {
IMacroEntry otherEntry = (IMacroEntry)obj;
@@ -74,11 +85,6 @@
return super.equals(obj);
}
- @Override
- public int hashCode() {
- return macroName.hashCode() + macroValue.hashCode() + super.hashCode();
- }
-
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
--- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MacroFileEntry.java Thu Jul 30 12:03:02 2009 -0500
+++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MacroFileEntry.java Thu Jul 30 14:23:38 2009 -0500
@@ -40,6 +40,15 @@
}
@Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result
+ + ((macroFilePath == null) ? 0 : macroFilePath.hashCode());
+ return result;
+ }
+
+ @Override
public boolean equals(Object obj) {
if (obj instanceof IMacroFileEntry) {
IMacroFileEntry otherEntry = (IMacroFileEntry) obj;
--- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntry.java Thu Jul 30 12:03:02 2009 -0500
+++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntry.java Thu Jul 30 14:23:38 2009 -0500
@@ -73,7 +73,12 @@
@Override
public int hashCode() {
- return path.hashCode() + entryKind * 17 + (isExported ? 3 : 2);
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + entryKind;
+ result = prime * result + (isExported ? 1231 : 1237);
+ result = prime * result + ((path == null) ? 0 : path.hashCode());
+ return result;
}
/**
--- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryUtil.java Thu Jul 30 12:03:02 2009 -0500
+++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryUtil.java Thu Jul 30 14:23:38 2009 -0500
@@ -12,9 +12,12 @@
package org.eclipse.cdt.internal.core.model;
import java.io.File;
+import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.model.CModelException;
@@ -335,17 +338,17 @@
public static ICModelStatus validatePathEntry(ICProject cProject, IPathEntry[] entries) {
// Check duplication.
+ Set<IPathEntry> entrySet = new HashSet<IPathEntry>(entries.length);
for (IPathEntry entry : entries) {
- if (entry == null) {
- continue;
- }
- for (IPathEntry otherEntry : entries) {
- if (otherEntry == null) {
- continue;
+ if (entry != null) {
+ if (entrySet.contains(entry)) {
+ return new CModelStatus(ICModelStatusConstants.INVALID_PATHENTRY,
+ MessageFormat.format("{0}{1}", //$NON-NLS-1$
+ CCorePlugin.getResourceString("CoreModel.PathEntry.DuplicateEntry"), //$NON-NLS-1$
+ entry.getPath().toString()));
}
- if (entry != otherEntry && otherEntry.equals(entry)) {
- StringBuffer errMesg = new StringBuffer(CCorePlugin.getResourceString("CoreModel.PathEntry.DuplicateEntry")); //$NON-NLS-1$
- return new CModelStatus(ICModelStatusConstants.INVALID_PATHENTRY, errMesg.toString());
+ else {
+ entrySet.add(entry);
}
}
}
--- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java Thu Jul 30 12:03:02 2009 -0500
+++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java Thu Jul 30 14:23:38 2009 -0500
@@ -1793,14 +1793,15 @@
newEntries = EMPTY_LANGUAGE_SETTINGS_ENTRIES_ARRAY;
}
+ Set<ICLanguageSettingEntry> newEntrySet = new HashSet<ICLanguageSettingEntry>(Arrays.asList(newEntries));
+ Set<ICLanguageSettingEntry> oldEntrySet = new HashSet<ICLanguageSettingEntry>(Arrays.asList(oldEntries));
+
// Check the removed entries.
- for (int i = 0; i < oldEntries.length; i++) {
+ for (ICLanguageSettingEntry oldEntry : oldEntries) {
boolean found = false;
- for (int j = 0; j < newEntries.length; j++) {
- if (oldEntries[i].equals(newEntries[j])) {
- found = true;
- break;
- }
+ if (newEntrySet.contains(oldEntry)) {
+ found = true;
+ break;
}
if(!found){
result[1] = true;
@@ -1809,13 +1810,11 @@
}
// Check the new entries.
- for (int i = 0; i < newEntries.length; i++) {
+ for (ICLanguageSettingEntry newEntry : newEntries) {
boolean found = false;
- for (int j = 0; j < oldEntries.length; j++) {
- if (newEntries[i].equals(oldEntries[j])) {
- found = true;
- break;
- }
+ if (oldEntrySet.contains(newEntry)) {
+ found = true;
+ break;
}
if(!found){
result[0] = true;
--- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CCorePluginResources.properties Thu Jul 30 12:03:02 2009 -0500
+++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CCorePluginResources.properties Thu Jul 30 14:23:38 2009 -0500
@@ -22,7 +22,7 @@
CoreModel.NullBinaryParser.Null_Format=Null Format
CoreModel.PathEntry.IllegalContainerPath= Illegal container entry
-CoreModel.PathEntry.DuplicateEntry= Duplicate path entries
+CoreModel.PathEntry.DuplicateEntry= Duplicate path entries found: {0}
CoreModel.PathEntry.NestedEntry= Nested path entries
CoreModel.PathEntry.InvalidPathEntry= Invalid path