]> git.uio.no Git - ifi-stolz-refaktor.git/blob - case-study/jdt-before/ui/org/eclipse/jdt/internal/ui/text/java/hover/JavaInformationProvider.java
Case Study: adding data and statistics
[ifi-stolz-refaktor.git] / case-study / jdt-before / ui / org / eclipse / jdt / internal / ui / text / java / hover / JavaInformationProvider.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2012 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  *******************************************************************************/
11 package org.eclipse.jdt.internal.ui.text.java.hover;
12
13 import org.eclipse.jface.text.IInformationControlCreator;
14 import org.eclipse.jface.text.IRegion;
15 import org.eclipse.jface.text.ITextViewer;
16 import org.eclipse.jface.text.information.IInformationProvider;
17 import org.eclipse.jface.text.information.IInformationProviderExtension;
18 import org.eclipse.jface.text.information.IInformationProviderExtension2;
19
20 import org.eclipse.ui.IEditorPart;
21
22 import org.eclipse.jdt.internal.ui.text.JavaWordFinder;
23
24
25 public class JavaInformationProvider implements IInformationProvider, IInformationProviderExtension, IInformationProviderExtension2 {
26
27         protected BestMatchHover fImplementation;
28
29         public JavaInformationProvider(IEditorPart editor) {
30                 if (editor != null) {
31                         fImplementation= new BestMatchHover();
32                         fImplementation.setEditor(editor);
33                 }
34         }
35
36         /*
37          * @see IInformationProvider#getSubject(ITextViewer, int)
38          */
39         public IRegion getSubject(ITextViewer textViewer, int offset) {
40
41                 if (textViewer != null)
42                         return JavaWordFinder.findWord(textViewer.getDocument(), offset);
43
44                 return null;
45         }
46
47         /**
48          * @see IInformationProvider#getInformation(ITextViewer, IRegion)
49          * @deprecated
50          */
51         public String getInformation(ITextViewer textViewer, IRegion subject) {
52                 if (fImplementation != null) {
53                         String s= fImplementation.getHoverInfo(textViewer, subject);
54                         if (s != null && s.trim().length() > 0) {
55                                 return s;
56                         }
57                 }
58                 return null;
59         }
60
61         /*
62          * @see org.eclipse.jface.text.information.IInformationProviderExtension#getInformation2(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion)
63          */
64         public Object getInformation2(ITextViewer textViewer, IRegion subject) {
65                 if (fImplementation == null)
66                         return null;
67                 return fImplementation.getHoverInfo2(textViewer, subject, true);
68         }
69
70         /*
71          * @see IInformationProviderExtension2#getInformationPresenterControlCreator()
72          * @since 3.1
73          */
74         public IInformationControlCreator getInformationPresenterControlCreator() {
75                 if (fImplementation == null)
76                         return null;
77                 return fImplementation.getInformationPresenterControlCreator();
78         }
79 }