This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 197458
Collapse All | Expand All

(-)html.navigator/src/org/netbeans/modules/html/navigator/Diff.java (-41 / +33 lines)
Lines 174-204 Link Here
174
            }
174
            }
175
        }
175
        }
176
176
177
        //now lets compare by the other attributes
177
        return d1.getElementPath().equals(d2.getElementPath());
178
        Map<String, String> d1Attrs = d1.getAttributes();
179
        Map<String, String> d2Attrs = d2.getAttributes();
180
        if (d1Attrs.size() != d2Attrs.size()) {
181
            return false;
182
        }
183
        //compare the name=value entries
184
        Collection<Map.Entry> attrsSet = new HashSet<Map.Entry>();
185
        //the algorithm expects same collections size!
186
        attrsSet.addAll(d1Attrs.entrySet());
187
        attrsSet.removeAll(d2Attrs.entrySet());
188
        if (!attrsSet.isEmpty()) {
189
            //they differ
190
            return false;
191
        }
192
178
193
        //ok, now we have same name, same attributes w/o id
179
//        //now lets compare by the other attributes
194
        //what next?=>compute the "index in similar nodes"
180
//        Map<String, String> d1Attrs = d1.getAttributes();
195
        if (checkIndexInParent && getIndexInParent(d1, forceIdAttrEquality) != getIndexInParent(d2, forceIdAttrEquality)) {
181
//        Map<String, String> d2Attrs = d2.getAttributes();
196
            return false;
182
//        if (d1Attrs.size() != d2Attrs.size()) {
183
//            return false;
184
//        }
185
//        //compare the name=value entries
186
//        Collection<Map.Entry> attrsSet = new HashSet<Map.Entry>();
187
//        //the algorithm expects same collections size!
188
//        attrsSet.addAll(d1Attrs.entrySet());
189
//        attrsSet.removeAll(d2Attrs.entrySet());
190
//        if (!attrsSet.isEmpty()) {
191
//            //they differ
192
//            return false;
193
//        }
194
//
195
//        //ok, now we have same name, same attributes w/o id
196
//        //what next?=>compute the "index in similar nodes"
197
//        if (checkIndexInParent && getIndexInParent(d1, forceIdAttrEquality) != getIndexInParent(d2, forceIdAttrEquality)) {
198
//            return false;
199
//        }
200
//
201
//        return true;
197
        }
202
        }
198
203
199
        return true;
200
    }
201
202
    /**
204
    /**
203
     * Computes hashCode for the given {@link Description}
205
     * Computes hashCode for the given {@link Description}
204
     * 
206
     * 
Lines 235-241 Link Here
235
            }
237
            }
236
        }
238
        }
237
239
238
        hash = 37 * hash + getIndexInParent(d, forceIdAttrEquality);
240
        hash = 37 * hash + d.getElementPath().hashCode();//getIndexInParent(d, forceIdAttrEquality);
239
241
240
        return hash;
242
        return hash;
241
    }
243
    }
Lines 245-269 Link Here
245
     * 
247
     * 
246
     */
248
     */
247
    static int getIndexInParent(Description d, boolean forceIdAttrEquality) {
249
    static int getIndexInParent(Description d, boolean forceIdAttrEquality) {
248
        int index = 0;
250
        int lastIndexOf = d.getElementPath().lastIndexOf('|');
249
        Description parent = d.getParent();
251
        if (lastIndexOf < 0) {
250
        if (parent == null) {
252
            return 0;
251
            //nothing to do w/o parent
252
            //should possibly return something like Integer.MIN_VALUE, but 
253
            //return 0 in this case to overcome the problem with different parent's of
254
            //dom node (html has no parent) and the source node (has the root node as parent)
255
            return index;
256
        }
253
        }
257
        for (Description ch : parent.getChildren()) {
254
        String substring = d.getElementPath().substring(lastIndexOf+1);
258
            if (ch == d) {
255
        try {
259
                //we found THE "D" element, break
256
            return Integer.parseInt(substring);
260
                break;
257
        } catch (NumberFormatException ex) {
258
            return 0;
261
            }
259
            }
262
            if (equals(ch, d, false, forceIdAttrEquality)) {
263
                //we found equal element, but not THE "D" element, increase index
264
                index++;
265
            }
260
            }
266
        }
261
        }
267
        return index;
268
    }
269
}

Return to bug 197458