]>
Commit | Line | Data |
---|---|---|
597db767 EK |
1 | package no.uio.ifi.refaktor.handlers; |
2 | ||
18447975 | 3 | import no.uio.ifi.refaktor.utils.CompilationUnitTextSelection; |
4c03afae | 4 | import no.uio.ifi.refaktor.utils.DocumentUtils; |
47501704 | 5 | import no.uio.ifi.refaktor.utils.ParseUtils; |
c519ffef | 6 | |
597db767 EK |
7 | import org.eclipse.core.commands.AbstractHandler; |
8 | import org.eclipse.core.commands.ExecutionEvent; | |
9 | import org.eclipse.core.commands.ExecutionException; | |
c519ffef | 10 | import org.eclipse.jdt.core.dom.ASTNode; |
597db767 | 11 | import org.eclipse.jface.dialogs.MessageDialog; |
597db767 EK |
12 | import org.eclipse.ui.IWorkbenchWindow; |
13 | import org.eclipse.ui.handlers.HandlerUtil; | |
14 | ||
87b2afda | 15 | public class TextSelectionInformationHandler extends AbstractHandler { |
597db767 EK |
16 | |
17 | @Override | |
18 | public Object execute(ExecutionEvent event) throws ExecutionException { | |
18447975 EK |
19 | CompilationUnitTextSelection textSelection = DocumentUtils.getCompilationUnitTextSelectionFromExecutionEvent(event); |
20 | ASTNode coveringNode = textSelection.getCoveringNode(); | |
21 | ASTNode coveredNode = textSelection.getCoveredNode(); | |
c519ffef | 22 | |
597db767 EK |
23 | String string = "Selection type: " + textSelection.getClass().toString() |
24 | + "\n\nStart line: " + (textSelection.getStartLine() + 1) | |
25 | + "\nEnd line: " + (textSelection.getEndLine() + 1) | |
26 | + "\nOffset: " + textSelection.getOffset() | |
27 | + "\nLength: " + textSelection.getLength() | |
34328ca2 | 28 | + "\nEnd: " + textSelection.getEnd() |
18447975 EK |
29 | + "\n\nCoveringNode: " + coveringNode.getClass().getCanonicalName() + ":\n" + ParseUtils.getNodeText(coveringNode) |
30 | + "\n\nCoveredNode: " + coveredNode.getClass().getCanonicalName() + ":\n" + ParseUtils.getNodeText(coveredNode) | |
597db767 | 31 | + "\n\nSelected text:\n\n" + textSelection.getText(); |
57ec7e36 EK |
32 | |
33 | IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); | |
c519ffef | 34 | MessageDialog.openInformation(window.getShell(), "Selection Info", string); |
597db767 EK |
35 | return null; |
36 | } | |
37 | ||
38 | } |