Skip to main content
summaryrefslogtreecommitdiffstats
blob: 00925ad5d8c89fd3933ea12a3aeaa3b42bb337c5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*******************************************************************************
 * Copyright (c) 2000, 2005 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.jface.text.contentassist;

import org.eclipse.jface.text.DocumentEvent;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITextViewer;


/**
 * Extends {@link org.eclipse.jface.text.contentassist.ICompletionProposal}
 * with the following functions:
 * <ul>
 *	<li>handling of trigger characters with modifiers</li>
 *	<li>visual indication for selection of a proposal</li>
 * </ul>
 *
 * @since 2.1
 */
public interface ICompletionProposalExtension2 {

	/**
	 * Applies the proposed completion to the given document. The insertion
	 * has been triggered by entering the given character with a modifier at the given offset.
	 * This method assumes that {@link #validate(IDocument, int, DocumentEvent)}
	 * returns <code>true</code> if called for <code>offset</code>.
	 *
	 * @param viewer the text viewer into which to insert the proposed completion
	 * @param trigger the trigger to apply the completion
	 * @param stateMask the state mask of the modifiers
	 * @param offset the offset at which the trigger has been activated
	 */
	void apply(ITextViewer viewer, char trigger, int stateMask, int offset);

	/**
	 * Called when the proposal is selected.
	 *
	 * @param viewer the text viewer.
	 * @param smartToggle the smart toggle key was pressed
	 */
	void selected(ITextViewer viewer, boolean smartToggle);

	/**
	 * Called when the proposal is unselected.
	 *
	 * @param viewer the text viewer.
	 */
	void unselected(ITextViewer viewer);

	/**
	 * Requests the proposal to be validated with respect to the document event.
	 * If the proposal cannot be validated, the methods returns <code>false</code>.
	 * If the document event was <code>null</code>, only the caret offset was changed, but not the document.
	 *
	 * This method replaces {@link ICompletionProposalExtension#isValidFor(IDocument, int)}
	 *
	 * @param document the document
	 * @param offset the caret offset
	 * @param event the document event, may be <code>null</code>
	 * @return boolean
	 */
	boolean validate(IDocument document, int offset, DocumentEvent event);

}

Back to the top