diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionUtil.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionUtil.java index 7591bf758df6..83caae82459b 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionUtil.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionUtil.java @@ -884,7 +884,7 @@ public class JavaCompletionUtil { } private static LookupElementDecorator castQualifier(final Project project, LookupElement item, final LookupElement to) { - return LookupElementDecorator.delegate(item, new InsertHandlerDecorator() { + return LookupElementDecorator.withInsertHandler(item, new InsertHandlerDecorator() { public void handleInsert(InsertionContext context, LookupElementDecorator item) { final Document document = context.getEditor().getDocument(); PsiDocumentManager.getInstance(project).commitDocument(document); diff --git a/platform/lang-api/src/com/intellij/codeInsight/lookup/LookupElementBuilder.java b/platform/lang-api/src/com/intellij/codeInsight/lookup/LookupElementBuilder.java index 29198503c6e0..62ace8b09019 100644 --- a/platform/lang-api/src/com/intellij/codeInsight/lookup/LookupElementBuilder.java +++ b/platform/lang-api/src/com/intellij/codeInsight/lookup/LookupElementBuilder.java @@ -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; } diff --git a/platform/lang-api/src/com/intellij/codeInsight/lookup/LookupElementDecorator.java b/platform/lang-api/src/com/intellij/codeInsight/lookup/LookupElementDecorator.java index cc856e91d4de..c60fbf700bd9 100644 --- a/platform/lang-api/src/com/intellij/codeInsight/lookup/LookupElementDecorator.java +++ b/platform/lang-api/src/com/intellij/codeInsight/lookup/LookupElementDecorator.java @@ -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 extends Lo } @NotNull - public static LookupElementDecorator delegate(@NotNull T element, @NotNull final InsertHandlerDecorator insertHandler) { + public static LookupElementDecorator withInsertHandler(@NotNull T element, @NotNull final InsertHandler> insertHandler) { return new InsertingDecorator(element, insertHandler); } @@ -123,9 +124,9 @@ public abstract class LookupElementDecorator extends Lo } private static class InsertingDecorator extends LookupElementDecorator { - private final InsertHandlerDecorator myInsertHandler; + private final InsertHandler> myInsertHandler; - public InsertingDecorator(T element, InsertHandlerDecorator insertHandler) { + public InsertingDecorator(T element, InsertHandler> insertHandler) { super(element); myInsertHandler = insertHandler; } diff --git a/plugins/ant/src/com/intellij/lang/ant/psi/impl/reference/AntEndElementNameReference.java b/plugins/ant/src/com/intellij/lang/ant/psi/impl/reference/AntEndElementNameReference.java index 057e53e9c24b..6866e8650935 100644 --- a/plugins/ant/src/com/intellij/lang/ant/psi/impl/reference/AntEndElementNameReference.java +++ b/plugins/ant/src/com/intellij/lang/ant/psi/impl/reference/AntEndElementNameReference.java @@ -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)}; } diff --git a/xml/impl/src/com/intellij/codeInsight/completion/XmlCompletionContributor.java b/xml/impl/src/com/intellij/codeInsight/completion/XmlCompletionContributor.java index ac0200102754..068eb71196bc 100644 --- a/xml/impl/src/com/intellij/codeInsight/completion/XmlCompletionContributor.java +++ b/xml/impl/src/com/intellij/codeInsight/completion/XmlCompletionContributor.java @@ -81,7 +81,7 @@ public class XmlCompletionContributor extends CompletionContributor { result.runRemainingContributors(parameters, new Consumer() { 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()) {