1 /******************************************************************************* 2 * Copyright (c) 2000, 2008 IBM Corporation and others. 3 * 4 * This program and the accompanying materials 5 * are made available under the terms of the Eclipse Public License 2.0 6 * which accompanies this distribution, and is available at 7 * https://www.eclipse.org/legal/epl-2.0/ 8 * 9 * SPDX-License-Identifier: EPL-2.0 10 * 11 * Contributors: 12 * IBM Corporation - initial API and implementation 13 *******************************************************************************/ 14 package org.eclipse.jface.text.information; 15 16 import org.eclipse.jface.text.IRegion; 17 import org.eclipse.jface.text.ITextViewer; 18 19 20 /** 21 * Provides information related to the content of a text viewer. 22 * <p> 23 * In order to provide backward compatibility for clients of <code>IInformationProvider</code>, 24 * extension interfaces are used to provide a means of evolution. The following extension interfaces 25 * exist: 26 * </p> 27 * <ul> 28 * <li>{@link IInformationProviderExtension} since version 2.1 introducing the ability to provide 29 * the element for a given subject</li> 30 * <li>{@link IInformationProviderExtension2} since version 3.0 introducing the ability to provide 31 * its own information control creator</li> 32 * </ul> 33 * <p> 34 * Clients may implement this interface. 35 * </p> 36 * 37 * @see org.eclipse.jface.text.information.IInformationProviderExtension 38 * @see org.eclipse.jface.text.information.IInformationProviderExtension2 39 * @see org.eclipse.jface.text.information.IInformationPresenter 40 * @see org.eclipse.jface.text.ITextViewer 41 * @since 2.0 42 */ 43 public interface IInformationProvider { 44 45 /** 46 * Returns the region of the text viewer's document close to the given 47 * offset that contains a subject about which information can be provided.<p> 48 * For example, if information can be provided on a per code block basis, 49 * the offset should be used to find the enclosing code block and the source 50 * range of the block should be returned. 51 * 52 * @param textViewer the text viewer in which information has been requested 53 * @param offset the offset at which information has been requested 54 * @return the region of the text viewer's document containing the information subject 55 */ getSubject(ITextViewer textViewer, int offset)56 IRegion getSubject(ITextViewer textViewer, int offset); 57 58 /** 59 * Returns the information about the given subject or <code>null</code> if 60 * no information is available. It depends on the concrete configuration in which 61 * format the information is to be provided. For example, information presented 62 * in an information control displaying HTML, should be provided in HTML. 63 * 64 * @param textViewer the viewer in whose document the subject is contained 65 * @param subject the text region constituting the information subject 66 * @return the information about the subject 67 * @see IInformationPresenter 68 * @deprecated As of 2.1, replaced by {@link IInformationProviderExtension#getInformation2(ITextViewer, IRegion)} 69 */ 70 @Deprecated getInformation(ITextViewer textViewer, IRegion subject)71 String getInformation(ITextViewer textViewer, IRegion subject); 72 } 73