1 /*******************************************************************************
2 * Copyright (c) 2000, 2003 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
12 package net.sourceforge.phpdt.internal.ui.text.java.hover;
14 import net.sourceforge.phpdt.core.IJavaElement;
15 import net.sourceforge.phpdt.internal.ui.text.JavaWordFinder;
16 import net.sourceforge.phpdt.ui.text.java.hover.IJavaEditorTextHover;
18 import org.eclipse.jface.text.IRegion;
19 import org.eclipse.jface.text.ITextViewer;
20 import org.eclipse.ui.IEditorPart;
23 * Abstract class for providing hover information for Java elements.
27 public abstract class AbstractJavaEditorTextHover implements IJavaEditorTextHover {
30 private IEditorPart fEditor;
34 * @see IJavaEditorTextHover#setEditor(IEditorPart)
36 public void setEditor(IEditorPart editor) {
40 protected IEditorPart getEditor() {
44 // protected ICodeAssist getCodeAssist() {
45 // if (fEditor != null) {
46 // IEditorInput input= fEditor.getEditorInput();
47 // if (input instanceof IClassFileEditorInput) {
48 // IClassFileEditorInput cfeInput= (IClassFileEditorInput) input;
49 // return cfeInput.getClassFile();
52 // IWorkingCopyManager manager= PHPeclipsePlugin.getDefault().getWorkingCopyManager();
53 // return manager.getWorkingCopy(input);
60 * @see ITextHover#getHoverRegion(ITextViewer, int)
62 public IRegion getHoverRegion(ITextViewer textViewer, int offset) {
63 return JavaWordFinder.findWord(textViewer.getDocument(), offset);
67 * @see ITextHover#getHoverInfo(ITextViewer, IRegion)
69 public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {
71 // ICodeAssist resolve= getCodeAssist();
72 // if (resolve != null) {
74 // IJavaElement[] result= null;
76 // synchronized (resolve) {
77 // result= resolve.codeSelect(hoverRegion.getOffset(), hoverRegion.getLength());
80 // if (result == null)
83 // int nResults= result.length;
87 // return getHoverInfo(result);
89 // } catch (JavaModelException x) {
90 // PHPeclipsePlugin.log(x.getStatus());
97 * Provides hover information for the given Java elements.
99 * @return the hover information string
102 protected String getHoverInfo(IJavaElement[] javaElements) {