wrap auto-insertion in a command,

API-ready MatchedLookupElement
This commit is contained in:
peter
2011-04-18 15:35:50 +02:00
parent 882612bcce
commit 75113532b3
3 changed files with 15 additions and 6 deletions
@@ -426,7 +426,15 @@ public class CodeCompletionHandlerBase implements CodeInsightActionHandler {
final Runnable restorePrefix = rememberDocumentState(indicator.getEditor());
final LookupElement item = ((AutoCompletionDecision.InsertItem)decision).getElement();
indicator.getLookup().finishLookup(Lookup.AUTO_INSERT_SELECT_CHAR, item);
CommandProcessor.getInstance().executeCommand(indicator.getProject(), new Runnable() {
@Override
public void run() {
indicator.setMergeCommand();
indicator.getLookup().finishLookup(Lookup.AUTO_INSERT_SELECT_CHAR, item);
}
}, "Autocompletion", null);
// the insert handler may have started a live template with completion
if (CompletionService.getCompletionService().getCurrentCompletion() == null &&
@@ -300,7 +300,7 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement
});
}
private void setMergeCommand() {
public void setMergeCommand() {
CommandProcessor.getInstance().setCurrentCommandGroupId(getCompletionCommandName());
}
@@ -370,7 +370,7 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement
LOG.assertTrue(myParameters.getPosition().isValid());
myItemSorters.put(item.getDelegate(), item.getSorter());
myItemSorters.put(item.getDelegate(), (CompletionSorterImpl) item.getSorter());
myLookup.addItem(item.getDelegate(), item.getPrefixMatcher());
myCount++;
if (unitTestMode) return;
@@ -15,6 +15,7 @@
*/
package com.intellij.codeInsight.completion.impl;
import com.intellij.codeInsight.completion.CompletionSorter;
import com.intellij.codeInsight.completion.PrefixMatcher;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.codeInsight.lookup.LookupElementDecorator;
@@ -26,9 +27,9 @@ import com.intellij.openapi.util.ClassConditionKey;
public class MatchedLookupElement extends LookupElementDecorator<LookupElement> {
public static final ClassConditionKey<MatchedLookupElement> CLASS_CONDITION_KEY = ClassConditionKey.create(MatchedLookupElement.class);
private final PrefixMatcher myMatcher;
private final CompletionSorterImpl mySorter;
private final CompletionSorter mySorter;
MatchedLookupElement(LookupElement delegate, PrefixMatcher matcher, CompletionSorterImpl sorter) {
MatchedLookupElement(LookupElement delegate, PrefixMatcher matcher, CompletionSorter sorter) {
super(delegate);
myMatcher = matcher;
mySorter = sorter;
@@ -38,7 +39,7 @@ public class MatchedLookupElement extends LookupElementDecorator<LookupElement>
return myMatcher;
}
public CompletionSorterImpl getSorter() {
public CompletionSorter getSorter() {
return mySorter;
}