KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jface > text > contentassist > ICompletionProposalExtension


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 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.jface.text.contentassist;
12
13 import org.eclipse.jface.text.IDocument;
14
15
16 /**
17  * Extends {@link org.eclipse.jface.text.contentassist.ICompletionProposal}
18  * with the following functions:
19  * <ul>
20  * <li>handling of trigger characters other than ENTER</li>
21  * <li>completion proposal validation for a given offset</li>
22  * <li>context information can be freely positioned</li>
23  * </ul>
24  *
25  * @since 2.0
26  */

27 public interface ICompletionProposalExtension {
28
29     /**
30      * Applies the proposed completion to the given document. The insertion
31      * has been triggered by entering the given character at the given offset.
32      * This method assumes that {@link #isValidFor(IDocument, int)} returns
33      * <code>true</code> if called for <code>offset</code>.
34      *
35      * @param document the document into which to insert the proposed completion
36      * @param trigger the trigger to apply the completion
37      * @param offset the offset at which the trigger has been activated
38      */

39     void apply(IDocument document, char trigger, int offset);
40
41     /**
42      * Returns whether this completion proposal is valid for the given
43      * position in the given document.
44      *
45      * @param document the document for which the proposal is tested
46      * @param offset the offset for which the proposal is tested
47      * @return <code>true</code> iff valid
48      */

49     boolean isValidFor(IDocument document, int offset);
50
51     /**
52      * Returns the characters which trigger the application of this completion proposal.
53      *
54      * @return the completion characters for this completion proposal or <code>null</code>
55      * if no completion other than the new line character is possible
56      */

57     char[] getTriggerCharacters();
58
59     /**
60      * Returns the position to which the computed context information refers to or
61      * <code>-1</code> if no context information can be provided by this completion proposal.
62      *
63      * @return the position to which the context information refers to or <code>-1</code> for no information
64      */

65     int getContextInformationPosition();
66 }
67
Popular Tags