Lines 39-44
Link Here
|
39 |
import org.eclipse.jface.text.contentassist.ContentAssistEvent; |
39 |
import org.eclipse.jface.text.contentassist.ContentAssistEvent; |
40 |
import org.eclipse.jface.text.contentassist.ContentAssistant; |
40 |
import org.eclipse.jface.text.contentassist.ContentAssistant; |
41 |
import org.eclipse.jface.text.contentassist.ICompletionListener; |
41 |
import org.eclipse.jface.text.contentassist.ICompletionListener; |
|
|
42 |
import org.eclipse.jface.text.contentassist.ICompletionListenerExtension; |
42 |
import org.eclipse.jface.text.contentassist.ICompletionProposal; |
43 |
import org.eclipse.jface.text.contentassist.ICompletionProposal; |
43 |
import org.eclipse.jface.text.contentassist.IContentAssistProcessor; |
44 |
import org.eclipse.jface.text.contentassist.IContentAssistProcessor; |
44 |
import org.eclipse.jface.text.contentassist.IContentAssistant; |
45 |
import org.eclipse.jface.text.contentassist.IContentAssistant; |
Lines 120-225
Link Here
|
120 |
private int fNumberOfComputedResults = 0; |
121 |
private int fNumberOfComputedResults = 0; |
121 |
|
122 |
|
122 |
private String fErrorMessage; |
123 |
private String fErrorMessage; |
|
|
124 |
class CompletionListener implements ICompletionListener, ICompletionListenerExtension { |
123 |
|
125 |
|
124 |
public ContentAssistProcessor(ContentAssistant assistant, String partition) { |
126 |
public void assistSessionStarted(ContentAssistEvent event) { |
125 |
Assert.isNotNull(partition); |
|
|
126 |
Assert.isNotNull(assistant); |
127 |
|
128 |
fPartition = partition; |
129 |
fCategories = CompletionProposalComputerRegistry.getDefault() |
130 |
.getProposalCategories(); |
131 |
fAssistant = assistant; |
132 |
fAssistant.addCompletionListener(new ICompletionListener() { |
133 |
|
134 |
public void assistSessionStarted(ContentAssistEvent event) { |
135 |
|
127 |
|
136 |
if (event.processor != ContentAssistProcessor.this) { |
128 |
if (event.processor != ContentAssistProcessor.this) { |
137 |
final IContentAssistant assistant = event.assistant; |
129 |
final IContentAssistant assistant = event.assistant; |
138 |
if (assistant instanceof IScriptContentAssistExtension) { |
130 |
if (assistant instanceof IScriptContentAssistExtension) { |
139 |
final IScriptContentAssistExtension extension = (IScriptContentAssistExtension) assistant; |
131 |
final IScriptContentAssistExtension extension = (IScriptContentAssistExtension) assistant; |
140 |
if (!extension.provide(event.processor)) |
132 |
if (!extension.provide(event.processor)) |
141 |
return; |
|
|
142 |
} else { |
143 |
return; |
133 |
return; |
144 |
} |
134 |
} else { |
145 |
} |
135 |
return; |
146 |
|
|
|
147 |
fIterationGesture = getIterationGesture(); |
148 |
KeySequence binding = getIterationBinding(); |
149 |
|
150 |
// this may show the warning dialog if all categories are |
151 |
// disabled |
152 |
fCategoryIteration = getCategoryIteration(); |
153 |
for (CompletionProposalCategory cat : fCategories) { |
154 |
cat.sessionStarted(); |
155 |
} |
136 |
} |
|
|
137 |
} |
156 |
|
138 |
|
157 |
fRepetition = 0; |
139 |
fIterationGesture = getIterationGesture(); |
158 |
if (event.assistant instanceof IContentAssistantExtension2) { |
140 |
KeySequence binding = getIterationBinding(); |
159 |
IContentAssistantExtension2 extension = (IContentAssistantExtension2) event.assistant; |
|
|
160 |
|
161 |
if (fCategoryIteration.size() == 1) { |
162 |
extension.setRepeatedInvocationMode(false); |
163 |
extension.setShowEmptyList(false); |
164 |
} else { |
165 |
extension.setRepeatedInvocationMode(true); |
166 |
extension.setStatusLineVisible(true); |
167 |
extension.setStatusMessage(createIterationMessage()); |
168 |
extension.setShowEmptyList(true); |
169 |
if (extension instanceof IContentAssistantExtension3) { |
170 |
IContentAssistantExtension3 ext3 = (IContentAssistantExtension3) extension; |
171 |
((ContentAssistant) ext3) |
172 |
.setRepeatedInvocationTrigger(binding); |
173 |
} |
174 |
} |
175 |
|
141 |
|
176 |
} |
142 |
// this may show the warning dialog if all categories are |
|
|
143 |
// disabled |
144 |
fCategoryIteration = getCategoryIteration(); |
145 |
for (CompletionProposalCategory cat : fCategories) { |
146 |
cat.sessionStarted(); |
177 |
} |
147 |
} |
178 |
|
148 |
|
179 |
/* |
149 |
fRepetition = 0; |
180 |
* @seeorg.eclipse.jface.text.contentassist.ICompletionListener# |
150 |
if (event.assistant instanceof IContentAssistantExtension2) { |
181 |
* assistSessionEnded |
151 |
IContentAssistantExtension2 extension = (IContentAssistantExtension2) event.assistant; |
182 |
* (org.eclipse.jface.text.contentassist.ContentAssistEvent) |
|
|
183 |
*/ |
184 |
public void assistSessionEnded(ContentAssistEvent event) { |
185 |
|
186 |
if (event.processor != ContentAssistProcessor.this) { |
187 |
final IContentAssistant assistant = event.assistant; |
188 |
if (assistant instanceof IScriptContentAssistExtension) { |
189 |
final IScriptContentAssistExtension extension = (IScriptContentAssistExtension) assistant; |
190 |
if (!extension.provide(event.processor)) |
191 |
return; |
192 |
} else { |
193 |
return; |
194 |
} |
195 |
} |
196 |
|
197 |
for (CompletionProposalCategory cat : fCategories) { |
198 |
cat.sessionEnded(); |
199 |
} |
200 |
|
152 |
|
201 |
fCategoryIteration = null; |
153 |
if (fCategoryIteration.size() == 1) { |
202 |
fRepetition = -1; |
|
|
203 |
fIterationGesture = null; |
204 |
if (event.assistant instanceof IContentAssistantExtension2) { |
205 |
IContentAssistantExtension2 extension = (IContentAssistantExtension2) event.assistant; |
206 |
extension.setShowEmptyList(false); |
207 |
extension.setRepeatedInvocationMode(false); |
154 |
extension.setRepeatedInvocationMode(false); |
208 |
extension.setStatusLineVisible(false); |
155 |
extension.setShowEmptyList(false); |
|
|
156 |
} else { |
157 |
extension.setRepeatedInvocationMode(true); |
158 |
extension.setStatusLineVisible(true); |
159 |
extension.setStatusMessage(createIterationMessage()); |
160 |
extension.setShowEmptyList(true); |
209 |
if (extension instanceof IContentAssistantExtension3) { |
161 |
if (extension instanceof IContentAssistantExtension3) { |
210 |
IContentAssistantExtension3 ext3 = (IContentAssistantExtension3) extension; |
162 |
IContentAssistantExtension3 ext3 = (IContentAssistantExtension3) extension; |
211 |
((ContentAssistant) ext3) |
163 |
((ContentAssistant) ext3) |
212 |
.setRepeatedInvocationTrigger(KeySequence |
164 |
.setRepeatedInvocationTrigger(binding); |
213 |
.getInstance()); |
|
|
214 |
} |
165 |
} |
215 |
} |
166 |
} |
|
|
167 |
|
168 |
} |
169 |
} |
170 |
|
171 |
/* |
172 |
* @seeorg.eclipse.jface.text.contentassist.ICompletionListener# |
173 |
* assistSessionEnded |
174 |
* (org.eclipse.jface.text.contentassist.ContentAssistEvent) |
175 |
*/ |
176 |
public void assistSessionEnded(ContentAssistEvent event) { |
177 |
|
178 |
if (event.processor != ContentAssistProcessor.this) { |
179 |
final IContentAssistant assistant = event.assistant; |
180 |
if (assistant instanceof IScriptContentAssistExtension) { |
181 |
final IScriptContentAssistExtension extension = (IScriptContentAssistExtension) assistant; |
182 |
if (!extension.provide(event.processor)) |
183 |
return; |
184 |
} else { |
185 |
return; |
186 |
} |
216 |
} |
187 |
} |
217 |
|
188 |
|
218 |
public void selectionChanged(ICompletionProposal proposal, |
189 |
for (CompletionProposalCategory cat : fCategories) { |
219 |
boolean smartToggle) { |
190 |
cat.sessionEnded(); |
220 |
} |
191 |
} |
221 |
|
192 |
|
222 |
}); |
193 |
fCategoryIteration = null; |
|
|
194 |
fRepetition = -1; |
195 |
fIterationGesture = null; |
196 |
if (event.assistant instanceof IContentAssistantExtension2) { |
197 |
IContentAssistantExtension2 extension = (IContentAssistantExtension2) event.assistant; |
198 |
extension.setShowEmptyList(false); |
199 |
extension.setRepeatedInvocationMode(false); |
200 |
extension.setStatusLineVisible(false); |
201 |
if (extension instanceof IContentAssistantExtension3) { |
202 |
IContentAssistantExtension3 ext3 = (IContentAssistantExtension3) extension; |
203 |
((ContentAssistant) ext3) |
204 |
.setRepeatedInvocationTrigger(KeySequence |
205 |
.getInstance()); |
206 |
} |
207 |
} |
208 |
} |
209 |
|
210 |
public void selectionChanged(ICompletionProposal proposal, |
211 |
boolean smartToggle) { |
212 |
} |
213 |
|
214 |
public void assistSessionRestarted(ContentAssistEvent event) { |
215 |
fRepetition = 0; |
216 |
} |
217 |
|
218 |
} |
219 |
public ContentAssistProcessor(ContentAssistant assistant, String partition) { |
220 |
Assert.isNotNull(partition); |
221 |
Assert.isNotNull(assistant); |
222 |
|
223 |
fPartition = partition; |
224 |
fCategories = CompletionProposalComputerRegistry.getDefault() |
225 |
.getProposalCategories(); |
226 |
fAssistant = assistant; |
227 |
fAssistant.addCompletionListener(new CompletionListener()); |
223 |
} |
228 |
} |
224 |
|
229 |
|
225 |
public final ICompletionProposal[] computeCompletionProposals( |
230 |
public final ICompletionProposal[] computeCompletionProposals( |