565a8aba4031073e58b5dce7156519d3266d1c46
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / ui / text / java / hover / AbstractJavaEditorTextHover.java
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
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11
12 package net.sourceforge.phpdt.internal.ui.text.java.hover;
13
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;
17
18 import org.eclipse.jface.text.IRegion;
19 import org.eclipse.jface.text.ITextViewer;
20 import org.eclipse.ui.IEditorPart;
21
22 /**
23  * Abstract class for providing hover information for Java elements.
24  * 
25  * @since 2.1
26  */
27 public abstract class AbstractJavaEditorTextHover implements IJavaEditorTextHover {
28
29
30         private IEditorPart fEditor;
31         
32
33         /*
34          * @see IJavaEditorTextHover#setEditor(IEditorPart)
35          */
36         public void setEditor(IEditorPart editor) {
37                 fEditor= editor;
38         }
39
40         protected IEditorPart getEditor() {
41                 return fEditor;
42         }
43
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();
50 //                      }
51 //                      
52 //                      IWorkingCopyManager manager= PHPeclipsePlugin.getDefault().getWorkingCopyManager();                             
53 //                      return manager.getWorkingCopy(input);
54 //              }
55 //              
56 //              return null;
57 //      }
58         
59         /*
60          * @see ITextHover#getHoverRegion(ITextViewer, int)
61          */
62         public IRegion getHoverRegion(ITextViewer textViewer, int offset) {
63                 return JavaWordFinder.findWord(textViewer.getDocument(), offset);
64         }
65         
66         /*
67          * @see ITextHover#getHoverInfo(ITextViewer, IRegion)
68          */
69         public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {
70         
71 //              ICodeAssist resolve= getCodeAssist();
72 //              if (resolve != null) {
73 //                      try {
74 //                              IJavaElement[] result= null;
75 //                              
76 //                              synchronized (resolve) {
77 //                                      result= resolve.codeSelect(hoverRegion.getOffset(), hoverRegion.getLength());
78 //                              }
79 //                              
80 //                              if (result == null)
81 //                                      return null;
82 //                              
83 //                              int nResults= result.length;    
84 //                              if (nResults == 0)
85 //                                      return null;
86 //                              
87 //                              return getHoverInfo(result);
88 //                              
89 //                      } catch (JavaModelException x) {
90 //                              PHPeclipsePlugin.log(x.getStatus());
91 //                      }
92 //              }
93                 return null;
94         }
95
96         /**
97          * Provides hover information for the given Java elements.
98          * 
99          * @return the hover information string
100          * @since 2.1
101          */
102         protected String getHoverInfo(IJavaElement[] javaElements) {
103                 return null;
104         }
105 }