diff --git a/idea/src/META-INF/plugin.xml b/idea/src/META-INF/plugin.xml
index 72d971128a4..7f98daea0f8 100644
--- a/idea/src/META-INF/plugin.xml
+++ b/idea/src/META-INF/plugin.xml
@@ -90,10 +90,13 @@
-
+
+
-
diff --git a/idea/src/org/jetbrains/jet/plugin/completion/JetClassCompletionContributor.java b/idea/src/org/jetbrains/jet/plugin/completion/JetClassCompletionContributor.java
index d75b684c3ff..71738d84ebc 100644
--- a/idea/src/org/jetbrains/jet/plugin/completion/JetClassCompletionContributor.java
+++ b/idea/src/org/jetbrains/jet/plugin/completion/JetClassCompletionContributor.java
@@ -62,6 +62,8 @@ public class JetClassCompletionContributor extends CompletionContributor {
});
result.stopHere();
}
+
+ result.stopHere();
}
});
}
diff --git a/idea/src/org/jetbrains/jet/plugin/completion/JetCompletionContributor.java b/idea/src/org/jetbrains/jet/plugin/completion/JetCompletionContributor.java
index c76c78dc49a..25fc3958602 100644
--- a/idea/src/org/jetbrains/jet/plugin/completion/JetCompletionContributor.java
+++ b/idea/src/org/jetbrains/jet/plugin/completion/JetCompletionContributor.java
@@ -77,6 +77,9 @@ public class JetCompletionContributor extends CompletionContributor {
completeForReference(parameters, result, position, jetReference, session);
}
}
+
+ // Prevent from adding reference variants from standard reference contributor
+ result.stopHere();
}
});
}
@@ -88,9 +91,6 @@ public class JetCompletionContributor extends CompletionContributor {
@NotNull JetSimpleNameReference jetReference,
@NotNull CompletionSession session
) {
- // Prevent from adding reference variants from standard reference contributor
- result.stopHere();
-
if (isOnlyKeywordCompletion(position)) {
return;
}
diff --git a/idea/src/org/jetbrains/jet/plugin/completion/JetExtensionReceiverTypeContributor.java b/idea/src/org/jetbrains/jet/plugin/completion/JetExtensionReceiverTypeContributor.java
new file mode 100644
index 00000000000..664584407c5
--- /dev/null
+++ b/idea/src/org/jetbrains/jet/plugin/completion/JetExtensionReceiverTypeContributor.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2010-2012 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.completion;
+
+import com.intellij.codeInsight.completion.*;
+import com.intellij.codeInsight.lookup.LookupElement;
+import com.intellij.patterns.ElementPattern;
+import com.intellij.patterns.PlatformPatterns;
+import com.intellij.psi.PsiElement;
+import com.intellij.util.Consumer;
+import com.intellij.util.ProcessingContext;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.jet.lexer.JetTokens;
+
+/**
+ * Special contributor for getting completion of type for extensions receiver.
+ *
+ * @author Nikolay Krasko
+ */
+public class JetExtensionReceiverTypeContributor extends CompletionContributor {
+ private static class ReceiverTypeCompletionProvider extends CompletionProvider {
+ @Override
+ protected void addCompletions(@NotNull CompletionParameters parameters,
+ ProcessingContext context,
+ final @NotNull CompletionResultSet result
+ ) {
+ if (parameters.getInvocationCount() > 0 || parameters.getCompletionType() == CompletionType.CLASS_NAME) {
+ JetClassCompletionContributor.addClasses(parameters, result, new Consumer() {
+ @Override
+ public void consume(@NotNull LookupElement element) {
+ result.addElement(element);
+ }
+ });
+ }
+
+ result.stopHere();
+ }
+ }
+
+ private static final ElementPattern extends PsiElement> ACTIVATION_PATTERN =
+ PlatformPatterns.psiElement().afterLeaf(JetTokens.FUN_KEYWORD.toString(), JetTokens.VAL_KEYWORD.toString(),
+ JetTokens.VAR_KEYWORD.toString());
+
+ public JetExtensionReceiverTypeContributor() {
+ extend(CompletionType.BASIC, ACTIVATION_PATTERN, new ReceiverTypeCompletionProvider());
+ extend(CompletionType.CLASS_NAME, ACTIVATION_PATTERN, new ReceiverTypeCompletionProvider());
+ }
+}
diff --git a/idea/testData/completion/basic/ExtensionForProperty.kt b/idea/testData/completion/basic/ExtensionForProperty.kt
new file mode 100644
index 00000000000..9cd78b02333
--- /dev/null
+++ b/idea/testData/completion/basic/ExtensionForProperty.kt
@@ -0,0 +1,7 @@
+class Test {
+ val Str
+}
+
+// TIME: 1
+// EXIST: String~(jet)
+// EXIST: StringBuffer
\ No newline at end of file
diff --git a/idea/testData/completion/basic/ExtensionFunReceiver.kt b/idea/testData/completion/basic/ExtensionFunReceiver.kt
new file mode 100644
index 00000000000..250177fc0fa
--- /dev/null
+++ b/idea/testData/completion/basic/ExtensionFunReceiver.kt
@@ -0,0 +1,11 @@
+fun testing() {}
+
+fun S
+
+// Should complete types for receiver after explicit basic completion call
+// TIME: 1
+// EXIST: String
+// EXIST: StringBuffer
+// EXIST: Set
+// ABSENT: testing
+
diff --git a/idea/tests/org/jetbrains/jet/completion/JetBasicCompletionTest.java b/idea/tests/org/jetbrains/jet/completion/JetBasicCompletionTest.java
index 9793160dbdc..5bcb019d722 100644
--- a/idea/tests/org/jetbrains/jet/completion/JetBasicCompletionTest.java
+++ b/idea/tests/org/jetbrains/jet/completion/JetBasicCompletionTest.java
@@ -49,6 +49,14 @@ public class JetBasicCompletionTest extends JetCompletionTestBase {
doTest();
}
+ public void testExtensionFunReceiver() {
+ doTest();
+ }
+
+ public void testExtensionForProperty() {
+ doTest();
+ }
+
public void testFromImports() {
doTest();
}