]> git.uio.no Git - ifi-stolz-refaktor.git/blame - case-study/jdt-after/ui/org/eclipse/jdt/internal/ui/javaeditor/selectionactions/StructureSelectEnclosingAction.java
Case Study: adding data and statistics
[ifi-stolz-refaktor.git] / case-study / jdt-after / ui / org / eclipse / jdt / internal / ui / javaeditor / selectionactions / StructureSelectEnclosingAction.java
CommitLineData
1b2798f6
EK
1/*******************************************************************************
2 * Copyright (c) 2000, 2011 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11package org.eclipse.jdt.internal.ui.javaeditor.selectionactions;
12
13import org.eclipse.ui.PlatformUI;
14
15import org.eclipse.jdt.core.ISourceRange;
16import org.eclipse.jdt.core.ISourceReference;
17import org.eclipse.jdt.core.JavaModelException;
18import org.eclipse.jdt.core.dom.ASTNode;
19
20import org.eclipse.jdt.internal.corext.dom.SelectionAnalyzer;
21
22import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
23import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
24
25public class StructureSelectEnclosingAction extends StructureSelectionAction {
26
27 public StructureSelectEnclosingAction(JavaEditor editor, SelectionHistory history) {
28 super(SelectionActionMessages.StructureSelectEnclosing_label, editor, history);
29 setToolTipText(SelectionActionMessages.StructureSelectEnclosing_tooltip);
30 setDescription(SelectionActionMessages.StructureSelectEnclosing_description);
31 PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.STRUCTURED_SELECT_ENCLOSING_ACTION);
32 }
33
34 /*
35 * This constructor is for testing purpose only.
36 */
37 public StructureSelectEnclosingAction() {
38 }
39
40 /*
41 * @see StructureSelectionAction#internalGetNewSelectionRange(ISourceRange, ICompilationUnit, SelectionAnalyzer)
42 */
43 @Override
44 ISourceRange internalGetNewSelectionRange(ISourceRange oldSourceRange, ISourceReference sr, SelectionAnalyzer selAnalyzer) throws JavaModelException{
45 ASTNode first= selAnalyzer.getFirstSelectedNode();
46 if (first == null || first.getParent() == null)
47 return getLastCoveringNodeRange(oldSourceRange, sr, selAnalyzer);
48
49 return getSelectedNodeSourceRange(sr, first.getParent());
50 }
51}