01: /*******************************************************************************
02: * Copyright (c) 2000, 2005 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.examples.javaeditor;
11:
12: import org.eclipse.jface.text.*;
13: import org.eclipse.jface.text.source.IAnnotationHover;
14: import org.eclipse.jface.text.source.ISourceViewer;
15:
16: /**
17: * The JavaAnnotationHover provides the hover support for java editors.
18: */
19:
20: public class JavaAnnotationHover implements IAnnotationHover {
21:
22: /* (non-Javadoc)
23: * Method declared on IAnnotationHover
24: */
25: public String getHoverInfo(ISourceViewer sourceViewer,
26: int lineNumber) {
27: IDocument document = sourceViewer.getDocument();
28:
29: try {
30: IRegion info = document.getLineInformation(lineNumber);
31: return document.get(info.getOffset(), info.getLength());
32: } catch (BadLocationException x) {
33: }
34:
35: return null;
36: }
37: }
|