129
|
1 /*******************************************************************************
|
|
2 * Copyright (c) 2000, 2008 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.ICompletionProposal;
|
|
14
|
131
|
15 import dwtx.jface.text.contentassist.ContentAssistEvent; // packageimport
|
|
16 import dwtx.jface.text.contentassist.Helper; // packageimport
|
|
17 import dwtx.jface.text.contentassist.PopupCloser; // packageimport
|
|
18 import dwtx.jface.text.contentassist.IContentAssistant; // packageimport
|
|
19 import dwtx.jface.text.contentassist.CompletionProposal; // packageimport
|
|
20 import dwtx.jface.text.contentassist.ICompletionProposalExtension5; // packageimport
|
|
21 import dwtx.jface.text.contentassist.IContextInformationValidator; // packageimport
|
|
22 import dwtx.jface.text.contentassist.IContentAssistListener; // packageimport
|
|
23 import dwtx.jface.text.contentassist.ICompletionProposalExtension6; // packageimport
|
|
24 import dwtx.jface.text.contentassist.ICompletionListener; // packageimport
|
|
25 import dwtx.jface.text.contentassist.ICompletionProposalExtension2; // packageimport
|
|
26 import dwtx.jface.text.contentassist.IContentAssistantExtension4; // packageimport
|
|
27 import dwtx.jface.text.contentassist.ContextInformation; // packageimport
|
|
28 import dwtx.jface.text.contentassist.ICompletionProposalExtension3; // packageimport
|
|
29 import dwtx.jface.text.contentassist.ContextInformationValidator; // packageimport
|
|
30 import dwtx.jface.text.contentassist.IContentAssistProcessor; // packageimport
|
|
31 import dwtx.jface.text.contentassist.AdditionalInfoController; // packageimport
|
|
32 import dwtx.jface.text.contentassist.IContextInformationPresenter; // packageimport
|
|
33 import dwtx.jface.text.contentassist.ICompletionProposalExtension4; // packageimport
|
|
34 import dwtx.jface.text.contentassist.ICompletionListenerExtension; // packageimport
|
|
35 import dwtx.jface.text.contentassist.ContextInformationPopup; // packageimport
|
|
36 import dwtx.jface.text.contentassist.IContextInformationExtension; // packageimport
|
|
37 import dwtx.jface.text.contentassist.IContentAssistantExtension2; // packageimport
|
|
38 import dwtx.jface.text.contentassist.ContentAssistSubjectControlAdapter; // packageimport
|
|
39 import dwtx.jface.text.contentassist.CompletionProposalPopup; // packageimport
|
|
40 import dwtx.jface.text.contentassist.ICompletionProposalExtension; // packageimport
|
|
41 import dwtx.jface.text.contentassist.IContextInformation; // packageimport
|
|
42 import dwtx.jface.text.contentassist.IContentAssistantExtension3; // packageimport
|
|
43 import dwtx.jface.text.contentassist.ContentAssistant; // packageimport
|
|
44 import dwtx.jface.text.contentassist.IContentAssistantExtension; // packageimport
|
|
45 import dwtx.jface.text.contentassist.JFaceTextMessages; // packageimport
|
|
46
|
|
47
|
129
|
48 import dwt.dwthelper.utils;
|
|
49
|
|
50
|
|
51
|
|
52 import dwt.graphics.Image;
|
|
53 import dwt.graphics.Point;
|
|
54 import dwtx.jface.text.IDocument;
|
|
55
|
|
56
|
|
57 /**
|
|
58 * The interface of completion proposals generated by content assist processors.
|
|
59 * A completion proposal contains information used to present the proposed completion
|
|
60 * to the user, to insert the completion should the user select it, and to present
|
|
61 * context information for the chosen completion once it has been inserted.
|
|
62 * <p>
|
|
63 * In order to provide backward compatibility for clients of <code>ICompletionProposal</code>, extension
|
|
64 * interfaces are used to provide a means of evolution. The following extension interfaces exist:
|
|
65 * <ul>
|
|
66 * <li>{@link dwtx.jface.text.contentassist.ICompletionProposalExtension} since version 2.0 introducing
|
|
67 * the following functions:
|
|
68 * <ul>
|
|
69 * <li>handling of trigger characters other than ENTER</li>
|
|
70 * <li>completion proposal validation for a given offset</li>
|
|
71 * <li>context information can be freely positioned</li>
|
|
72 * </ul>
|
|
73 * </li>
|
|
74 * <li>{@link dwtx.jface.text.contentassist.ICompletionProposalExtension2} since version 2.1 introducing
|
|
75 * the following functions:
|
|
76 * <ul>
|
|
77 * <li>handling of trigger characters with modifiers</li>
|
|
78 * <li>visual indication for selection of a proposal</li>
|
|
79 * </ul>
|
|
80 * </li>
|
|
81 * <li>{@link dwtx.jface.text.contentassist.ICompletionProposalExtension3} since version 3.0 introducing
|
|
82 * the following functions:
|
|
83 * <ul>
|
|
84 * <li>provision of a custom information control creator</li>
|
|
85 * <li>provide a custom completion text and offset for prefix completion</li>
|
|
86 * </ul>
|
|
87 * </li>
|
|
88 * <li>{@link dwtx.jface.text.contentassist.ICompletionProposalExtension4} since version 3.1 introducing
|
|
89 * the following functions:
|
|
90 * <ul>
|
|
91 * <li>specify whether a proposal is automatically insertable</li>
|
|
92 * </ul>
|
|
93 * </li>
|
|
94 * <li>{@link dwtx.jface.text.contentassist.ICompletionProposalExtension5} since version 3.2 introducing
|
|
95 * the following function:
|
|
96 * <ul>
|
|
97 * <li>Allow background computation of the additional info</li>
|
|
98 * </ul>
|
|
99 * </li>
|
|
100 * <li>{@link dwtx.jface.text.contentassist.ICompletionProposalExtension6} since version 3.4 introducing
|
|
101 * the following function:
|
|
102 * <ul>
|
|
103 * <li>Allow styled ranges in the display string.</li>
|
|
104 * </ul>
|
|
105 * </li>
|
|
106 * </ul>
|
|
107 * </p>
|
|
108 * <p>
|
|
109 * This interface can be implemented by clients. By default, clients use
|
|
110 * {@link dwtx.jface.text.contentassist.CompletionProposal} as the
|
|
111 * standard implementer of this interface.
|
|
112 * </p>
|
|
113 *
|
|
114 * @see IContentAssistProcessor
|
|
115 */
|
|
116 public interface ICompletionProposal {
|
|
117
|
|
118 /**
|
|
119 * Inserts the proposed completion into the given document.
|
|
120 *
|
|
121 * @param document the document into which to insert the proposed completion
|
|
122 */
|
|
123 void apply(IDocument document);
|
|
124
|
|
125 /**
|
|
126 * Returns the new selection after the proposal has been applied to
|
|
127 * the given document in absolute document coordinates. If it returns
|
|
128 * <code>null</code>, no new selection is set.
|
|
129 *
|
|
130 * A document change can trigger other document changes, which have
|
|
131 * to be taken into account when calculating the new selection. Typically,
|
|
132 * this would be done by installing a document listener or by using a
|
|
133 * document position during {@link #apply(IDocument)}.
|
|
134 *
|
|
135 * @param document the document into which the proposed completion has been inserted
|
|
136 * @return the new selection in absolute document coordinates
|
|
137 */
|
|
138 Point getSelection(IDocument document);
|
|
139
|
|
140 /**
|
|
141 * Returns optional additional information about the proposal. The additional information will
|
|
142 * be presented to assist the user in deciding if the selected proposal is the desired choice.
|
|
143 * <p>
|
|
144 * If {@link ICompletionProposalExtension5} is implemented, this method should not be called any
|
|
145 * longer. This method may be deprecated in a future release.
|
|
146 * </p>
|
|
147 *
|
|
148 * @return the additional information or <code>null</code>
|
|
149 */
|
|
150 String getAdditionalProposalInfo();
|
|
151
|
|
152 /**
|
|
153 * Returns the string to be displayed in the list of completion proposals.
|
|
154 *
|
|
155 * @return the string to be displayed
|
|
156 */
|
|
157 String getDisplayString();
|
|
158
|
|
159 /**
|
|
160 * Returns the image to be displayed in the list of completion proposals.
|
|
161 * The image would typically be shown to the left of the display string.
|
|
162 *
|
|
163 * @return the image to be shown or <code>null</code> if no image is desired
|
|
164 */
|
|
165 Image getImage();
|
|
166
|
|
167 /**
|
|
168 * Returns optional context information associated with this proposal.
|
|
169 * The context information will automatically be shown if the proposal
|
|
170 * has been applied.
|
|
171 *
|
|
172 * @return the context information for this proposal or <code>null</code>
|
|
173 */
|
|
174 IContextInformation getContextInformation();
|
|
175 }
|