mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup LookupElementBuilder API, non-invasive groovy insert handler setting, no semicolons after break/continue, better 'delegate' name
This commit is contained in:
@@ -884,7 +884,7 @@ public class JavaCompletionUtil {
|
||||
}
|
||||
|
||||
private static LookupElementDecorator<LookupElement> castQualifier(final Project project, LookupElement item, final LookupElement to) {
|
||||
return LookupElementDecorator.delegate(item, new InsertHandlerDecorator<LookupElement>() {
|
||||
return LookupElementDecorator.withInsertHandler(item, new InsertHandlerDecorator<LookupElement>() {
|
||||
public void handleInsert(InsertionContext context, LookupElementDecorator<LookupElement> item) {
|
||||
final Document document = context.getEditor().getDocument();
|
||||
PsiDocumentManager.getInstance(project).commitDocument(document);
|
||||
|
||||
@@ -69,10 +69,6 @@ public class LookupElementBuilder extends LookupElement {
|
||||
return new LookupElementBuilder(ObjectUtils.assertNotNull(element.getName()), element);
|
||||
}
|
||||
|
||||
public static LookupElementBuilder create(@NotNull String lookupString, @NotNull Object lookupObject) {
|
||||
return new LookupElementBuilder(lookupString, lookupObject);
|
||||
}
|
||||
|
||||
public static LookupElementBuilder create(@NotNull Object lookupObject, @NotNull String lookupString) {
|
||||
return new LookupElementBuilder(lookupString, lookupObject);
|
||||
}
|
||||
@@ -179,11 +175,6 @@ public class LookupElementBuilder extends LookupElement {
|
||||
myAllLookupStrings, myCaseSensitive);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public LookupElement createLookupElement() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public AutoCompletionPolicy getAutoCompletionPolicy() {
|
||||
return myAutoCompletionPolicy;
|
||||
}
|
||||
|
||||
@@ -15,9 +15,10 @@
|
||||
*/
|
||||
package com.intellij.codeInsight.lookup;
|
||||
|
||||
import com.intellij.codeInsight.completion.CompletionService;
|
||||
import com.intellij.codeInsight.completion.InsertHandler;
|
||||
import com.intellij.codeInsight.completion.InsertionContext;
|
||||
import com.intellij.codeInsight.completion.PrefixMatcher;
|
||||
import com.intellij.codeInsight.completion.CompletionService;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Set;
|
||||
@@ -107,7 +108,7 @@ public abstract class LookupElementDecorator<T extends LookupElement> extends Lo
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <T extends LookupElement> LookupElementDecorator<T> delegate(@NotNull T element, @NotNull final InsertHandlerDecorator<T> insertHandler) {
|
||||
public static <T extends LookupElement> LookupElementDecorator<T> withInsertHandler(@NotNull T element, @NotNull final InsertHandler<LookupElementDecorator<T>> insertHandler) {
|
||||
return new InsertingDecorator<T>(element, insertHandler);
|
||||
}
|
||||
|
||||
@@ -123,9 +124,9 @@ public abstract class LookupElementDecorator<T extends LookupElement> extends Lo
|
||||
}
|
||||
|
||||
private static class InsertingDecorator<T extends LookupElement> extends LookupElementDecorator<T> {
|
||||
private final InsertHandlerDecorator<T> myInsertHandler;
|
||||
private final InsertHandler<LookupElementDecorator<T>> myInsertHandler;
|
||||
|
||||
public InsertingDecorator(T element, InsertHandlerDecorator<T> insertHandler) {
|
||||
public InsertingDecorator(T element, InsertHandler<LookupElementDecorator<T>> insertHandler) {
|
||||
super(element);
|
||||
myInsertHandler = insertHandler;
|
||||
}
|
||||
|
||||
+4
-2
@@ -10,6 +10,7 @@ import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.xml.XmlTag;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class AntEndElementNameReference extends AntElementNameReference {
|
||||
private final TextRange myRange;
|
||||
@@ -25,7 +26,8 @@ public class AntEndElementNameReference extends AntElementNameReference {
|
||||
return getElement();
|
||||
}
|
||||
|
||||
public Object[] getVariants() {
|
||||
@NotNull
|
||||
public LookupElement[] getVariants() {
|
||||
final AntStructuredElement element = getElement();
|
||||
final XmlTag xmlTag = element.getSourceElement();
|
||||
final String completionText = myIsTagClosed ? element.getSourceElement().getName() : element.getSourceElement().getName() + ">";
|
||||
@@ -35,7 +37,7 @@ public class AntEndElementNameReference extends AntElementNameReference {
|
||||
return xmlTag;
|
||||
}
|
||||
};
|
||||
return new LookupElement[] {LookupElementBuilder.create(completionText, wrapper).setAutoCompletionPolicy(
|
||||
return new LookupElement[] {LookupElementBuilder.create(wrapper, completionText).setAutoCompletionPolicy(
|
||||
AutoCompletionPolicy.GIVE_CHANCE_TO_OVERWRITE)};
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ public class XmlCompletionContributor extends CompletionContributor {
|
||||
result.runRemainingContributors(parameters, new Consumer<LookupElement>() {
|
||||
public void consume(LookupElement element) {
|
||||
addWordVariants.set(false);
|
||||
result.addElement(LookupElementDecorator.delegate(element, QUOTE_EATER));
|
||||
result.addElement(LookupElementDecorator.withInsertHandler(element, QUOTE_EATER));
|
||||
}
|
||||
});
|
||||
if (addWordVariants.get().booleanValue()) {
|
||||
|
||||
Reference in New Issue
Block a user