--- html.navigator/src/org/netbeans/modules/html/navigator/Diff.java
+++ html.navigator/src/org/netbeans/modules/html/navigator/Diff.java
@@ -174,31 +174,33 @@
}
}
- //now lets compare by the other attributes
- Map d1Attrs = d1.getAttributes();
- Map d2Attrs = d2.getAttributes();
- if (d1Attrs.size() != d2Attrs.size()) {
- return false;
- }
- //compare the name=value entries
- Collection attrsSet = new HashSet();
- //the algorithm expects same collections size!
- attrsSet.addAll(d1Attrs.entrySet());
- attrsSet.removeAll(d2Attrs.entrySet());
- if (!attrsSet.isEmpty()) {
- //they differ
- return false;
- }
+ return d1.getElementPath().equals(d2.getElementPath());
- //ok, now we have same name, same attributes w/o id
- //what next?=>compute the "index in similar nodes"
- if (checkIndexInParent && getIndexInParent(d1, forceIdAttrEquality) != getIndexInParent(d2, forceIdAttrEquality)) {
- return false;
+// //now lets compare by the other attributes
+// Map d1Attrs = d1.getAttributes();
+// Map d2Attrs = d2.getAttributes();
+// if (d1Attrs.size() != d2Attrs.size()) {
+// return false;
+// }
+// //compare the name=value entries
+// Collection attrsSet = new HashSet();
+// //the algorithm expects same collections size!
+// attrsSet.addAll(d1Attrs.entrySet());
+// attrsSet.removeAll(d2Attrs.entrySet());
+// if (!attrsSet.isEmpty()) {
+// //they differ
+// return false;
+// }
+//
+// //ok, now we have same name, same attributes w/o id
+// //what next?=>compute the "index in similar nodes"
+// if (checkIndexInParent && getIndexInParent(d1, forceIdAttrEquality) != getIndexInParent(d2, forceIdAttrEquality)) {
+// return false;
+// }
+//
+// return true;
}
- return true;
- }
-
/**
* Computes hashCode for the given {@link Description}
*
@@ -235,7 +237,7 @@
}
}
- hash = 37 * hash + getIndexInParent(d, forceIdAttrEquality);
+ hash = 37 * hash + d.getElementPath().hashCode();//getIndexInParent(d, forceIdAttrEquality);
return hash;
}
@@ -245,25 +247,15 @@
*
*/
static int getIndexInParent(Description d, boolean forceIdAttrEquality) {
- int index = 0;
- Description parent = d.getParent();
- if (parent == null) {
- //nothing to do w/o parent
- //should possibly return something like Integer.MIN_VALUE, but
- //return 0 in this case to overcome the problem with different parent's of
- //dom node (html has no parent) and the source node (has the root node as parent)
- return index;
+ int lastIndexOf = d.getElementPath().lastIndexOf('|');
+ if (lastIndexOf < 0) {
+ return 0;
}
- for (Description ch : parent.getChildren()) {
- if (ch == d) {
- //we found THE "D" element, break
- break;
+ String substring = d.getElementPath().substring(lastIndexOf+1);
+ try {
+ return Integer.parseInt(substring);
+ } catch (NumberFormatException ex) {
+ return 0;
}
- if (equals(ch, d, false, forceIdAttrEquality)) {
- //we found equal element, but not THE "D" element, increase index
- index++;
}
}
- return index;
- }
-}