Very initial implementation of smart completion
This commit is contained in:
@@ -22,7 +22,7 @@ import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.JetNodeType;
|
||||
|
||||
abstract class JetExpressionImpl extends JetElementImpl implements JetExpression {
|
||||
public abstract class JetExpressionImpl extends JetElementImpl implements JetExpression {
|
||||
public JetExpressionImpl(@NotNull ASTNode node) {
|
||||
super(node);
|
||||
}
|
||||
|
||||
@@ -27,10 +27,7 @@ import org.jetbrains.jet.codegen.AbstractTopLevelMembersInvocationTest;
|
||||
import org.jetbrains.jet.codegen.defaultConstructor.AbstractDefaultConstructorCodegenTest;
|
||||
import org.jetbrains.jet.codegen.flags.AbstractWriteFlagsTest;
|
||||
import org.jetbrains.jet.codegen.generated.AbstractBlackBoxCodegenTest;
|
||||
import org.jetbrains.jet.completion.AbstractJavaCompletionTest;
|
||||
import org.jetbrains.jet.completion.AbstractJavaWithLibCompletionTest;
|
||||
import org.jetbrains.jet.completion.AbstractJetJSCompletionTest;
|
||||
import org.jetbrains.jet.completion.AbstractKeywordCompletionTest;
|
||||
import org.jetbrains.jet.completion.*;
|
||||
import org.jetbrains.jet.completion.weighers.AbstractCompletionWeigherTest;
|
||||
import org.jetbrains.jet.descriptors.serialization.AbstractDescriptorSerializationTest;
|
||||
import org.jetbrains.jet.editor.quickDoc.AbstractJetQuickDocProviderTest;
|
||||
@@ -294,7 +291,7 @@ public class GenerateTests {
|
||||
generateTest(
|
||||
"idea/tests/",
|
||||
"JetBasicJSCompletionTestGenerated",
|
||||
AbstractJetJSCompletionTest.class,
|
||||
AbstractJSBasicCompletionTest.class,
|
||||
testModel("idea/testData/completion/basic/common"),
|
||||
testModel("idea/testData/completion/basic/js")
|
||||
);
|
||||
@@ -302,11 +299,18 @@ public class GenerateTests {
|
||||
generateTest(
|
||||
"idea/tests/",
|
||||
"JetBasicJavaCompletionTestGenerated",
|
||||
AbstractJavaCompletionTest.class,
|
||||
AbstractJvmBasicCompletionTest.class,
|
||||
testModel("idea/testData/completion/basic/common"),
|
||||
testModel("idea/testData/completion/basic/java")
|
||||
);
|
||||
|
||||
generateTest(
|
||||
"idea/tests/",
|
||||
"JetSmartCompletionTestGenerated",
|
||||
AbstractJvmSmartCompletionTest.class,
|
||||
testModel("idea/testData/completion/smart")
|
||||
);
|
||||
|
||||
generateTest(
|
||||
"idea/tests/",
|
||||
"JetKeywordCompletionTestGenerated",
|
||||
@@ -317,7 +321,7 @@ public class GenerateTests {
|
||||
generateTest(
|
||||
"idea/tests",
|
||||
"JetJavaLibCompletionTestGenerated",
|
||||
AbstractJavaWithLibCompletionTest.class,
|
||||
AbstractJvmWithLibBasicCompletionTest.class,
|
||||
testModel("idea/testData/completion/basic/custom", false, "doTest"));
|
||||
|
||||
generateTest(
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Collections2;
|
||||
import com.intellij.codeInsight.completion.CompletionParameters;
|
||||
import com.intellij.codeInsight.completion.CompletionResultSet;
|
||||
import com.intellij.codeInsight.completion.CompletionType;
|
||||
import com.intellij.codeInsight.completion.JavaCompletionContributor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
@@ -43,7 +44,7 @@ import org.jetbrains.jet.plugin.references.JetSimpleNameReference;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public class CompletionSession {
|
||||
class CompletionSession {
|
||||
@Nullable
|
||||
private final DeclarationDescriptor inDescriptor;
|
||||
private final CompletionParameters parameters;
|
||||
@@ -78,7 +79,9 @@ public class CompletionSession {
|
||||
});
|
||||
}
|
||||
|
||||
void completeForReference() {
|
||||
public void completeForReference() {
|
||||
assert parameters.getCompletionType() == CompletionType.BASIC;
|
||||
|
||||
if (isOnlyKeywordCompletion(getPosition())) {
|
||||
return;
|
||||
}
|
||||
@@ -126,6 +129,21 @@ public class CompletionSession {
|
||||
}
|
||||
}
|
||||
|
||||
public void completeSmart() {
|
||||
assert parameters.getCompletionType() == CompletionType.SMART;
|
||||
|
||||
//noinspection StaticMethodReferencedViaSubclass
|
||||
final SmartCompletionFilter filter = CompletionPackage.buildSmartCompletionFilter(jetReference.getExpression(), getResolveSession());
|
||||
if (filter != null) {
|
||||
addReferenceVariants(new Condition<DeclarationDescriptor>() {
|
||||
@Override
|
||||
public boolean value(DeclarationDescriptor descriptor) {
|
||||
return filter.accepts(descriptor);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isOnlyKeywordCompletion(PsiElement position) {
|
||||
return PsiTreeUtil.getParentOfType(position, JetModifierList.class) != null;
|
||||
}
|
||||
|
||||
@@ -31,17 +31,18 @@ import org.jetbrains.jet.plugin.references.JetSimpleNameReference;
|
||||
|
||||
public class JetCompletionContributor extends CompletionContributor {
|
||||
public JetCompletionContributor() {
|
||||
extend(CompletionType.BASIC, PlatformPatterns.psiElement(),
|
||||
new CompletionProvider<CompletionParameters>() {
|
||||
@Override
|
||||
protected void addCompletions(
|
||||
@NotNull CompletionParameters parameters,
|
||||
ProcessingContext context,
|
||||
@NotNull CompletionResultSet result
|
||||
) {
|
||||
doSimpleReferenceCompletion(parameters, result);
|
||||
}
|
||||
});
|
||||
final CompletionProvider<CompletionParameters> provider = new CompletionProvider<CompletionParameters>() {
|
||||
@Override
|
||||
protected void addCompletions(
|
||||
@NotNull CompletionParameters parameters,
|
||||
ProcessingContext context,
|
||||
@NotNull CompletionResultSet result
|
||||
) {
|
||||
doSimpleReferenceCompletion(parameters, result);
|
||||
}
|
||||
};
|
||||
extend(CompletionType.BASIC, PlatformPatterns.psiElement(), provider);
|
||||
extend(CompletionType.SMART, PlatformPatterns.psiElement(), provider);
|
||||
}
|
||||
|
||||
public static void doSimpleReferenceCompletion(CompletionParameters parameters, CompletionResultSet result) {
|
||||
@@ -57,12 +58,18 @@ public class JetCompletionContributor extends CompletionContributor {
|
||||
result.restartCompletionWhenNothingMatches();
|
||||
|
||||
CompletionSession session = new CompletionSession(parameters, result, jetReference, position);
|
||||
session.completeForReference();
|
||||
|
||||
if (!session.getJetResult().isSomethingAdded() && session.getParameters().getInvocationCount() < 2) {
|
||||
// Rerun completion if nothing was found
|
||||
session = new CompletionSession(parameters.withInvocationCount(2), result, jetReference, position);
|
||||
if (parameters.getCompletionType() == CompletionType.BASIC) {
|
||||
session.completeForReference();
|
||||
|
||||
if (!session.getJetResult().isSomethingAdded()
|
||||
&& session.getParameters().getInvocationCount() < 2) {
|
||||
// Rerun completion if nothing was found
|
||||
session = new CompletionSession(parameters.withInvocationCount(2), result, jetReference, position);
|
||||
session.completeForReference();
|
||||
}
|
||||
}
|
||||
else {
|
||||
session.completeSmart();
|
||||
}
|
||||
|
||||
// Prevent from adding reference variants from standard reference contributor
|
||||
@@ -106,6 +113,9 @@ public class JetCompletionContributor extends CompletionContributor {
|
||||
else if (JetExtensionReceiverTypeContributor.ACTIVATION_PATTERN.accepts(position)) {
|
||||
context.setDummyIdentifier(JetExtensionReceiverTypeContributor.DUMMY_IDENTIFIER);
|
||||
}
|
||||
else{
|
||||
context.setDummyIdentifier(CompletionUtilCore.DUMMY_IDENTIFIER_TRIMMED);
|
||||
}
|
||||
|
||||
if (!context.getEditor().getSelectionModel().hasSelection()) {
|
||||
PsiReference reference = context.getFile().findReferenceAt(offset);
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
package org.jetbrains.jet.plugin.completion
|
||||
|
||||
import com.intellij.codeInsight.completion.*
|
||||
import com.intellij.util.*
|
||||
import org.jetbrains.jet.lang.descriptors.*
|
||||
import org.jetbrains.jet.lang.resolve.*
|
||||
import org.jetbrains.jet.lang.psi.*
|
||||
import org.jetbrains.jet.lexer.JetToken
|
||||
import org.jetbrains.jet.lexer.JetTokens
|
||||
import org.jetbrains.jet.plugin.project.CancelableResolveSession
|
||||
import org.jetbrains.jet.lang.types.JetType
|
||||
import org.jetbrains.jet.lang.types.checker.JetTypeChecker
|
||||
|
||||
trait SmartCompletionFilter{
|
||||
fun accepts(descriptor: DeclarationDescriptor): Boolean
|
||||
}
|
||||
|
||||
fun buildSmartCompletionFilter(expression: JetSimpleNameExpression, resolveSession: CancelableResolveSession): SmartCompletionFilter? {
|
||||
val parent = expression.getParent()
|
||||
val expressionWithType = if (parent is JetQualifiedExpression) parent else expression
|
||||
val expectedType: JetType? = resolveSession.resolveToElement(expressionWithType).get(BindingContext.EXPECTED_EXPRESSION_TYPE, expressionWithType)
|
||||
if (expectedType == null) return null
|
||||
|
||||
val itemsToSkip = calcItemsToSkip(expressionWithType, resolveSession)
|
||||
|
||||
return object: SmartCompletionFilter{
|
||||
override fun accepts(descriptor: DeclarationDescriptor): Boolean {
|
||||
if (itemsToSkip.contains(descriptor)) return false
|
||||
|
||||
if (descriptor is CallableDescriptor) {
|
||||
val returnType = descriptor.getReturnType()
|
||||
return returnType != null && JetTypeChecker.INSTANCE.isSubtypeOf(returnType, expectedType)
|
||||
}
|
||||
else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun <T : Any> T?.toList(): List<T> = if (this != null) listOf(this) else listOf()
|
||||
|
||||
private fun calcItemsToSkip(expression: JetExpression, resolveSession: CancelableResolveSession): Collection<DeclarationDescriptor> {
|
||||
val parent = expression.getParent()
|
||||
when(parent) {
|
||||
is JetProperty -> {
|
||||
//TODO: this can be filtered out by ordinary completion
|
||||
if (expression == parent.getInitializer()) {
|
||||
return resolveSession.resolveToElement(parent).get(BindingContext.DECLARATION_TO_DESCRIPTOR, parent).toList()
|
||||
}
|
||||
}
|
||||
|
||||
is JetBinaryExpression -> {
|
||||
if (parent.getRight() == expression && parent.getOperationToken() == JetTokens.EQ) {
|
||||
val left = parent.getLeft()
|
||||
if (left is JetReferenceExpression) {
|
||||
return resolveSession.resolveToElement(left).get(BindingContext.REFERENCE_TARGET, left).toList()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return listOf()
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fun f(p: Object) {
|
||||
if (p is String){
|
||||
var a : String = <caret>
|
||||
}
|
||||
}
|
||||
|
||||
// EXIST: p
|
||||
@@ -0,0 +1,20 @@
|
||||
trait Foo{
|
||||
public fun foo() : Foo
|
||||
public fun s() : String
|
||||
public val prop : String
|
||||
}
|
||||
|
||||
val foo = Foo()
|
||||
|
||||
fun f(p1: Foo, p2: String) {
|
||||
var a : String
|
||||
a = p1.foo().<caret>
|
||||
}
|
||||
|
||||
// ABSENT: foo
|
||||
// EXIST: s
|
||||
// EXIST: prop
|
||||
// ABSENT: foo
|
||||
// ABSENT: p1
|
||||
// ABSENT: p2
|
||||
// ABSENT: a
|
||||
@@ -0,0 +1,26 @@
|
||||
class Foo
|
||||
class Bar : Foo
|
||||
|
||||
val foo = Foo()
|
||||
val bar = Bar()
|
||||
val o : Object = Object()
|
||||
|
||||
fun f(p1 : Foo, p2 : Bar, p3 : String, p4 : Foo?) {
|
||||
var a : Foo
|
||||
a = <caret>
|
||||
}
|
||||
|
||||
fun f1() : Foo{}
|
||||
fun f2() : Bar{}
|
||||
fun f3() : String{}
|
||||
|
||||
// EXIST: foo
|
||||
// EXIST: bar
|
||||
// ABSENT: o
|
||||
// EXIST: p1
|
||||
// EXIST: p2
|
||||
// ABSENT: p3
|
||||
// ABSENT: p4
|
||||
// EXIST: f1
|
||||
// EXIST: f2
|
||||
// ABSENT: f3
|
||||
@@ -0,0 +1,19 @@
|
||||
class Foo
|
||||
class Bar : Foo
|
||||
|
||||
val xfoo = Foo()
|
||||
val xbar = Bar()
|
||||
val xo : Object = Object()
|
||||
|
||||
fun f(xp1 : Foo, xp2 : Bar, xp3 : String, p4 : Foo) {
|
||||
var a : Foo
|
||||
a = x<caret>y
|
||||
}
|
||||
|
||||
// EXIST: xfoo
|
||||
// EXIST: xbar
|
||||
// ABSENT: xo
|
||||
// EXIST: xp1
|
||||
// EXIST: xp2
|
||||
// ABSENT: xp3
|
||||
// ABSENT: p4
|
||||
@@ -0,0 +1,13 @@
|
||||
val s = ""
|
||||
|
||||
fun f(p1: Object, p2: String) {
|
||||
foo(<caret>)
|
||||
}
|
||||
|
||||
fun foo(p1: String, p2: Object) : String{
|
||||
}
|
||||
|
||||
// ABSENT: p1
|
||||
// EXIST: p2
|
||||
// EXIST: s
|
||||
// EXIST: foo
|
||||
@@ -0,0 +1,7 @@
|
||||
fun f(p : String) {
|
||||
var a : String
|
||||
a = <caret>
|
||||
}
|
||||
|
||||
// EXIST: p
|
||||
// ABSENT: a
|
||||
@@ -0,0 +1,7 @@
|
||||
class Foo(val prop : String)
|
||||
|
||||
fun f(foo1 : Foo, foo2 : Foo) {
|
||||
foo1.prop = foo2.<caret>
|
||||
}
|
||||
|
||||
// EXIST: prop
|
||||
@@ -0,0 +1,10 @@
|
||||
val foo = ""
|
||||
|
||||
fun f(p1: Object, p2: String) {
|
||||
var a : String = <caret>
|
||||
}
|
||||
|
||||
// ABSENT: p1
|
||||
// EXIST: p2
|
||||
// EXIST: foo
|
||||
// ABSENT: a
|
||||
@@ -0,0 +1,19 @@
|
||||
class Foo
|
||||
class Bar : Foo
|
||||
|
||||
val xfoo = Foo()
|
||||
val xbar = Bar()
|
||||
val xo : Object = Object()
|
||||
|
||||
fun f(xp1 : Foo, xp2 : Bar, xp3 : String, p4 : Foo) {
|
||||
var a : Foo
|
||||
a = x<caret>
|
||||
}
|
||||
|
||||
// EXIST: xfoo
|
||||
// EXIST: xbar
|
||||
// ABSENT: xo
|
||||
// EXIST: xp1
|
||||
// EXIST: xp2
|
||||
// ABSENT: xp3
|
||||
// ABSENT: p4
|
||||
@@ -0,0 +1,23 @@
|
||||
trait Foo{
|
||||
fun foo1() : String
|
||||
fun foo2() : Object
|
||||
val prop : String
|
||||
}
|
||||
|
||||
val foo = Foo()
|
||||
|
||||
fun f(p1: Foo, p2: String) {
|
||||
var a : String
|
||||
a = p1.<caret>
|
||||
}
|
||||
|
||||
fun Foo.ext() : String{}
|
||||
|
||||
// EXIST: foo1
|
||||
// ABSENT: foo2
|
||||
// EXIST: prop
|
||||
// EXIST: ext
|
||||
// ABSENT: foo
|
||||
// ABSENT: p1
|
||||
// ABSENT: p2
|
||||
// ABSENT: a
|
||||
+6
-1
@@ -16,12 +16,13 @@
|
||||
|
||||
package org.jetbrains.jet.completion;
|
||||
|
||||
import com.intellij.codeInsight.completion.CompletionType;
|
||||
import com.intellij.testFramework.LightProjectDescriptor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.plugin.JetStdJSProjectDescriptor;
|
||||
import org.jetbrains.jet.plugin.project.TargetPlatform;
|
||||
|
||||
public abstract class AbstractJetJSCompletionTest extends JetFixtureCompletionBaseTestCase {
|
||||
public abstract class AbstractJSBasicCompletionTest extends JetFixtureCompletionBaseTestCase {
|
||||
@NotNull
|
||||
@Override
|
||||
protected LightProjectDescriptor getProjectDescriptor() {
|
||||
@@ -32,4 +33,8 @@ public abstract class AbstractJetJSCompletionTest extends JetFixtureCompletionBa
|
||||
public TargetPlatform getPlatform() {
|
||||
return TargetPlatform.JS;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected CompletionType completionType() { return CompletionType.BASIC; }
|
||||
}
|
||||
+6
-1
@@ -16,12 +16,13 @@
|
||||
|
||||
package org.jetbrains.jet.completion;
|
||||
|
||||
import com.intellij.codeInsight.completion.CompletionType;
|
||||
import com.intellij.testFramework.LightProjectDescriptor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.plugin.JetWithJdkAndRuntimeLightProjectDescriptor;
|
||||
import org.jetbrains.jet.plugin.project.TargetPlatform;
|
||||
|
||||
public abstract class AbstractJavaCompletionTest extends JetFixtureCompletionBaseTestCase {
|
||||
public abstract class AbstractJvmBasicCompletionTest extends JetFixtureCompletionBaseTestCase {
|
||||
@NotNull
|
||||
@Override
|
||||
protected LightProjectDescriptor getProjectDescriptor() {
|
||||
@@ -32,4 +33,8 @@ public abstract class AbstractJavaCompletionTest extends JetFixtureCompletionBas
|
||||
public TargetPlatform getPlatform() {
|
||||
return TargetPlatform.JVM;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected CompletionType completionType() { return CompletionType.BASIC; }
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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.completion;
|
||||
|
||||
import com.intellij.codeInsight.completion.CompletionType;
|
||||
import com.intellij.testFramework.LightProjectDescriptor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.plugin.JetWithJdkAndRuntimeLightProjectDescriptor;
|
||||
import org.jetbrains.jet.plugin.project.TargetPlatform;
|
||||
|
||||
public abstract class AbstractJvmSmartCompletionTest extends JetFixtureCompletionBaseTestCase {
|
||||
@NotNull
|
||||
@Override
|
||||
protected LightProjectDescriptor getProjectDescriptor() {
|
||||
return JetWithJdkAndRuntimeLightProjectDescriptor.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TargetPlatform getPlatform() {
|
||||
return TargetPlatform.JVM;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected CompletionType completionType() { return CompletionType.SMART; }
|
||||
}
|
||||
+6
-1
@@ -16,13 +16,14 @@
|
||||
|
||||
package org.jetbrains.jet.completion;
|
||||
|
||||
import com.intellij.codeInsight.completion.CompletionType;
|
||||
import com.intellij.testFramework.LightProjectDescriptor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.plugin.JdkAndMockLibraryProjectDescriptor;
|
||||
import org.jetbrains.jet.plugin.PluginTestCaseBase;
|
||||
import org.jetbrains.jet.plugin.project.TargetPlatform;
|
||||
|
||||
public abstract class AbstractJavaWithLibCompletionTest extends JetFixtureCompletionBaseTestCase {
|
||||
public abstract class AbstractJvmWithLibBasicCompletionTest extends JetFixtureCompletionBaseTestCase {
|
||||
private static final String TEST_PATH = PluginTestCaseBase.getTestDataPathBase() + "/completion/basic/custom";
|
||||
|
||||
@NotNull
|
||||
@@ -38,4 +39,8 @@ public abstract class AbstractJavaWithLibCompletionTest extends JetFixtureComple
|
||||
public TargetPlatform getPlatform() {
|
||||
return TargetPlatform.JVM;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected CompletionType completionType() { return CompletionType.BASIC; }
|
||||
}
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.jetbrains.jet.completion;
|
||||
|
||||
import com.intellij.codeInsight.completion.CompletionType;
|
||||
import com.intellij.testFramework.LightProjectDescriptor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.plugin.JetLightProjectDescriptor;
|
||||
@@ -27,6 +28,10 @@ public abstract class AbstractKeywordCompletionTest extends JetFixtureCompletion
|
||||
return TargetPlatform.JVM;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected CompletionType completionType() { return CompletionType.BASIC; }
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected LightProjectDescriptor getProjectDescriptor() {
|
||||
|
||||
@@ -26,15 +26,15 @@ import org.jetbrains.jet.JetTestUtils;
|
||||
import org.jetbrains.jet.test.InnerTestClasses;
|
||||
import org.jetbrains.jet.test.TestMetadata;
|
||||
|
||||
import org.jetbrains.jet.completion.AbstractJetJSCompletionTest;
|
||||
import org.jetbrains.jet.completion.AbstractJSBasicCompletionTest;
|
||||
|
||||
/** This class is generated by {@link org.jetbrains.jet.generators.tests.GenerateTests}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@InnerTestClasses({JetBasicJSCompletionTestGenerated.Common.class, JetBasicJSCompletionTestGenerated.Js.class})
|
||||
public class JetBasicJSCompletionTestGenerated extends AbstractJetJSCompletionTest {
|
||||
public class JetBasicJSCompletionTestGenerated extends AbstractJSBasicCompletionTest {
|
||||
@TestMetadata("idea/testData/completion/basic/common")
|
||||
@InnerTestClasses({Common.Extensions.class})
|
||||
public static class Common extends AbstractJetJSCompletionTest {
|
||||
public static class Common extends AbstractJSBasicCompletionTest {
|
||||
public void testAllFilesPresentInCommon() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/completion/basic/common"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
@@ -385,7 +385,7 @@ public class JetBasicJSCompletionTestGenerated extends AbstractJetJSCompletionTe
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/completion/basic/common/extensions")
|
||||
public static class Extensions extends AbstractJetJSCompletionTest {
|
||||
public static class Extensions extends AbstractJSBasicCompletionTest {
|
||||
public void testAllFilesPresentInExtensions() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/completion/basic/common/extensions"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
@@ -446,7 +446,7 @@ public class JetBasicJSCompletionTestGenerated extends AbstractJetJSCompletionTe
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/completion/basic/js")
|
||||
public static class Js extends AbstractJetJSCompletionTest {
|
||||
public static class Js extends AbstractJSBasicCompletionTest {
|
||||
public void testAllFilesPresentInJs() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/completion/basic/js"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@@ -26,15 +26,15 @@ import org.jetbrains.jet.JetTestUtils;
|
||||
import org.jetbrains.jet.test.InnerTestClasses;
|
||||
import org.jetbrains.jet.test.TestMetadata;
|
||||
|
||||
import org.jetbrains.jet.completion.AbstractJavaCompletionTest;
|
||||
import org.jetbrains.jet.completion.AbstractJvmBasicCompletionTest;
|
||||
|
||||
/** This class is generated by {@link org.jetbrains.jet.generators.tests.GenerateTests}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@InnerTestClasses({JetBasicJavaCompletionTestGenerated.Common.class, JetBasicJavaCompletionTestGenerated.Java.class})
|
||||
public class JetBasicJavaCompletionTestGenerated extends AbstractJavaCompletionTest {
|
||||
public class JetBasicJavaCompletionTestGenerated extends AbstractJvmBasicCompletionTest {
|
||||
@TestMetadata("idea/testData/completion/basic/common")
|
||||
@InnerTestClasses({Common.Extensions.class})
|
||||
public static class Common extends AbstractJavaCompletionTest {
|
||||
public static class Common extends AbstractJvmBasicCompletionTest {
|
||||
public void testAllFilesPresentInCommon() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/completion/basic/common"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
@@ -385,7 +385,7 @@ public class JetBasicJavaCompletionTestGenerated extends AbstractJavaCompletionT
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/completion/basic/common/extensions")
|
||||
public static class Extensions extends AbstractJavaCompletionTest {
|
||||
public static class Extensions extends AbstractJvmBasicCompletionTest {
|
||||
public void testAllFilesPresentInExtensions() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/completion/basic/common/extensions"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
@@ -446,7 +446,7 @@ public class JetBasicJavaCompletionTestGenerated extends AbstractJavaCompletionT
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/completion/basic/java")
|
||||
public static class Java extends AbstractJavaCompletionTest {
|
||||
public static class Java extends AbstractJvmBasicCompletionTest {
|
||||
public void testAllFilesPresentInJava() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/completion/basic/java"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.intellij.codeInsight.CodeInsightSettings;
|
||||
import com.intellij.codeInsight.completion.CompletionType;
|
||||
import com.intellij.codeInsight.lookup.LookupElement;
|
||||
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.plugin.project.TargetPlatform;
|
||||
|
||||
public abstract class JetFixtureCompletionBaseTestCase extends LightCodeInsightFixtureTestCase {
|
||||
@@ -42,6 +43,9 @@ public abstract class JetFixtureCompletionBaseTestCase extends LightCodeInsightF
|
||||
|
||||
public abstract TargetPlatform getPlatform();
|
||||
|
||||
@NotNull
|
||||
protected abstract CompletionType completionType();
|
||||
|
||||
public void doTest(String testPath) {
|
||||
myFixture.configureByFile(testPath);
|
||||
|
||||
@@ -49,7 +53,7 @@ public abstract class JetFixtureCompletionBaseTestCase extends LightCodeInsightF
|
||||
|
||||
Integer invocationCount = ExpectedCompletionUtils.getInvocationCount(fileText);
|
||||
|
||||
myFixture.complete(CompletionType.BASIC, invocationCount == null ? 0 : invocationCount);
|
||||
myFixture.complete(completionType(), invocationCount == null ? 0 : invocationCount);
|
||||
|
||||
ExpectedCompletionUtils.assertDirectivesValid(fileText);
|
||||
|
||||
|
||||
@@ -26,12 +26,12 @@ import org.jetbrains.jet.JetTestUtils;
|
||||
import org.jetbrains.jet.test.InnerTestClasses;
|
||||
import org.jetbrains.jet.test.TestMetadata;
|
||||
|
||||
import org.jetbrains.jet.completion.AbstractJavaWithLibCompletionTest;
|
||||
import org.jetbrains.jet.completion.AbstractJvmWithLibBasicCompletionTest;
|
||||
|
||||
/** This class is generated by {@link org.jetbrains.jet.generators.tests.GenerateTests}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@TestMetadata("idea/testData/completion/basic/custom")
|
||||
public class JetJavaLibCompletionTestGenerated extends AbstractJavaWithLibCompletionTest {
|
||||
public class JetJavaLibCompletionTestGenerated extends AbstractJvmWithLibBasicCompletionTest {
|
||||
public void testAllFilesPresentInCustom() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/completion/basic/custom"), Pattern.compile("^(.+)\\.kt$"), false);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* 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.completion;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.regex.Pattern;
|
||||
import org.jetbrains.jet.JetTestUtils;
|
||||
import org.jetbrains.jet.test.InnerTestClasses;
|
||||
import org.jetbrains.jet.test.TestMetadata;
|
||||
|
||||
import org.jetbrains.jet.completion.AbstractJvmSmartCompletionTest;
|
||||
|
||||
/** This class is generated by {@link org.jetbrains.jet.generators.tests.GenerateTests}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@TestMetadata("idea/testData/completion/smart")
|
||||
public class JetSmartCompletionTestGenerated extends AbstractJvmSmartCompletionTest {
|
||||
public void testAllFilesPresentInSmart() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/completion/smart"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("ChainedCall.kt")
|
||||
public void testChainedCall() throws Exception {
|
||||
doTest("idea/testData/completion/smart/ChainedCall.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("EmptyPrefix.kt")
|
||||
public void testEmptyPrefix() throws Exception {
|
||||
doTest("idea/testData/completion/smart/EmptyPrefix.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("InsideIdentifier.kt")
|
||||
public void testInsideIdentifier() throws Exception {
|
||||
doTest("idea/testData/completion/smart/InsideIdentifier.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("MethodCallArgument.kt")
|
||||
public void testMethodCallArgument() throws Exception {
|
||||
doTest("idea/testData/completion/smart/MethodCallArgument.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("NoSillyAssignment.kt")
|
||||
public void testNoSillyAssignment() throws Exception {
|
||||
doTest("idea/testData/completion/smart/NoSillyAssignment.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("NotSillyAssignment.kt")
|
||||
public void testNotSillyAssignment() throws Exception {
|
||||
doTest("idea/testData/completion/smart/NotSillyAssignment.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("VariableInitializer.kt")
|
||||
public void testVariableInitializer() throws Exception {
|
||||
doTest("idea/testData/completion/smart/VariableInitializer.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("WithPrefix.kt")
|
||||
public void testWithPrefix() throws Exception {
|
||||
doTest("idea/testData/completion/smart/WithPrefix.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("WithQualifier.kt")
|
||||
public void testWithQualifier() throws Exception {
|
||||
doTest("idea/testData/completion/smart/WithQualifier.kt");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user