Light class test for classes with dollars in name
This commit is contained in:
@@ -0,0 +1,15 @@
|
|||||||
|
public final class A$B {
|
||||||
|
public A$B() { /* compiled code */ }
|
||||||
|
|
||||||
|
public final class C$D {
|
||||||
|
public C$D() { /* compiled code */ }
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class $$$$$$$ {
|
||||||
|
public $$$$$$$() { /* compiled code */ }
|
||||||
|
|
||||||
|
public final class G$G$ {
|
||||||
|
public G$G$() { /* compiled code */ }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
// c.b.a.A$B
|
||||||
|
package c.b.a
|
||||||
|
|
||||||
|
class `A$B` {
|
||||||
|
inner class `C$D`
|
||||||
|
|
||||||
|
class `$$$$$$$` {
|
||||||
|
inner class `G$G$`
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
public final class A$B {
|
||||||
|
public A$B() { /* compiled code */ }
|
||||||
|
|
||||||
|
public final class C$D {
|
||||||
|
public C$D() { /* compiled code */ }
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class $$$$$$$ {
|
||||||
|
public $$$$$$$() { /* compiled code */ }
|
||||||
|
|
||||||
|
public final class G$G$ {
|
||||||
|
public G$G$() { /* compiled code */ }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// A$B
|
||||||
|
class `A$B` {
|
||||||
|
inner class `C$D`
|
||||||
|
|
||||||
|
class `$$$$$$$` {
|
||||||
|
inner class `G$G$`
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
static final class Foo$bar$A$B {
|
||||||
|
public Foo$bar$A$B() { /* compiled code */ }
|
||||||
|
|
||||||
|
final class C$D {
|
||||||
|
public C$D() { /* compiled code */ }
|
||||||
|
}
|
||||||
|
|
||||||
|
final class $$$$$$$ {
|
||||||
|
public $$$$$$$() { /* compiled code */ }
|
||||||
|
|
||||||
|
final class G$G$ {
|
||||||
|
public G$G$() { /* compiled code */ }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
// c.b.a.Foo$bar$A$B
|
||||||
|
package c.b.a
|
||||||
|
|
||||||
|
class Foo {
|
||||||
|
fun bar() {
|
||||||
|
class `A$B` {
|
||||||
|
inner class `C$D`
|
||||||
|
|
||||||
|
inner class `$$$$$$$` {
|
||||||
|
inner class `G$G$`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -32,7 +32,7 @@ import java.util.regex.Pattern;
|
|||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
public class CompilerLightClassTestGenerated extends AbstractCompilerLightClassTest {
|
public class CompilerLightClassTestGenerated extends AbstractCompilerLightClassTest {
|
||||||
public void testAllFilesPresentInLightClasses() throws Exception {
|
public void testAllFilesPresentInLightClasses() throws Exception {
|
||||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/asJava/lightClasses"), Pattern.compile("^(.+)\\.kt$"), true);
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/asJava/lightClasses"), Pattern.compile("^(.+)\\.kt$"), true, "local");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("AnnotationClass.kt")
|
@TestMetadata("AnnotationClass.kt")
|
||||||
@@ -47,6 +47,18 @@ public class CompilerLightClassTestGenerated extends AbstractCompilerLightClassT
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("DollarsInName.kt")
|
||||||
|
public void testDollarsInName() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/asJava/lightClasses/DollarsInName.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("DollarsInNameNoPackage.kt")
|
||||||
|
public void testDollarsInNameNoPackage() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/asJava/lightClasses/DollarsInNameNoPackage.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/asJava/lightClasses/delegation")
|
@TestMetadata("compiler/testData/asJava/lightClasses/delegation")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
|||||||
@@ -333,7 +333,7 @@ fun main(args: Array<String>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
testClass<AbstractCompilerLightClassTest>() {
|
testClass<AbstractCompilerLightClassTest>() {
|
||||||
model("asJava/lightClasses")
|
model("asJava/lightClasses", excludeDirs = listOf("local"))
|
||||||
}
|
}
|
||||||
|
|
||||||
testClass<AbstractTypeBindingTest>() {
|
testClass<AbstractTypeBindingTest>() {
|
||||||
@@ -855,7 +855,7 @@ fun main(args: Array<String>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
testClass<AbstractIdeCompiledLightClassTest> {
|
testClass<AbstractIdeCompiledLightClassTest> {
|
||||||
model("asJava/lightClasses", pattern = KT_WITHOUT_DOTS_IN_NAME)
|
model("asJava/lightClasses", excludeDirs = listOf("local"), pattern = KT_WITHOUT_DOTS_IN_NAME)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
* Copyright 2010-2016 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -20,12 +20,17 @@ import com.intellij.openapi.project.Project
|
|||||||
import com.intellij.openapi.roots.ModuleRootModificationUtil
|
import com.intellij.openapi.roots.ModuleRootModificationUtil
|
||||||
import com.intellij.openapi.util.io.FileUtilRt
|
import com.intellij.openapi.util.io.FileUtilRt
|
||||||
import com.intellij.psi.JavaPsiFacade
|
import com.intellij.psi.JavaPsiFacade
|
||||||
|
import com.intellij.psi.PsiClass
|
||||||
import com.intellij.psi.search.GlobalSearchScope
|
import com.intellij.psi.search.GlobalSearchScope
|
||||||
|
import com.intellij.psi.util.PsiTreeUtil
|
||||||
import org.jetbrains.kotlin.asJava.LightClassTestCommon
|
import org.jetbrains.kotlin.asJava.LightClassTestCommon
|
||||||
|
import org.jetbrains.kotlin.asJava.classes.KtLightClassForSourceDeclaration
|
||||||
import org.jetbrains.kotlin.idea.KotlinDaemonAnalyzerTestCase
|
import org.jetbrains.kotlin.idea.KotlinDaemonAnalyzerTestCase
|
||||||
import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase
|
import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase
|
||||||
import org.jetbrains.kotlin.idea.test.KotlinWithJdkAndRuntimeLightProjectDescriptor
|
import org.jetbrains.kotlin.idea.test.KotlinWithJdkAndRuntimeLightProjectDescriptor
|
||||||
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
|
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
|
||||||
|
import org.jetbrains.kotlin.psi.KtClassOrObject
|
||||||
|
import org.jetbrains.kotlin.psi.KtFile
|
||||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||||
import org.jetbrains.kotlin.test.MockLibraryUtil
|
import org.jetbrains.kotlin.test.MockLibraryUtil
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
@@ -34,7 +39,7 @@ import java.io.File
|
|||||||
abstract class AbstractIdeLightClassTest : KotlinLightCodeInsightFixtureTestCase() {
|
abstract class AbstractIdeLightClassTest : KotlinLightCodeInsightFixtureTestCase() {
|
||||||
fun doTest(testDataPath: String) {
|
fun doTest(testDataPath: String) {
|
||||||
myFixture.configureByFile(testDataPath)
|
myFixture.configureByFile(testDataPath)
|
||||||
testLightClass(project, testDataPath, { LightClassTestCommon.removeEmptyDefaultImpls(it) })
|
testLightClass(project, myFixture.file as KtFile, testDataPath, { LightClassTestCommon.removeEmptyDefaultImpls(it) })
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getProjectDescriptor() = KotlinWithJdkAndRuntimeLightProjectDescriptor.INSTANCE
|
override fun getProjectDescriptor() = KotlinWithJdkAndRuntimeLightProjectDescriptor.INSTANCE
|
||||||
@@ -59,15 +64,20 @@ abstract class AbstractIdeCompiledLightClassTest : KotlinDaemonAnalyzerTestCase(
|
|||||||
private fun libName() = "libFor" + getTestName(false)
|
private fun libName() = "libFor" + getTestName(false)
|
||||||
|
|
||||||
fun doTest(testDataPath: String) {
|
fun doTest(testDataPath: String) {
|
||||||
testLightClass(project, testDataPath, { it })
|
testLightClass(project, null, testDataPath, { it })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun testLightClass(project: Project, testDataPath: String, normalize: (String) -> String) {
|
private fun testLightClass(project: Project, ktFile: KtFile?, testDataPath: String, normalize: (String) -> String) {
|
||||||
LightClassTestCommon.testLightClass(
|
LightClassTestCommon.testLightClass(
|
||||||
File(testDataPath),
|
File(testDataPath),
|
||||||
findLightClass = {
|
findLightClass = { fqName ->
|
||||||
val clazz = JavaPsiFacade.getInstance(project).findClass(it, GlobalSearchScope.allScope(project))
|
var clazz: PsiClass? = JavaPsiFacade.getInstance(project).findClass(fqName, GlobalSearchScope.allScope(project))
|
||||||
|
if (clazz == null) {
|
||||||
|
clazz = PsiTreeUtil.findChildrenOfType(ktFile, KtClassOrObject::class.java)
|
||||||
|
.find { fqName.endsWith(it.nameAsName!!.asString()) }
|
||||||
|
?.let { KtLightClassForSourceDeclaration.create(it) }
|
||||||
|
}
|
||||||
if (clazz != null) {
|
if (clazz != null) {
|
||||||
PsiElementChecker.checkPsiElementStructure(clazz)
|
PsiElementChecker.checkPsiElementStructure(clazz)
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-1
@@ -32,7 +32,7 @@ import java.util.regex.Pattern;
|
|||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
public class IdeCompiledLightClassTestGenerated extends AbstractIdeCompiledLightClassTest {
|
public class IdeCompiledLightClassTestGenerated extends AbstractIdeCompiledLightClassTest {
|
||||||
public void testAllFilesPresentInLightClasses() throws Exception {
|
public void testAllFilesPresentInLightClasses() throws Exception {
|
||||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/asJava/lightClasses"), Pattern.compile("^([^.]+)\\.kt$"), true);
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/asJava/lightClasses"), Pattern.compile("^([^.]+)\\.kt$"), true, "local");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("AnnotationClass.kt")
|
@TestMetadata("AnnotationClass.kt")
|
||||||
@@ -47,6 +47,18 @@ public class IdeCompiledLightClassTestGenerated extends AbstractIdeCompiledLight
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("DollarsInName.kt")
|
||||||
|
public void testDollarsInName() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/asJava/lightClasses/DollarsInName.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("DollarsInNameNoPackage.kt")
|
||||||
|
public void testDollarsInNameNoPackage() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/asJava/lightClasses/DollarsInNameNoPackage.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/asJava/lightClasses/delegation")
|
@TestMetadata("compiler/testData/asJava/lightClasses/delegation")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
|||||||
@@ -47,6 +47,18 @@ public class IdeLightClassTestGenerated extends AbstractIdeLightClassTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("DollarsInName.kt")
|
||||||
|
public void testDollarsInName() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/asJava/lightClasses/DollarsInName.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("DollarsInNameNoPackage.kt")
|
||||||
|
public void testDollarsInNameNoPackage() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/asJava/lightClasses/DollarsInNameNoPackage.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/asJava/lightClasses/facades")
|
@TestMetadata("compiler/testData/asJava/lightClasses/facades")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
@@ -80,6 +92,21 @@ public class IdeLightClassTestGenerated extends AbstractIdeLightClassTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("compiler/testData/asJava/lightClasses/local")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public static class Local extends AbstractIdeLightClassTest {
|
||||||
|
public void testAllFilesPresentInLocal() throws Exception {
|
||||||
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/asJava/lightClasses/local"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("DollarsInNameLocal.kt")
|
||||||
|
public void testDollarsInNameLocal() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/asJava/lightClasses/local/DollarsInNameLocal.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/asJava/lightClasses/nullabilityAnnotations")
|
@TestMetadata("compiler/testData/asJava/lightClasses/nullabilityAnnotations")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
|||||||
Reference in New Issue
Block a user