diff --git a/idea/src/META-INF/plugin.xml b/idea/src/META-INF/plugin.xml index 3820112ad89..3e6f1921a06 100644 --- a/idea/src/META-INF/plugin.xml +++ b/idea/src/META-INF/plugin.xml @@ -249,19 +249,11 @@ order="first" implementationClass="org.jetbrains.jet.plugin.completion.KotlinCompletionContributor"/> - - - - diff --git a/idea/src/org/jetbrains/jet/plugin/liveTemplates/JetLiveTemplateCompletionContributor.java b/idea/src/org/jetbrains/jet/plugin/liveTemplates/JetLiveTemplateCompletionContributor.java deleted file mode 100644 index 836ba09cf1d..00000000000 --- a/idea/src/org/jetbrains/jet/plugin/liveTemplates/JetLiveTemplateCompletionContributor.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright 2010-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.jet.plugin.liveTemplates; - -import com.intellij.codeInsight.completion.*; -import com.intellij.codeInsight.lookup.LookupElement; -import com.intellij.codeInsight.template.TemplateContextType; -import com.intellij.codeInsight.template.impl.*; -import com.intellij.openapi.util.Ref; -import com.intellij.patterns.PlatformPatterns; -import com.intellij.psi.PsiFile; -import com.intellij.util.Consumer; -import com.intellij.util.ProcessingContext; -import com.intellij.util.containers.ContainerUtil; -import org.jetbrains.annotations.NotNull; - -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -public class JetLiveTemplateCompletionContributor extends CompletionContributor { - public JetLiveTemplateCompletionContributor() { - extend(CompletionType.BASIC, PlatformPatterns.psiElement(), new CompletionProvider() { - @Override - protected void addCompletions(@NotNull CompletionParameters parameters, - ProcessingContext context, - @NotNull final CompletionResultSet result) { - if (parameters.getInvocationCount() == 0) return; - - PsiFile file = parameters.getPosition().getContainingFile(); - int offset = parameters.getOffset(); - final List templates = listApplicableTemplates(file, offset); - final Ref templatesShown = Ref.create(false); - - result.runRemainingContributors(parameters, new Consumer() { - @Override - public void consume(CompletionResult completionResult) { - result.passResult(completionResult); - ensureTemplatesShown(templatesShown, templates, result); - } - }); - - ensureTemplatesShown(templatesShown, templates, result); - } - }); - } - - private static void ensureTemplatesShown(Ref templatesShown, List templates, CompletionResultSet result) { - if (!templatesShown.get()) { - templatesShown.set(true); - for (TemplateImpl possible : templates) { - result.addElement(new LiveTemplateLookupElementImpl(possible, false)); - } - } - } - - private static List listApplicableTemplates(PsiFile file, int offset) { - Set contextTypes = TemplateManagerImpl.getApplicableContextTypes(file, offset); - - ArrayList result = ContainerUtil.newArrayList(); - for (TemplateImpl template : TemplateSettings.getInstance().getTemplates()) { - if (!template.isDeactivated() && !template.isSelectionTemplate() && TemplateManagerImpl.isApplicable(template, contextTypes)) { - result.add(template); - } - } - return result; - } - - public static class Skipper extends CompletionPreselectSkipper { - - @Override - public boolean skipElement(LookupElement element, CompletionLocation location) { - return element instanceof LiveTemplateLookupElement && ((LiveTemplateLookupElement) element).sudden; - } - } -} diff --git a/idea/testData/completion/weighers/basic/ExactMatchForKeyword.kt b/idea/testData/completion/weighers/basic/ExactMatchForKeyword.kt index 6bd32422189..37afaa2932c 100644 --- a/idea/testData/completion/weighers/basic/ExactMatchForKeyword.kt +++ b/idea/testData/completion/weighers/basic/ExactMatchForKeyword.kt @@ -7,5 +7,4 @@ fun test() { // ORDER: if // ORDER: ifMore // ORDER: isFirst -// ORDER: ifn // SELECTED: 0 \ No newline at end of file