Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNoopur Gupta2019-05-28 11:21:04 +0000
committerNoopur Gupta2019-05-28 11:21:04 +0000
commit69239e274d730439bd878a4c30f1a0b6884ace15 (patch)
treeb9f4c2d91e8fd79f12d71d507fec0618ff15f589
parente223d80a20616fdfc17fd324fa2c170fc034d4b5 (diff)
downloadeclipse.jdt.ui-69239e274d730439bd878a4c30f1a0b6884ace15.tar.gz
eclipse.jdt.ui-69239e274d730439bd878a4c30f1a0b6884ace15.tar.xz
eclipse.jdt.ui-69239e274d730439bd878a4c30f1a0b6884ace15.zip
Bug 547120: [12][switch expression] Ctrl+Click or F3 does not work with
case, default, break Change-Id: I3e440c9a931c8e3aad7cba7954c67a513651d059
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaElementHyperlinkDetector.java11
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/BreakContinueTargetFinder.java5
2 files changed, 11 insertions, 5 deletions
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaElementHyperlinkDetector.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaElementHyperlinkDetector.java
index c0fad8602e..44d951f8cc 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaElementHyperlinkDetector.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaElementHyperlinkDetector.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -42,6 +42,7 @@ import org.eclipse.jdt.core.dom.NodeFinder;
import org.eclipse.jdt.core.dom.SimpleName;
import org.eclipse.jdt.core.dom.StructuralPropertyDescriptor;
import org.eclipse.jdt.core.dom.SwitchCase;
+import org.eclipse.jdt.core.dom.SwitchExpression;
import org.eclipse.jdt.core.dom.SwitchStatement;
import org.eclipse.jdt.core.manipulation.SharedASTProviderCore;
@@ -267,10 +268,14 @@ public class JavaElementHyperlinkDetector extends AbstractHyperlinkDetector {
SwitchCase caseNode= (SwitchCase) node;
ASTNode parent= caseNode.getParent();
- if (!(parent instanceof SwitchStatement)) {
+ ASTNode switchNode;
+ if (parent instanceof SwitchStatement) {
+ switchNode= parent;
+ } else if (parent instanceof SwitchExpression) {
+ switchNode= parent;
+ } else {
return null;
}
- SwitchStatement switchNode= (SwitchStatement) parent;
String description= Messages.format(SearchMessages.BreakContinueTargetFinder_occurrence_description, BasicElementLabels.getJavaElementName(ASTNodes.asString(caseNode)));
return new OccurrenceLocation(switchNode.getStartPosition(), 6, 0, description); // '6' is the length of 'switch'
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/BreakContinueTargetFinder.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/BreakContinueTargetFinder.java
index 97c5e5ee0e..96478752eb 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/BreakContinueTargetFinder.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/BreakContinueTargetFinder.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -32,6 +32,7 @@ import org.eclipse.jdt.core.dom.LabeledStatement;
import org.eclipse.jdt.core.dom.MethodDeclaration;
import org.eclipse.jdt.core.dom.NodeFinder;
import org.eclipse.jdt.core.dom.SimpleName;
+import org.eclipse.jdt.core.dom.SwitchExpression;
import org.eclipse.jdt.core.dom.SwitchStatement;
import org.eclipse.jdt.core.dom.WhileStatement;
@@ -63,7 +64,7 @@ public class BreakContinueTargetFinder extends ASTVisitor implements IOccurrence
private CompilationUnit fASTRoot;
private static final Class<?>[] STOPPERS= {MethodDeclaration.class, Initializer.class};
- private static final Class<?>[] BREAKTARGETS= {ForStatement.class, EnhancedForStatement.class, WhileStatement.class, DoStatement.class, SwitchStatement.class};
+ private static final Class<?>[] BREAKTARGETS= {ForStatement.class, EnhancedForStatement.class, WhileStatement.class, DoStatement.class, SwitchStatement.class, SwitchExpression.class};
private static final Class<?>[] CONTINUETARGETS= {ForStatement.class, EnhancedForStatement.class, WhileStatement.class, DoStatement.class};
private static final int BRACE_LENGTH= 1;

Back to the top