Add MultiFileHighlightingTest which checks that other files are not parsed during highlighting
This commit is contained in:
@@ -111,6 +111,7 @@ import org.jetbrains.jet.plugin.debugger.evaluate.AbstractSelectExpressionForDeb
|
|||||||
import org.jetbrains.jet.plugin.debugger.evaluate.AbstractCodeFragmentCompletionTest
|
import org.jetbrains.jet.plugin.debugger.evaluate.AbstractCodeFragmentCompletionTest
|
||||||
import org.jetbrains.jet.plugin.debugger.evaluate.AbstractCodeFragmentHighlightingTest
|
import org.jetbrains.jet.plugin.debugger.evaluate.AbstractCodeFragmentHighlightingTest
|
||||||
import org.jetbrains.jet.plugin.stubs.AbstractLazyResolveByStubTest
|
import org.jetbrains.jet.plugin.stubs.AbstractLazyResolveByStubTest
|
||||||
|
import org.jetbrains.jet.plugin.stubs.AbstractMultiFileHighlightingTest
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
System.setProperty("java.awt.headless", "true")
|
System.setProperty("java.awt.headless", "true")
|
||||||
@@ -602,6 +603,10 @@ fun main(args: Array<String>) {
|
|||||||
model("completion/basic/multifile", extension = null, recursive = false)
|
model("completion/basic/multifile", extension = null, recursive = false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
testClass(javaClass<AbstractMultiFileHighlightingTest>()) {
|
||||||
|
model("multiFileHighlighting", recursive = false)
|
||||||
|
}
|
||||||
|
|
||||||
testClass(javaClass<AbstractJetExtractionTest>()) {
|
testClass(javaClass<AbstractJetExtractionTest>()) {
|
||||||
model("refactoring/introduceVariable", extension = "kt", testMethod = "doIntroduceVariableTest")
|
model("refactoring/introduceVariable", extension = "kt", testMethod = "doIntroduceVariableTest")
|
||||||
model("refactoring/extractFunction", extension = "kt", testMethod = "doExtractFunctionTest")
|
model("refactoring/extractFunction", extension = "kt", testMethod = "doExtractFunctionTest")
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
import delegates.*
|
||||||
|
import util.*
|
||||||
|
|
||||||
|
fun f() {
|
||||||
|
val d = D(C("", 0), object : T2 {})
|
||||||
|
d.anotherFun()
|
||||||
|
d.<error>invalidFun</error>()
|
||||||
|
WithDelegatedProperty().i
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package delegates
|
||||||
|
|
||||||
|
import util.*
|
||||||
|
|
||||||
|
class D(val t: T, val t2: T2): T by t, T2 by t2 {
|
||||||
|
fun anotherFun() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class WithDelegatedProperty() {
|
||||||
|
val i: Int by someInvalidCode
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package enums
|
||||||
|
|
||||||
|
trait Base {
|
||||||
|
fun f() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
enum class E(val i: Int = 0): Base {
|
||||||
|
E1: E() {
|
||||||
|
override fun f() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
E2: E(3) {
|
||||||
|
override fun f() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
E3
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
public package util
|
||||||
|
|
||||||
|
trait T {
|
||||||
|
fun f()
|
||||||
|
}
|
||||||
|
|
||||||
|
trait T2 {
|
||||||
|
fun g() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
suppress("UNRESOLVED_REFERENCE")
|
||||||
|
class Invalid: I
|
||||||
|
|
||||||
|
class A(val i: Int)
|
||||||
|
|
||||||
|
suppress("FINAL_SUPERTYPE")
|
||||||
|
class B: A(1) {
|
||||||
|
}
|
||||||
|
|
||||||
|
open class C(val s: String, i: Int): A(i), T {
|
||||||
|
override fun f() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun topLevelFun(u: A): A {
|
||||||
|
return A(u.i)
|
||||||
|
}
|
||||||
|
|
||||||
|
val topLevelVal: A = C("", 0)
|
||||||
|
var topLevelVar: A = B()
|
||||||
|
|
||||||
|
object topLevelObject: T {
|
||||||
|
override fun f() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
fun g() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun funWithUnspecifiedType() = 3
|
||||||
|
|
||||||
|
fun funWithVararg(vararg i: Int): IntArray {
|
||||||
|
return i
|
||||||
|
}
|
||||||
|
|
||||||
|
fun <T, G> funWithWhere(a: G, b: T) where T: Collection<G> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package some
|
||||||
|
|
||||||
|
import enums.E
|
||||||
|
import enums.Base
|
||||||
|
|
||||||
|
fun f(<warning>e</warning>: Base) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
f(E.E1)
|
||||||
|
f(E.E2)
|
||||||
|
f(E.E3)
|
||||||
|
f(E.<error>E4</error>)
|
||||||
|
f(E.<error>Invalid</error>)
|
||||||
|
E.E1.f()
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package shouldFail
|
||||||
|
|
||||||
|
import util.*
|
||||||
|
|
||||||
|
fun f() {
|
||||||
|
val c = funWithUnspecifiedType()
|
||||||
|
c + 3
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package first
|
||||||
|
|
||||||
|
import util.*
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
topLevelFun(topLevelVar)
|
||||||
|
topLevelFun(topLevelVal)
|
||||||
|
val c = C("ff", 1)
|
||||||
|
c.s.<error>invalid</error>
|
||||||
|
val <warning>b</warning> = B()
|
||||||
|
funWithVararg(1, 2, 3)
|
||||||
|
val <warning>i</warning> = Invalid()
|
||||||
|
topLevelObject.f()
|
||||||
|
topLevelObject.g()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun testWhere(list: List<Int>) {
|
||||||
|
funWithWhere(1, list)
|
||||||
|
<error>funWithWhere</error>(1, 2)
|
||||||
|
}
|
||||||
|
|
||||||
|
class Example : C("foo", 0)
|
||||||
|
class Example2 : <error>A</error>(2)
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
/*
|
||||||
|
* 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.plugin.stubs;
|
||||||
|
|
||||||
|
import com.intellij.codeInsight.completion.CompletionTestCase;
|
||||||
|
import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl;
|
||||||
|
import com.intellij.codeInsight.daemon.impl.HighlightInfo;
|
||||||
|
import com.intellij.openapi.application.ApplicationManager;
|
||||||
|
import com.intellij.openapi.project.DumbService;
|
||||||
|
import com.intellij.psi.PsiDocumentManager;
|
||||||
|
import com.intellij.psi.impl.cache.CacheManager;
|
||||||
|
import com.intellij.psi.impl.source.tree.TreeElement;
|
||||||
|
import com.intellij.psi.impl.source.tree.TreeUtil;
|
||||||
|
import com.intellij.psi.search.GlobalSearchScope;
|
||||||
|
import com.intellij.psi.search.UsageSearchContext;
|
||||||
|
import com.intellij.testFramework.ExpectedHighlightingData;
|
||||||
|
import kotlin.Function0;
|
||||||
|
import kotlin.Unit;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.jet.plugin.PluginTestCaseBase;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
public abstract class AbstractMultiFileHighlightingTest extends CompletionTestCase {
|
||||||
|
|
||||||
|
public void doTest(@NotNull String filePath) throws Exception {
|
||||||
|
configureByFile(new File(filePath).getName(), "");
|
||||||
|
boolean shouldFail = getName().contains("UnspecifiedType");
|
||||||
|
AstAccessControl.instance$.testWithControlledAccessToAst(
|
||||||
|
shouldFail, getFile().getVirtualFile(), getProject(), getTestRootDisposable(),
|
||||||
|
new Function0<Unit>() {
|
||||||
|
@Override
|
||||||
|
public Unit invoke() {
|
||||||
|
checkHighlighting(myEditor, true, false);
|
||||||
|
return Unit.VALUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getTestDataPath() {
|
||||||
|
return PluginTestCaseBase.getTestDataPathBase() + "/multiFileHighlighting/";
|
||||||
|
}
|
||||||
|
|
||||||
|
//NOTE: partially copied from DaemonAnalyzerTestCase#checkHighlighting
|
||||||
|
@Override
|
||||||
|
@NotNull
|
||||||
|
protected Collection<HighlightInfo> checkHighlighting(@NotNull ExpectedHighlightingData data) {
|
||||||
|
data.init();
|
||||||
|
PsiDocumentManager.getInstance(myProject).commitAllDocuments();
|
||||||
|
|
||||||
|
//to load text
|
||||||
|
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
TreeUtil.clearCaches((TreeElement) myFile.getNode());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//to initialize caches
|
||||||
|
if (!DumbService.isDumb(getProject())) {
|
||||||
|
CacheManager.SERVICE.getInstance(myProject)
|
||||||
|
.getFilesWithWord("XXX", UsageSearchContext.IN_COMMENTS, GlobalSearchScope.allScope(myProject), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
Collection<HighlightInfo> infos = doHighlighting();
|
||||||
|
|
||||||
|
String text = myEditor.getDocument().getText();
|
||||||
|
data.checkLineMarkers(DaemonCodeAnalyzerImpl.getLineMarkers(getDocument(getFile()), getProject()), text);
|
||||||
|
data.checkResult(infos, text);
|
||||||
|
return infos;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* 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.plugin.stubs;
|
||||||
|
|
||||||
|
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.plugin.stubs.AbstractMultiFileHighlightingTest;
|
||||||
|
|
||||||
|
/** This class is generated by {@link org.jetbrains.jet.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
|
||||||
|
@SuppressWarnings("all")
|
||||||
|
@TestMetadata("idea/testData/multiFileHighlighting")
|
||||||
|
public class MultiFileHighlightingTestGenerated extends AbstractMultiFileHighlightingTest {
|
||||||
|
public void testAllFilesPresentInMultiFileHighlighting() throws Exception {
|
||||||
|
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("idea/testData/multiFileHighlighting"), Pattern.compile("^(.+)\\.kt$"), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("delegatesReference.kt")
|
||||||
|
public void testDelegatesReference() throws Exception {
|
||||||
|
doTest("idea/testData/multiFileHighlighting/delegatesReference.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("enumReference.kt")
|
||||||
|
public void testEnumReference() throws Exception {
|
||||||
|
doTest("idea/testData/multiFileHighlighting/enumReference.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("referencesFunWithUnspecifiedType.kt")
|
||||||
|
public void testReferencesFunWithUnspecifiedType() throws Exception {
|
||||||
|
doTest("idea/testData/multiFileHighlighting/referencesFunWithUnspecifiedType.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("topLevelMembersReference.kt")
|
||||||
|
public void testTopLevelMembersReference() throws Exception {
|
||||||
|
doTest("idea/testData/multiFileHighlighting/topLevelMembersReference.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user