diff --git a/.idea/compiler.xml b/.idea/compiler.xml
index 8c89653e336..539635056d8 100644
--- a/.idea/compiler.xml
+++ b/.idea/compiler.xml
@@ -19,7 +19,11 @@
-
+
+
+
+
+
diff --git a/.idea/inspectionProfiles/idea_default.xml b/.idea/inspectionProfiles/idea_default.xml
index 23bae163cd7..6c2f8ad45ac 100644
--- a/.idea/inspectionProfiles/idea_default.xml
+++ b/.idea/inspectionProfiles/idea_default.xml
@@ -410,6 +410,9 @@
+
diff --git a/.idea/libraries/idea_full.xml b/.idea/libraries/idea_full.xml
index 58b04f543b5..2e24dd5d11b 100644
--- a/.idea/libraries/idea_full.xml
+++ b/.idea/libraries/idea_full.xml
@@ -1,152 +1,559 @@
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/idea/src/org/jetbrains/jet/plugin/completion/JetKeywordCompletionContributor.java b/idea/src/org/jetbrains/jet/plugin/completion/JetKeywordCompletionContributor.java
index fa8cc613c9c..a8df4aeedaa 100644
--- a/idea/src/org/jetbrains/jet/plugin/completion/JetKeywordCompletionContributor.java
+++ b/idea/src/org/jetbrains/jet/plugin/completion/JetKeywordCompletionContributor.java
@@ -17,7 +17,9 @@
package org.jetbrains.jet.plugin.completion;
import com.google.common.base.Function;
+import com.google.common.base.Predicate;
import com.google.common.collect.Collections2;
+import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.intellij.codeInsight.CommentUtil;
import com.intellij.codeInsight.completion.*;
@@ -28,12 +30,15 @@ import com.intellij.patterns.PlatformPatterns;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiWhiteSpace;
import com.intellij.psi.filters.*;
-import com.intellij.psi.filters.position.*;
+import com.intellij.psi.filters.position.FilterPattern;
+import com.intellij.psi.filters.position.LeftNeighbour;
+import com.intellij.psi.filters.position.PositionElementFilter;
import com.intellij.psi.impl.source.tree.LeafPsiElement;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.ArrayUtil;
import com.intellij.util.ProcessingContext;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.psi.*;
import org.jetbrains.jet.lexer.JetToken;
import org.jetbrains.jet.lexer.JetTokens;
@@ -250,20 +255,25 @@ public class JetKeywordCompletionContributor extends CompletionContributor {
}
if (!FUNCTION_KEYWORDS.contains(keyword)) {
- return lookupElementBuilder.setInsertHandler(KEYWORDS_INSERT_HANDLER);
+ return lookupElementBuilder.withInsertHandler(KEYWORDS_INSERT_HANDLER);
}
- return lookupElementBuilder.setInsertHandler(FUNCTION_INSERT_HANDLER);
+ return lookupElementBuilder.withInsertHandler(FUNCTION_INSERT_HANDLER);
}
});
}
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context,
- @NotNull CompletionResultSet result) {
- result.addAllElements(elements);
+ @NotNull final CompletionResultSet result) {
+ result.addAllElements(Iterables.filter(elements, new Predicate() {
+ @Override
+ public boolean apply(@Nullable LookupElement element) {
+ assert element != null;
+ return result.getPrefixMatcher().isStartMatch(element.getLookupString());
+ }
+ }));
}
-
}
public JetKeywordCompletionContributor() {