Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 59017 Details for
Bug 112630
hyperlink debugging
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
feature
112630.patch (text/plain), 16.81 KB, created by
Michael Rennie
on 2007-02-14 17:25:13 EST
(
hide
)
Description:
feature
Filename:
MIME Type:
Creator:
Michael Rennie
Created:
2007-02-14 17:25:13 EST
Size:
16.81 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.debug.ui >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.debug.ui/plugin.xml,v >retrieving revision 1.436 >diff -u -r1.436 plugin.xml >--- plugin.xml 14 Feb 2007 19:13:55 -0000 1.436 >+++ plugin.xml 14 Feb 2007 22:18:37 -0000 >@@ -2914,6 +2914,17 @@ > id="org.eclipse.jdt.debug.ui.bpMarkerUpdater" > markerType="org.eclipse.debug.core.breakpointMarker"> > </updater> >- </extension> >+ </extension> >+ <extension >+ point="org.eclipse.ui.workbench.texteditor.hyperlinkDetectors"> >+ <hyperlinkDetector >+ activate="true" >+ class="org.eclipse.jdt.internal.debug.ui.actions.StepIntoSelectionHyperlinkDetector" >+ description="%stepIntoSelectionHyperlinkDetector.description" >+ id="org.eclipse.jdt.debug.ui.hyperlinkdetector.stepIntoSelection" >+ name="%stepIntoSelectionHyperlinkDetector.label" >+ targetId="org.eclipse.jdt.ui.javaCode"> >+ </hyperlinkDetector> >+ </extension> > > </plugin> >Index: plugin.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.debug.ui/plugin.properties,v >retrieving revision 1.199 >diff -u -r1.199 plugin.properties >--- plugin.properties 14 Feb 2007 19:13:55 -0000 1.199 >+++ plugin.properties 14 Feb 2007 22:18:36 -0000 >@@ -156,6 +156,8 @@ > showNullEntriesAction.tooltip=Show Null Array Entries > > stepIntoSelectionAction.label=Step &Into Selection >+stepIntoSelectionHyperlinkDetector.label=Step Into Selection >+stepIntoSelectionHyperlinkDetector.description=Performs the step into selection command on demand via a hyperlink > > suspendPolicy.label=&Suspend VM > suspendPolicy.tooltip=Changes the suspend policy of the selected breakpoint(s) >Index: ui/org/eclipse/jdt/internal/debug/ui/actions/StepIntoSelectionActionDelegate.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/StepIntoSelectionActionDelegate.java,v >retrieving revision 1.28 >diff -u -r1.28 StepIntoSelectionActionDelegate.java >--- ui/org/eclipse/jdt/internal/debug/ui/actions/StepIntoSelectionActionDelegate.java 5 Aug 2005 15:57:55 -0000 1.28 >+++ ui/org/eclipse/jdt/internal/debug/ui/actions/StepIntoSelectionActionDelegate.java 14 Feb 2007 22:18:37 -0000 >@@ -21,23 +21,18 @@ > import org.eclipse.debug.core.model.IStackFrame; > import org.eclipse.debug.core.model.IThread; > import org.eclipse.debug.ui.actions.IRunToLineTarget; >-import org.eclipse.jdt.core.IClassFile; >-import org.eclipse.jdt.core.ICodeAssist; >-import org.eclipse.jdt.core.IJavaElement; > import org.eclipse.jdt.core.IMember; > import org.eclipse.jdt.core.IMethod; > import org.eclipse.jdt.core.IType; >+import org.eclipse.jdt.core.JavaModelException; > import org.eclipse.jdt.debug.core.IJavaStackFrame; > import org.eclipse.jdt.debug.core.IJavaThread; >-import org.eclipse.jdt.internal.debug.core.JDIDebugPlugin; > import org.eclipse.jdt.internal.debug.ui.EvaluationContextManager; > import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin; >-import org.eclipse.jdt.ui.JavaUI; > import org.eclipse.jface.action.IAction; > import org.eclipse.jface.text.ITextSelection; > import org.eclipse.jface.viewers.ISelection; > import org.eclipse.ui.IEditorActionDelegate; >-import org.eclipse.ui.IEditorInput; > import org.eclipse.ui.IEditorPart; > import org.eclipse.ui.IWorkbenchWindow; > import org.eclipse.ui.IWorkbenchWindowActionDelegate; >@@ -55,12 +50,12 @@ > * The name of the type being "run to". > * @see StepIntoSelectionActionDelegate#runToLineBeforeStepIn(ITextSelection, IJavaStackFrame, IMethod) > */ >- private String runToLineType= null; >+ private String fRunToLineType= null; > /** > * The line number being "run to." > * @see StepIntoSelectionActionDelegate#runToLineBeforeStepIn(ITextSelection, IJavaStackFrame, IMethod) > */ >- private int runToLineLine= -1; >+ private int fRunToLineLine= -1; > /** > * The debug event list listener used to know when a run to line has finished. > * @see StepIntoSelectionActionDelegate#runToLineBeforeStepIn(ITextSelection, IJavaStackFrame, IMethod) >@@ -76,13 +71,13 @@ > // no longer suspended - unexpected > return; > } >- ITextSelection textSelection= getTextSelection(); >- IMethod method= getMethod(); >- IType callingType= getType(); >- if (method == null || callingType == null) { >- return; >- } >+ ITextSelection textSelection = getTextSelection(); > try { >+ IMethod method = StepIntoSelectionUtils.getMethod(getTextSelection(),StepIntoSelectionUtils.getJavaElement(getActiveEditor().getEditorInput())); >+ IType callingType = getType(); >+ if (method == null || callingType == null) { >+ return; >+ } > int lineNumber = frame.getLineNumber(); > String callingTypeName = stripInnerNames(callingType.getFullyQualifiedName()); > String frameName = stripInnerNames(frame.getDeclaringTypeName()); >@@ -94,25 +89,16 @@ > runToLineBeforeStepIn(textSelection, frame.getThread(), method); > return; > } >- } catch (DebugException e) { >+ } >+ catch (DebugException e) { > showErrorMessage(e.getStatus().getMessage()); > return; > } >+ catch(JavaModelException jme) { >+ showErrorMessage(jme.getStatus().getMessage()); >+ return; >+ } > } >- >- /** >- * Strips inner class names from the given type name. >- * >- * @param fullyQualifiedName >- */ >- private String stripInnerNames(String fullyQualifiedName) { >- // ignore inner class qualification, as the compiler generated names and java model names can be different >- int index = fullyQualifiedName.indexOf('$'); >- if (index > 0) { >- return fullyQualifiedName.substring(0, index); >- } >- return fullyQualifiedName; >- } > > /** > * Steps into the given method in the given stack frame >@@ -140,12 +126,12 @@ > * the desired location, then perform a "step into selection." > */ > private void runToLineBeforeStepIn(ITextSelection textSelection, final IThread thread, final IMethod method) { >- runToLineType= getType().getFullyQualifiedName(); >- runToLineLine= textSelection.getStartLine() + 1; >- if (runToLineType == null || runToLineLine == -1) { >+ fRunToLineType = getType().getFullyQualifiedName(); >+ fRunToLineLine = textSelection.getStartLine() + 1; >+ if (fRunToLineType == null || fRunToLineLine == -1) { > return; > } >- // see bug 65489 - get the run-to-line adapater from the editor >+ // see bug 65489 - get the run-to-line adapter from the editor > IRunToLineTarget runToLineAction = null; > IEditorPart ed = getActiveEditor(); > if (ed != null) { >@@ -217,8 +203,8 @@ > */ > private boolean isExpectedFrame(IJavaStackFrame frame) throws DebugException { > return frame != null && >- runToLineLine == frame.getLineNumber() && >- frame.getReceivingTypeName().equals(runToLineType); >+ fRunToLineLine == frame.getLineNumber() && >+ frame.getReceivingTypeName().equals(fRunToLineType); > } > /** > * When the debug target we're listening for terminates, stop listening >@@ -242,6 +228,10 @@ > } > } > >+ /** >+ * Gets the current text selection from the currently active editor >+ * @return the current text selection >+ */ > private ITextSelection getTextSelection() { > IEditorPart part = getActiveEditor(); > if (part instanceof ITextEditor) { >@@ -252,42 +242,6 @@ > return null; > } > >- private IMethod getMethod() { >- ITextSelection textSelection= getTextSelection(); >- IEditorInput input = getActiveEditor().getEditorInput(); >- ICodeAssist codeAssist = null; >- Object element = JavaUI.getWorkingCopyManager().getWorkingCopy(input); >- if (element == null) { >- element = input.getAdapter(IClassFile.class); >- } >- if (element instanceof ICodeAssist) { >- codeAssist = ((ICodeAssist)element); >- } else { >- // editor does not support code assist >- showErrorMessage(ActionMessages.StepIntoSelectionActionDelegate_Step_into_selection_only_available_for_types_in_Java_projects__1); >- return null; >- } >- >- IMethod method = null; >- try { >- IJavaElement[] resolve = codeAssist.codeSelect(textSelection.getOffset(), 0); >- for (int i = 0; i < resolve.length; i++) { >- IJavaElement javaElement = resolve[i]; >- if (javaElement instanceof IMethod) { >- method = (IMethod)javaElement; >- break; >- } >- } >- } catch (CoreException e) { >- JDIDebugPlugin.log(e); >- } >- if (method == null) { >- // no resolved method >- showErrorMessage(ActionMessages.StepIntoSelectionActionDelegate_No_Method); >- } >- return method; >- } >- > /** > * Return the type containing the selected text, or <code>null</code> if the > * selection is not in a type. >@@ -303,8 +257,6 @@ > return type; > } > >- >- > /** > * Displays an error message in the status area > * >@@ -343,6 +295,20 @@ > } > > /** >+ * Strips inner class names from the given type name. >+ * >+ * @param fullyQualifiedName >+ */ >+ private String stripInnerNames(String fullyQualifiedName) { >+ // ignore inner class qualification, as the compiler generated names and java model names can be different >+ int index = fullyQualifiedName.indexOf('$'); >+ if (index > 0) { >+ return fullyQualifiedName.substring(0, index); >+ } >+ return fullyQualifiedName; >+ } >+ >+ /** > * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) > */ > public void selectionChanged(IAction action, ISelection selection) { >@@ -360,8 +326,7 @@ > /** > * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose() > */ >- public void dispose() { >- } >+ public void dispose() {} > > /** > * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow) >Index: ui/org/eclipse/jdt/internal/debug/ui/actions/StepIntoSelectionHyperlinkDetector.java >=================================================================== >RCS file: ui/org/eclipse/jdt/internal/debug/ui/actions/StepIntoSelectionHyperlinkDetector.java >diff -N ui/org/eclipse/jdt/internal/debug/ui/actions/StepIntoSelectionHyperlinkDetector.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/jdt/internal/debug/ui/actions/StepIntoSelectionHyperlinkDetector.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,105 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 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 >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.debug.ui.actions; >+ >+import org.eclipse.jdt.core.IJavaElement; >+import org.eclipse.jdt.core.IMethod; >+import org.eclipse.jdt.core.JavaModelException; >+import org.eclipse.jdt.internal.debug.ui.EvaluationContextManager; >+import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin; >+import org.eclipse.jdt.internal.debug.ui.JavaWordFinder; >+import org.eclipse.jface.text.IDocument; >+import org.eclipse.jface.text.IRegion; >+import org.eclipse.jface.text.ITextViewer; >+import org.eclipse.jface.text.TextSelection; >+import org.eclipse.jface.text.hyperlink.AbstractHyperlinkDetector; >+import org.eclipse.jface.text.hyperlink.IHyperlink; >+import org.eclipse.ui.IEditorInput; >+import org.eclipse.ui.texteditor.ITextEditor; >+ >+/** >+ * This is a specialization of a hyperlink detector for the step into selection command >+ * >+ * @since 3.3 >+ */ >+public class StepIntoSelectionHyperlinkDetector extends AbstractHyperlinkDetector { >+ >+ /** >+ * Specific implementation of a hyperlink for step into command >+ */ >+ class StepIntoSelectionHyperlink implements IHyperlink { >+ >+ private IRegion fRegion = null; >+ >+ /** >+ * Constructor >+ * @param region >+ */ >+ public StepIntoSelectionHyperlink(IRegion region) { >+ fRegion = region; >+ } >+ /** >+ * @see org.eclipse.jface.text.hyperlink.IHyperlink#getHyperlinkRegion() >+ */ >+ public IRegion getHyperlinkRegion() { >+ return fRegion; >+ } >+ /** >+ * @see org.eclipse.jface.text.hyperlink.IHyperlink#getHyperlinkText() >+ */ >+ public String getHyperlinkText() { >+ return null; >+ } >+ /** >+ * @see org.eclipse.jface.text.hyperlink.IHyperlink#getTypeLabel() >+ */ >+ public String getTypeLabel() { >+ return null; >+ } >+ /** >+ * @see org.eclipse.jface.text.hyperlink.IHyperlink#open() >+ */ >+ public void open() { >+ StepIntoSelectionActionDelegate delegate = new StepIntoSelectionActionDelegate(); >+ delegate.init(JDIDebugUIPlugin.getActiveWorkbenchWindow()); >+ delegate.run(null); >+ } >+ >+ } >+ >+ /** >+ * @see org.eclipse.jface.text.hyperlink.IHyperlinkDetector#detectHyperlinks(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion, boolean) >+ */ >+ public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boolean canShowMultipleHyperlinks) { >+ ITextEditor editor = (ITextEditor) getAdapter(ITextEditor.class); >+ if(editor != null && !canShowMultipleHyperlinks && EvaluationContextManager.getEvaluationContext(JDIDebugUIPlugin.getActiveWorkbenchWindow()) != null) { >+ IEditorInput input = editor.getEditorInput(); >+ IJavaElement element = StepIntoSelectionUtils.getJavaElement(input); >+ int offset = region.getOffset(); >+ if(element != null) { >+ try { >+ IDocument document = editor.getDocumentProvider().getDocument(editor.getEditorInput()); >+ if(document != null) { >+ IRegion wregion = JavaWordFinder.findWord(document, offset); >+ if(wregion != null) { >+ IMethod method = StepIntoSelectionUtils.getMethod(new TextSelection(document, wregion.getOffset(), wregion.getLength()), element); >+ if (method != null) { >+ return new IHyperlink[] {new StepIntoSelectionHyperlink(wregion)}; >+ } >+ } >+ } >+ } >+ catch(JavaModelException jme) {JDIDebugUIPlugin.log(jme);} >+ } >+ } >+ return null; >+ } >+} >Index: ui/org/eclipse/jdt/internal/debug/ui/actions/StepIntoSelectionUtils.java >=================================================================== >RCS file: ui/org/eclipse/jdt/internal/debug/ui/actions/StepIntoSelectionUtils.java >diff -N ui/org/eclipse/jdt/internal/debug/ui/actions/StepIntoSelectionUtils.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/jdt/internal/debug/ui/actions/StepIntoSelectionUtils.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,64 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 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 >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.debug.ui.actions; >+ >+import org.eclipse.jdt.core.ICodeAssist; >+import org.eclipse.jdt.core.IJavaElement; >+import org.eclipse.jdt.core.IMethod; >+import org.eclipse.jdt.core.JavaModelException; >+import org.eclipse.jdt.ui.JavaUI; >+import org.eclipse.jface.text.ITextSelection; >+import org.eclipse.ui.IEditorInput; >+ >+/** >+ * Utility class for aiding step into selection actions and hyper-linking >+ * >+ * @see StepIntoSelectionActionDelegate >+ * @see StepIntoSelectionHyperlinkDetector >+ * >+ * @since 3.3 >+ */ >+public class StepIntoSelectionUtils { >+ >+ >+ /** >+ * gets the <code>IJavaElement</code> from the editor input >+ * @param input the current editor input >+ * @return the corresponding <code>IJavaElement</code> >+ */ >+ public static IJavaElement getJavaElement(IEditorInput input) { >+ IJavaElement je = JavaUI.getEditorInputJavaElement(input); >+ if(je != null) { >+ return je; >+ } >+ return JavaUI.getWorkingCopyManager().getWorkingCopy(input); >+ } >+ >+ /** >+ * Returns the <code>IMethod</code> from the given selection within the given <code>IJavaElement</code>, >+ * or <code>null</code> if the selection does not container or is not an <code>IMethod</code> >+ * @param selection >+ * @param element >+ * @return the corresponding <code>IMethod</code> from the selection within the provided <code>IJavaElement</code> >+ * @throws JavaModelException >+ */ >+ public static IMethod getMethod(ITextSelection selection, IJavaElement element) throws JavaModelException { >+ if(element != null && element instanceof ICodeAssist) { >+ IJavaElement[] elements = ((ICodeAssist)element).codeSelect(selection.getOffset(), selection.getLength()); >+ for (int i = 0; i < elements.length; i++) { >+ if (elements[i] instanceof IMethod) { >+ return (IMethod)elements[i]; >+ } >+ } >+ } >+ return null; >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 112630
: 59017