More correct completion testing + fixed small bug in keyword completion
This commit is contained in:
committed by
valentin
parent
afbd1aeffc
commit
e6ea0537c8
@@ -120,7 +120,7 @@ class KeywordCompletion {
|
|||||||
|
|
||||||
add(JetTokens.OUT_KEYWORD, InTypeParameterFirstChildFilter)
|
add(JetTokens.OUT_KEYWORD, InTypeParameterFirstChildFilter)
|
||||||
|
|
||||||
add(JetTokens.OBJECT_KEYWORD, inNonClassBlock, AfterClassInClassBodyFilter)
|
add(JetTokens.OBJECT_KEYWORD, inNonClassBlock, inClassBody, AfterClassInClassBodyFilter)
|
||||||
|
|
||||||
add(JetTokens.ELSE_KEYWORD, inNonClassBlock, inPropertyBody)
|
add(JetTokens.ELSE_KEYWORD, inNonClassBlock, inPropertyBody)
|
||||||
add(JetTokens.IF_KEYWORD, inNonClassBlock, inPropertyBody)
|
add(JetTokens.IF_KEYWORD, inNonClassBlock, inPropertyBody)
|
||||||
|
|||||||
+1
@@ -2,6 +2,7 @@ fun test() {
|
|||||||
val <caret>
|
val <caret>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// INVOCATION_COUNT: 0
|
||||||
// NUMBER: 0
|
// NUMBER: 0
|
||||||
|
|
||||||
/* KT-4158 Type "var i" and press space. "var if" is auto-inserted. */
|
/* KT-4158 Type "var i" and press space. "var if" is auto-inserted. */
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
fun f<caret>
|
||||||
|
|
||||||
|
// INVOCATION_COUNT: 0
|
||||||
|
// NUMBER: 0
|
||||||
+1
@@ -1,5 +1,6 @@
|
|||||||
var <caret>
|
var <caret>
|
||||||
|
|
||||||
|
// INVOCATION_COUNT: 0
|
||||||
// NUMBER: 0
|
// NUMBER: 0
|
||||||
|
|
||||||
/* KT-4158 Type "var i" and press space. "var if" is auto-inserted. */
|
/* KT-4158 Type "var i" and press space. "var if" is auto-inserted. */
|
||||||
@@ -5,7 +5,7 @@ class TestClass {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ABSENT: abstract, annotation, as, break, by, catch, class, continue, default, do
|
// ABSENT: abstract, annotation, as, break, by, catch, class, continue, default, do
|
||||||
// ABSENT: else, enum, false, final, finally, for, fun, get, if, import, in, inline
|
// ABSENT: else, enum, false, final, finally, for, fun, get, if, import, in
|
||||||
// ABSENT: internal, is, null, object, open, out, override, package, private, protected, public
|
// ABSENT: internal, is, null, object, open, out, override, package, private, protected, public
|
||||||
// ABSENT: ref, return, set, super, This, this, throw, trait, true, try, type, val, var
|
// ABSENT: ref, return, set, super, This, this, throw, trait, true, try, type, val, var
|
||||||
// ABSENT: vararg, when, where, while
|
// ABSENT: vararg, when, where, while
|
||||||
@@ -5,7 +5,7 @@ class TestClass {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ABSENT: abstract, annotation, as, break, by, catch, class, continue, default, do
|
// ABSENT: abstract, annotation, as, break, by, catch, class, continue, default, do
|
||||||
// ABSENT: else, enum, false, final, finally, for, fun, get, if, import, in, inline
|
// ABSENT: else, enum, false, final, finally, for, fun, get, if, import, in
|
||||||
// ABSENT: internal, is, null, object, open, out, override, package, private, protected, public
|
// ABSENT: internal, is, null, object, open, out, override, package, private, protected, public
|
||||||
// ABSENT: ref, return, set, super, This, this, throw, trait, true, try, type, val, var
|
// ABSENT: ref, return, set, super, This, this, throw, trait, true, try, type, val, var
|
||||||
// ABSENT: vararg, when, where, while
|
// ABSENT: vararg, when, where, while
|
||||||
@@ -7,8 +7,6 @@ public class Test {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// INVOCATION_COUNT: 1
|
|
||||||
|
|
||||||
// EXIST: abstract
|
// EXIST: abstract
|
||||||
/* // ABSENT: annotation */
|
/* // ABSENT: annotation */
|
||||||
// ABSENT: as
|
// ABSENT: as
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ class TestClass {
|
|||||||
<caret>
|
<caret>
|
||||||
}
|
}
|
||||||
|
|
||||||
// INVOCATION_COUNT: 1
|
|
||||||
|
|
||||||
// EXIST: abstract
|
// EXIST: abstract
|
||||||
// ABSENT: annotation
|
// ABSENT: annotation
|
||||||
// ABSENT: as
|
// ABSENT: as
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ fun foo() {
|
|||||||
// EXIST: if
|
// EXIST: if
|
||||||
// ABSENT: import
|
// ABSENT: import
|
||||||
// EXIST: in
|
// EXIST: in
|
||||||
// EXIST: inline
|
|
||||||
// EXIST: internal
|
// EXIST: internal
|
||||||
// EXIST: is
|
// EXIST: is
|
||||||
// EXIST: null
|
// EXIST: null
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ class TestSample() {
|
|||||||
// ABSENT: if
|
// ABSENT: if
|
||||||
// ABSENT: import
|
// ABSENT: import
|
||||||
// ABSENT: in
|
// ABSENT: in
|
||||||
// ABSENT: inline
|
|
||||||
// ABSENT: internal
|
// ABSENT: internal
|
||||||
// ABSENT: is
|
// ABSENT: is
|
||||||
// ABSENT: null
|
// ABSENT: null
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ fun test(<caret>) {
|
|||||||
// ABSENT: if
|
// ABSENT: if
|
||||||
// ABSENT: import
|
// ABSENT: import
|
||||||
// ABSENT: in
|
// ABSENT: in
|
||||||
// ABSENT: inline
|
|
||||||
// ABSENT: internal
|
// ABSENT: internal
|
||||||
// ABSENT: is
|
// ABSENT: is
|
||||||
// ABSENT: null
|
// ABSENT: null
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ class TestClass {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ABSENT: abstract, annotation, as, break, by, catch, class, continue, default, do
|
// ABSENT: abstract, annotation, as, break, by, catch, class, continue, default, do
|
||||||
// ABSENT: else, enum, false, final, finally, for, fun, get, if, import, in, inline
|
// ABSENT: else, enum, false, final, finally, for, fun, get, if, import, in
|
||||||
// ABSENT: internal, is, null, object, open, out, override, package, private, protected, public
|
// ABSENT: internal, is, null, object, open, out, override, package, private, protected, public
|
||||||
// ABSENT: ref, return, set, super, This, this, throw, trait, true, try, type, val, var
|
// ABSENT: ref, return, set, super, This, this, throw, trait, true, try, type, val, var
|
||||||
// ABSENT: vararg, when, where, while
|
// ABSENT: vararg, when, where, while
|
||||||
@@ -22,7 +22,6 @@ fun foo() {
|
|||||||
// EXIST: if
|
// EXIST: if
|
||||||
// ABSENT: import
|
// ABSENT: import
|
||||||
// EXIST: in
|
// EXIST: in
|
||||||
// EXIST: inline
|
|
||||||
// EXIST: internal
|
// EXIST: internal
|
||||||
// EXIST: is
|
// EXIST: is
|
||||||
// EXIST: null
|
// EXIST: null
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ class TestClass {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ABSENT: abstract, annotation, as, break, by, catch, class, continue, default, do
|
// ABSENT: abstract, annotation, as, break, by, catch, class, continue, default, do
|
||||||
// ABSENT: else, enum, false, final, finally, for, fun, get, if, import, in, inline
|
// ABSENT: else, enum, false, final, finally, for, fun, get, if, import, in
|
||||||
// ABSENT: internal, is, null, object, open, out, override, package, private, protected, public
|
// ABSENT: internal, is, null, object, open, out, override, package, private, protected, public
|
||||||
// ABSENT: ref, return, set, super, This, this, throw, trait, true, try, type, val, var
|
// ABSENT: ref, return, set, super, This, this, throw, trait, true, try, type, val, var
|
||||||
// ABSENT: vararg, when, where, while
|
// ABSENT: vararg, when, where, while
|
||||||
+3
-3
@@ -17,6 +17,7 @@
|
|||||||
package org.jetbrains.jet.completion;
|
package org.jetbrains.jet.completion;
|
||||||
|
|
||||||
import com.intellij.codeInsight.completion.CompletionType;
|
import com.intellij.codeInsight.completion.CompletionType;
|
||||||
|
import com.intellij.codeInsight.lookup.LookupElement;
|
||||||
import com.intellij.testFramework.LightProjectDescriptor;
|
import com.intellij.testFramework.LightProjectDescriptor;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.jet.plugin.JdkAndMockLibraryProjectDescriptor;
|
import org.jetbrains.jet.plugin.JdkAndMockLibraryProjectDescriptor;
|
||||||
@@ -35,9 +36,8 @@ public abstract class AbstractCompiledKotlinInJavaCompletionTest extends JetFixt
|
|||||||
return new JdkAndMockLibraryProjectDescriptor(PluginTestCaseBase.getTestDataPathBase() + "/completion/injava/mockLib", false);
|
return new JdkAndMockLibraryProjectDescriptor(PluginTestCaseBase.getTestDataPathBase() + "/completion/injava/mockLib", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
@Override
|
||||||
protected CompletionType completionType() {
|
protected LookupElement[] complete(int invocationCount) {
|
||||||
return CompletionType.BASIC;
|
return myFixture.complete(CompletionType.BASIC, invocationCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
package org.jetbrains.jet.completion;
|
package org.jetbrains.jet.completion;
|
||||||
|
|
||||||
import com.intellij.codeInsight.completion.CompletionType;
|
import com.intellij.codeInsight.completion.CompletionType;
|
||||||
|
import com.intellij.codeInsight.lookup.LookupElement;
|
||||||
import com.intellij.testFramework.LightProjectDescriptor;
|
import com.intellij.testFramework.LightProjectDescriptor;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.jet.plugin.JetStdJSProjectDescriptor;
|
import org.jetbrains.jet.plugin.JetStdJSProjectDescriptor;
|
||||||
@@ -34,7 +35,8 @@ public abstract class AbstractJSBasicCompletionTest extends JetFixtureCompletion
|
|||||||
return TargetPlatform.JS;
|
return TargetPlatform.JS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
@Override
|
||||||
protected CompletionType completionType() { return CompletionType.BASIC; }
|
protected LookupElement[] complete(int invocationCount) {
|
||||||
|
return myFixture.complete(CompletionType.BASIC, invocationCount);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
package org.jetbrains.jet.completion;
|
package org.jetbrains.jet.completion;
|
||||||
|
|
||||||
import com.intellij.codeInsight.completion.CompletionType;
|
import com.intellij.codeInsight.completion.CompletionType;
|
||||||
|
import com.intellij.codeInsight.lookup.LookupElement;
|
||||||
import com.intellij.testFramework.LightProjectDescriptor;
|
import com.intellij.testFramework.LightProjectDescriptor;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.jet.plugin.JetWithJdkAndRuntimeLightProjectDescriptor;
|
import org.jetbrains.jet.plugin.JetWithJdkAndRuntimeLightProjectDescriptor;
|
||||||
@@ -34,7 +35,8 @@ public abstract class AbstractJvmBasicCompletionTest extends JetFixtureCompletio
|
|||||||
return TargetPlatform.JVM;
|
return TargetPlatform.JVM;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
@Override
|
||||||
protected CompletionType completionType() { return CompletionType.BASIC; }
|
protected LookupElement[] complete(int invocationCount) {
|
||||||
|
return myFixture.complete(CompletionType.BASIC, invocationCount);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -17,6 +17,7 @@
|
|||||||
package org.jetbrains.jet.completion;
|
package org.jetbrains.jet.completion;
|
||||||
|
|
||||||
import com.intellij.codeInsight.completion.CompletionType;
|
import com.intellij.codeInsight.completion.CompletionType;
|
||||||
|
import com.intellij.codeInsight.lookup.LookupElement;
|
||||||
import com.intellij.testFramework.LightProjectDescriptor;
|
import com.intellij.testFramework.LightProjectDescriptor;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.jet.plugin.JetWithJdkAndRuntimeLightProjectDescriptor;
|
import org.jetbrains.jet.plugin.JetWithJdkAndRuntimeLightProjectDescriptor;
|
||||||
@@ -34,7 +35,8 @@ public abstract class AbstractJvmSmartCompletionTest extends JetFixtureCompletio
|
|||||||
return TargetPlatform.JVM;
|
return TargetPlatform.JVM;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
@Override
|
||||||
protected CompletionType completionType() { return CompletionType.SMART; }
|
protected LookupElement[] complete(int invocationCount) {
|
||||||
|
return myFixture.complete(CompletionType.SMART, invocationCount);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -17,6 +17,7 @@
|
|||||||
package org.jetbrains.jet.completion;
|
package org.jetbrains.jet.completion;
|
||||||
|
|
||||||
import com.intellij.codeInsight.completion.CompletionType;
|
import com.intellij.codeInsight.completion.CompletionType;
|
||||||
|
import com.intellij.codeInsight.lookup.LookupElement;
|
||||||
import com.intellij.testFramework.LightProjectDescriptor;
|
import com.intellij.testFramework.LightProjectDescriptor;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.jet.plugin.JdkAndMockLibraryProjectDescriptor;
|
import org.jetbrains.jet.plugin.JdkAndMockLibraryProjectDescriptor;
|
||||||
@@ -40,7 +41,8 @@ public abstract class AbstractJvmWithLibBasicCompletionTest extends JetFixtureCo
|
|||||||
return TargetPlatform.JVM;
|
return TargetPlatform.JVM;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
@Override
|
||||||
protected CompletionType completionType() { return CompletionType.BASIC; }
|
protected LookupElement[] complete(int invocationCount) {
|
||||||
|
return myFixture.complete(CompletionType.BASIC, invocationCount);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,40 +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.completion;
|
|
||||||
|
|
||||||
import com.intellij.codeInsight.completion.CompletionType;
|
|
||||||
import com.intellij.testFramework.LightProjectDescriptor;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.jet.plugin.JetLightProjectDescriptor;
|
|
||||||
import org.jetbrains.jet.plugin.project.TargetPlatform;
|
|
||||||
|
|
||||||
public abstract class AbstractKeywordCompletionTest extends JetFixtureCompletionBaseTestCase {
|
|
||||||
@Override
|
|
||||||
public TargetPlatform getPlatform() {
|
|
||||||
return TargetPlatform.JVM;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
protected CompletionType completionType() { return CompletionType.BASIC; }
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
protected LightProjectDescriptor getProjectDescriptor() {
|
|
||||||
return JetLightProjectDescriptor.INSTANCE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2014 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.codeInsight.lookup.LookupElement
|
||||||
|
import org.jetbrains.jet.plugin.JetLightProjectDescriptor
|
||||||
|
import org.jetbrains.jet.plugin.completion.KeywordLookupObject
|
||||||
|
import org.jetbrains.jet.plugin.project.TargetPlatform
|
||||||
|
|
||||||
|
public abstract class AbstractKeywordCompletionTest : JetFixtureCompletionBaseTestCase() {
|
||||||
|
override fun getPlatform() = TargetPlatform.JVM
|
||||||
|
|
||||||
|
override fun complete(invocationCount: Int): Array<LookupElement>? {
|
||||||
|
val items = myFixture.complete(CompletionType.BASIC)
|
||||||
|
if (items == null) return null
|
||||||
|
return items.filter { it.getObject() is KeywordLookupObject }.copyToArray()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getProjectDescriptor() = JetLightProjectDescriptor.INSTANCE
|
||||||
|
|
||||||
|
override fun defaultInvocationCount() = 1
|
||||||
|
}
|
||||||
+3
-3
@@ -17,6 +17,7 @@
|
|||||||
package org.jetbrains.jet.completion;
|
package org.jetbrains.jet.completion;
|
||||||
|
|
||||||
import com.intellij.codeInsight.completion.CompletionType;
|
import com.intellij.codeInsight.completion.CompletionType;
|
||||||
|
import com.intellij.codeInsight.lookup.LookupElement;
|
||||||
import com.intellij.openapi.util.io.FileUtil;
|
import com.intellij.openapi.util.io.FileUtil;
|
||||||
import com.intellij.testFramework.LightProjectDescriptor;
|
import com.intellij.testFramework.LightProjectDescriptor;
|
||||||
import com.intellij.util.ArrayUtil;
|
import com.intellij.util.ArrayUtil;
|
||||||
@@ -55,9 +56,8 @@ public abstract class AbstractKotlinSourceInJavaCompletionTest extends JetFixtur
|
|||||||
return JAVA_LATEST;
|
return JAVA_LATEST;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
@Override
|
||||||
protected CompletionType completionType() {
|
protected LookupElement[] complete(int invocationCount) {
|
||||||
return CompletionType.BASIC;
|
return myFixture.complete(CompletionType.BASIC, invocationCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -42,7 +42,7 @@ public abstract class AbstractMultiFileJvmBasicCompletionTest extends KotlinComp
|
|||||||
complete(invocationCount);
|
complete(invocationCount);
|
||||||
return myItems;
|
return myItems;
|
||||||
}
|
}
|
||||||
});
|
}, 0);
|
||||||
return Unit.INSTANCE$;
|
return Unit.INSTANCE$;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ import org.jetbrains.jet.plugin.project.TargetPlatform
|
|||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.jetbrains.jet.completion.ExpectedCompletionUtils
|
import org.jetbrains.jet.completion.ExpectedCompletionUtils
|
||||||
|
|
||||||
fun testCompletion(fileText: String, platform: TargetPlatform?, complete: (Int) -> Array<LookupElement>?) {
|
fun testCompletion(fileText: String, platform: TargetPlatform?, complete: (Int) -> Array<LookupElement>?, defaultInvocationCount: Int = 0) {
|
||||||
val invocationCount = ExpectedCompletionUtils.getInvocationCount(fileText) ?: 0
|
val invocationCount = ExpectedCompletionUtils.getInvocationCount(fileText) ?: defaultInvocationCount
|
||||||
val items = complete(invocationCount) ?: array()
|
val items = complete(invocationCount) ?: array()
|
||||||
|
|
||||||
ExpectedCompletionUtils.assertDirectivesValid(fileText)
|
ExpectedCompletionUtils.assertDirectivesValid(fileText)
|
||||||
|
|||||||
@@ -17,13 +17,10 @@
|
|||||||
package org.jetbrains.jet.completion;
|
package org.jetbrains.jet.completion;
|
||||||
|
|
||||||
import com.intellij.testFramework.TestDataPath;
|
import com.intellij.testFramework.TestDataPath;
|
||||||
import junit.framework.Test;
|
|
||||||
import junit.framework.TestSuite;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.jetbrains.jet.JetTestUtils;
|
import org.jetbrains.jet.JetTestUtils;
|
||||||
import org.jetbrains.jet.test.InnerTestClasses;
|
import org.jetbrains.jet.test.InnerTestClasses;
|
||||||
import org.jetbrains.jet.test.TestMetadata;
|
import org.jetbrains.jet.test.TestMetadata;
|
||||||
import org.jetbrains.jet.JUnit3RunnerWithInners;
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
@@ -450,6 +447,24 @@ public class JSBasicCompletionTestGenerated extends AbstractJSBasicCompletionTes
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("NoAutoPopupInValName.kt")
|
||||||
|
public void testNoAutoPopupInValName() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/basic/common/NoAutoPopupInValName.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("NoAutopopupInFunName.kt")
|
||||||
|
public void testNoAutopopupInFunName() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/basic/common/NoAutopopupInFunName.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("NoAutopopupInVarName.kt")
|
||||||
|
public void testNoAutopopupInVarName() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/basic/common/NoAutopopupInVarName.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("NoClassNameDuplication.kt")
|
@TestMetadata("NoClassNameDuplication.kt")
|
||||||
public void testNoClassNameDuplication() throws Exception {
|
public void testNoClassNameDuplication() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/basic/common/NoClassNameDuplication.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/basic/common/NoClassNameDuplication.kt");
|
||||||
|
|||||||
@@ -17,11 +17,12 @@
|
|||||||
package org.jetbrains.jet.completion;
|
package org.jetbrains.jet.completion;
|
||||||
|
|
||||||
import com.intellij.codeInsight.CodeInsightSettings;
|
import com.intellij.codeInsight.CodeInsightSettings;
|
||||||
import com.intellij.codeInsight.completion.CompletionType;
|
|
||||||
import com.intellij.codeInsight.lookup.LookupElement;
|
import com.intellij.codeInsight.lookup.LookupElement;
|
||||||
|
import com.intellij.openapi.util.Pair;
|
||||||
import com.intellij.openapi.util.io.FileUtil;
|
import com.intellij.openapi.util.io.FileUtil;
|
||||||
import kotlin.Function1;
|
import kotlin.Function1;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.completion.util.UtilPackage;
|
import org.jetbrains.jet.completion.util.UtilPackage;
|
||||||
import org.jetbrains.jet.plugin.JetLightCodeInsightFixtureTestCase;
|
import org.jetbrains.jet.plugin.JetLightCodeInsightFixtureTestCase;
|
||||||
import org.jetbrains.jet.plugin.caches.resolve.LibraryModificationTracker;
|
import org.jetbrains.jet.plugin.caches.resolve.LibraryModificationTracker;
|
||||||
@@ -30,40 +31,37 @@ import org.jetbrains.jet.plugin.project.TargetPlatform;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
public abstract class JetFixtureCompletionBaseTestCase extends JetLightCodeInsightFixtureTestCase {
|
public abstract class JetFixtureCompletionBaseTestCase extends JetLightCodeInsightFixtureTestCase {
|
||||||
private boolean autoCompleteSetting;
|
private Pair<Boolean, Boolean> savedAutoCompleteSettings;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
|
|
||||||
autoCompleteSetting = setAutoCompleteSetting(false);
|
savedAutoCompleteSettings = setAutoCompleteSetting(new Pair<Boolean, Boolean>(false, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void tearDown() throws Exception {
|
protected void tearDown() throws Exception {
|
||||||
setAutoCompleteSetting(autoCompleteSetting);
|
setAutoCompleteSetting(savedAutoCompleteSettings);
|
||||||
|
|
||||||
super.tearDown();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean setAutoCompleteSetting(boolean value){
|
private static Pair<Boolean, Boolean> setAutoCompleteSetting(Pair<Boolean, Boolean> value){
|
||||||
CodeInsightSettings settings = CodeInsightSettings.getInstance();
|
CodeInsightSettings settings = CodeInsightSettings.getInstance();
|
||||||
boolean oldValue;
|
boolean oldValue1 = settings.AUTOCOMPLETE_ON_CODE_COMPLETION;
|
||||||
if (completionType() == CompletionType.SMART){
|
boolean oldValue2 = settings.AUTOCOMPLETE_ON_SMART_TYPE_COMPLETION;
|
||||||
oldValue = settings.AUTOCOMPLETE_ON_SMART_TYPE_COMPLETION;
|
settings.AUTOCOMPLETE_ON_CODE_COMPLETION = value.first;
|
||||||
settings.AUTOCOMPLETE_ON_SMART_TYPE_COMPLETION = value;
|
settings.AUTOCOMPLETE_ON_SMART_TYPE_COMPLETION = value.second;
|
||||||
}
|
return new Pair<Boolean, Boolean>(oldValue1, oldValue2);
|
||||||
else {
|
|
||||||
oldValue = settings.AUTOCOMPLETE_COMMON_PREFIX;
|
|
||||||
settings.AUTOCOMPLETE_ON_CODE_COMPLETION = value;
|
|
||||||
}
|
|
||||||
return oldValue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract TargetPlatform getPlatform();
|
public abstract TargetPlatform getPlatform();
|
||||||
|
|
||||||
@NotNull
|
@Nullable
|
||||||
protected abstract CompletionType completionType();
|
protected abstract LookupElement[] complete(int invocationCount);
|
||||||
|
|
||||||
|
protected int defaultInvocationCount() { return 0; }
|
||||||
|
|
||||||
public void doTest(String testPath) throws Exception {
|
public void doTest(String testPath) throws Exception {
|
||||||
setUpFixture(testPath);
|
setUpFixture(testPath);
|
||||||
@@ -72,9 +70,9 @@ public abstract class JetFixtureCompletionBaseTestCase extends JetLightCodeInsig
|
|||||||
UtilPackage.testCompletion(fileText, getPlatform(), new Function1<Integer, LookupElement[]>() {
|
UtilPackage.testCompletion(fileText, getPlatform(), new Function1<Integer, LookupElement[]>() {
|
||||||
@Override
|
@Override
|
||||||
public LookupElement[] invoke(Integer invocationCount) {
|
public LookupElement[] invoke(Integer invocationCount) {
|
||||||
return myFixture.complete(completionType(), invocationCount);
|
return complete(invocationCount);
|
||||||
}
|
}
|
||||||
});
|
}, defaultInvocationCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setUpFixture(@NotNull String testPath) {
|
protected void setUpFixture(@NotNull String testPath) {
|
||||||
|
|||||||
@@ -17,10 +17,13 @@
|
|||||||
package org.jetbrains.jet.completion;
|
package org.jetbrains.jet.completion;
|
||||||
|
|
||||||
import com.intellij.testFramework.TestDataPath;
|
import com.intellij.testFramework.TestDataPath;
|
||||||
|
import junit.framework.Test;
|
||||||
|
import junit.framework.TestSuite;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
import org.jetbrains.jet.JetTestUtils;
|
import org.jetbrains.jet.JetTestUtils;
|
||||||
import org.jetbrains.jet.test.InnerTestClasses;
|
import org.jetbrains.jet.test.InnerTestClasses;
|
||||||
import org.jetbrains.jet.test.TestMetadata;
|
import org.jetbrains.jet.test.TestMetadata;
|
||||||
import org.junit.runner.RunWith;
|
import org.jetbrains.jet.JUnit3RunnerWithInners;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
@@ -447,6 +450,24 @@ public class JvmBasicCompletionTestGenerated extends AbstractJvmBasicCompletionT
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("NoAutoPopupInValName.kt")
|
||||||
|
public void testNoAutoPopupInValName() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/basic/common/NoAutoPopupInValName.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("NoAutopopupInFunName.kt")
|
||||||
|
public void testNoAutopopupInFunName() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/basic/common/NoAutopopupInFunName.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("NoAutopopupInVarName.kt")
|
||||||
|
public void testNoAutopopupInVarName() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/basic/common/NoAutopopupInVarName.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("NoClassNameDuplication.kt")
|
@TestMetadata("NoClassNameDuplication.kt")
|
||||||
public void testNoClassNameDuplication() throws Exception {
|
public void testNoClassNameDuplication() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/basic/common/NoClassNameDuplication.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/basic/common/NoClassNameDuplication.kt");
|
||||||
|
|||||||
@@ -110,12 +110,6 @@ public class KeywordCompletionTestGenerated extends AbstractKeywordCompletionTes
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("InFunctionNoCompletionInValName.kt")
|
|
||||||
public void testInFunctionNoCompletionInValName() throws Exception {
|
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/keywords/InFunctionNoCompletionInValName.kt");
|
|
||||||
doTest(fileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("InFunctionScope.kt")
|
@TestMetadata("InFunctionScope.kt")
|
||||||
public void testInFunctionScope() throws Exception {
|
public void testInFunctionScope() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/keywords/InFunctionScope.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/keywords/InFunctionScope.kt");
|
||||||
@@ -164,12 +158,6 @@ public class KeywordCompletionTestGenerated extends AbstractKeywordCompletionTes
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("InTopNoCompletionInVarName.kt")
|
|
||||||
public void testInTopNoCompletionInVarName() throws Exception {
|
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/keywords/InTopNoCompletionInVarName.kt");
|
|
||||||
doTest(fileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("InTopProperty.kt")
|
@TestMetadata("InTopProperty.kt")
|
||||||
public void testInTopProperty() throws Exception {
|
public void testInTopProperty() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/keywords/InTopProperty.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/keywords/InTopProperty.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user