1 /*******************************************************************************
2 * Copyright (c) 2010, 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
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package org.eclipse.jdt.internal.ui.javaeditor;
13 import java.util.List;
15 import org.eclipse.jface.text.IRegion;
16 import org.eclipse.jface.text.hyperlink.IHyperlink;
18 import org.eclipse.jdt.core.IJavaElement;
19 import org.eclipse.jdt.core.IMethod;
20 import org.eclipse.jdt.core.JavaModelException;
22 import org.eclipse.jdt.internal.corext.util.JdtFlags;
24 import org.eclipse.jdt.ui.actions.SelectionDispatchAction;
26 import org.eclipse.jdt.internal.ui.JavaPlugin;
27 import org.eclipse.jdt.internal.ui.actions.SelectionConverter;
30 * Java element super implementation hyperlink detector for methods.
34 public class JavaElementHyperlinkSuperImplementationDetector extends JavaElementHyperlinkDetector {
36 * @see org.eclipse.jdt.internal.ui.javaeditor.JavaElementHyperlinkDetector#createHyperlink(org.eclipse.jface.text.IRegion, org.eclipse.jdt.ui.actions.SelectionDispatchAction, org.eclipse.jdt.core.IJavaElement, boolean, org.eclipse.ui.texteditor.ITextEditor)
40 protected void addHyperlinks(List<IHyperlink> hyperlinksCollector, IRegion wordRegion, SelectionDispatchAction openAction, IJavaElement element, boolean qualify, JavaEditor editor) {
41 if (element.getElementType() == IJavaElement.METHOD && SelectionConverter.canOperateOn(editor) && isOverriddenMethod((IMethod)element)) {
42 hyperlinksCollector.add(new JavaElementSuperImplementationHyperlink(wordRegion, openAction, (IMethod)element, qualify));
47 * Indicates whether a method is overridden.
49 * @param method the method to check
50 * @return <code>true</code> if the method is overridden, <code>false</code> otherwise
52 private boolean isOverriddenMethod(IMethod method) {
54 if (JdtFlags.isPrivate(method) || JdtFlags.isStatic(method) || method.isConstructor())
56 if (JavaElementSuperImplementationHyperlink.findSuperImplementation(method) != null)
58 } catch (JavaModelException e) {