mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
wrap auto-insertion in a command,
API-ready MatchedLookupElement
This commit is contained in:
+9
-1
@@ -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 &&
|
||||
|
||||
+2
-2
@@ -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;
|
||||
|
||||
+4
-3
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user