Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoerg Kubitz2021-11-16 12:19:28 +0000
committerJeff Johnston2022-02-02 17:31:44 +0000
commitae6ea96ff770bcca4cb20f6f2c81482f30a25f16 (patch)
tree5407615b10d8174f20d5afa0aee09b92258e5f4e
parent9f5e11f4e1d7203395128c3961713b7e4630c645 (diff)
downloadeclipse.jdt.ui-ae6ea96ff770bcca4cb20f6f2c81482f30a25f16.tar.gz
eclipse.jdt.ui-ae6ea96ff770bcca4cb20f6f2c81482f30a25f16.tar.xz
eclipse.jdt.ui-ae6ea96ff770bcca4cb20f6f2c81482f30a25f16.zip
Bug 577286 - partially qualified names need a asterisk wildcardI20220203-1310I20220203-0300I20220202-1800
(Only for inner class names A$B) to be found by Open Type dialog Change-Id: I9a8dd58d0349ee599778373b66ead071c399f48d Signed-off-by: Joerg Kubitz <jkubitz-eclipse@gmx.de> Reviewed-on: https://git.eclipse.org/r/c/jdt/eclipse.jdt.ui/+/187780 Tested-by: JDT Bot <jdt-bot@eclipse.org> Tested-by: Jeff Johnston <jjohnstn@redhat.com> Reviewed-by: Jeff Johnston <jjohnstn@redhat.com>
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/TypeInfoTest.java7
-rw-r--r--org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/util/TypeInfoFilter.java15
2 files changed, 19 insertions, 3 deletions
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/TypeInfoTest.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/TypeInfoTest.java
index c039d428f4..d2914acae0 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/TypeInfoTest.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/TypeInfoTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2020 IBM Corporation and others.
+ * Copyright (c) 2000, 2022 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -243,6 +243,9 @@ public class TypeInfoTest {
assertEquals("java.lang.Throwable", TypeInfoFilter.simplifySearchText(" at java.lang.Throwable.fillInStackTrace ()"));
assertEquals("java.io.FileOutputStream", TypeInfoFilter.simplifySearchText(" at java.io.FileOutputStream.<init> ()"));
assertEquals("java.util.Map.Entry", TypeInfoFilter.simplifySearchText(" at java.util.Map$Entry.anything() (x.java:1)"));
+ assertEquals("*.Map.Entry", TypeInfoFilter.simplifySearchText("Map$Entry"));
+ assertEquals("org.eclipse.jdt.ui.tests.core.Main.Runner.Executor", TypeInfoFilter.simplifySearchText("org.eclipse.jdt.ui.tests.core.Main$Runner$Executor.exec(Main.java:10)"));
+ assertEquals("*.Main.Runner.Executor", TypeInfoFilter.simplifySearchText("Main$Runner$Executor.exec(Main.java:10)"));
assertEquals("java.io.FileOutputStream", TypeInfoFilter.simplifySearchText(" at java.io.FileOutputStream$1.close ()"));
assertEquals("org.eclipse.swt.internal.win32.OS", TypeInfoFilter.simplifySearchText(" at org.eclipse.swt.internal.win32.OS.WaitMessage(Native Method)"));
@@ -266,6 +269,8 @@ public class TypeInfoTest {
// convert inner types to qualified name:
assertEquals("java.lang.ref.ReferenceQueue.Lock", TypeInfoFilter.simplifySearchText(" at java.lang.ref.ReferenceQueue$Lock "));
assertEquals("java.util.concurrent.ThreadPoolExecutor.Worker", TypeInfoFilter.simplifySearchText(" at java.util.concurrent.ThreadPoolExecutor$Worker.run(java.base@16.0.2/ThreadPoolExecutor.java:630) "));
+ assertEquals("*.DebugPlugin.EventDispatchJob",TypeInfoFilter.simplifySearchText("\"C:\\org.eclipse.debug.core\\bin\\org\\eclipse\\debug\\core\\DebugPlugin$EventDispatchJob.class\""));
+
/** possible future features if useful: **/
// // locks from thread dumps:
diff --git a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/util/TypeInfoFilter.java b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/util/TypeInfoFilter.java
index d664de26f9..9a1a016e60 100644
--- a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/util/TypeInfoFilter.java
+++ b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/util/TypeInfoFilter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2022 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -84,11 +84,18 @@ public class TypeInfoFilter {
// skip $1, $2 ... - typenames cannot start with a number
s= skipSynthetic(s);
// binary name of Inner Class to qualified name
- s= s.replace('$', '.');
+ int inner= countContains(s, '$');
+ if (inner > 0) {
+ s= s.replace('$', '.');
+ }
if (s.isEmpty()) {
// oversimplified
return input;
}
+ // partially qualified names need a asterisk wildcard to be found by Open Type dialog:
+ if (inner > 0 && !input.trim().equals(s.trim()) && countContains(s, '.') == inner && !s.contains("*")) { //$NON-NLS-1$
+ s= "*." + s; //$NON-NLS-1$
+ }
} catch (Exception e) {
// just in case anything bad happened:
return input;
@@ -96,6 +103,10 @@ public class TypeInfoFilter {
return s;
}
+ private static int countContains(String s, char c) {
+ return (int) s.chars().filter(i -> c == (char) i).count();
+ }
+
private static String skipBefore(String s, String skip) {
int i= s.lastIndexOf(skip);
if (i != -1) {

Back to the top