reverted Bug 269112: [navigation] make break and continue label identifiers clickable links
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/ActionMessages.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/ActionMessages.java
index 5fd4b4f..40d5f89 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/ActionMessages.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/ActionMessages.java
@@ -68,8 +68,6 @@
public static String OpenAction_multistatus_message;
public static String OpenViewActionGroup_showInAction_label;
public static String OpenWithMenu_label;
- public static String OpenAction_error_text;
- public static String OpenAction_error_no_label_found_message;
public static String RefactorMenu_label;
public static String SourceMenu_label;
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/ActionMessages.properties b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/ActionMessages.properties
index 20aa653..6851be4 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/ActionMessages.properties
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/ActionMessages.properties
@@ -38,8 +38,6 @@
OpenAction_multistatus_message=See details for editors that could not be opened.
OpenAction_error_messageBadSelection=Current text selection cannot be opened in an editor
OpenAction_error_problem_opening_editor=Problem opening editor for ''{0}'': ''{1}''
-OpenAction_error_text=Open Declaration
-OpenAction_error_no_label_found_message=Could not find the target for label: ''{0}''
OpenSuperImplementationAction_label=Open S&uper Implementation
OpenSuperImplementationAction_tooltip=Open the Implementation in the Super Type
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaElementHyperlink.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaElementHyperlink.java
index b4da4f9..a1cc3e8 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaElementHyperlink.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaElementHyperlink.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -15,7 +15,6 @@
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.TextSelection;
import org.eclipse.jface.text.hyperlink.IHyperlink;
import org.eclipse.jdt.core.IJavaElement;
@@ -44,13 +43,14 @@
*
* @param region the region of the link
* @param openAction the action to use to open the java elements
- * @param element the java element to open or <code>null</code> if the element is a label
+ * @param element the java element to open
* @param qualify <code>true</code> if the hyperlink text should show a qualified name for
* element.
*/
public JavaElementHyperlink(IRegion region, SelectionDispatchAction openAction, IJavaElement element, boolean qualify) {
Assert.isNotNull(openAction);
Assert.isNotNull(region);
+ Assert.isNotNull(element);
fRegion= region;
fOpenAction= openAction;
@@ -71,10 +71,7 @@
* @since 3.1
*/
public void open() {
- if (fElement != null)
- fOpenAction.run(new StructuredSelection(fElement));
- else
- fOpenAction.run(new TextSelection(fRegion.getOffset(), fRegion.getLength()));
+ fOpenAction.run(new StructuredSelection(fElement));
}
/*
@@ -90,7 +87,7 @@
* @since 3.1
*/
public String getHyperlinkText() {
- if (fQualify && fElement != null) {
+ if (fQualify) {
String elementLabel= JavaElementLabels.getElementLabel(fElement, JavaElementLabels.ALL_POST_QUALIFIED);
return Messages.format(JavaEditorMessages.JavaElementHyperlink_hyperlinkText_qualified, new Object[] { elementLabel });
} else {
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaElementHyperlinkDeclaredTypeDetector.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaElementHyperlinkDeclaredTypeDetector.java
index 19ef23f..41a753f 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaElementHyperlinkDeclaredTypeDetector.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaElementHyperlinkDeclaredTypeDetector.java
@@ -38,7 +38,7 @@
*/
protected IHyperlink createHyperlink(IRegion wordRegion, SelectionDispatchAction openAction, IJavaElement element, boolean qualify, JavaEditor editor) {
try {
- if (element != null && (element.getElementType() == IJavaElement.FIELD || element.getElementType() == IJavaElement.LOCAL_VARIABLE) && !JavaModelUtil.isPrimitive(getTypeSignature(element))
+ if ((element.getElementType() == IJavaElement.FIELD || element.getElementType() == IJavaElement.LOCAL_VARIABLE) && !JavaModelUtil.isPrimitive(getTypeSignature(element))
&& SelectionConverter.canOperateOn(editor)) {
return new JavaElementDeclaredTypeHyperlink(wordRegion, openAction, element, qualify);
}
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 0c64cba..42ffc1f 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
@@ -26,16 +26,8 @@
import org.eclipse.jdt.core.ICodeAssist;
import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.ITypeRoot;
import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.BreakStatement;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.ContinueStatement;
-import org.eclipse.jdt.core.dom.NodeFinder;
-import org.eclipse.jdt.core.dom.SimpleName;
-import org.eclipse.jdt.ui.SharedASTProvider;
import org.eclipse.jdt.ui.actions.SelectionDispatchAction;
import org.eclipse.jdt.internal.ui.text.JavaWordFinder;
@@ -75,13 +67,8 @@
if (isInheritDoc(document, wordRegion) && getClass() != JavaElementHyperlinkDetector.class)
return null;
- ASTNode labelNode= getBreakOrContinueLabelNode(input, region);
- if (labelNode != null) {
- IHyperlink link= createHyperlink(wordRegion, (SelectionDispatchAction)openAction, null, false, null);
- return link != null ? new IHyperlink[] { link } : null;
- }
-
- IJavaElement[] elements= ((ICodeAssist) input).codeSelect(wordRegion.getOffset(), wordRegion.getLength());
+ IJavaElement[] elements= null;
+ elements= ((ICodeAssist) input).codeSelect(wordRegion.getOffset(), wordRegion.getLength());
elements= selectOpenableElements(elements);
if (elements.length == 0)
return null;
@@ -130,7 +117,7 @@
*
* @param wordRegion the region of the link
* @param openAction the action to use to open the java elements
- * @param element the java element to open or <code>null</code> if its a label
+ * @param element the java element to open
* @param qualify <code>true</code> if the hyperlink text should show a qualified name for
* element
* @param editor the active java editor
@@ -168,27 +155,4 @@
}
return (IJavaElement[]) result.toArray(new IJavaElement[result.size()]);
}
-
- /**
- * Gets the break/continue label node.
- *
- * @param input the editor input
- * @param region the region
- * @return the break/continue label or <code>null</code> if none
- * @since 3.7
- */
- public static ASTNode getBreakOrContinueLabelNode(IJavaElement input, IRegion region) {
- CompilationUnit ast= SharedASTProvider.getAST((ITypeRoot)input, SharedASTProvider.WAIT_NO, null);
- if (ast == null)
- return null;
-
- ASTNode node= NodeFinder.perform(ast, region.getOffset(), region.getLength());
- if (node instanceof SimpleName) {
- SimpleName simpleName= (SimpleName)node;
- ASTNode parent= simpleName.getParent();
- if (parent instanceof ContinueStatement || parent instanceof BreakStatement)
- return simpleName;
- }
- return null;
- }
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaElementHyperlinkImplementationDetector.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaElementHyperlinkImplementationDetector.java
index 766825c..207b003 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaElementHyperlinkImplementationDetector.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaElementHyperlinkImplementationDetector.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2011 IBM Corporation and others.
+ * Copyright (c) 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -33,7 +33,7 @@
* @since 3.5
*/
protected IHyperlink createHyperlink(IRegion wordRegion, SelectionDispatchAction openAction, IJavaElement element, boolean qualify, JavaEditor editor) {
- if (element != null && element.getElementType() == IJavaElement.METHOD && SelectionConverter.canOperateOn(editor)) {
+ if (element.getElementType() == IJavaElement.METHOD && SelectionConverter.canOperateOn(editor)) {
return new JavaElementImplementationHyperlink(wordRegion, openAction, (IMethod)element, qualify, editor);
}
return null;
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaElementHyperlinkReturnTypeDetector.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaElementHyperlinkReturnTypeDetector.java
index 440f26e..c0f5182 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaElementHyperlinkReturnTypeDetector.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaElementHyperlinkReturnTypeDetector.java
@@ -37,7 +37,7 @@
*/
protected IHyperlink createHyperlink(IRegion wordRegion, SelectionDispatchAction openAction, IJavaElement element, boolean qualify, JavaEditor editor) {
try {
- if (element != null && element.getElementType() == IJavaElement.METHOD && !JavaModelUtil.isPrimitive(((IMethod)element).getReturnType()) && SelectionConverter.canOperateOn(editor)) {
+ if (element.getElementType() == IJavaElement.METHOD && !JavaModelUtil.isPrimitive(((IMethod)element).getReturnType()) && SelectionConverter.canOperateOn(editor)) {
return new JavaElementReturnTypeHyperlink(wordRegion, openAction, (IMethod)element, qualify);
}
} catch (JavaModelException e) {
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaElementHyperlinkSuperImplementationDetector.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaElementHyperlinkSuperImplementationDetector.java
index 9843656..580a21f 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaElementHyperlinkSuperImplementationDetector.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaElementHyperlinkSuperImplementationDetector.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2011 IBM Corporation and others.
+ * Copyright (c) 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -35,7 +35,7 @@
* @since 3.7
*/
protected IHyperlink createHyperlink(IRegion wordRegion, SelectionDispatchAction openAction, IJavaElement element, boolean qualify, JavaEditor editor) {
- if (element != null && element.getElementType() == IJavaElement.METHOD && SelectionConverter.canOperateOn(editor) && isOverriddenMethod((IMethod)element)) {
+ if (element.getElementType() == IJavaElement.METHOD && SelectionConverter.canOperateOn(editor) && isOverriddenMethod((IMethod)element)) {
return new JavaElementSuperImplementationHyperlink(wordRegion, openAction, (IMethod)element, qualify);
}
return null;
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/OpenAction.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/OpenAction.java
index e168e12..ba75ce7 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/OpenAction.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/OpenAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -15,7 +15,6 @@
import java.util.Iterator;
import java.util.List;
-import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
@@ -24,15 +23,10 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.util.OpenStrategy;
import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchSite;
@@ -43,17 +37,13 @@
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.ISourceReference;
-import org.eclipse.jdt.core.ITypeRoot;
import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
import org.eclipse.jdt.internal.corext.util.Messages;
import org.eclipse.jdt.ui.JavaElementLabels;
import org.eclipse.jdt.ui.JavaUI;
-import org.eclipse.jdt.ui.SharedASTProvider;
import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
import org.eclipse.jdt.internal.ui.JavaPlugin;
@@ -62,9 +52,6 @@
import org.eclipse.jdt.internal.ui.actions.SelectionConverter;
import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility;
import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
-import org.eclipse.jdt.internal.ui.javaeditor.JavaElementHyperlinkDetector;
-import org.eclipse.jdt.internal.ui.search.BreakContinueTargetFinder;
-import org.eclipse.jdt.internal.ui.search.IOccurrencesFinder.OccurrenceLocation;
import org.eclipse.jdt.internal.ui.util.ExceptionHandler;
@@ -148,16 +135,6 @@
* Method declared on SelectionDispatchAction.
*/
public void run(ITextSelection selection) {
- IJavaElement input= EditorUtility.getEditorInputJavaElement(fEditor, false);
- if (input == null)
- return;
- IRegion region= new Region(selection.getOffset(), selection.getLength());
- ASTNode labelNode= JavaElementHyperlinkDetector.getBreakOrContinueLabelNode(input, region);
- ISourceViewer viewer= fEditor.getViewer();
- if (labelNode != null && viewer != null) {
- jumpToLabel(viewer, labelNode, (ITypeRoot)input);
- return;
- }
try {
IJavaElement[] elements= SelectionConverter.codeResolveForked(fEditor, false);
elements= selectOpenableElements(elements);
@@ -187,33 +164,6 @@
}
/**
- * Jumps to the label of the break/continue statement.
- *
- * @param viewer the text viewer
- * @param labelNode the label node
- * @param input the editor input
- * @since 3.7
- */
- private void jumpToLabel(ITextViewer viewer, ASTNode labelNode, ITypeRoot input) {
- Assert.isNotNull(input);
- CompilationUnit ast= SharedASTProvider.getAST(input, SharedASTProvider.WAIT_ACTIVE_ONLY, null);
- if (ast == null)
- return;
- BreakContinueTargetFinder finder= new BreakContinueTargetFinder();
- if (finder.initialize(ast, labelNode) == null) {
- OccurrenceLocation[] locations= finder.getOccurrences();
- if (locations != null) {
- OccurrenceLocation location= locations[0]; // the first location is the labeled statement target location
- viewer.setSelectedRange(location.getOffset(), location.getLength());
- return;
- }
- }
- MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
- ActionMessages.OpenAction_error_text,
- Messages.format(ActionMessages.OpenAction_error_no_label_found_message, labelNode.toString()));
- }
-
- /**
* Selects the openable elements out of the given ones.
*
* @param elements the elements to filter