1 /*******************************************************************************
2  * Copyright (c) 2000, 2015 IBM Corporation and others.
3  *
4  * This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License 2.0
6  * which accompanies this distribution, and is available at
7  * https://www.eclipse.org/legal/epl-2.0/
8  *
9  * SPDX-License-Identifier: EPL-2.0
10  *
11  * Contributors:
12  *     IBM Corporation - initial API and implementation
13  *******************************************************************************/
14 package org.eclipse.jdt.internal.debug.ui.actions;
15 
16 
17 import org.eclipse.core.runtime.CoreException;
18 import org.eclipse.debug.core.model.IDebugElement;
19 import org.eclipse.jdt.debug.core.IJavaObject;
20 import org.eclipse.jdt.debug.core.IJavaStackFrame;
21 import org.eclipse.jdt.debug.core.IJavaType;
22 
23 /**
24  * Opens the receiving type of a stack frame.
25  */
26 public class OpenReceivingTypeAction extends OpenStackFrameAction {
27 
28 	/* (non-Javadoc)
29 	 * @see org.eclipse.jdt.internal.debug.ui.actions.OpenTypeAction#getTypeToOpen(org.eclipse.debug.core.model.IDebugElement)
30 	 */
31 	@Override
getTypeToOpen(IDebugElement element)32 	protected IJavaType getTypeToOpen(IDebugElement element) throws CoreException {
33 		if (element instanceof IJavaStackFrame) {
34 			IJavaStackFrame frame = (IJavaStackFrame) element;
35 			if (frame.isStatic()) {
36 				return frame.getReferenceType();
37 			}
38 			IJavaObject ths = frame.getThis();
39 			if (ths != null) {
40 				return ths.getJavaType();
41 			}
42 		}
43 		return null;
44 	}
45 }
46