diff --git a/generators/build.gradle.kts b/generators/build.gradle.kts index c4608bc8e5a..b5da3a2ef0b 100644 --- a/generators/build.gradle.kts +++ b/generators/build.gradle.kts @@ -30,6 +30,7 @@ dependencies { compile(projectTests(":kotlin-sam-with-receiver-compiler-plugin")) compile(projectTests(":kotlinx-serialization-compiler-plugin")) compile(projectTests(":generators:test-generator")) + compile(projectTests(":idea")) builtinsCompile("org.jetbrains.kotlin:kotlin-stdlib:$bootstrapKotlinVersion") testCompileOnly(project(":kotlin-reflect-api")) testCompile(builtinsSourceSet.output) diff --git a/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt b/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt index f673d5b9f1a..105aa3bd7bc 100644 --- a/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt +++ b/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt @@ -105,6 +105,8 @@ import org.jetbrains.kotlin.idea.maven.AbstractKotlinMavenInspectionTest import org.jetbrains.kotlin.idea.maven.configuration.AbstractMavenConfigureProjectByChangingFileTest import org.jetbrains.kotlin.idea.navigation.* import org.jetbrains.kotlin.idea.parameterInfo.AbstractParameterInfoTest +import org.jetbrains.kotlin.idea.perf.AbstractPerformanceJavaToKotlinCopyPasteConversionTest +import org.jetbrains.kotlin.idea.perf.AbstractPerformanceNewJavaToKotlinCopyPasteConversionTest import org.jetbrains.kotlin.idea.quickfix.AbstractQuickFixMultiFileTest import org.jetbrains.kotlin.idea.quickfix.AbstractQuickFixMultiModuleTest import org.jetbrains.kotlin.idea.quickfix.AbstractQuickFixTest @@ -1171,6 +1173,16 @@ fun main(args: Array) { model("codegen") } } + + testGroup("idea/performanceTests", "idea/testData") { + testClass { + model("copyPaste/conversion", testMethod = "doPerfTest", pattern = """^([^\.]+)\.java$""") + } + + testClass { + model("copyPaste/conversion", testMethod = "doPerfTest", pattern = """^([^\.]+)\.java$""") + } + } /* testGroup("plugins/android-extensions/android-extensions-idea/tests", "plugins/android-extensions/android-extensions-idea/testData") { testClass { diff --git a/idea/build.gradle.kts b/idea/build.gradle.kts index 69f7c05a41f..2e4a0d840c0 100644 --- a/idea/build.gradle.kts +++ b/idea/build.gradle.kts @@ -174,6 +174,7 @@ dependencies { performanceTestCompile(sourceSets["test"].output) performanceTestCompile(sourceSets["main"].output) + performanceTestCompile(project(":nj2k")) performanceTestRuntime(sourceSets["performanceTest"].output) } @@ -205,6 +206,8 @@ projectTest(taskName = "performanceTest") { } } -testsJar {} +testsJar { + from(sourceSets["performanceTest"].output) +} configureFormInstrumentation() diff --git a/idea/performanceTests/org/jetbrains/kotlin/idea/perf/AbstractKotlinProjectsPerformanceTest.kt b/idea/performanceTests/org/jetbrains/kotlin/idea/perf/AbstractKotlinProjectsPerformanceTest.kt index 89c00ea3278..47fd34be010 100644 --- a/idea/performanceTests/org/jetbrains/kotlin/idea/perf/AbstractKotlinProjectsPerformanceTest.kt +++ b/idea/performanceTests/org/jetbrains/kotlin/idea/perf/AbstractKotlinProjectsPerformanceTest.kt @@ -52,6 +52,8 @@ import org.jetbrains.kotlin.idea.core.util.toPsiFile import org.jetbrains.kotlin.idea.framework.KotlinSdkType import org.jetbrains.kotlin.idea.test.ConfigLibraryUtil import org.jetbrains.kotlin.idea.test.KotlinWithJdkAndRuntimeLightProjectDescriptor +import org.junit.AfterClass +import org.junit.BeforeClass import java.io.File import java.nio.file.Paths @@ -62,7 +64,25 @@ abstract class AbstractKotlinProjectsPerformanceTest : UsefulTestCase() { private lateinit var jdk18: Sdk private lateinit var myApplication: IdeaTestApplication - private val stats: Stats = Stats("-perf") + companion object { + @JvmStatic + var warmedUp: Boolean = false + + @JvmStatic + val stats: Stats = Stats("-perf") + + @BeforeClass + @JvmStatic + fun setup() { + // things to execute once and keep around for the class + } + + @AfterClass + @JvmStatic + fun teardown() { + stats.close() + } + } override fun setUp() { super.setUp() @@ -88,17 +108,22 @@ abstract class AbstractKotlinProjectsPerformanceTest : UsefulTestCase() { InspectionProfileImpl.INIT_INSPECTIONS = true // warm up: open simple small project - val project = innerPerfOpenProject("helloKotlin", "warm-up ") - val perfHighlightFile = perfHighlightFile(project, "src/HelloMain.kt", "warm-up ") - assertTrue("kotlin project has been not imported properly", perfHighlightFile.isNotEmpty()) + if (!warmedUp) { + val project = innerPerfOpenProject("helloKotlin", "warm-up ") + val perfHighlightFile = perfHighlightFile(project, "src/HelloMain.kt", "warm-up ") + assertTrue("kotlin project has been not imported properly", perfHighlightFile.isNotEmpty()) + PsiDocumentManager.getInstance(project).commitAllDocuments() + ProjectManagerEx.getInstanceEx().forceCloseProject(project, true) - ProjectManagerEx.getInstanceEx().forceCloseProject(project, true) + warmedUp = true + } } override fun tearDown() { var runAll = RunAll() if (myProject != null) { + PsiDocumentManager.getInstance(myProject!!).commitAllDocuments() runAll = runAll .append(ThrowableRunnable { LightPlatformTestCase.doTearDown(myProject!!, myApplication) }) } @@ -107,7 +132,7 @@ abstract class AbstractKotlinProjectsPerformanceTest : UsefulTestCase() { .run() } - protected fun getTempDirFixture(): TempDirTestFixture { + private fun getTempDirFixture(): TempDirTestFixture { val policy = IdeaTestExecutionPolicy.current() return if (policy != null) policy.createTempDirTestFixture() @@ -136,6 +161,8 @@ abstract class AbstractKotlinProjectsPerformanceTest : UsefulTestCase() { } } }, "change doc $fileName $nameOfChange", "") + + manager.commitAllDocuments() } protected fun perfOpenProject(name: String, path: String = "idea/testData/perfTest") { @@ -164,6 +191,8 @@ abstract class AbstractKotlinProjectsPerformanceTest : UsefulTestCase() { val changeListManagerImpl = ChangeListManager.getInstance(project) as ChangeListManagerImpl changeListManagerImpl.waitUntilRefreshed() + PsiDocumentManager.getInstance(project).commitAllDocuments() + return project } @@ -207,16 +236,6 @@ abstract class AbstractKotlinProjectsPerformanceTest : UsefulTestCase() { return highlightFile } - inline fun attempts(block: (v: Int) -> Unit) { - attempts(3, block) - } - - inline fun attempts(count: Int, block: (v: Int) -> Unit) { - for (attempt in 0..count) { - block(attempt) - } - } - fun perfAutoCompletion( name: String, before: String, @@ -244,10 +263,14 @@ abstract class AbstractKotlinProjectsPerformanceTest : UsefulTestCase() { val actualSuggestions = complete?.map { it.lookupString }?.toList() ?: emptyList() assertTrue(actualSuggestions.containsAll(suggestions.toList())) - with(fixture) { - type(type) - checkResult(after) - tearDown() + try { + with(fixture) { + type(type) + checkResult(after) + } + } finally { + PsiDocumentManager.getInstance(fixture.project).commitAllDocuments() + fixture.tearDown() } } diff --git a/idea/performanceTests/org/jetbrains/kotlin/idea/perf/AbstractPerformanceJavaToKotlinCopyPasteConversionTest.kt b/idea/performanceTests/org/jetbrains/kotlin/idea/perf/AbstractPerformanceJavaToKotlinCopyPasteConversionTest.kt new file mode 100644 index 00000000000..64fcdbe50e8 --- /dev/null +++ b/idea/performanceTests/org/jetbrains/kotlin/idea/perf/AbstractPerformanceJavaToKotlinCopyPasteConversionTest.kt @@ -0,0 +1,100 @@ +/* + * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.idea.perf + +import com.intellij.ide.highlighter.JavaFileType +import com.intellij.openapi.actionSystem.IdeActions +import com.intellij.openapi.util.registry.Registry +import org.jetbrains.kotlin.idea.KotlinFileType +import org.jetbrains.kotlin.idea.conversion.copy.AbstractJavaToKotlinCopyPasteConversionTest +import org.jetbrains.kotlin.idea.conversion.copy.ConvertJavaCopyPasteProcessor +import org.jetbrains.kotlin.test.InTextDirectivesUtils +import org.jetbrains.kotlin.test.KotlinTestUtils +import java.io.File + +abstract class AbstractPerformanceJavaToKotlinCopyPasteConversionTest(private val newJ2K: Boolean = false) : + AbstractJavaToKotlinCopyPasteConversionTest() { + + private val stats: Stats = Stats("-${j2kPrefix()}-j2k") + + companion object { + @JvmStatic + var warmedUp: Array = arrayOf(false, false) + + } + + override fun setUp() { + super.setUp() + + Registry.get("kotlin.use.new.j2k").setValue(newJ2K) + + val index = if (newJ2K) 1 else 0 + if (!warmedUp[index]) { + doWarmUpPerfTest() + warmedUp[index] = true + } + } + + private fun doWarmUpPerfTest() { + val prefix = j2kPrefix() + with(myFixture) { + configureByText(JavaFileType.INSTANCE, "public class Foo {\nprivate String value;\n}") + performEditorAction(IdeActions.ACTION_CUT) + configureByText(KotlinFileType.INSTANCE, "") + ConvertJavaCopyPasteProcessor.conversionPerformed = false + tcSimplePerfTest("", "warm-up ${prefix} java2kotlin conversion", stats) { + performEditorAction(IdeActions.ACTION_PASTE) + } + } + + kotlin.test.assertFalse(!ConvertJavaCopyPasteProcessor.conversionPerformed, "No conversion to Kotlin suggested") + assertEquals("class Foo {\n private val value: String? = null\n}", myFixture.file.text) + } + + private fun j2kPrefix(): String { + return if (newJ2K) "new" else "old" + } + + fun doPerfTest(path: String) { + myFixture.testDataPath = testDataPath + val testName = getTestName(false) + + myFixture.configureByFiles("$testName.java") + + val fileText = myFixture.editor.document.text + val noConversionExpected = InTextDirectivesUtils.findListWithPrefixes(fileText, "// NO_CONVERSION_EXPECTED").isNotEmpty() + + myFixture.performEditorAction(IdeActions.ACTION_COPY) + + configureByDependencyIfExists("$testName.dependency.kt") + configureByDependencyIfExists("$testName.dependency.java") + + configureTargetFile("$testName.to.kt") + + ConvertJavaCopyPasteProcessor.conversionPerformed = false + + val prefix = j2kPrefix() + + attempts { + tcSimplePerfTest(testName, "${prefix} java2kotlin conversion$it: $testName", stats) { + myFixture.performEditorAction(IdeActions.ACTION_PASTE) + } + + validate(path, noConversionExpected) + + myFixture.performEditorAction(IdeActions.ACTION_UNDO) + } + + } + + open fun validate(path: String, noConversionExpected: Boolean) { + kotlin.test.assertEquals( + noConversionExpected, !ConvertJavaCopyPasteProcessor.conversionPerformed, + if (noConversionExpected) "Conversion to Kotlin should not be suggested" else "No conversion to Kotlin suggested" + ) + KotlinTestUtils.assertEqualsToFile(File(path.replace(".java", ".expected.kt")), myFixture.file.text) + } +} \ No newline at end of file diff --git a/idea/performanceTests/org/jetbrains/kotlin/idea/perf/AbstractPerformanceNewJavaToKotlinCopyPasteConversionTest.kt b/idea/performanceTests/org/jetbrains/kotlin/idea/perf/AbstractPerformanceNewJavaToKotlinCopyPasteConversionTest.kt new file mode 100644 index 00000000000..f4dd1e58b50 --- /dev/null +++ b/idea/performanceTests/org/jetbrains/kotlin/idea/perf/AbstractPerformanceNewJavaToKotlinCopyPasteConversionTest.kt @@ -0,0 +1,24 @@ +/* + * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.idea.perf + +import org.jetbrains.kotlin.idea.conversion.copy.ConvertJavaCopyPasteProcessor + +abstract class AbstractPerformanceNewJavaToKotlinCopyPasteConversionTest : + AbstractPerformanceJavaToKotlinCopyPasteConversionTest(newJ2K = true) { + + override fun validate(path: String, noConversionExpected: Boolean) { + // nj2k behaves slightly different to classic j2k in cases where conversion is not expected + // this is a performance test rather validation test + if (!noConversionExpected) { + kotlin.test.assertEquals( + noConversionExpected, !ConvertJavaCopyPasteProcessor.conversionPerformed, + if (noConversionExpected) "Conversion to Kotlin should not be suggested" else "No conversion to Kotlin suggested" + ) + } + // as well output of nj2k could be slightly different to output of j2k those test data is used + } +} \ No newline at end of file diff --git a/idea/performanceTests/org/jetbrains/kotlin/idea/perf/PerformanceJavaToKotlinCopyPasteConversionTestGenerated.java b/idea/performanceTests/org/jetbrains/kotlin/idea/perf/PerformanceJavaToKotlinCopyPasteConversionTestGenerated.java new file mode 100644 index 00000000000..fefedfd67ae --- /dev/null +++ b/idea/performanceTests/org/jetbrains/kotlin/idea/perf/PerformanceJavaToKotlinCopyPasteConversionTestGenerated.java @@ -0,0 +1,226 @@ +/* + * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.idea.perf; + +import com.intellij.testFramework.TestDataPath; +import org.jetbrains.kotlin.test.JUnit3RunnerWithInners; +import org.jetbrains.kotlin.test.KotlinTestUtils; +import org.jetbrains.kotlin.test.TargetBackend; +import org.jetbrains.kotlin.test.TestMetadata; +import org.junit.runner.RunWith; + +import java.io.File; +import java.util.regex.Pattern; + +/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */ +@SuppressWarnings("all") +@TestMetadata("idea/testData/copyPaste/conversion") +@TestDataPath("$PROJECT_ROOT") +@RunWith(JUnit3RunnerWithInners.class) +public class PerformanceJavaToKotlinCopyPasteConversionTestGenerated extends AbstractPerformanceJavaToKotlinCopyPasteConversionTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doPerfTest, TargetBackend.ANY, testDataFilePath); + } + + @TestMetadata("AddImports.java") + public void testAddImports() throws Exception { + runTest("idea/testData/copyPaste/conversion/AddImports.java"); + } + + @TestMetadata("AddImportsButNoConversion.java") + public void testAddImportsButNoConversion() throws Exception { + runTest("idea/testData/copyPaste/conversion/AddImportsButNoConversion.java"); + } + + @TestMetadata("AddImportsButNoConversion2.java") + public void testAddImportsButNoConversion2() throws Exception { + runTest("idea/testData/copyPaste/conversion/AddImportsButNoConversion2.java"); + } + + @TestMetadata("AddImportsClassInSamePackage.java") + public void testAddImportsClassInSamePackage() throws Exception { + runTest("idea/testData/copyPaste/conversion/AddImportsClassInSamePackage.java"); + } + + @TestMetadata("AddImportsDummyConflict.java") + public void testAddImportsDummyConflict() throws Exception { + runTest("idea/testData/copyPaste/conversion/AddImportsDummyConflict.java"); + } + + @TestMetadata("AddImportsWithExplicitImports.java") + public void testAddImportsWithExplicitImports() throws Exception { + runTest("idea/testData/copyPaste/conversion/AddImportsWithExplicitImports.java"); + } + + @TestMetadata("AddKClassImport.java") + public void testAddKClassImport() throws Exception { + runTest("idea/testData/copyPaste/conversion/AddKClassImport.java"); + } + + public void testAllFilesPresentInConversion() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/copyPaste/conversion"), Pattern.compile("^([^\\.]+)\\.java$"), TargetBackend.ANY, true); + } + + @TestMetadata("Arithmetic.java") + public void testArithmetic() throws Exception { + runTest("idea/testData/copyPaste/conversion/Arithmetic.java"); + } + + @TestMetadata("ClassWithNoDocComment.java") + public void testClassWithNoDocComment() throws Exception { + runTest("idea/testData/copyPaste/conversion/ClassWithNoDocComment.java"); + } + + @TestMetadata("ClassWithOverrides.java") + public void testClassWithOverrides() throws Exception { + runTest("idea/testData/copyPaste/conversion/ClassWithOverrides.java"); + } + + @TestMetadata("Constructor.java") + public void testConstructor() throws Exception { + runTest("idea/testData/copyPaste/conversion/Constructor.java"); + } + + @TestMetadata("ConversionInCorrectContext.java") + public void testConversionInCorrectContext() throws Exception { + runTest("idea/testData/copyPaste/conversion/ConversionInCorrectContext.java"); + } + + @TestMetadata("CopyAnnotation.java") + public void testCopyAnnotation() throws Exception { + runTest("idea/testData/copyPaste/conversion/CopyAnnotation.java"); + } + + @TestMetadata("ExtendsTypeRef.java") + public void testExtendsTypeRef() throws Exception { + runTest("idea/testData/copyPaste/conversion/ExtendsTypeRef.java"); + } + + @TestMetadata("FieldWithNoEndComment.java") + public void testFieldWithNoEndComment() throws Exception { + runTest("idea/testData/copyPaste/conversion/FieldWithNoEndComment.java"); + } + + @TestMetadata("FieldWithNoModifierAndNoSemicolon.java") + public void testFieldWithNoModifierAndNoSemicolon() throws Exception { + runTest("idea/testData/copyPaste/conversion/FieldWithNoModifierAndNoSemicolon.java"); + } + + @TestMetadata("FileWithNoPackageStatement.java") + public void testFileWithNoPackageStatement() throws Exception { + runTest("idea/testData/copyPaste/conversion/FileWithNoPackageStatement.java"); + } + + @TestMetadata("HalfTheWhiteSpace.java") + public void testHalfTheWhiteSpace() throws Exception { + runTest("idea/testData/copyPaste/conversion/HalfTheWhiteSpace.java"); + } + + @TestMetadata("ImplementsTypeRef.java") + public void testImplementsTypeRef() throws Exception { + runTest("idea/testData/copyPaste/conversion/ImplementsTypeRef.java"); + } + + @TestMetadata("Imports1.java") + public void testImports1() throws Exception { + runTest("idea/testData/copyPaste/conversion/Imports1.java"); + } + + @TestMetadata("Imports2.java") + public void testImports2() throws Exception { + runTest("idea/testData/copyPaste/conversion/Imports2.java"); + } + + @TestMetadata("Imports3.java") + public void testImports3() throws Exception { + runTest("idea/testData/copyPaste/conversion/Imports3.java"); + } + + @TestMetadata("Indentation.java") + public void testIndentation() throws Exception { + runTest("idea/testData/copyPaste/conversion/Indentation.java"); + } + + @TestMetadata("InsertIntoComment.java") + public void testInsertIntoComment() throws Exception { + runTest("idea/testData/copyPaste/conversion/InsertIntoComment.java"); + } + + @TestMetadata("InsertIntoString.java") + public void testInsertIntoString() throws Exception { + runTest("idea/testData/copyPaste/conversion/InsertIntoString.java"); + } + + @TestMetadata("Kt31848.java") + public void testKt31848() throws Exception { + runTest("idea/testData/copyPaste/conversion/Kt31848.java"); + } + + @TestMetadata("MethodDeclarationWithNoBody.java") + public void testMethodDeclarationWithNoBody() throws Exception { + runTest("idea/testData/copyPaste/conversion/MethodDeclarationWithNoBody.java"); + } + + @TestMetadata("MethodReferenceWithoutQualifier.java") + public void testMethodReferenceWithoutQualifier() throws Exception { + runTest("idea/testData/copyPaste/conversion/MethodReferenceWithoutQualifier.java"); + } + + @TestMetadata("MethodWithNoAnnotation.java") + public void testMethodWithNoAnnotation() throws Exception { + runTest("idea/testData/copyPaste/conversion/MethodWithNoAnnotation.java"); + } + + @TestMetadata("MethodWithOnlyOneAnnotation.java") + public void testMethodWithOnlyOneAnnotation() throws Exception { + runTest("idea/testData/copyPaste/conversion/MethodWithOnlyOneAnnotation.java"); + } + + @TestMetadata("OnlyClosingBrace.java") + public void testOnlyClosingBrace() throws Exception { + runTest("idea/testData/copyPaste/conversion/OnlyClosingBrace.java"); + } + + @TestMetadata("OnlyOneBraceFromBlock.java") + public void testOnlyOneBraceFromBlock() throws Exception { + runTest("idea/testData/copyPaste/conversion/OnlyOneBraceFromBlock.java"); + } + + @TestMetadata("OnlyQualifier.java") + public void testOnlyQualifier() throws Exception { + runTest("idea/testData/copyPaste/conversion/OnlyQualifier.java"); + } + + @TestMetadata("RawTypeRef.java") + public void testRawTypeRef() throws Exception { + runTest("idea/testData/copyPaste/conversion/RawTypeRef.java"); + } + + @TestMetadata("RedundantTypeCast.java") + public void testRedundantTypeCast() throws Exception { + runTest("idea/testData/copyPaste/conversion/RedundantTypeCast.java"); + } + + @TestMetadata("RedundantTypeCast2.java") + public void testRedundantTypeCast2() throws Exception { + runTest("idea/testData/copyPaste/conversion/RedundantTypeCast2.java"); + } + + @TestMetadata("SampleBlock.java") + public void testSampleBlock() throws Exception { + runTest("idea/testData/copyPaste/conversion/SampleBlock.java"); + } + + @TestMetadata("SeveralMethodsSample.java") + public void testSeveralMethodsSample() throws Exception { + runTest("idea/testData/copyPaste/conversion/SeveralMethodsSample.java"); + } + + @TestMetadata("SingleWordFromIdentifier.java") + public void testSingleWordFromIdentifier() throws Exception { + runTest("idea/testData/copyPaste/conversion/SingleWordFromIdentifier.java"); + } +} diff --git a/idea/performanceTests/org/jetbrains/kotlin/idea/perf/PerformanceNewJavaToKotlinCopyPasteConversionTestGenerated.java b/idea/performanceTests/org/jetbrains/kotlin/idea/perf/PerformanceNewJavaToKotlinCopyPasteConversionTestGenerated.java new file mode 100644 index 00000000000..05b6432ace4 --- /dev/null +++ b/idea/performanceTests/org/jetbrains/kotlin/idea/perf/PerformanceNewJavaToKotlinCopyPasteConversionTestGenerated.java @@ -0,0 +1,227 @@ +/* + * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.idea.perf; + +import com.intellij.testFramework.TestDataPath; +import org.jetbrains.kotlin.test.JUnit3RunnerWithInners; +import org.jetbrains.kotlin.test.KotlinTestUtils; +import org.jetbrains.kotlin.test.TargetBackend; +import org.jetbrains.kotlin.test.TestMetadata; +import org.junit.runner.RunWith; + +import java.io.File; +import java.util.regex.Pattern; + +/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */ +@SuppressWarnings("all") +@TestMetadata("idea/testData/copyPaste/conversion") +@TestDataPath("$PROJECT_ROOT") +@RunWith(JUnit3RunnerWithInners.class) +public class PerformanceNewJavaToKotlinCopyPasteConversionTestGenerated extends AbstractPerformanceNewJavaToKotlinCopyPasteConversionTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doPerfTest, TargetBackend.ANY, testDataFilePath); + } + + @TestMetadata("AddImports.java") + public void testAddImports() throws Exception { + runTest("idea/testData/copyPaste/conversion/AddImports.java"); + } + + @TestMetadata("AddImportsButNoConversion.java") + public void testAddImportsButNoConversion() throws Exception { + runTest("idea/testData/copyPaste/conversion/AddImportsButNoConversion.java"); + } + + @TestMetadata("AddImportsButNoConversion2.java") + public void testAddImportsButNoConversion2() throws Exception { + runTest("idea/testData/copyPaste/conversion/AddImportsButNoConversion2.java"); + } + + @TestMetadata("AddImportsClassInSamePackage.java") + public void testAddImportsClassInSamePackage() throws Exception { + runTest("idea/testData/copyPaste/conversion/AddImportsClassInSamePackage.java"); + } + + @TestMetadata("AddImportsDummyConflict.java") + public void testAddImportsDummyConflict() throws Exception { + runTest("idea/testData/copyPaste/conversion/AddImportsDummyConflict.java"); + } + + @TestMetadata("AddImportsWithExplicitImports.java") + public void testAddImportsWithExplicitImports() throws Exception { + runTest("idea/testData/copyPaste/conversion/AddImportsWithExplicitImports.java"); + } + + @TestMetadata("AddKClassImport.java") + public void testAddKClassImport() throws Exception { + runTest("idea/testData/copyPaste/conversion/AddKClassImport.java"); + } + + public void testAllFilesPresentInConversion() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/copyPaste/conversion"), Pattern.compile("^([^\\.]+)\\.java$"), TargetBackend.ANY, true); + } + + @TestMetadata("Arithmetic.java") + public void testArithmetic() throws Exception { + runTest("idea/testData/copyPaste/conversion/Arithmetic.java"); + } + + @TestMetadata("ClassWithNoDocComment.java") + public void testClassWithNoDocComment() throws Exception { + runTest("idea/testData/copyPaste/conversion/ClassWithNoDocComment.java"); + } + + @TestMetadata("ClassWithOverrides.java") + public void testClassWithOverrides() throws Exception { + runTest("idea/testData/copyPaste/conversion/ClassWithOverrides.java"); + } + + @TestMetadata("Constructor.java") + public void testConstructor() throws Exception { + runTest("idea/testData/copyPaste/conversion/Constructor.java"); + } + + @TestMetadata("ConversionInCorrectContext.java") + public void testConversionInCorrectContext() throws Exception { + runTest("idea/testData/copyPaste/conversion/ConversionInCorrectContext.java"); + } + + @TestMetadata("CopyAnnotation.java") + public void testCopyAnnotation() throws Exception { + runTest("idea/testData/copyPaste/conversion/CopyAnnotation.java"); + } + + @TestMetadata("ExtendsTypeRef.java") + public void testExtendsTypeRef() throws Exception { + runTest("idea/testData/copyPaste/conversion/ExtendsTypeRef.java"); + } + + @TestMetadata("FieldWithNoEndComment.java") + public void testFieldWithNoEndComment() throws Exception { + runTest("idea/testData/copyPaste/conversion/FieldWithNoEndComment.java"); + } + + @TestMetadata("FieldWithNoModifierAndNoSemicolon.java") + public void testFieldWithNoModifierAndNoSemicolon() throws Exception { + runTest("idea/testData/copyPaste/conversion/FieldWithNoModifierAndNoSemicolon.java"); + } + + @TestMetadata("FileWithNoPackageStatement.java") + public void testFileWithNoPackageStatement() throws Exception { + runTest("idea/testData/copyPaste/conversion/FileWithNoPackageStatement.java"); + } + + @TestMetadata("HalfTheWhiteSpace.java") + public void testHalfTheWhiteSpace() throws Exception { + runTest("idea/testData/copyPaste/conversion/HalfTheWhiteSpace.java"); + } + + @TestMetadata("ImplementsTypeRef.java") + public void testImplementsTypeRef() throws Exception { + runTest("idea/testData/copyPaste/conversion/ImplementsTypeRef.java"); + } + + @TestMetadata("Imports1.java") + public void testImports1() throws Exception { + runTest("idea/testData/copyPaste/conversion/Imports1.java"); + } + + @TestMetadata("Imports2.java") + public void testImports2() throws Exception { + // TODO: commented until rr/darthorimar/range-marker-fix is merged + // runTest("idea/testData/copyPaste/conversion/Imports2.java"); + } + + @TestMetadata("Imports3.java") + public void testImports3() throws Exception { + runTest("idea/testData/copyPaste/conversion/Imports3.java"); + } + + @TestMetadata("Indentation.java") + public void testIndentation() throws Exception { + runTest("idea/testData/copyPaste/conversion/Indentation.java"); + } + + @TestMetadata("InsertIntoComment.java") + public void testInsertIntoComment() throws Exception { + runTest("idea/testData/copyPaste/conversion/InsertIntoComment.java"); + } + + @TestMetadata("InsertIntoString.java") + public void testInsertIntoString() throws Exception { + runTest("idea/testData/copyPaste/conversion/InsertIntoString.java"); + } + + @TestMetadata("Kt31848.java") + public void testKt31848() throws Exception { + runTest("idea/testData/copyPaste/conversion/Kt31848.java"); + } + + @TestMetadata("MethodDeclarationWithNoBody.java") + public void testMethodDeclarationWithNoBody() throws Exception { + runTest("idea/testData/copyPaste/conversion/MethodDeclarationWithNoBody.java"); + } + + @TestMetadata("MethodReferenceWithoutQualifier.java") + public void testMethodReferenceWithoutQualifier() throws Exception { + runTest("idea/testData/copyPaste/conversion/MethodReferenceWithoutQualifier.java"); + } + + @TestMetadata("MethodWithNoAnnotation.java") + public void testMethodWithNoAnnotation() throws Exception { + runTest("idea/testData/copyPaste/conversion/MethodWithNoAnnotation.java"); + } + + @TestMetadata("MethodWithOnlyOneAnnotation.java") + public void testMethodWithOnlyOneAnnotation() throws Exception { + runTest("idea/testData/copyPaste/conversion/MethodWithOnlyOneAnnotation.java"); + } + + @TestMetadata("OnlyClosingBrace.java") + public void testOnlyClosingBrace() throws Exception { + runTest("idea/testData/copyPaste/conversion/OnlyClosingBrace.java"); + } + + @TestMetadata("OnlyOneBraceFromBlock.java") + public void testOnlyOneBraceFromBlock() throws Exception { + runTest("idea/testData/copyPaste/conversion/OnlyOneBraceFromBlock.java"); + } + + @TestMetadata("OnlyQualifier.java") + public void testOnlyQualifier() throws Exception { + runTest("idea/testData/copyPaste/conversion/OnlyQualifier.java"); + } + + @TestMetadata("RawTypeRef.java") + public void testRawTypeRef() throws Exception { + runTest("idea/testData/copyPaste/conversion/RawTypeRef.java"); + } + + @TestMetadata("RedundantTypeCast.java") + public void testRedundantTypeCast() throws Exception { + runTest("idea/testData/copyPaste/conversion/RedundantTypeCast.java"); + } + + @TestMetadata("RedundantTypeCast2.java") + public void testRedundantTypeCast2() throws Exception { + runTest("idea/testData/copyPaste/conversion/RedundantTypeCast2.java"); + } + + @TestMetadata("SampleBlock.java") + public void testSampleBlock() throws Exception { + runTest("idea/testData/copyPaste/conversion/SampleBlock.java"); + } + + @TestMetadata("SeveralMethodsSample.java") + public void testSeveralMethodsSample() throws Exception { + runTest("idea/testData/copyPaste/conversion/SeveralMethodsSample.java"); + } + + @TestMetadata("SingleWordFromIdentifier.java") + public void testSingleWordFromIdentifier() throws Exception { + runTest("idea/testData/copyPaste/conversion/SingleWordFromIdentifier.java"); + } +} diff --git a/idea/performanceTests/org/jetbrains/kotlin/idea/perf/Stats.kt b/idea/performanceTests/org/jetbrains/kotlin/idea/perf/Stats.kt index e6d2680757c..3ae54960b14 100644 --- a/idea/performanceTests/org/jetbrains/kotlin/idea/perf/Stats.kt +++ b/idea/performanceTests/org/jetbrains/kotlin/idea/perf/Stats.kt @@ -77,6 +77,21 @@ inline fun tcSimplePerfTest(file: String, name: String, stats: Stats, block: () println("##teamcity[buildStatisticValue key='$name' value='$spentMs']") } +inline fun attempts(block: (v: String) -> Unit) = attempts(3) { + block(it) +} + +inline fun attempts(count: Int, block: (v: String) -> Unit) { + for (attempt in 0..count) { + val n = when (attempt) { + 0 -> "" + count -> "N" + else -> attempt.toString() + } + block(n) + } +} + fun String.tcEscape(): String { return this .replace("|", "||") diff --git a/idea/testData/copyPaste/conversion/Kt31848.expected.kt b/idea/testData/copyPaste/conversion/Kt31848.expected.kt new file mode 100644 index 00000000000..16cee1e82f2 --- /dev/null +++ b/idea/testData/copyPaste/conversion/Kt31848.expected.kt @@ -0,0 +1,7 @@ +import java.util.ArrayList + +class Kt31848 { + internal fun test() { + val list = ArrayList() + } +} diff --git a/idea/testData/copyPaste/conversion/Kt31848.java b/idea/testData/copyPaste/conversion/Kt31848.java new file mode 100644 index 00000000000..825288bb88e --- /dev/null +++ b/idea/testData/copyPaste/conversion/Kt31848.java @@ -0,0 +1,8 @@ +import java.util.ArrayList; +import java.util.List; + +public class Kt31848 { + void test(){ + List list = new ArrayList(); + } +} \ No newline at end of file diff --git a/idea/testData/copyPaste/conversion/Kt31848.to.kt b/idea/testData/copyPaste/conversion/Kt31848.to.kt new file mode 100644 index 00000000000..81389d50841 --- /dev/null +++ b/idea/testData/copyPaste/conversion/Kt31848.to.kt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/conversion/copy/JavaToKotlinCopyPasteConversionTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/conversion/copy/JavaToKotlinCopyPasteConversionTestGenerated.java index 53df7e5a595..fe18762a3d4 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/conversion/copy/JavaToKotlinCopyPasteConversionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/conversion/copy/JavaToKotlinCopyPasteConversionTestGenerated.java @@ -154,6 +154,11 @@ public class JavaToKotlinCopyPasteConversionTestGenerated extends AbstractJavaTo runTest("idea/testData/copyPaste/conversion/InsertIntoString.java"); } + @TestMetadata("Kt31848.java") + public void testKt31848() throws Exception { + runTest("idea/testData/copyPaste/conversion/Kt31848.java"); + } + @TestMetadata("MethodDeclarationWithNoBody.java") public void testMethodDeclarationWithNoBody() throws Exception { runTest("idea/testData/copyPaste/conversion/MethodDeclarationWithNoBody.java");