-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Compare two objects in Variable View #531
This commit provides a new feature to compare elements of commonly used objects of similar types like Map, HashMap, LinkedHashMap, ConcurrentHashMap, Hashtable , IdentityHashMap, WeakHashMap, TreeMap, List, ArrayList, Stack, Vector, LinkedList, HashSet, LinkedHashSet, TreeSet, CopyOnWriteArraySet, Arrays, Wrappers and custom objects from Variables view and display differences of both in either diff viewer or dialog box. Fixes eclipse-platform/eclipse.platform#531
- Loading branch information
Showing
17 changed files
with
2,937 additions
and
6 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
org.eclipse.jdt.debug.tests/testprograms/compare/CompareArrayObjects.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2025 IBM Corporation and others. | ||
* | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* IBM Corporation - initial API and implementation | ||
*******************************************************************************/ | ||
package compare; | ||
import java.util.*; | ||
public class CompareArrayObjects { | ||
public static void main(String[] ecs) { | ||
String[] args2 = {"asdasd","asdasd"}; | ||
String[] args1 = {"asdasd","asdasd"}; | ||
|
||
Integer[] args11 = {1,2}; | ||
Integer[] args12 = {2,3}; | ||
int p = 100; | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
org.eclipse.jdt.debug.tests/testprograms/compare/CompareListObjects.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2025 IBM Corporation and others. | ||
* | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* IBM Corporation - initial API and implementation | ||
*******************************************************************************/ | ||
package compare; | ||
|
||
import java.util.*; | ||
|
||
public class CompareListObjects { | ||
public static void main(String[] ecs) { | ||
List<String> s1 = new ArrayList<>(Arrays.asList("apple", "banana")); | ||
List<String> s2 = new ArrayList<>(Arrays.asList("banana", "apple")); | ||
List<String> s3 = new ArrayList<>(Arrays.asList("apple", "banana")); | ||
List<String> s4 = new ArrayList<>(Arrays.asList("apple1", "banana")); | ||
|
||
List<Integer> linkedList1 = new LinkedList<>(); | ||
linkedList1.add(22); | ||
linkedList1.add(12); | ||
List<Integer> linkedList2 = new LinkedList<>(); | ||
linkedList2.add(12); | ||
linkedList2.add(221); | ||
|
||
List<String> Stack = new Stack<>(); | ||
Stack.add("Cherry"); | ||
Stack.add("Banana"); | ||
Stack.add("Apple"); | ||
List<String> ArrayList = new ArrayList<>(); | ||
ArrayList.add("Apple"); | ||
ArrayList.add("Banana"); | ||
ArrayList.add("Cherry"); | ||
List<String> Vector = new Vector<>(); | ||
Vector.add("Banana"); | ||
Vector.add("Cherry"); | ||
Vector.add("Apple"); | ||
List<String> LinkedList = new LinkedList<>(); | ||
LinkedList.add("Apple"); | ||
LinkedList.add("Cherry"); | ||
|
||
int p = 100; | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
org.eclipse.jdt.debug.tests/testprograms/compare/CompareMapObjects.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2025 IBM Corporation and others. | ||
* | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* IBM Corporation - initial API and implementation | ||
*******************************************************************************/ | ||
package compare; | ||
import java.util.*; | ||
public class CompareMapObjects { | ||
public static void main(String[] ecs) { | ||
Map<Integer, Integer> map8 = new TreeMap<>(); | ||
map8.put(1, 4); | ||
Map<Integer, Integer> map9 = new TreeMap<>(); | ||
map9.put(12, 4); | ||
Map<Integer, Integer> map2 = new HashMap<>(); | ||
map2.put(1, 7); | ||
Map<Integer, Integer> map1 = new HashMap<>(); | ||
map1.put(1, 7); | ||
|
||
Map<String, Double> map4 = new WeakHashMap<>(); | ||
map4.put("key1", 17d); | ||
Map<String, Double> map5 = new WeakHashMap<>(); | ||
map5.put("key1", 7d); | ||
|
||
Map<String, Double> map6 = new IdentityHashMap<>(); | ||
map6.put("key1", 7d); | ||
Map<String, Double> map7 = new IdentityHashMap<>(); | ||
map7.put("key2", 8d); | ||
int p = 100; | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
org.eclipse.jdt.debug.tests/testprograms/compare/CompareNormalObjects.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2025 IBM Corporation and others. | ||
* | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* IBM Corporation - initial API and implementation | ||
*******************************************************************************/ | ||
package compare; | ||
import java.util.*; | ||
|
||
class A { | ||
public int custom; | ||
public A(int custom) { | ||
this.custom = custom; | ||
} | ||
} | ||
public class CompareNormalObjects { | ||
public static void main(String[] ecs) { | ||
A a1 = new A(1); | ||
A a2 = new A(2); | ||
A a3 = a1; | ||
Integer i1 = Integer.valueOf(10); | ||
Integer i2 = Integer.valueOf(10); | ||
Float f1 = Float.valueOf(12f); | ||
Float f2 = Float.valueOf(112f); | ||
int p = 100; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
org.eclipse.jdt.debug.tests/testprograms/compare/CompareObjectsStringTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2025 IBM Corporation and others. | ||
* | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* IBM Corporation - initial API and implementation | ||
*******************************************************************************/ | ||
package compare; | ||
|
||
public class CompareObjectsStringTest { | ||
public static void main(String[] ecs) { | ||
String s1 = new String("eclipse"); | ||
String s2 = new String("eclipse"); | ||
|
||
String s3 = "false1"; | ||
String s4 = "false"; | ||
|
||
StringBuffer s5 = new StringBuffer("SDK"); | ||
StringBuffer s6 = new StringBuffer("SDK"); | ||
|
||
StringBuilder s7 = new StringBuilder("Java"); | ||
StringBuffer s8 = new StringBuffer("Java"); | ||
|
||
StringBuilder s9 = new StringBuilder("Java1"); | ||
int p = 100; | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
org.eclipse.jdt.debug.tests/testprograms/compare/CompareSetObjects.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2025 IBM Corporation and others. | ||
* | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* IBM Corporation - initial API and implementation | ||
*******************************************************************************/ | ||
package compare; | ||
import java.util.*; | ||
import java.util.concurrent.CopyOnWriteArraySet; | ||
public class CompareSetObjects { | ||
public static void main(String[] ecs) { | ||
TreeSet<Integer> xx11 = new TreeSet<>(); | ||
xx11.add(1); | ||
xx11.add(2); | ||
TreeSet<Integer> xx22 = new TreeSet<>(); | ||
xx22.add(1); | ||
xx22.add(21); | ||
Set<Integer> hashS1 = new HashSet<>(); | ||
Set<Integer> hashS2 = new HashSet<>(); | ||
hashS1.add(1); | ||
hashS1.add(21); | ||
hashS2.add(1); | ||
hashS2.add(21); | ||
|
||
Set<Integer> linkedHashS1 = new LinkedHashSet<>(); | ||
Set<Integer> linkedHashS2 = new LinkedHashSet<>(); | ||
linkedHashS1.add(1); | ||
linkedHashS1.add(21); | ||
linkedHashS2.add(1); | ||
linkedHashS2.add(2); | ||
|
||
Set<String> xx1 = new CopyOnWriteArraySet<>(); | ||
xx1.add("one"); | ||
xx1.add("two"); | ||
Set<String> xx2 = new CopyOnWriteArraySet<>(); | ||
xx2.add("two"); | ||
xx2.add("one"); | ||
int p = 100; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.