129
|
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 * Port to the D programming language:
|
|
11 * Frank Benoit <benoit@tionex.de>
|
|
12 *******************************************************************************/
|
|
13 module dwtx.jface.text.contentassist.ICompletionProposalExtension;
|
|
14
|
|
15 import dwt.dwthelper.utils;
|
|
16
|
|
17 import dwtx.jface.text.IDocument;
|
|
18
|
|
19
|
|
20 /**
|
|
21 * Extends {@link dwtx.jface.text.contentassist.ICompletionProposal}
|
|
22 * with the following functions:
|
|
23 * <ul>
|
|
24 * <li>handling of trigger characters other than ENTER</li>
|
|
25 * <li>completion proposal validation for a given offset</li>
|
|
26 * <li>context information can be freely positioned</li>
|
|
27 * </ul>
|
|
28 *
|
|
29 * @since 2.0
|
|
30 */
|
|
31 public interface ICompletionProposalExtension {
|
|
32
|
|
33 /**
|
|
34 * Applies the proposed completion to the given document. The insertion
|
|
35 * has been triggered by entering the given character at the given offset.
|
|
36 * This method assumes that {@link #isValidFor(IDocument, int)} returns
|
|
37 * <code>true</code> if called for <code>offset</code>.
|
|
38 *
|
|
39 * @param document the document into which to insert the proposed completion
|
|
40 * @param trigger the trigger to apply the completion
|
|
41 * @param offset the offset at which the trigger has been activated
|
|
42 */
|
|
43 void apply(IDocument document, char trigger, int offset);
|
|
44
|
|
45 /**
|
|
46 * Returns whether this completion proposal is valid for the given
|
|
47 * position in the given document.
|
|
48 *
|
|
49 * @param document the document for which the proposal is tested
|
|
50 * @param offset the offset for which the proposal is tested
|
|
51 * @return <code>true</code> iff valid
|
|
52 */
|
|
53 bool isValidFor(IDocument document, int offset);
|
|
54
|
|
55 /**
|
|
56 * Returns the characters which trigger the application of this completion proposal.
|
|
57 *
|
|
58 * @return the completion characters for this completion proposal or <code>null</code>
|
|
59 * if no completion other than the new line character is possible
|
|
60 */
|
|
61 char[] getTriggerCharacters();
|
|
62
|
|
63 /**
|
|
64 * Returns the position to which the computed context information refers to or
|
|
65 * <code>-1</code> if no context information can be provided by this completion proposal.
|
|
66 *
|
|
67 * @return the position to which the context information refers to or <code>-1</code> for no information
|
|
68 */
|
|
69 int getContextInformationPosition();
|
|
70 }
|