diff --git a/.bunch b/.bunch index de35f65eaed..9b679f675ed 100644 --- a/.bunch +++ b/.bunch @@ -4,6 +4,6 @@ as31_173_181 as32_181 as33 -as34_as33 +as34_183 183 191_183 diff --git a/buildSrc/src/main/kotlin/IdeCompatibilityDsl.kt b/buildSrc/src/main/kotlin/IdeCompatibilityDsl.kt index ffc1106b8db..162fd33083c 100644 --- a/buildSrc/src/main/kotlin/IdeCompatibilityDsl.kt +++ b/buildSrc/src/main/kotlin/IdeCompatibilityDsl.kt @@ -27,7 +27,7 @@ fun CompatibilityPredicate.or(other: CompatibilityPredicate): CompatibilityPredi } enum class Platform : CompatibilityPredicate { - P173, P181, P182, P183; + P173, P181, P182, P183, P191; val version: Int = name.drop(1).toInt() @@ -46,10 +46,12 @@ enum class Ide(val platform: Platform) : CompatibilityPredicate { IJ181(Platform.P181), IJ182(Platform.P182), IJ183(Platform.P183), + IJ191(Platform.P191), AS31(Platform.P173), AS32(Platform.P181), - AS33(Platform.P182); + AS33(Platform.P182), + AS34(Platform.P183); val kind = Kind.values().first { it.shortName == name.take(2) } val version = name.dropWhile { !it.isDigit() }.toInt() diff --git a/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/AndroidJpsBuildTestCase.java.as34 b/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/AndroidJpsBuildTestCase.java.as34 new file mode 100644 index 00000000000..e69de29bb2d diff --git a/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/AndroidRunner.java.as34 b/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/AndroidRunner.java.as34 new file mode 100644 index 00000000000..e69de29bb2d diff --git a/generators/build.gradle.kts.as34 b/generators/build.gradle.kts.as34 new file mode 100644 index 00000000000..f8f5c882fb6 --- /dev/null +++ b/generators/build.gradle.kts.as34 @@ -0,0 +1,53 @@ + +plugins { + kotlin("jvm") + id("jps-compatible") +} + +sourceSets { + "main" { } + "test" { projectDefault() } +} + +val builtinsSourceSet = sourceSets.create("builtins") { + java.srcDir("builtins") +} +val builtinsCompile by configurations + +dependencies { + compile(projectTests(":compiler:cli")) + compile(projectTests(":idea:idea-maven")) + compile(projectTests(":j2k")) + compile(projectTests(":idea:idea-android")) + compile(projectTests(":jps-plugin")) + compile(projectTests(":plugins:android-extensions-compiler")) + compile(projectTests(":plugins:android-extensions-ide")) + compile(projectTests(":plugins:android-extensions-jps")) + compile(projectTests(":kotlin-annotation-processing")) + compile(projectTests(":kotlin-allopen-compiler-plugin")) + compile(projectTests(":kotlin-noarg-compiler-plugin")) + compile(projectTests(":kotlin-sam-with-receiver-compiler-plugin")) + compile(projectTests(":generators:test-generator")) + // testCompileOnly(intellijDep("jps-build-test")) + builtinsCompile("org.jetbrains.kotlin:kotlin-stdlib:$bootstrapKotlinVersion") + testCompileOnly(project(":kotlin-reflect-api")) + testCompile(builtinsSourceSet.output) + testRuntime(intellijDep()) { includeJars("idea_rt") } + testRuntime(project(":kotlin-reflect")) +} + + +projectTest { + workingDir = rootDir +} + +val generateTests by generator("org.jetbrains.kotlin.generators.tests.GenerateTestsKt") + +val generateProtoBuf by generator("org.jetbrains.kotlin.generators.protobuf.GenerateProtoBufKt") +val generateProtoBufCompare by generator("org.jetbrains.kotlin.generators.protobuf.GenerateProtoBufCompare") + +val generateGradleOptions by generator("org.jetbrains.kotlin.generators.arguments.GenerateGradleOptionsKt") + +val generateBuiltins by generator("org.jetbrains.kotlin.generators.builtins.generateBuiltIns.GenerateBuiltInsKt", builtinsSourceSet) + +testsJar() diff --git a/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt.as34 b/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt.as34 new file mode 100644 index 00000000000..aee3556e831 --- /dev/null +++ b/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt.as34 @@ -0,0 +1,1092 @@ +/* + * Copyright 2010-2017 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.kotlin.generators.tests + +import org.jetbrains.kotlin.AbstractDataFlowValueRenderingTest +import org.jetbrains.kotlin.addImport.AbstractAddImportTest +import org.jetbrains.kotlin.allopen.AbstractBytecodeListingTestForAllOpen +import org.jetbrains.kotlin.android.parcel.AbstractParcelBytecodeListingTest +import org.jetbrains.kotlin.android.synthetic.test.AbstractAndroidBoxTest +import org.jetbrains.kotlin.android.synthetic.test.AbstractAndroidBytecodeShapeTest +import org.jetbrains.kotlin.android.synthetic.test.AbstractAndroidSyntheticPropertyDescriptorTest +import org.jetbrains.kotlin.checkers.AbstractJavaAgainstKotlinBinariesCheckerTest +import org.jetbrains.kotlin.checkers.AbstractJavaAgainstKotlinSourceCheckerTest +import org.jetbrains.kotlin.checkers.AbstractJsCheckerTest +import org.jetbrains.kotlin.checkers.AbstractPsiCheckerTest +import org.jetbrains.kotlin.findUsages.AbstractFindUsagesTest +import org.jetbrains.kotlin.findUsages.AbstractKotlinFindUsagesWithLibraryTest +import org.jetbrains.kotlin.formatter.AbstractFormatterTest +import org.jetbrains.kotlin.formatter.AbstractTypingIndentationTestBase +import org.jetbrains.kotlin.generators.tests.generator.TestGroup +import org.jetbrains.kotlin.generators.tests.generator.testGroup +import org.jetbrains.kotlin.generators.util.KT_OR_KTS +import org.jetbrains.kotlin.generators.util.KT_OR_KTS_WITHOUT_DOTS_IN_NAME +import org.jetbrains.kotlin.generators.util.KT_WITHOUT_DOTS_IN_NAME +import org.jetbrains.kotlin.idea.AbstractExpressionSelectionTest +import org.jetbrains.kotlin.idea.AbstractKotlinTypeAliasByExpansionShortNameIndexTest +import org.jetbrains.kotlin.idea.AbstractSmartSelectionTest +import org.jetbrains.kotlin.idea.actions.AbstractGotoTestOrCodeActionTest +import org.jetbrains.kotlin.idea.caches.resolve.AbstractIdeCompiledLightClassTest +import org.jetbrains.kotlin.idea.caches.resolve.AbstractIdeLightClassTest +import org.jetbrains.kotlin.idea.caches.resolve.AbstractMultiModuleLineMarkerTest +import org.jetbrains.kotlin.idea.caches.resolve.AbstractMultiPlatformHighlightingTest +import org.jetbrains.kotlin.idea.codeInsight.* +import org.jetbrains.kotlin.idea.codeInsight.generate.AbstractCodeInsightActionTest +import org.jetbrains.kotlin.idea.codeInsight.generate.AbstractGenerateHashCodeAndEqualsActionTest +import org.jetbrains.kotlin.idea.codeInsight.generate.AbstractGenerateTestSupportMethodActionTest +import org.jetbrains.kotlin.idea.codeInsight.generate.AbstractGenerateToStringActionTest +import org.jetbrains.kotlin.idea.codeInsight.moveUpDown.AbstractMoveLeftRightTest +import org.jetbrains.kotlin.idea.codeInsight.moveUpDown.AbstractMoveStatementTest +import org.jetbrains.kotlin.idea.codeInsight.postfix.AbstractPostfixTemplateProviderTest +import org.jetbrains.kotlin.idea.codeInsight.surroundWith.AbstractSurroundWithTest +import org.jetbrains.kotlin.idea.codeInsight.unwrap.AbstractUnwrapRemoveTest +import org.jetbrains.kotlin.idea.completion.test.* +import org.jetbrains.kotlin.idea.completion.test.handlers.AbstractBasicCompletionHandlerTest +import org.jetbrains.kotlin.idea.completion.test.handlers.AbstractCompletionCharFilterTest +import org.jetbrains.kotlin.idea.completion.test.handlers.AbstractKeywordCompletionHandlerTest +import org.jetbrains.kotlin.idea.completion.test.handlers.AbstractSmartCompletionHandlerTest +import org.jetbrains.kotlin.idea.completion.test.weighers.AbstractBasicCompletionWeigherTest +import org.jetbrains.kotlin.idea.completion.test.weighers.AbstractSmartCompletionWeigherTest +import org.jetbrains.kotlin.idea.configuration.AbstractGradleConfigureProjectByChangingFileTest +import org.jetbrains.kotlin.idea.conversion.copy.AbstractJavaToKotlinCopyPasteConversionTest +import org.jetbrains.kotlin.idea.conversion.copy.AbstractLiteralKotlinToKotlinCopyPasteTest +import org.jetbrains.kotlin.idea.conversion.copy.AbstractLiteralTextToKotlinCopyPasteTest +import org.jetbrains.kotlin.idea.conversion.copy.AbstractTextJavaToKotlinCopyPasteConversionTest +import org.jetbrains.kotlin.idea.coverage.AbstractKotlinCoverageOutputFilesTest +import org.jetbrains.kotlin.idea.debugger.AbstractBeforeExtractFunctionInsertionTest +import org.jetbrains.kotlin.idea.debugger.AbstractKotlinSteppingTest +import org.jetbrains.kotlin.idea.debugger.AbstractPositionManagerTest +import org.jetbrains.kotlin.idea.debugger.AbstractSmartStepIntoTest +import org.jetbrains.kotlin.idea.debugger.evaluate.* +import org.jetbrains.kotlin.idea.decompiler.navigation.AbstractNavigateToDecompiledLibraryTest +import org.jetbrains.kotlin.idea.decompiler.navigation.AbstractNavigateToLibrarySourceTest +import org.jetbrains.kotlin.idea.decompiler.stubBuilder.AbstractClsStubBuilderTest +import org.jetbrains.kotlin.idea.decompiler.stubBuilder.AbstractLoadJavaClsStubTest +import org.jetbrains.kotlin.idea.decompiler.textBuilder.AbstractCommonDecompiledTextFromJsMetadataTest +import org.jetbrains.kotlin.idea.decompiler.textBuilder.AbstractCommonDecompiledTextTest +import org.jetbrains.kotlin.idea.decompiler.textBuilder.AbstractJsDecompiledTextFromJsMetadataTest +import org.jetbrains.kotlin.idea.decompiler.textBuilder.AbstractJvmDecompiledTextTest +import org.jetbrains.kotlin.idea.editor.AbstractMultiLineStringIndentTest +import org.jetbrains.kotlin.idea.editor.backspaceHandler.AbstractBackspaceHandlerTest +import org.jetbrains.kotlin.idea.editor.quickDoc.AbstractQuickDocProviderTest +import org.jetbrains.kotlin.idea.filters.AbstractKotlinExceptionFilterTest +import org.jetbrains.kotlin.idea.folding.AbstractKotlinFoldingTest +import org.jetbrains.kotlin.idea.hierarchy.AbstractHierarchyTest +import org.jetbrains.kotlin.idea.hierarchy.AbstractHierarchyWithLibTest +import org.jetbrains.kotlin.idea.highlighter.* +import org.jetbrains.kotlin.idea.imports.AbstractJsOptimizeImportsTest +import org.jetbrains.kotlin.idea.imports.AbstractJvmOptimizeImportsTest +import org.jetbrains.kotlin.idea.inspections.AbstractLocalInspectionTest +import org.jetbrains.kotlin.idea.inspections.AbstractMultiFileLocalInspectionTest +import org.jetbrains.kotlin.idea.intentions.AbstractConcatenatedStringGeneratorTest +import org.jetbrains.kotlin.idea.intentions.AbstractIntentionTest +import org.jetbrains.kotlin.idea.intentions.AbstractIntentionTest2 +import org.jetbrains.kotlin.idea.intentions.AbstractMultiFileIntentionTest +import org.jetbrains.kotlin.idea.intentions.declarations.AbstractJoinLinesTest +import org.jetbrains.kotlin.idea.internal.AbstractBytecodeToolWindowTest +import org.jetbrains.kotlin.idea.kdoc.AbstractKDocHighlightingTest +import org.jetbrains.kotlin.idea.kdoc.AbstractKDocTypingTest +import org.jetbrains.kotlin.idea.navigation.* +import org.jetbrains.kotlin.idea.parameterInfo.AbstractParameterInfoTest +import org.jetbrains.kotlin.idea.quickfix.AbstractQuickFixMultiFileTest +import org.jetbrains.kotlin.idea.quickfix.AbstractQuickFixMultiModuleTest +import org.jetbrains.kotlin.idea.quickfix.AbstractQuickFixTest +import org.jetbrains.kotlin.idea.refactoring.AbstractNameSuggestionProviderTest +import org.jetbrains.kotlin.idea.refactoring.copy.AbstractCopyTest +import org.jetbrains.kotlin.idea.refactoring.copy.AbstractMultiModuleCopyTest +import org.jetbrains.kotlin.idea.refactoring.inline.AbstractInlineTest +import org.jetbrains.kotlin.idea.refactoring.introduce.AbstractExtractionTest +import org.jetbrains.kotlin.idea.refactoring.move.AbstractMoveTest +import org.jetbrains.kotlin.idea.refactoring.move.AbstractMultiModuleMoveTest +import org.jetbrains.kotlin.idea.refactoring.pullUp.AbstractPullUpTest +import org.jetbrains.kotlin.idea.refactoring.pushDown.AbstractPushDownTest +import org.jetbrains.kotlin.idea.refactoring.rename.AbstractMultiModuleRenameTest +import org.jetbrains.kotlin.idea.refactoring.rename.AbstractRenameTest +import org.jetbrains.kotlin.idea.refactoring.safeDelete.AbstractMultiModuleSafeDeleteTest +import org.jetbrains.kotlin.idea.refactoring.safeDelete.AbstractSafeDeleteTest +import org.jetbrains.kotlin.idea.repl.AbstractIdeReplCompletionTest +import org.jetbrains.kotlin.idea.resolve.* +import org.jetbrains.kotlin.idea.scratch.AbstractScratchRunActionTest +import org.jetbrains.kotlin.idea.script.AbstractScriptConfigurationCompletionTest +import org.jetbrains.kotlin.idea.script.AbstractScriptConfigurationHighlightingTest +import org.jetbrains.kotlin.idea.script.AbstractScriptConfigurationNavigationTest +import org.jetbrains.kotlin.idea.script.AbstractScriptDefinitionsOrderTest +import org.jetbrains.kotlin.idea.slicer.AbstractSlicerLeafGroupingTest +import org.jetbrains.kotlin.idea.slicer.AbstractSlicerNullnessGroupingTest +import org.jetbrains.kotlin.idea.slicer.AbstractSlicerTreeTest +import org.jetbrains.kotlin.idea.structureView.AbstractKotlinFileStructureTest +import org.jetbrains.kotlin.idea.stubs.AbstractMultiFileHighlightingTest +import org.jetbrains.kotlin.idea.stubs.AbstractResolveByStubTest +import org.jetbrains.kotlin.idea.stubs.AbstractStubBuilderTest +import org.jetbrains.kotlin.incremental.* +import org.jetbrains.kotlin.j2k.AbstractJavaToKotlinConverterForWebDemoTest +import org.jetbrains.kotlin.j2k.AbstractJavaToKotlinConverterMultiFileTest +import org.jetbrains.kotlin.j2k.AbstractJavaToKotlinConverterSingleFileTest +//import org.jetbrains.kotlin.jps.build.* +//import org.jetbrains.kotlin.jps.build.android.AbstractAndroidJpsTestCase +//import org.jetbrains.kotlin.jps.incremental.AbstractJsProtoComparisonTest +//import org.jetbrains.kotlin.jps.incremental.AbstractJvmProtoComparisonTest +import org.jetbrains.kotlin.kapt3.test.AbstractClassFileToSourceStubConverterTest +import org.jetbrains.kotlin.kapt3.test.AbstractKotlinKaptContextTest +import org.jetbrains.kotlin.noarg.AbstractBlackBoxCodegenTestForNoArg +import org.jetbrains.kotlin.noarg.AbstractBytecodeListingTestForNoArg +import org.jetbrains.kotlin.psi.patternMatching.AbstractPsiUnifierTest +import org.jetbrains.kotlin.samWithReceiver.AbstractSamWithReceiverScriptTest +import org.jetbrains.kotlin.samWithReceiver.AbstractSamWithReceiverTest +import org.jetbrains.kotlin.search.AbstractAnnotatedMembersSearchTest +import org.jetbrains.kotlin.search.AbstractInheritorsSearchTest +import org.jetbrains.kotlin.shortenRefs.AbstractShortenRefsTest +import org.jetbrains.kotlin.test.TargetBackend + +fun main(args: Array) { + System.setProperty("java.awt.headless", "true") + + testGroup("idea/tests", "idea/testData") { + testClass { + model("resolve/additionalLazyResolve") + } + + testClass { + model("resolve/partialBodyResolve") + } + + testClass { + model("checker", recursive = false) + model("checker/regression") + model("checker/recovery") + model("checker/rendering") + model("checker/scripts", extension = "kts") + model("checker/duplicateJvmSignature") + model("checker/infos", testMethod = "doTestWithInfos") + model("checker/diagnosticsMessage") + } + + testClass { + model("kotlinAndJavaChecker/javaAgainstKotlin") + model("kotlinAndJavaChecker/javaWithKotlin") + } + + testClass { + model("kotlinAndJavaChecker/javaAgainstKotlin") + } + + testClass { + model("unifier") + } + + testClass { + model("checker/codeFragments", extension = "kt", recursive = false) + model("checker/codeFragments/imports", testMethod = "doTestWithImport", extension = "kt") + } + + testClass { + model("quickfix.special/codeFragmentAutoImport", extension = "kt", recursive = false) + } + + testClass { + model("checker/js") + } + + testClass { + model("quickfix", pattern = "^([\\w\\-_]+)\\.kt$", filenameStartsLowerCase = true) + } + + testClass { + model("navigation/gotoSuper", extension = "test", recursive = false) + } + + testClass { + model("navigation/gotoTypeDeclaration", extension = "test") + } + + testClass { + model("navigation/gotoDeclaration", extension = "test") + } + + testClass { + model( + "parameterInfo", + pattern = "^([\\w\\-_]+)\\.kt$", recursive = true, + excludeDirs = listOf("withLib1/sharedLib", "withLib2/sharedLib", "withLib3/sharedLib") + ) + } + + testClass { + model("navigation/gotoClass", testMethod = "doClassTest") + model("navigation/gotoSymbol", testMethod = "doSymbolTest") + } + + testClass { + model("decompiler/navigation/usercode") + model("decompiler/navigation/usercode", testClassName ="UsercodeWithJSModule", testMethod = "doWithJSModuleTest") + } + + testClass { + model("decompiler/navigation/usercode") + } + + testClass { + model("navigation/implementations", recursive = false) + } + + testClass { + model("navigation/gotoTestOrCode", pattern = "^(.+)\\.main\\..+\$") + } + + testClass { + model("search/inheritance") + } + + testClass { + model("search/annotations") + } + + testClass { + model("quickfix", pattern = """^(\w+)\.((before\.Main\.\w+)|(test))$""", testMethod = "doTestWithExtraFile") + } + + testClass { + model("typealiasExpansionIndex") + } + + testClass { + model("highlighter") + } + + testClass { + model("dslHighlighter") + } + + testClass { + model("usageHighlighter") + } + + testClass { + model("folding/noCollapse") + model("folding/checkCollapse", testMethod = "doSettingsFoldingTest") + } + + testClass { + model("codeInsight/surroundWith/if", testMethod = "doTestWithIfSurrounder") + model("codeInsight/surroundWith/ifElse", testMethod = "doTestWithIfElseSurrounder") + model("codeInsight/surroundWith/ifElseExpression", testMethod = "doTestWithIfElseExpressionSurrounder") + model("codeInsight/surroundWith/ifElseExpressionBraces", testMethod = "doTestWithIfElseExpressionBracesSurrounder") + model("codeInsight/surroundWith/not", testMethod = "doTestWithNotSurrounder") + model("codeInsight/surroundWith/parentheses", testMethod = "doTestWithParenthesesSurrounder") + model("codeInsight/surroundWith/stringTemplate", testMethod = "doTestWithStringTemplateSurrounder") + model("codeInsight/surroundWith/when", testMethod = "doTestWithWhenSurrounder") + model("codeInsight/surroundWith/tryCatch", testMethod = "doTestWithTryCatchSurrounder") + model("codeInsight/surroundWith/tryCatchExpression", testMethod = "doTestWithTryCatchExpressionSurrounder") + model("codeInsight/surroundWith/tryCatchFinally", testMethod = "doTestWithTryCatchFinallySurrounder") + model("codeInsight/surroundWith/tryCatchFinallyExpression", testMethod = "doTestWithTryCatchFinallyExpressionSurrounder") + model("codeInsight/surroundWith/tryFinally", testMethod = "doTestWithTryFinallySurrounder") + model("codeInsight/surroundWith/functionLiteral", testMethod = "doTestWithFunctionLiteralSurrounder") + model("codeInsight/surroundWith/withIfExpression", testMethod = "doTestWithSurroundWithIfExpression") + model("codeInsight/surroundWith/withIfElseExpression", testMethod = "doTestWithSurroundWithIfElseExpression") + } + + testClass { + model("joinLines") + } + + testClass { + model("codeInsight/breadcrumbs") + } + + testClass { + model("intentions", pattern = "^([\\w\\-_]+)\\.(kt|kts)$") + } + + testClass { + model("intentions/loopToCallChain", pattern = "^([\\w\\-_]+)\\.kt$") + } + + testClass { + model("concatenatedStringGenerator", pattern = "^([\\w\\-_]+)\\.kt$") + } + + testClass { + model("intentions", pattern = "^(inspections\\.test)$", singleClass = true) + model("inspections", pattern = "^(inspections\\.test)$", singleClass = true) + model("inspectionsLocal", pattern = "^(inspections\\.test)$", singleClass = true) + } + + testClass { + model("inspectionsLocal", pattern = "^([\\w\\-_]+)\\.(kt|kts)$") + } + + testClass { + model("hierarchy/class/type", extension = null, recursive = false, testMethod = "doTypeClassHierarchyTest") + model("hierarchy/class/super", extension = null, recursive = false, testMethod = "doSuperClassHierarchyTest") + model("hierarchy/class/sub", extension = null, recursive = false, testMethod = "doSubClassHierarchyTest") + model("hierarchy/calls/callers", extension = null, recursive = false, testMethod = "doCallerHierarchyTest") + model("hierarchy/calls/callersJava", extension = null, recursive = false, testMethod = "doCallerJavaHierarchyTest") + model("hierarchy/calls/callees", extension = null, recursive = false, testMethod = "doCalleeHierarchyTest") + model("hierarchy/overrides", extension = null, recursive = false, testMethod = "doOverrideHierarchyTest") + } + + testClass { + model("hierarchy/withLib", extension = null, recursive = false) + } + + testClass { + model("codeInsight/moveUpDown/classBodyDeclarations", pattern = KT_OR_KTS, testMethod = "doTestClassBodyDeclaration") + model("codeInsight/moveUpDown/closingBraces", testMethod = "doTestExpression") + model("codeInsight/moveUpDown/expressions", pattern = KT_OR_KTS, testMethod = "doTestExpression") + model("codeInsight/moveUpDown/parametersAndArguments", testMethod = "doTestExpression") + } + + testClass { + model("codeInsight/moveLeftRight") + } + + testClass { + model("refactoring/inline", pattern = "^(\\w+)\\.kt$") + } + + testClass { + model("codeInsight/unwrapAndRemove/removeExpression", testMethod = "doTestExpressionRemover") + model("codeInsight/unwrapAndRemove/unwrapThen", testMethod = "doTestThenUnwrapper") + model("codeInsight/unwrapAndRemove/unwrapElse", testMethod = "doTestElseUnwrapper") + model("codeInsight/unwrapAndRemove/removeElse", testMethod = "doTestElseRemover") + model("codeInsight/unwrapAndRemove/unwrapLoop", testMethod = "doTestLoopUnwrapper") + model("codeInsight/unwrapAndRemove/unwrapTry", testMethod = "doTestTryUnwrapper") + model("codeInsight/unwrapAndRemove/unwrapCatch", testMethod = "doTestCatchUnwrapper") + model("codeInsight/unwrapAndRemove/removeCatch", testMethod = "doTestCatchRemover") + model("codeInsight/unwrapAndRemove/unwrapFinally", testMethod = "doTestFinallyUnwrapper") + model("codeInsight/unwrapAndRemove/removeFinally", testMethod = "doTestFinallyRemover") + model("codeInsight/unwrapAndRemove/unwrapLambda", testMethod = "doTestLambdaUnwrapper") + model("codeInsight/unwrapAndRemove/unwrapFunctionParameter", testMethod = "doTestFunctionParameterUnwrapper") + } + + testClass { + model("codeInsight/expressionType") + } + + testClass { + model("editor/backspaceHandler") + } + + testClass { + model("editor/enterHandler/multilineString") + } + + testClass { + model("editor/quickDoc", pattern = """^([^_]+)\.(kt|java)$""") + } + + testClass { + model("refactoring/safeDelete/deleteClass/kotlinClass", testMethod = "doClassTest") + model("refactoring/safeDelete/deleteClass/kotlinClassWithJava", testMethod = "doClassTestWithJava") + model("refactoring/safeDelete/deleteClass/javaClassWithKotlin", extension = "java", testMethod = "doJavaClassTest") + model("refactoring/safeDelete/deleteObject/kotlinObject", testMethod = "doObjectTest") + model("refactoring/safeDelete/deleteFunction/kotlinFunction", testMethod = "doFunctionTest") + model("refactoring/safeDelete/deleteFunction/kotlinFunctionWithJava", testMethod = "doFunctionTestWithJava") + model("refactoring/safeDelete/deleteFunction/javaFunctionWithKotlin", testMethod = "doJavaMethodTest") + model("refactoring/safeDelete/deleteProperty/kotlinProperty", testMethod = "doPropertyTest") + model("refactoring/safeDelete/deleteProperty/kotlinPropertyWithJava", testMethod = "doPropertyTestWithJava") + model("refactoring/safeDelete/deleteProperty/javaPropertyWithKotlin", testMethod = "doJavaPropertyTest") + model("refactoring/safeDelete/deleteTypeAlias/kotlinTypeAlias", testMethod = "doTypeAliasTest") + model("refactoring/safeDelete/deleteTypeParameter/kotlinTypeParameter", testMethod = "doTypeParameterTest") + model("refactoring/safeDelete/deleteTypeParameter/kotlinTypeParameterWithJava", testMethod = "doTypeParameterTestWithJava") + model("refactoring/safeDelete/deleteValueParameter/kotlinValueParameter", testMethod = "doValueParameterTest") + model("refactoring/safeDelete/deleteValueParameter/kotlinValueParameterWithJava", testMethod = "doValueParameterTestWithJava") + } + + testClass { + model("resolve/references", pattern = KT_WITHOUT_DOTS_IN_NAME) + } + + testClass { + model("resolve/referenceInJava/binaryAndSource", extension = "java") + model("resolve/referenceInJava/sourceOnly", extension = "java") + } + + testClass { + model("resolve/referenceInJava/binaryAndSource", extension = "java") + } + + testClass { + model("resolve/referenceWithLib", recursive = false) + } + + testClass { + model("resolve/referenceInLib", recursive = false) + } + + testClass { + model("resolve/referenceToJavaWithWrongFileStructure", recursive = false) + } + + testClass { + model("findUsages/kotlin", pattern = """^(.+)\.0\.(kt|kts)$""") + model("findUsages/java", pattern = """^(.+)\.0\.java$""") + model("findUsages/propertyFiles", pattern = """^(.+)\.0\.properties$""") + } + + testClass { + model("findUsages/libraryUsages", pattern = """^(.+)\.0\.kt$""") + } + + testClass { + model("refactoring/move", extension = "test", singleClass = true) + } + + testClass { + model("refactoring/copy", extension = "test", singleClass = true) + } + + testClass { + model("refactoring/moveMultiModule", extension = "test", singleClass = true) + } + + testClass { + model("refactoring/copyMultiModule", extension = "test", singleClass = true) + } + + testClass { + model("refactoring/safeDeleteMultiModule", extension = "test", singleClass = true) + } + + testClass { + model("multiFileIntentions", extension = "test", singleClass = true, filenameStartsLowerCase = true) + } + + testClass { + model("multiFileLocalInspections", extension = "test", singleClass = true, filenameStartsLowerCase = true) + } + + testClass { + model("multiFileInspections", extension = "test", singleClass = true) + } + + testClass { + model("formatter", pattern = """^([^\.]+)\.after\.kt.*$""") + model("formatter", pattern = """^([^\.]+)\.after\.inv\.kt.*$""", + testMethod = "doTestInverted", testClassName = "FormatterInverted") + } + + testClass { + model("indentationOnNewline", pattern = """^([^\.]+)\.after\.kt.*$""", testMethod = "doNewlineTest", + testClassName = "DirectSettings") + model("indentationOnNewline", pattern = """^([^\.]+)\.after\.inv\.kt.*$""", testMethod = "doNewlineTestWithInvert", + testClassName = "InvertedSettings") + } + + testClass { + model("diagnosticMessage", recursive = false) + } + + testClass { + model("diagnosticMessage/js", recursive = false, targetBackend = TargetBackend.JS) + } + + testClass { + model("refactoring/rename", extension = "test", singleClass = true) + } + + testClass { + model("refactoring/renameMultiModule", extension = "test", singleClass = true) + } + + testClass { + model("codeInsight/outOfBlock") + } + + testClass { + model("dataFlowValueRendering") + } + + testClass { + model("copyPaste/conversion", pattern = """^([^\.]+)\.java$""") + } + + testClass { + model("copyPaste/plainTextConversion", pattern = """^([^\.]+)\.txt$""") + } + + testClass { + model("copyPaste/plainTextLiteral", pattern = """^([^\.]+)\.txt$""") + } + + testClass { + model("copyPaste/literal", pattern = """^([^\.]+)\.kt$""") + } + + testClass { + model("copyPaste/imports", pattern = KT_WITHOUT_DOTS_IN_NAME, testMethod = "doTestCopy", testClassName = "Copy", recursive = false) + model("copyPaste/imports", pattern = KT_WITHOUT_DOTS_IN_NAME, testMethod = "doTestCut", testClassName = "Cut", recursive = false) + } + + testClass { + model("copyPaste/moveDeclarations", pattern = KT_WITHOUT_DOTS_IN_NAME, testMethod = "doTest") + } + + testClass { + model("exitPoints") + } + + testClass { + model("codeInsight/lineMarker") + } + + testClass { + model("codeInsightInLibrary/lineMarker", testMethod = "doTestWithLibrary") + } + + testClass { + model("multiModuleLineMarker", extension = null, recursive = false) + } + + testClass { + model("shortenRefs", pattern = KT_WITHOUT_DOTS_IN_NAME) + } + testClass { + model("addImport", pattern = KT_WITHOUT_DOTS_IN_NAME) + } + + testClass { + model("smartSelection", testMethod = "doTestSmartSelection", pattern = KT_WITHOUT_DOTS_IN_NAME) + } + + testClass { + model("structureView/fileStructure", pattern = KT_WITHOUT_DOTS_IN_NAME) + } + + testClass { + model("expressionSelection", testMethod = "doTestExpressionSelection", pattern = KT_WITHOUT_DOTS_IN_NAME) + } + + testClass { + model("decompiler/decompiledText", pattern = """^([^\.]+)$""") + } + + testClass { + model("decompiler/decompiledTextJvm", pattern = """^([^\.]+)$""") + } + + testClass { + model("decompiler/decompiledText", pattern = """^([^\.]+)$""", targetBackend = TargetBackend.JS) + } + + testClass { + model("decompiler/decompiledTextJs", pattern = """^([^\.]+)$""", targetBackend = TargetBackend.JS) + } + + testClass { + model("decompiler/stubBuilder", extension = null, recursive = false) + } + + testClass { + model("editor/optimizeImports/jvm", pattern = KT_OR_KTS_WITHOUT_DOTS_IN_NAME) + model("editor/optimizeImports/common", pattern = KT_WITHOUT_DOTS_IN_NAME) + } + testClass { + model("editor/optimizeImports/js", pattern = KT_WITHOUT_DOTS_IN_NAME) + model("editor/optimizeImports/common", pattern = KT_WITHOUT_DOTS_IN_NAME) + } + + testClass { + model("debugger/positionManager", recursive = false, extension = "kt", testClassName = "SingleFile") + model("debugger/positionManager", recursive = false, extension = null, testClassName = "MultiFile") + } + + testClass { + model("debugger/exceptionFilter", pattern = """^([^\.]+)$""", recursive = false) + } + + testClass { + model("debugger/smartStepInto") + } + + testClass { + model("debugger/insertBeforeExtractFunction", extension = "kt") + } + + testClass { + model("debugger/tinyApp/src/stepping/stepIntoAndSmartStepInto", pattern = KT_WITHOUT_DOTS_IN_NAME, testMethod = "doStepIntoTest", testClassName = "StepInto") + model("debugger/tinyApp/src/stepping/stepIntoAndSmartStepInto", pattern = KT_WITHOUT_DOTS_IN_NAME, testMethod = "doSmartStepIntoTest", testClassName = "SmartStepInto") + model("debugger/tinyApp/src/stepping/stepInto", pattern = KT_WITHOUT_DOTS_IN_NAME, testMethod = "doStepIntoTest", testClassName = "StepIntoOnly") + model("debugger/tinyApp/src/stepping/stepOut", pattern = KT_WITHOUT_DOTS_IN_NAME, testMethod = "doStepOutTest") + model("debugger/tinyApp/src/stepping/stepOver", pattern = KT_WITHOUT_DOTS_IN_NAME, testMethod = "doStepOverTest") + model("debugger/tinyApp/src/stepping/stepOverForce", pattern = KT_WITHOUT_DOTS_IN_NAME, testMethod = "doStepOverForceTest") + model("debugger/tinyApp/src/stepping/filters", pattern = KT_WITHOUT_DOTS_IN_NAME, testMethod = "doStepIntoTest") + model("debugger/tinyApp/src/stepping/custom", pattern = KT_WITHOUT_DOTS_IN_NAME, testMethod = "doCustomTest") + } + + testClass { + model("debugger/tinyApp/src/evaluate/singleBreakpoint", testMethod = "doSingleBreakpointTest") + model("debugger/tinyApp/src/evaluate/multipleBreakpoints", testMethod = "doMultipleBreakpointsTest") + } + + testClass { + model("stubs", extension = "kt") + } + + testClass { + model("multiFileHighlighting", recursive = false) + } + + testClass { + model("multiModuleHighlighting/multiplatform/", recursive = false, extension = null) + } + + testClass { + model("multiModuleQuickFix", recursive = false, extension = null) + } + + testClass { + model("navigation/implementations/multiModule", recursive = false, extension = null) + } + + testClass { + model("navigation/relatedSymbols/multiModule", recursive = false, extension = null) + } + + testClass { + model("navigation/gotoSuper/multiModule", recursive = false, extension = null) + } + + testClass { + model("refactoring/introduceVariable", pattern = KT_OR_KTS, testMethod = "doIntroduceVariableTest") + model("refactoring/extractFunction", pattern = KT_OR_KTS, testMethod = "doExtractFunctionTest") + model("refactoring/introduceProperty", pattern = KT_OR_KTS, testMethod = "doIntroducePropertyTest") + model("refactoring/introduceParameter", pattern = KT_OR_KTS, testMethod = "doIntroduceSimpleParameterTest") + model("refactoring/introduceLambdaParameter", pattern = KT_OR_KTS, testMethod = "doIntroduceLambdaParameterTest") + model("refactoring/introduceJavaParameter", extension = "java", testMethod = "doIntroduceJavaParameterTest") + model("refactoring/introduceTypeParameter", pattern = KT_OR_KTS, testMethod = "doIntroduceTypeParameterTest") + model("refactoring/introduceTypeAlias", pattern = KT_OR_KTS, testMethod = "doIntroduceTypeAliasTest") + model("refactoring/extractSuperclass", pattern = KT_OR_KTS_WITHOUT_DOTS_IN_NAME, testMethod = "doExtractSuperclassTest") + model("refactoring/extractInterface", pattern = KT_OR_KTS_WITHOUT_DOTS_IN_NAME, testMethod = "doExtractInterfaceTest") + } + + testClass { + model("refactoring/pullUp/k2k", extension = "kt", singleClass = true, testClassName = "K2K", testMethod = "doKotlinTest") + model("refactoring/pullUp/k2j", extension = "kt", singleClass = true, testClassName = "K2J", testMethod = "doKotlinTest") + model("refactoring/pullUp/j2k", extension = "java", singleClass = true, testClassName = "J2K", testMethod = "doJavaTest") + } + + testClass { + model("refactoring/pushDown/k2k", extension = "kt", singleClass = true, testClassName = "K2K", testMethod = "doKotlinTest") + model("refactoring/pushDown/k2j", extension = "kt", singleClass = true, testClassName = "K2J", testMethod = "doKotlinTest") + model("refactoring/pushDown/j2k", extension = "java", singleClass = true, testClassName = "J2K", testMethod = "doJavaTest") + } + + testClass { + model("debugger/selectExpression", recursive = false) + model("debugger/selectExpression/disallowMethodCalls", testMethod = "doTestWoMethodCalls") + } + + testClass { + model("coverage/outputFiles") + } + + testClass { + model("internal/toolWindow", recursive = false, extension = null) + } + + testClass("org.jetbrains.kotlin.idea.kdoc.KdocResolveTestGenerated") { + model("kdoc/resolve") + } + + testClass { + model("kdoc/highlighting") + } + + testClass { + model("kdoc/typing") + } + + testClass { + model("codeInsight/generate/testFrameworkSupport") + } + + testClass { + model("codeInsight/generate/equalsWithHashCode") + } + + testClass { + model("codeInsight/generate/secondaryConstructors") + } + + testClass { + model("codeInsight/generate/toString") + } + + testClass { + model("repl/completion") + } + + testClass { + model("codeInsight/postfix") + } + + testClass { + model("script/definition/highlighting", extension = null, recursive = false) + model("script/definition/complex", extension = null, recursive = false, testMethod = "doComplexTest") + } + + testClass { + model("script/definition/navigation", extension = null, recursive = false) + } + + testClass { + model("script/definition/completion", extension = null, recursive = false) + } + + testClass { + model("script/definition/order", extension = null, recursive = false) + } + + testClass { + model("refactoring/nameSuggestionProvider") + } + + testClass { + model("slicer", singleClass = true) + } + + testClass { + model("slicer/inflow", singleClass = true) + } + + testClass { + model("slicer/inflow", singleClass = true) + } + + testClass { + model("scratch", extension = "kts", testMethod = "doCompilingTest", testClassName = "Compiling", recursive = false) + model("scratch", extension = "kts", testMethod = "doReplTest", testClassName = "Repl", recursive = false) + model("scratch/multiFile", extension = null, testMethod = "doMultiFileTest", recursive = false) + } + } + + /* + // Maven and Gradle are not relevent for AS branch + + testGroup("idea/idea-maven/test", "idea/idea-maven/testData") { + testClass { + model("configurator/jvm", extension = null, recursive = false, testMethod = "doTestWithMaven") + model("configurator/js", extension = null, recursive = false, testMethod = "doTestWithJSMaven") + } + + testClass { + model("maven-inspections", pattern = "^([\\w\\-]+).xml$", singleClass = true) + } + } + + testGroup("idea/idea-gradle/tests", "idea/testData") { + testClass { + model("configuration/gradle", extension = null, recursive = false, testMethod = "doTestGradle") + model("configuration/gsk", extension = null, recursive = false, testMethod = "doTestGradle") + } + } + + */ + + testGroup("idea/tests", "compiler/testData") { + testClass { + model("loadJava/compiledKotlin") + } + + testClass { + model("loadJava/compiledKotlin", testMethod = "doTestCompiledKotlin") + } + + testClass { + model("asJava/lightClasses", excludeDirs = listOf("delegation"), pattern = KT_OR_KTS_WITHOUT_DOTS_IN_NAME) + } + + testClass { + model("asJava/lightClasses", excludeDirs = listOf("local", "compilationErrors", "ideRegression"), pattern = KT_OR_KTS_WITHOUT_DOTS_IN_NAME) + } + } + + testGroup("idea/idea-completion/tests", "idea/idea-completion/testData") { + testClass { + model("injava", extension = "java", recursive = false) + } + + testClass { + model("injava", extension = "java", recursive = false) + } + + testClass { + model("injava/stdlib", extension = "java", recursive = false) + } + + testClass { + model("weighers/basic", pattern = KT_OR_KTS_WITHOUT_DOTS_IN_NAME) + } + + testClass { + model("weighers/smart", pattern = KT_WITHOUT_DOTS_IN_NAME) + } + + testClass { + model("basic/common") + model("basic/js") + } + + testClass { + model("basic/common") + model("basic/java") + } + + testClass { + model("smart") + } + + testClass { + model("keywords", recursive = false) + } + + testClass { + model("basic/withLib", recursive = false) + } + + testClass { + model("handlers/basic", pattern = KT_WITHOUT_DOTS_IN_NAME) + } + + testClass { + model("handlers/smart") + } + + testClass { + model("handlers/keywords") + } + + testClass { + model("handlers/charFilter") + } + + testClass { + model("basic/multifile", extension = null, recursive = false) + } + + testClass { + model("smartMultiFile", extension = null, recursive = false) + } + + testClass("KDocCompletionTestGenerated") { + model("kdoc") + } + + testClass { + model("basic/java8") + } + + testClass { + model("incrementalResolve") + } + + testClass { + model("multiPlatform", recursive = false, extension = null) + } + } + + //TODO: move these tests into idea-completion module + testGroup("idea/tests", "idea/idea-completion/testData") { + testClass { + model("handlers/runtimeCast") + } + + testClass { + model("basic/codeFragments", extension = "kt") + } + } + + testGroup("j2k/tests", "j2k/testData") { + testClass { + model("fileOrElement", extension = "java") + } + } + testGroup("j2k/tests", "j2k/testData") { + testClass { + model("multiFile", extension = null, recursive = false) + } + } + testGroup("j2k/tests", "j2k/testData") { + testClass { + model("fileOrElement", extension = "java") + } + } +/* There is no jps in AS + .... +*/ + testGroup("compiler/incremental-compilation-impl/test", "jps-plugin/testData") { + testClass { + model("incremental/pureKotlin", extension = null, recursive = false) + model("incremental/classHierarchyAffected", extension = null, recursive = false) + model("incremental/inlineFunCallSite", extension = null, excludeParentDirs = true) + model("incremental/withJava", extension = null, excludeParentDirs = true) + model("incremental/incrementalJvmCompilerOnly", extension = null, excludeParentDirs = true) + } + + testClass { + model("incremental/pureKotlin", extension = null, recursive = false) + model("incremental/classHierarchyAffected", extension = null, recursive = false) + model("incremental/js", extension = null, excludeParentDirs = true) + } + + testClass { + model("incremental/js/friendsModuleDisabled", extension = null, recursive = false) + } + + testClass { + model("incremental/multiplatform/singleModule", extension = null, excludeParentDirs = true) + } + testClass { + model("incremental/multiplatform/singleModule", extension = null, excludeParentDirs = true) + } + } + + testGroup("plugins/android-extensions/android-extensions-compiler/test", "plugins/android-extensions/android-extensions-compiler/testData") { + testClass { + model("descriptors", recursive = false, extension = null) + } + + testClass { + model("codegen/android", recursive = false, extension = null, testMethod = "doCompileAgainstAndroidSdkTest") + model("codegen/android", recursive = false, extension = null, testMethod = "doFakeInvocationTest", testClassName = "Invoke") + } + + testClass { + model("codegen/bytecodeShape", recursive = false, extension = null) + } + + testClass { + model("parcel/codegen") + } + } + + testGroup("plugins/kapt3/kapt3-compiler/test", "plugins/kapt3/kapt3-compiler/testData") { + testClass { + model("converter") + } + + testClass { + model("kotlinRunner") + } + } + + testGroup("plugins/allopen/allopen-cli/test", "plugins/allopen/allopen-cli/testData") { + testClass { + model("bytecodeListing", extension = "kt") + } + } + + testGroup("plugins/noarg/noarg-cli/test", "plugins/noarg/noarg-cli/testData") { + testClass { + model("bytecodeListing", extension = "kt") + } + + testClass { + model("box", targetBackend = TargetBackend.JVM) + } + } + + testGroup("plugins/sam-with-receiver/sam-with-receiver-cli/test", "plugins/sam-with-receiver/sam-with-receiver-cli/testData") { + testClass { + model("diagnostics") + } + testClass { + model("script", extension = "kts") + } + } +/* + testGroup("plugins/android-extensions/android-extensions-idea/tests", "plugins/android-extensions/android-extensions-idea/testData") { + testClass { + model("android/completion", recursive = false, extension = null) + } + + testClass { + model("android/goto", recursive = false, extension = null) + } + + testClass { + model("android/rename", recursive = false, extension = null) + } + + testClass { + model("android/renameLayout", recursive = false, extension = null) + } + + testClass { + model("android/findUsages", recursive = false, extension = null) + } + + testClass { + model("android/usageHighlighting", recursive = false, extension = null) + } + + testClass { + model("android/extraction", recursive = false, extension = null) + } + + testClass { + model("android/parcel/checker", excludeParentDirs = true) + } + + testClass { + model("android/parcel/quickfix", pattern = """^(\w+)\.((before\.Main\.\w+)|(test))$""", testMethod = "doTestWithExtraFile") + } + } + + testGroup("idea/idea-android/tests", "idea/testData") { + testClass { + model("configuration/android-gradle", pattern = """(\w+)_before\.gradle$""", testMethod = "doTestAndroidGradle") + model("configuration/android-gsk", pattern = """(\w+)_before\.gradle.kts$""", testMethod = "doTestAndroidGradle") + } + + testClass { + model("android/intention", pattern = "^([\\w\\-_]+)\\.kt$") + } + + testClass { + model("android/resourceIntention", extension = "test", singleClass = true) + } + + testClass { + model("android/quickfix", pattern = """^(\w+)\.((before\.Main\.\w+)|(test))$""", testMethod = "doTestWithExtraFile") + } + + testClass { + model("android/lint", excludeParentDirs = true) + } + + testClass { + model("android/lintQuickfix", pattern = "^([\\w\\-_]+)\\.kt$") + } + + testClass { + model("android/folding") + } + + testClass { + model("android/gutterIcon") + } + } + + testGroup("plugins/android-extensions/android-extensions-jps/test", "plugins/android-extensions/android-extensions-jps/testData") { + testClass { + model("android", recursive = false, extension = null) + } + } +*/ +} diff --git a/gradle.properties.as34 b/gradle.properties.as34 new file mode 100644 index 00000000000..79f347b5f28 --- /dev/null +++ b/gradle.properties.as34 @@ -0,0 +1,16 @@ +org.gradle.daemon=true +org.gradle.parallel=false +org.gradle.configureondemand=false +org.gradle.jvmargs=-Duser.country=US -Dkotlin.daemon.jvm.options=-Xmx1600m + +cacheRedirectorEnabled=true + +kotlin.compiler.effectSystemEnabled=true +kotlin.compiler.newInferenceEnabled=true +#maven.repository.mirror=http://repository.jetbrains.com/remote-repos/ +#bootstrap.kotlin.repo=https://dl.bintray.com/kotlin/kotlin-dev +#bootstrap.kotlin.version=1.1.50-dev-1451 +#signingRequired=true + +intellijUltimateEnabled=false +intellijEnforceCommunitySdk=true \ No newline at end of file diff --git a/idea/build.gradle.kts.as34 b/idea/build.gradle.kts.as34 new file mode 100644 index 00000000000..b7a7e7639b2 --- /dev/null +++ b/idea/build.gradle.kts.as34 @@ -0,0 +1,196 @@ +import org.gradle.jvm.tasks.Jar + +plugins { + kotlin("jvm") + id("jps-compatible") +} + +repositories.withRedirector(project) { + maven("https://jetbrains.bintray.com/markdown") +} + +dependencies { + testRuntime(intellijDep()) + + compile(project(":kotlin-stdlib-jre8")) + compileOnly(project(":kotlin-reflect-api")) + compile(project(":core:descriptors")) + compile(project(":core:descriptors.jvm")) + compile(project(":compiler:backend")) + compile(project(":compiler:cli-common")) + compile(project(":compiler:frontend")) + compile(project(":compiler:frontend.java")) + compile(project(":compiler:frontend.script")) + compile(project(":js:js.frontend")) + compile(project(":js:js.serializer")) + compile(project(":compiler:light-classes")) + compile(project(":compiler:util")) + compile(project(":kotlin-build-common")) + compile(project(":compiler:daemon-common")) + compile(projectRuntimeJar(":kotlin-daemon-client")) + compile(project(":kotlin-compiler-runner")) { isTransitive = false } + compile(project(":compiler:plugin-api")) + compile(project(":eval4j")) + compile(project(":j2k")) + compile(project(":idea:formatter")) + compile(project(":idea:idea-core")) + compile(project(":idea:ide-common")) + compile(project(":idea:idea-jps-common")) + compile(project(":idea:kotlin-gradle-tooling")) + compile(project(":plugins:uast-kotlin")) + compile(project(":plugins:uast-kotlin-idea")) + compile(project(":kotlin-script-util")) { isTransitive = false } + compile(project(":kotlin-scripting-intellij")) + + compile(commonDep("org.jetbrains.kotlinx", "kotlinx-coroutines-core")) { isTransitive = false } + + compileOnly(project(":kotlin-daemon-client")) + + compileOnly(intellijDep()) + compileOnly(commonDep("org.jetbrains", "markdown")) + compileOnly(commonDep("com.google.code.findbugs", "jsr305")) + compileOnly(intellijPluginDep("IntelliLang")) + compileOnly(intellijPluginDep("copyright")) + compileOnly(intellijPluginDep("properties")) + compileOnly(intellijPluginDep("java-i18n")) + + testCompile(project(":kotlin-test:kotlin-test-junit")) + testCompile(projectTests(":compiler:tests-common")) + testCompile(projectTests(":idea:idea-test-framework")) { isTransitive = false } + testCompile(project(":idea:idea-jvm")) { isTransitive = false } + testCompile(project(":idea:idea-gradle")) { isTransitive = false } + testCompile(project(":idea:idea-maven")) { isTransitive = false } + testCompile(project(":idea:idea-native")) { isTransitive = false } + testCompile(project(":idea:idea-gradle-native")) { isTransitive = false } + testCompile(commonDep("junit:junit")) + + testRuntime(project(":kotlin-native:kotlin-native-library-reader")) { isTransitive = false } + testRuntime(project(":kotlin-native:kotlin-native-utils")) { isTransitive = false } + + testRuntime(commonDep("org.jetbrains", "markdown")) + testRuntime(project(":plugins:kapt3-idea")) { isTransitive = false } + testRuntime(project(":kotlin-reflect")) + testRuntime(project(":kotlin-preloader")) + + testCompile(project(":kotlin-sam-with-receiver-compiler-plugin")) { isTransitive = false } + + testRuntime(project(":plugins:android-extensions-compiler")) + testRuntime(project(":plugins:android-extensions-ide")) { isTransitive = false } + testRuntime(project(":allopen-ide-plugin")) { isTransitive = false } + testRuntime(project(":kotlin-allopen-compiler-plugin")) + testRuntime(project(":noarg-ide-plugin")) { isTransitive = false } + testRuntime(project(":kotlin-noarg-compiler-plugin")) + testRuntime(project(":plugins:annotation-based-compiler-plugins-ide-support")) { isTransitive = false } + testRuntime(project(":kotlin-scripting-idea")) { isTransitive = false } + testRuntime(project(":kotlin-scripting-compiler")) + testRuntime(project(":sam-with-receiver-ide-plugin")) { isTransitive = false } + testRuntime(project(":kotlinx-serialization-compiler-plugin")) + testRuntime(project(":kotlinx-serialization-ide-plugin")) { isTransitive = false } + testRuntime(project(":idea:idea-android")) { isTransitive = false } + testRuntime(project(":plugins:lint")) { isTransitive = false } + testRuntime(project(":plugins:uast-kotlin")) + + (rootProject.extra["compilerModules"] as Array).forEach { + testRuntime(project(it)) + } + + testCompile(intellijPluginDep("IntelliLang")) + testCompile(intellijPluginDep("copyright")) + testCompile(intellijPluginDep("properties")) + testCompile(intellijPluginDep("java-i18n")) + testCompile(intellijPluginDep("stream-debugger")) + testCompileOnly(intellijDep()) + testCompileOnly(commonDep("com.google.code.findbugs", "jsr305")) + testCompileOnly(intellijPluginDep("gradle")) + testCompileOnly(intellijPluginDep("Groovy")) + //testCompileOnly(intellijPluginDep("maven")) + + testRuntime(intellijPluginDep("junit")) + testRuntime(intellijPluginDep("gradle")) + testRuntime(intellijPluginDep("Groovy")) + testRuntime(intellijPluginDep("coverage")) + //testRuntime(intellijPluginDep("maven")) + testRuntime(intellijPluginDep("android")) + testRuntime(intellijPluginDep("smali")) + testRuntime(intellijPluginDep("testng")) +} + +sourceSets { + "main" { + projectDefault() + java.srcDirs( + "idea-completion/src", + "idea-live-templates/src", + "idea-repl/src" + ) + resources.srcDirs("idea-repl/src").apply { include("META-INF/**") } + } + "test" { + projectDefault() + java.srcDirs( + "idea-completion/tests", + "idea-live-templates/tests" + ) + } + +} + +val performanceTestCompile by configurations.creating { + extendsFrom(configurations["testCompile"]) +} + +val performanceTestRuntime by configurations.creating { + extendsFrom(configurations["testRuntime"]) +} + +val performanceTest by run { + sourceSets.creating { + compileClasspath += sourceSets["test"].output + compileClasspath += sourceSets["main"].output + runtimeClasspath += sourceSets["test"].output + runtimeClasspath += sourceSets["main"].output + java.srcDirs("performanceTests") + } +} + +projectTest { + dependsOn(":dist") + workingDir = rootDir +} + + +projectTest(taskName = "performanceTest") { + dependsOn(":dist") + dependsOn(performanceTest.output) + testClassesDirs = performanceTest.output.classesDirs + classpath = performanceTest.runtimeClasspath + workingDir = rootDir + + jvmArgs?.removeAll { it.startsWith("-Xmx") } + + maxHeapSize = "3g" + jvmArgs("-XX:SoftRefLRUPolicyMSPerMB=50") + jvmArgs( + "-XX:ReservedCodeCacheSize=240m", + "-XX:+UseCompressedOops", + "-XX:+UseConcMarkSweepGC" + ) + jvmArgs("-XX:+UnlockCommercialFeatures", "-XX:+FlightRecorder") + + if (hasProperty("perf.flight.recorder.override")) { + jvmArgs(property("perf.flight.recorder.override")) + } else { + val settings = if (hasProperty("perf.flight.recorder.settings")) ",settings=${property("perf.flight.recorder.settings")}" else "" + jvmArgs("-XX:StartFlightRecording=delay=15m,duration=5h,filename=perf.jfr$settings") + } + + doFirst { + systemProperty("idea.home.path", intellijRootDir().canonicalPath) + } +} + +testsJar {} + +classesDirsArtifact() +configureInstrumentation() + diff --git a/idea/idea-android/idea-android-output-parser/build.gradle.kts.as34 b/idea/idea-android/idea-android-output-parser/build.gradle.kts.as34 new file mode 100644 index 00000000000..f4a76a3ba5f --- /dev/null +++ b/idea/idea-android/idea-android-output-parser/build.gradle.kts.as34 @@ -0,0 +1,25 @@ + +plugins { + kotlin("jvm") +} + +apply { plugin("jps-compatible") } + +dependencies { + compile(project(":compiler:util")) + compileOnly(intellijCoreDep()) { includeJars("intellij-core") } + compileOnly(intellijDep()) + compileOnly(intellijPluginDep("gradle")) + compileOnly(intellijPluginDep("android")) +} + +sourceSets { + "main" {} + "test" {} +} + +runtimeJar { + archiveName = "android-output-parser-ide.jar" +} + +ideaPlugin() diff --git a/idea/idea-git/src/org/jetbrains/kotlin/git/KotlinExplicitMovementProvider.kt.as34 b/idea/idea-git/src/org/jetbrains/kotlin/git/KotlinExplicitMovementProvider.kt.as34 new file mode 100644 index 00000000000..e69de29bb2d diff --git a/idea/idea-gradle/build.gradle.kts.as34 b/idea/idea-gradle/build.gradle.kts.as34 new file mode 100644 index 00000000000..dbf27511683 --- /dev/null +++ b/idea/idea-gradle/build.gradle.kts.as34 @@ -0,0 +1,75 @@ +plugins { + kotlin("jvm") + id("jps-compatible") +} + +dependencies { + testRuntime(intellijDep()) + + compileOnly(project(":idea")) + compileOnly(project(":idea:idea-jvm")) + compile(project(":idea:kotlin-gradle-tooling")) + + compile(project(":compiler:frontend")) + compile(project(":compiler:frontend.java")) + compile(project(":compiler:frontend.script")) + + compile(project(":js:js.frontend")) + + compileOnly(intellijDep()) + compileOnly(intellijPluginDep("gradle")) + compileOnly(intellijPluginDep("Groovy")) + compileOnly(intellijPluginDep("junit")) + compileOnly(intellijPluginDep("testng")) + + testCompile(projectTests(":idea")) + testCompile(projectTests(":idea:idea-test-framework")) + + testCompile(intellijPluginDep("gradle")) + testCompileOnly(intellijPluginDep("Groovy")) + testCompileOnly(intellijDep()) + + testCompile(project(":idea:idea-native")) { isTransitive = false } + testCompile(project(":idea:idea-gradle-native")) { isTransitive = false } + testRuntime(project(":kotlin-native:kotlin-native-library-reader")) { isTransitive = false } + testRuntime(project(":kotlin-native:kotlin-native-utils")) { isTransitive = false } + + testRuntime(project(":kotlin-reflect")) + testRuntime(project(":idea:idea-jvm")) + testRuntime(project(":idea:idea-android")) + testRuntime(project(":plugins:kapt3-idea")) + testRuntime(project(":plugins:android-extensions-ide")) + testRuntime(project(":plugins:lint")) + testRuntime(project(":sam-with-receiver-ide-plugin")) + testRuntime(project(":allopen-ide-plugin")) + testRuntime(project(":noarg-ide-plugin")) + testRuntime(project(":kotlin-scripting-idea")) + testRuntime(project(":kotlinx-serialization-ide-plugin")) + // TODO: the order of the plugins matters here, consider avoiding order-dependency + testRuntime(intellijPluginDep("junit")) + testRuntime(intellijPluginDep("testng")) + testRuntime(intellijPluginDep("properties")) + testRuntime(intellijPluginDep("gradle")) + testRuntime(intellijPluginDep("Groovy")) + testRuntime(intellijPluginDep("coverage")) + //testRuntime(intellijPluginDep("maven")) + testRuntime(intellijPluginDep("android")) + testRuntime(intellijPluginDep("smali")) +} + +sourceSets { + "main" { + projectDefault() + resources.srcDir("res") + } + "test" { projectDefault() } +} + +testsJar() + +projectTest { + workingDir = rootDir + useAndroidSdk() +} + +configureInstrumentation() diff --git a/idea/idea-gradle/tests/org/jetbrains/kotlin/gradle/GradleMultiplatformWizardTest.kt.as34 b/idea/idea-gradle/tests/org/jetbrains/kotlin/gradle/GradleMultiplatformWizardTest.kt.as34 new file mode 100644 index 00000000000..77ec73ac56a --- /dev/null +++ b/idea/idea-gradle/tests/org/jetbrains/kotlin/gradle/GradleMultiplatformWizardTest.kt.as34 @@ -0,0 +1,9 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. 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.gradle + +class GradleMultiplatformWizardTest : AbstractGradleMultiplatformWizardTest() { +} \ No newline at end of file diff --git a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/debugger/DebuggerUtils.kt b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/debugger/DebuggerUtils.kt index ff4d6a4fc48..198875872fb 100644 --- a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/debugger/DebuggerUtils.kt +++ b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/debugger/DebuggerUtils.kt @@ -21,6 +21,7 @@ import com.intellij.openapi.project.Project import com.intellij.openapi.util.io.FileUtilRt import com.intellij.psi.search.GlobalSearchScope import com.sun.jdi.Location +import org.jetbrains.annotations.TestOnly import org.jetbrains.kotlin.asJava.finder.JavaElementFinder import org.jetbrains.kotlin.descriptors.CallableDescriptor import org.jetbrains.kotlin.idea.KotlinFileTypeFactory @@ -42,6 +43,9 @@ import org.jetbrains.kotlin.utils.addIfNotNull import java.util.* object DebuggerUtils { + @TestOnly + var forceRanking = false + fun findSourceFileForClassIncludeLibrarySources( project: Project, scope: GlobalSearchScope, @@ -74,7 +78,7 @@ object DebuggerUtils { if (filesWithExactName.isEmpty()) return null - if (filesWithExactName.size == 1) { + if (filesWithExactName.size == 1 && !forceRanking) { return filesWithExactName.single() } diff --git a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/debugger/FileRankingCalculator.kt b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/debugger/FileRankingCalculator.kt index 1b371bd5d41..a7ac8cea0c8 100644 --- a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/debugger/FileRankingCalculator.kt +++ b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/debugger/FileRankingCalculator.kt @@ -6,9 +6,9 @@ package org.jetbrains.kotlin.idea.debugger import com.intellij.openapi.diagnostic.Logger +import com.intellij.openapi.progress.ProcessCanceledException import com.intellij.psi.PsiElement import com.sun.jdi.* -import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.codegen.ClassBuilderMode import org.jetbrains.kotlin.codegen.state.IncompatibleClassTracker import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper @@ -28,10 +28,9 @@ import org.jetbrains.kotlin.psi.psiUtil.getParentOfTypes2 import org.jetbrains.kotlin.psi.psiUtil.getParentOfTypes3 import org.jetbrains.kotlin.psi.psiUtil.isAncestor import org.jetbrains.kotlin.resolve.BindingContext +import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.descriptorUtil.varargParameterPosition import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode -import org.jetbrains.kotlin.types.KotlinType -import org.jetbrains.kotlin.types.typeUtil.builtIns import org.jetbrains.kotlin.utils.keysToMap import kotlin.jvm.internal.FunctionBase import org.jetbrains.org.objectweb.asm.Type as AsmType @@ -40,30 +39,20 @@ object FileRankingCalculatorForIde : FileRankingCalculator() { override fun analyze(element: KtElement) = element.analyze(BodyResolveMode.PARTIAL) } -abstract class FileRankingCalculator( - private val checkClassFqName: Boolean = true, - private val strictMode: Boolean = false -) { +abstract class FileRankingCalculator(private val checkClassFqName: Boolean = true) { abstract fun analyze(element: KtElement): BindingContext fun findMostAppropriateSource(files: Collection, location: Location): KtFile { - assert(files.isNotEmpty()) - - val fileWithRankings = files.keysToMap { fileRankingSafe(it, location) } + val fileWithRankings: Map = rankFiles(files, location) val fileWithMaxScore = fileWithRankings.maxBy { it.value }!! - - if (strictMode) { - require(fileWithMaxScore.value.value >= 0) { "Max score is negative" } - - // Allow only one element with max ranking - require(fileWithRankings.count { it.value == fileWithMaxScore.value } == 1) { - "Score is the same for several files" - } - } - return fileWithMaxScore.key } + fun rankFiles(files: Collection, location: Location): Map { + assert(files.isNotEmpty()) + return files.keysToMap { fileRankingSafe(it, location).value } + } + private class Ranking(val value: Int) : Comparable { companion object { val LOW = Ranking(-1000) @@ -119,6 +108,8 @@ abstract class FileRankingCalculator( } private fun rankingForClassName(fqName: String, descriptor: ClassDescriptor, bindingContext: BindingContext): Ranking { + if (DescriptorUtils.isLocal(descriptor)) return Ranking.ZERO + val expectedFqName = makeTypeMapper(bindingContext).mapType(descriptor).className return when { checkClassFqName -> if (expectedFqName == fqName) MAJOR else LOW @@ -207,6 +198,11 @@ abstract class FileRankingCalculator( ZERO } catch (e: InternalException) { ZERO + } catch (e: ProcessCanceledException) { + throw e + } catch (e: RuntimeException) { + LOG.error("Exception during Kotlin sources ranking", e) + ZERO } } diff --git a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/run/runConfigurationsCompat.kt.as34 b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/run/runConfigurationsCompat.kt.as34 new file mode 100644 index 00000000000..76daf1f43e5 --- /dev/null +++ b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/run/runConfigurationsCompat.kt.as34 @@ -0,0 +1,29 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. + */ + +@file:Suppress("IncompatibleAPI") + +package org.jetbrains.kotlin.idea.run + +import com.intellij.execution.configurations.LocatableConfigurationBase +import com.intellij.execution.configurations.ModuleBasedConfiguration +import com.intellij.execution.configurations.RunConfigurationBase +import org.jdom.Element + +// Generalized in 183 +// BUNCH: 183 +typealias RunConfigurationBaseAny = RunConfigurationBase + +// Generalized in 183 +// BUNCH: 183 +typealias ModuleBasedConfigurationAny = ModuleBasedConfiguration<*> + +// Generalized in 183 +// BUNCH: 183 +typealias LocatableConfigurationBaseAny = LocatableConfigurationBase + +// Generalized in 183 +// BUNCH: 183 +typealias ModuleBasedConfigurationElement = ModuleBasedConfiguration \ No newline at end of file diff --git a/idea/idea-maven/build.gradle.kts.as34 b/idea/idea-maven/build.gradle.kts.as34 new file mode 100644 index 00000000000..4ecbe3f70dc --- /dev/null +++ b/idea/idea-maven/build.gradle.kts.as34 @@ -0,0 +1,74 @@ + +plugins { + kotlin("jvm") + id("jps-compatible") +} + +dependencies { + compile(project(":core:util.runtime")) + compile(project(":compiler:frontend")) + compile(project(":compiler:frontend.java")) + compile(project(":compiler:util")) + compile(project(":compiler:cli-common")) + compile(project(":kotlin-build-common")) + + compile(project(":js:js.frontend")) + + compile(project(":idea")) + compile(project(":idea:idea-jvm")) + compile(project(":idea:idea-jps-common")) + + compileOnly(intellijDep()) + excludeInAndroidStudio(rootProject) { compileOnly(intellijPluginDep("maven")) } + + testCompile(projectTests(":idea")) + testCompile(projectTests(":compiler:tests-common")) + testCompile(projectTests(":idea:idea-test-framework")) + + testCompileOnly(intellijDep()) + //testCompileOnly(intellijPluginDep("maven")) + + testCompile(project(":idea:idea-native")) { isTransitive = false } + testRuntime(project(":kotlin-native:kotlin-native-library-reader")) { isTransitive = false } + testRuntime(project(":kotlin-native:kotlin-native-utils")) { isTransitive = false } + + testRuntime(project(":kotlin-reflect")) + testRuntime(project(":idea:idea-jvm")) + testRuntime(project(":idea:idea-android")) + testRuntime(project(":plugins:android-extensions-ide")) + testRuntime(project(":plugins:lint")) + testRuntime(project(":sam-with-receiver-ide-plugin")) + testRuntime(project(":allopen-ide-plugin")) + testRuntime(project(":noarg-ide-plugin")) + testRuntime(project(":kotlin-scripting-idea")) + testRuntime(project(":kotlinx-serialization-ide-plugin")) + + testRuntime(intellijDep()) + // TODO: the order of the plugins matters here, consider avoiding order-dependency + testRuntime(intellijPluginDep("junit")) + testRuntime(intellijPluginDep("testng")) + testRuntime(intellijPluginDep("properties")) + testRuntime(intellijPluginDep("gradle")) + testRuntime(intellijPluginDep("Groovy")) + testRuntime(intellijPluginDep("coverage")) + //testRuntime(intellijPluginDep("maven")) + testRuntime(intellijPluginDep("android")) + testRuntime(intellijPluginDep("smali")) +} + +sourceSets { + "main" { /*projectDefault()*/ } + "test" { /*projectDefault()*/ } +} + +testsJar() + +projectTest { + workingDir = rootDir +} + +runtimeJar { + archiveName = "maven-ide.jar" +} + +ideaPlugin() \ No newline at end of file diff --git a/idea/src/META-INF/android-lint.xml.as34 b/idea/src/META-INF/android-lint.xml.as34 new file mode 100644 index 00000000000..5a029687008 --- /dev/null +++ b/idea/src/META-INF/android-lint.xml.as34 @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/idea/src/META-INF/extensions/ide.xml.as34 b/idea/src/META-INF/extensions/ide.xml.as34 new file mode 100644 index 00000000000..d7fa2a47c4a --- /dev/null +++ b/idea/src/META-INF/extensions/ide.xml.as34 @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/idea/src/META-INF/git4idea.xml.as34 b/idea/src/META-INF/git4idea.xml.as34 new file mode 100644 index 00000000000..1bb24d148a3 --- /dev/null +++ b/idea/src/META-INF/git4idea.xml.as34 @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/idea/src/META-INF/gradle-java.xml.as34 b/idea/src/META-INF/gradle-java.xml.as34 new file mode 100644 index 00000000000..f6fb58a1c94 --- /dev/null +++ b/idea/src/META-INF/gradle-java.xml.as34 @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/idea/src/META-INF/plugin.xml.as34 b/idea/src/META-INF/plugin.xml.as34 index 8dae5016de1..fb9f8952141 100644 --- a/idea/src/META-INF/plugin.xml.as34 +++ b/idea/src/META-INF/plugin.xml.as34 @@ -13,7 +13,7 @@ The Kotlin plugin provides language support in IntelliJ IDEA and Android Studio. @snapshot@ JetBrains - + com.intellij.modules.platform com.intellij.modules.androidstudio diff --git a/idea/src/org/jetbrains/kotlin/idea/highlighter/markers/HasActualMarker.kt b/idea/src/org/jetbrains/kotlin/idea/highlighter/markers/HasActualMarker.kt index f0de41025bf..c6000042107 100644 --- a/idea/src/org/jetbrains/kotlin/idea/highlighter/markers/HasActualMarker.kt +++ b/idea/src/org/jetbrains/kotlin/idea/highlighter/markers/HasActualMarker.kt @@ -16,7 +16,6 @@ package org.jetbrains.kotlin.idea.highlighter.markers -import com.intellij.codeInsight.daemon.impl.PsiElementListNavigator import com.intellij.ide.util.DefaultPsiElementCellRenderer import com.intellij.psi.PsiElement import org.jetbrains.kotlin.analyzer.ModuleInfo @@ -64,19 +63,26 @@ fun getPlatformActualTooltip(declaration: KtDeclaration): String? { } } -fun navigateToPlatformActual(e: MouseEvent?, declaration: KtDeclaration) { - val actualDeclarations = - declaration.actualsForExpected() + declaration.findMarkerBoundDeclarations().flatMap { it.actualsForExpected() } - if (actualDeclarations.isEmpty()) return +fun KtDeclaration.allNavigatableActualDeclarations(): Set = + actualsForExpected() + findMarkerBoundDeclarations().flatMap { it.actualsForExpected() } - val renderer = object : DefaultPsiElementCellRenderer() { - override fun getContainerText(element: PsiElement?, name: String?) = "" +class ActualExpectedPsiElementCellRenderer : DefaultPsiElementCellRenderer() { + override fun getContainerText(element: PsiElement?, name: String?) = "" +} + +fun KtDeclaration.navigateToActualTitle() = "Choose actual for $name" + +fun KtDeclaration.navigateToActualUsagesTitle() = "Actuals for $name" + +fun buildNavigateToActualDeclarationsPopup(e: MouseEvent?, element: PsiElement?): NavigationPopupDescriptor? { + return element?.markerDeclaration?.let { + val navigatableActualDeclarations = it.allNavigatableActualDeclarations() + if (navigatableActualDeclarations.isEmpty()) return null + return NavigationPopupDescriptor( + navigatableActualDeclarations, + it.navigateToActualTitle(), + it.navigateToActualUsagesTitle(), + ActualExpectedPsiElementCellRenderer() + ) } - PsiElementListNavigator.openTargets( - e, - actualDeclarations.toTypedArray(), - "Choose actual for ${declaration.name}", - "Actuals for ${declaration.name}", - renderer - ) } \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/highlighter/markers/HasExpectedMarker.kt b/idea/src/org/jetbrains/kotlin/idea/highlighter/markers/HasExpectedMarker.kt index 7351d752f76..ff9d7dac6f9 100644 --- a/idea/src/org/jetbrains/kotlin/idea/highlighter/markers/HasExpectedMarker.kt +++ b/idea/src/org/jetbrains/kotlin/idea/highlighter/markers/HasExpectedMarker.kt @@ -16,8 +16,6 @@ package org.jetbrains.kotlin.idea.highlighter.markers -import com.intellij.codeInsight.daemon.impl.PsiElementListNavigator -import com.intellij.ide.util.DefaultPsiElementCellRenderer import com.intellij.psi.PsiElement import org.jetbrains.kotlin.descriptors.MemberDescriptor import org.jetbrains.kotlin.idea.caches.project.implementedDescriptors @@ -38,20 +36,22 @@ fun getExpectedDeclarationTooltip(declaration: KtDeclaration): String? { return "Has declaration in common module" } -fun navigateToExpectedDeclaration(e: MouseEvent?, declaration: KtDeclaration) { - val expectedDeclarations = - listOfNotNull(declaration.expectedDeclarationIfAny()) + - declaration.findMarkerBoundDeclarations().mapNotNull { it.expectedDeclarationIfAny() } - if (expectedDeclarations.isEmpty()) return +fun KtDeclaration.allNavigatableExpectedDeclarations(): List = + listOfNotNull(expectedDeclarationIfAny()) + findMarkerBoundDeclarations().mapNotNull { it.expectedDeclarationIfAny() } - val renderer = object : DefaultPsiElementCellRenderer() { - override fun getContainerText(element: PsiElement?, name: String?) = "" +fun KtDeclaration.navigateToExpectedTitle() = "Choose expected for $name" + +fun KtDeclaration.navigateToExpectedUsagesTitle() = "Expected for $name" + +fun buildNavigateToExpectedDeclarationsPopup(e: MouseEvent?, element: PsiElement?): NavigationPopupDescriptor? { + return element?.markerDeclaration?.let { + val navigatableExpectedDeclarations = it.allNavigatableExpectedDeclarations() + if (navigatableExpectedDeclarations.isEmpty()) return null + return NavigationPopupDescriptor( + navigatableExpectedDeclarations, + it.navigateToExpectedTitle(), + it.navigateToExpectedUsagesTitle(), + ActualExpectedPsiElementCellRenderer() + ) } - PsiElementListNavigator.openTargets( - e, - expectedDeclarations.toTypedArray(), - "Choose expected for ${declaration.name}", - "Expected for ${declaration.name}", - renderer - ) } \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/highlighter/markers/KotlinLineMarkerProvider.kt b/idea/src/org/jetbrains/kotlin/idea/highlighter/markers/KotlinLineMarkerProvider.kt index cfa1e5e385c..5a607520807 100644 --- a/idea/src/org/jetbrains/kotlin/idea/highlighter/markers/KotlinLineMarkerProvider.kt +++ b/idea/src/org/jetbrains/kotlin/idea/highlighter/markers/KotlinLineMarkerProvider.kt @@ -198,28 +198,52 @@ private val OVERRIDDEN_PROPERTY = object : MarkerType( } } -private val PsiElement.markerDeclaration +val PsiElement.markerDeclaration get() = (this as? KtDeclaration) ?: (parent as? KtDeclaration) -private val PLATFORM_ACTUAL = MarkerType( +private val PLATFORM_ACTUAL = object : MarkerType( "PLATFORM_ACTUAL", { element -> element?.markerDeclaration?.let { getPlatformActualTooltip(it) } }, object : LineMarkerNavigator() { override fun browse(e: MouseEvent?, element: PsiElement?) { - element?.markerDeclaration?.let { navigateToPlatformActual(e, it) } + buildNavigateToActualDeclarationsPopup(e, element)?.showPopup(e) + } + }) { + override fun getNavigationHandler(): GutterIconNavigationHandler { + val superHandler = super.getNavigationHandler() + return object : GutterIconNavigationHandler, TestableLineMarkerNavigator { + override fun navigate(e: MouseEvent?, elt: PsiElement?) { + superHandler.navigate(e, elt) + } + + override fun getTargetsPopupDescriptor(element: PsiElement?): NavigationPopupDescriptor? { + return buildNavigateToActualDeclarationsPopup(null, element) + } } } -) +} -private val EXPECTED_DECLARATION = MarkerType( +private val EXPECTED_DECLARATION = object : MarkerType( "EXPECTED_DECLARATION", { element -> element?.markerDeclaration?.let { getExpectedDeclarationTooltip(it) } }, object : LineMarkerNavigator() { override fun browse(e: MouseEvent?, element: PsiElement?) { - element?.markerDeclaration?.let { navigateToExpectedDeclaration(e, it) } + buildNavigateToExpectedDeclarationsPopup(e, element)?.showPopup(e) + } + }) { + override fun getNavigationHandler(): GutterIconNavigationHandler { + val superHandler = super.getNavigationHandler() + return object : GutterIconNavigationHandler, TestableLineMarkerNavigator { + override fun navigate(e: MouseEvent?, elt: PsiElement?) { + superHandler.navigate(e, elt) + } + + override fun getTargetsPopupDescriptor(element: PsiElement?): NavigationPopupDescriptor? { + return buildNavigateToExpectedDeclarationsPopup(null, element) + } } } -) +} private fun isImplementsAndNotOverrides( descriptor: CallableMemberDescriptor, diff --git a/idea/src/org/jetbrains/kotlin/idea/reporter/KotlinReportSubmitter.kt.as34 b/idea/src/org/jetbrains/kotlin/idea/reporter/KotlinReportSubmitter.kt.as34 new file mode 100644 index 00000000000..9572b8bca94 --- /dev/null +++ b/idea/src/org/jetbrains/kotlin/idea/reporter/KotlinReportSubmitter.kt.as34 @@ -0,0 +1,82 @@ +/* + * Copyright 2010-2015 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.kotlin.idea.reporter + +import com.intellij.diagnostic.ITNReporter +import com.intellij.openapi.application.ApplicationManager +import com.intellij.openapi.diagnostic.IdeaLoggingEvent +import com.intellij.openapi.diagnostic.SubmittedReportInfo +import com.intellij.openapi.ui.Messages +import com.intellij.util.Consumer +import org.jetbrains.kotlin.idea.KotlinPluginUpdater +import org.jetbrains.kotlin.idea.KotlinPluginUtil +import org.jetbrains.kotlin.idea.PluginUpdateStatus +import java.awt.Component + +/** + * We need to wrap ITNReporter for force showing or errors from kotlin plugin even from released version of IDEA. + */ +class KotlinReportSubmitter : ITNReporter() { + private var hasUpdate = false + private var hasLatestVersion = false + + override fun showErrorInRelease(event: IdeaLoggingEvent): Boolean { + val notificationEnabled = "disabled" != System.getProperty("kotlin.fatal.error.notification", "enabled") + return notificationEnabled && (!hasUpdate || ApplicationManager.getApplication().isInternal) + } + + override fun submit(events: Array, additionalInfo: String?, parentComponent: Component?, consumer: Consumer): Boolean { + if (hasUpdate) { + if (ApplicationManager.getApplication().isInternal) { + return super.submit(events, additionalInfo, parentComponent, consumer) + } + return true + } + + if (hasLatestVersion) { + return super.submit(events, additionalInfo, parentComponent, consumer) + } + + KotlinPluginUpdater.getInstance().runUpdateCheck { status -> + if (status is PluginUpdateStatus.Update) { + hasUpdate = true + if (parentComponent != null) { + + if (ApplicationManager.getApplication().isInternal) { + super.submit(events, additionalInfo, parentComponent, consumer) + } + + val rc = Messages.showDialog(parentComponent, + "You're running Kotlin plugin version ${KotlinPluginUtil.getPluginVersion()}, " + + "while the latest version is ${status.pluginDescriptor.version}", + "Update Kotlin Plugin", + arrayOf("Update", "Ignore"), + 0, Messages.getInformationIcon()) + if (rc == 0) { + KotlinPluginUpdater.getInstance().installPluginUpdate(status) + } + } + } + else { + hasLatestVersion = true + super.submit(events, additionalInfo, parentComponent, consumer) + } + false + } + return true + } +} diff --git a/idea/src/org/jetbrains/kotlin/idea/testResourceBundle.kt.as34 b/idea/src/org/jetbrains/kotlin/idea/testResourceBundle.kt.as34 new file mode 100644 index 00000000000..d48f9598c24 --- /dev/null +++ b/idea/src/org/jetbrains/kotlin/idea/testResourceBundle.kt.as34 @@ -0,0 +1,38 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. + */ + +@file:Suppress("DEPRECATION") + +package org.jetbrains.kotlin.idea + +import com.intellij.featureStatistics.FeatureStatisticsBundleProvider +import com.intellij.openapi.application.ApplicationManager +import com.intellij.openapi.extensions.Extensions +import java.lang.IllegalStateException + +private const val CIDR_FEATURE_STATISTICS_PROVIDER_FQNAME = "com.jetbrains.cidr.lang.OCFeatureStatisticsBundleProvider" + +fun registerAdditionalResourceBundleInTests() { + if (!ApplicationManager.getApplication().isUnitTestMode) { + return + } + + val isAlreadyRegistered = FeatureStatisticsBundleProvider.EP_NAME.extensions.any { provider -> + provider.javaClass.name == CIDR_FEATURE_STATISTICS_PROVIDER_FQNAME + } + if (isAlreadyRegistered) { + throw IllegalStateException("Remove this registration for the current platform: bundle is already registered.") + } + + val cidrFSBundleProviderClass = try { + Class.forName(CIDR_FEATURE_STATISTICS_PROVIDER_FQNAME) + } catch (_: ClassNotFoundException) { + throw IllegalStateException("Remove this registration for the current platform: class wasn't found.") + } + + val cidrFSBundleProvider = cidrFSBundleProviderClass.newInstance() as FeatureStatisticsBundleProvider + + Extensions.getRootArea().getExtensionPoint(FeatureStatisticsBundleProvider.EP_NAME).registerExtension(cidrFSBundleProvider) +} \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/update/GooglePluginUpdateVerifier.kt.as34 b/idea/src/org/jetbrains/kotlin/idea/update/GooglePluginUpdateVerifier.kt.as34 new file mode 100644 index 00000000000..77f54309b20 --- /dev/null +++ b/idea/src/org/jetbrains/kotlin/idea/update/GooglePluginUpdateVerifier.kt.as34 @@ -0,0 +1,152 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. 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.update + +import com.intellij.ide.plugins.IdeaPluginDescriptor +import com.intellij.ide.plugins.PluginManagerCore +import com.intellij.ide.plugins.PluginNode +import com.intellij.openapi.diagnostic.Logger +import org.jetbrains.kotlin.idea.util.isDev +import org.jetbrains.kotlin.idea.util.isEap +import java.io.IOException +import java.net.URL +import java.util.* +import javax.xml.bind.JAXBContext +import javax.xml.bind.JAXBException +import javax.xml.bind.annotation.* + +class GooglePluginUpdateVerifier : PluginUpdateVerifier() { + override val verifierName: String + get() = "Android Studio" + + // Verifies if a plugin can be installed in Android Studio 3.2+. + // Currently used only by KotlinPluginUpdater. + override fun verify(pluginDescriptor: IdeaPluginDescriptor): PluginVerifyResult? { + if (pluginDescriptor.pluginId.idString != KOTLIN_PLUGIN_ID) { + return null + } + + val version = pluginDescriptor.version + if (isEap(version) || isDev(version)) { + return PluginVerifyResult.accept() + } + + try { + val url = URL(METADATA_FILE_URL) + val stream = url.openStream() + val context = JAXBContext.newInstance(PluginCompatibility::class.java) + val unmarshaller = context.createUnmarshaller() + val pluginCompatibility = unmarshaller.unmarshal(stream) as PluginCompatibility + + val release = getRelease(pluginCompatibility) + ?: return PluginVerifyResult.decline("No verified versions for this build.") + + return if (release.plugins().any { KOTLIN_PLUGIN_ID == it.id && version == it.version }) + PluginVerifyResult.accept() + else + PluginVerifyResult.decline("Version to be verified.") + } catch (e: Exception) { + LOG.info("Exception when verifying plugin ${pluginDescriptor.pluginId.idString} version $version", e) + return when (e) { + is IOException -> + PluginVerifyResult.decline("unable to connect to compatibility verification repository") + is JAXBException -> PluginVerifyResult.decline("unable to parse compatibility verification metadata") + else -> PluginVerifyResult.decline("exception during verification ${e.message}") + } + } + } + + private fun getRelease(pluginCompatibility: PluginCompatibility): StudioRelease? { + for (studioRelease in pluginCompatibility.releases()) { + if (buildInRange(studioRelease.name, studioRelease.sinceBuild, studioRelease.untilBuild)) { + return studioRelease + } + } + return null + } + + private fun buildInRange(name: String?, sinceBuild: String?, untilBuild: String?): Boolean { + val descriptor = PluginNode() + descriptor.name = name + descriptor.sinceBuild = sinceBuild + descriptor.untilBuild = untilBuild + return PluginManagerCore.isCompatible(descriptor) + } + + companion object { + private const val KOTLIN_PLUGIN_ID = "org.jetbrains.kotlin" + private const val METADATA_FILE_URL = "https://dl.google.com/android/studio/plugins/compatibility.xml" + + private val LOG = Logger.getInstance(GooglePluginUpdateVerifier::class.java) + + private fun PluginCompatibility.releases() = studioRelease ?: emptyArray() + private fun StudioRelease.plugins() = ideaPlugin ?: emptyArray() + + @XmlRootElement(name = "plugin-compatibility") + @XmlAccessorType(XmlAccessType.FIELD) + class PluginCompatibility { + @XmlElement(name = "studio-release") + var studioRelease: Array? = null + + override fun toString(): String { + return "PluginCompatibility(studioRelease=${Arrays.toString(studioRelease)})" + } + } + + @XmlAccessorType(XmlAccessType.FIELD) + class StudioRelease { + @XmlAttribute(name = "until-build") + var untilBuild: String? = null + @XmlAttribute(name = "since-build") + var sinceBuild: String? = null + @XmlAttribute + var name: String? = null + @XmlAttribute + var channel: String? = null + + @XmlElement(name = "idea-plugin") + var ideaPlugin: Array? = null + + override fun toString(): String { + return "StudioRelease(" + + "untilBuild=$untilBuild, name=$name, ideaPlugin=${Arrays.toString(ideaPlugin)}, " + + "sinceBuild=$sinceBuild, channel=$channel" + + ")" + } + } + + @XmlAccessorType(XmlAccessType.FIELD) + class IdeaPlugin { + @XmlAttribute + var id: String? = null + @XmlAttribute + var sha256: String? = null + @XmlAttribute + var channel: String? = null + @XmlAttribute + var version: String? = null + + @XmlElement(name = "idea-version") + var ideaVersion: IdeaVersion? = null + + override fun toString(): String { + return "IdeaPlugin(id=$id, sha256=$sha256, ideaVersion=$ideaVersion, channel=$channel, version=$version)" + } + } + + @XmlAccessorType(XmlAccessType.FIELD) + class IdeaVersion { + @XmlAttribute(name = "until-build") + var untilBuild: String? = null + @XmlAttribute(name = "since-build") + var sinceBuild: String? = null + + override fun toString(): String { + return "IdeaVersion(untilBuild=$untilBuild, sinceBuild=$sinceBuild)" + } + } + } +} diff --git a/idea/src/org/jetbrains/kotlin/idea/update/verify.kt.as34 b/idea/src/org/jetbrains/kotlin/idea/update/verify.kt.as34 new file mode 100644 index 00000000000..7899e34573b --- /dev/null +++ b/idea/src/org/jetbrains/kotlin/idea/update/verify.kt.as34 @@ -0,0 +1,35 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. 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.update + +import com.intellij.ide.plugins.IdeaPluginDescriptor +import com.intellij.openapi.util.registry.Registry +import org.jetbrains.kotlin.idea.PluginUpdateStatus + +// Do an additional verification with PluginUpdateVerifier. Enabled only in AS 3.2+ +fun verify(updateStatus: PluginUpdateStatus.Update): PluginUpdateStatus { + @Suppress("InvalidBundleOrProperty") + val pluginVerifierEnabled = Registry.`is`("kotlin.plugin.update.verifier.enabled", true) + if (!pluginVerifierEnabled) { + return updateStatus + } + + val pluginDescriptor: IdeaPluginDescriptor = updateStatus.pluginDescriptor + val pluginVerifiers = PluginUpdateVerifier.EP_NAME.extensions + + for (pluginVerifier in pluginVerifiers) { + val verifyResult = pluginVerifier.verify(pluginDescriptor) ?: continue + if (!verifyResult.verified) { + return PluginUpdateStatus.Unverified( + pluginVerifier.verifierName, + verifyResult.declineMessage, + updateStatus + ) + } + } + + return updateStatus +} \ No newline at end of file diff --git a/idea/testData/debugger/fileRanking/anonymousClasses.kt b/idea/testData/debugger/fileRanking/anonymousClasses.kt new file mode 100644 index 00000000000..85b7d33b84d --- /dev/null +++ b/idea/testData/debugger/fileRanking/anonymousClasses.kt @@ -0,0 +1,22 @@ +//FILE: a/a.kt +// DISABLE_STRICT_MODE +package a + +abstract class R { + abstract fun run() +} + +fun eval(r: R) { + r.run() +} + +class Some { + fun foo() { + eval(object : R() { // Line with negative score + override fun run() { + val a = 1 // R: 4 L: 17 + val b = 12 // R: 4 L: 18 + } + }) + } +} \ No newline at end of file diff --git a/idea/testData/debugger/fileRanking/lambdas.kt b/idea/testData/debugger/fileRanking/lambdas.kt index 167fa5e2c41..e49a637fe3a 100644 --- a/idea/testData/debugger/fileRanking/lambdas.kt +++ b/idea/testData/debugger/fileRanking/lambdas.kt @@ -1,11 +1,12 @@ // DO_NOT_CHECK_CLASS_FQNAME +// DISABLE_STRICT_MODE //FILE: a/a.kt package a fun block(l: () -> Unit) {} -class A { +class A { // Line with the same rank fun a() { block { val a = 5 @@ -18,12 +19,13 @@ class A { //FILE: b/a.kt package b +// Fake Line import a.block class A { fun b() { - val g = 5 + val g = 5 // Line with the same rank val x = 1 block { val y = 2 } block { diff --git a/idea/testData/debugger/tinyApp/src/stepping/stepOver/stopInObjectLiteralInInlineCallWithClosureInAnonymous.kt b/idea/testData/debugger/tinyApp/src/stepping/stepOver/stopInObjectLiteralInInlineCallWithClosureInAnonymous.kt index e0f38eb7c3b..cdbfd45122a 100644 --- a/idea/testData/debugger/tinyApp/src/stepping/stepOver/stopInObjectLiteralInInlineCallWithClosureInAnonymous.kt +++ b/idea/testData/debugger/tinyApp/src/stepping/stepOver/stopInObjectLiteralInInlineCallWithClosureInAnonymous.kt @@ -1,5 +1,7 @@ package stopInObjectLiteralInInlineCallWithClosureInAnonymous +// FORCE_RANKING + fun main(args: Array) { val a = 12 diff --git a/idea/testData/multiModuleLineMarker/actualConstructorWithProperties/jvm/jvm.kt b/idea/testData/multiModuleLineMarker/actualConstructorWithProperties/jvm/jvm.kt index b7e353ffa64..463d99ff1d1 100644 --- a/idea/testData/multiModuleLineMarker/actualConstructorWithProperties/jvm/jvm.kt +++ b/idea/testData/multiModuleLineMarker/actualConstructorWithProperties/jvm/jvm.kt @@ -1 +1,11 @@ -actual class WithConstructor actual constructor(actual val x: Int, actual val s: String) +actual class WithConstructor actual constructor(actual val x: Int, actual val s: String) + +/* +LINEMARKER: Has declaration in common module +TARGETS: +common.kt +expect class <1>WithConstructor(x: Int, s: String) { + val <3>x: Int + + val <2>s: String +*/ diff --git a/idea/testData/multiModuleLineMarker/actualEnumEntriesInOneLine/jvm/jvm.kt b/idea/testData/multiModuleLineMarker/actualEnumEntriesInOneLine/jvm/jvm.kt index ca49aaa4b60..0c6e2c14140 100644 --- a/idea/testData/multiModuleLineMarker/actualEnumEntriesInOneLine/jvm/jvm.kt +++ b/idea/testData/multiModuleLineMarker/actualEnumEntriesInOneLine/jvm/jvm.kt @@ -1,3 +1,10 @@ package test -actual enum class Enum { A, B, C } \ No newline at end of file +actual enum class Enum { A, B, C } + +/* +LINEMARKER: Has declaration in common module +TARGETS: +common.kt +expect enum class <4>Enum { <1>A, <2>B, <3>C } +*/ diff --git a/idea/testData/multiModuleLineMarker/expectEnumEntriesInOneLine/common/common.kt b/idea/testData/multiModuleLineMarker/expectEnumEntriesInOneLine/common/common.kt index 1cd143e045b..065dd8f0523 100644 --- a/idea/testData/multiModuleLineMarker/expectEnumEntriesInOneLine/common/common.kt +++ b/idea/testData/multiModuleLineMarker/expectEnumEntriesInOneLine/common/common.kt @@ -1,3 +1,10 @@ package test -expect enum class Enum { A, B, C, D } \ No newline at end of file +expect enum class Enum { A, B, C, D } + +/* +LINEMARKER: Has actuals in JVM +TARGETS: +jvm.kt +actual enum class <5>Enum { <1>A, <2>B, <3>C, <4>D } +*/ diff --git a/idea/testData/multiModuleLineMarker/suspendImplInPlatformModules/common/common.kt b/idea/testData/multiModuleLineMarker/suspendImplInPlatformModules/common/common.kt index 2103943d8e5..dd5b060371c 100644 --- a/idea/testData/multiModuleLineMarker/suspendImplInPlatformModules/common/common.kt +++ b/idea/testData/multiModuleLineMarker/suspendImplInPlatformModules/common/common.kt @@ -1,3 +1,12 @@ interface I { suspend fun foo(s: String) -} \ No newline at end of file +} + +/* +LINEMARKER: Is implemented in
    KJs
    KJvm +TARGETS: +js.kt + suspend override fun <1>foo(s: String) { + jvm.kt + suspend override fun <2>foo(s: String) { +*/ diff --git a/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/AbstractMultiModuleHighlightingTest.kt b/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/AbstractMultiModuleHighlightingTest.kt index 8af9176dde4..4e9c40a9592 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/AbstractMultiModuleHighlightingTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/AbstractMultiModuleHighlightingTest.kt @@ -16,16 +16,30 @@ package org.jetbrains.kotlin.idea.caches.resolve +import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl import com.intellij.psi.PsiFile +import org.jetbrains.kotlin.idea.codeInsight.AbstractLineMarkersTest import org.jetbrains.kotlin.idea.multiplatform.setupMppProjectFromDirStructure import org.jetbrains.kotlin.idea.stubs.AbstractMultiHighlightingTest import org.jetbrains.kotlin.idea.test.PluginTestCaseBase import org.jetbrains.kotlin.idea.test.allJavaFiles import org.jetbrains.kotlin.idea.test.allKotlinFiles +import org.jetbrains.kotlin.psi.KtFile import java.io.File abstract class AbstractMultiModuleHighlightingTest : AbstractMultiHighlightingTest() { + protected open fun checkLineMarkersInProject( + findFiles: () -> List = { project.allKotlinFiles().excludeByDirective() } + ) { + checkFiles(findFiles) { + checkHighlighting(myEditor, true, false) + + val markers = DaemonCodeAnalyzerImpl.getLineMarkers(getDocument(file), project) + AbstractLineMarkersTest.assertNavigationElements(project, myFile as KtFile, markers) + } + } + protected open fun checkHighlightingInProject( findFiles: () -> List = { project.allKotlinFiles().excludeByDirective() } ) { diff --git a/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/AbstractMultiModuleLineMarkerTest.kt b/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/AbstractMultiModuleLineMarkerTest.kt index 4e4cc334bf0..7ffafa5d6a8 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/AbstractMultiModuleLineMarkerTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/AbstractMultiModuleLineMarkerTest.kt @@ -32,6 +32,6 @@ abstract class AbstractMultiModuleLineMarkerTest : AbstractMultiModuleHighlighti protected fun doTest(path: String) { setupMppProjectFromDirStructure(File(path)) - checkHighlightingInProject() + checkLineMarkersInProject() } } \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/PsiElementChecker.kt.183 b/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/PsiElementChecker.kt.183 new file mode 100644 index 00000000000..d8642a4df65 --- /dev/null +++ b/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/PsiElementChecker.kt.183 @@ -0,0 +1,131 @@ +/* + * Copyright 2010-2015 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.kotlin.idea.caches.resolve + +import com.intellij.openapi.util.Key +import com.intellij.psi.* +import org.jetbrains.kotlin.asJava.elements.KtLightElement +import org.jetbrains.kotlin.asJava.elements.KtLightModifierList +import org.jetbrains.kotlin.idea.KotlinLanguage +import org.junit.Assert + +object PsiElementChecker { + val TEST_DATA_KEY = Key.create("Test Key") + + fun checkPsiElementStructure(lightClass: PsiClass) { + checkPsiElement(lightClass) + + lightClass.methods.forEach { + it.parameterList.parameters.forEach { checkPsiElement(it) } + checkPsiElement(it) + } + + lightClass.fields.forEach { checkPsiElement(it) } + + lightClass.innerClasses.forEach { checkPsiElementStructure(it) } + } + + private fun checkPsiElement(element: PsiElement) { + if (element !is KtLightElement<*, *> && element !is KtLightModifierList<*>) return + + if (element is PsiModifierListOwner) { + val modifierList = element.modifierList + if (modifierList != null) { + checkPsiElement(modifierList) + } + } + + if (element is PsiTypeParameterListOwner) { + val typeParameterList = element.typeParameterList + if (typeParameterList != null) { + checkPsiElement(typeParameterList) + typeParameterList.typeParameters.forEach { checkPsiElement(it) } + } + } + + with(element) { + try { + Assert.assertEquals("Number of methods has changed. Please update test.", 55, PsiElement::class.java.methods.size) + + project + Assert.assertTrue(language == KotlinLanguage.INSTANCE) + manager + children + parent + firstChild + lastChild + nextSibling + prevSibling + containingFile + textRange + //textRangeInParent - throws an exception for non-physical elements, it is expected behaviour + startOffsetInParent + textLength + findElementAt(0) + findReferenceAt(0) + textOffset + text + textToCharArray() + navigationElement + originalElement + textMatches("") + Assert.assertTrue(textMatches(this)) + textContains('a') + accept(PsiElementVisitor.EMPTY_VISITOR) + acceptChildren(PsiElementVisitor.EMPTY_VISITOR) + + val copy = copy() + Assert.assertTrue(copy == null || copy::class.java == this::class.java) + + // Modify methods: + // add(this) + // addBefore(this, lastChild) + // addAfter(firstChild, this) + // checkAdd(this) + // addRange(firstChild, lastChild) + // addRangeBefore(firstChild, lastChild, lastChild) + // addRangeAfter(firstChild, lastChild, firstChild) + // delete() + // checkDelete() + // deleteChildRange(firstChild, lastChild) + // replace(this) + + Assert.assertTrue(isValid) + isWritable + reference + references + putCopyableUserData(TEST_DATA_KEY, 12) + + Assert.assertTrue(getCopyableUserData(TEST_DATA_KEY) == 12) + // Assert.assertTrue(copy().getCopyableUserData(TEST_DATA_KEY) == 12) { this } Doesn't work + + // processDeclarations(...) + + context + isPhysical + resolveScope + useScope + node + toString() + Assert.assertTrue(isEquivalentTo(this)) + } + catch (t: Throwable) { + throw AssertionErrorWithCause("Failed for ${this::class.java} ${this}", t) + } + } + } +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/AbstractLineMarkersTest.kt b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/AbstractLineMarkersTest.kt index 8f566226319..5eda3ce7b8b 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/AbstractLineMarkersTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/AbstractLineMarkersTest.kt @@ -9,6 +9,7 @@ import com.intellij.codeInsight.daemon.DaemonCodeAnalyzerSettings import com.intellij.codeInsight.daemon.LineMarkerInfo import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl import com.intellij.openapi.editor.Document +import com.intellij.openapi.project.Project import com.intellij.openapi.util.io.FileUtil import com.intellij.psi.PsiDocumentManager import com.intellij.rt.execution.junit.FileComparisonFailure @@ -93,7 +94,7 @@ abstract class AbstractLineMarkersTest : KotlinLightCodeInsightFixtureTestCase() val markers = doAndCheckHighlighting(document, data, File(path)) - assertNavigationElements(markers) + assertNavigationElements(myFixture.project, myFixture.file as KtFile, markers) additionalCheck() } catch (exc: Exception) { throw RuntimeException(exc) @@ -104,45 +105,53 @@ abstract class AbstractLineMarkersTest : KotlinLightCodeInsightFixtureTestCase() } - private fun assertNavigationElements(markers: List>) { - val navigationDataComments = KotlinTestUtils.getLastCommentsInFile( - myFixture.file as KtFile, KotlinTestUtils.CommentType.BLOCK_COMMENT, false) - if (navigationDataComments.isEmpty()) return - - for (navigationComment in navigationDataComments) { - val description = getLineMarkerDescription(navigationComment) - val navigateMarker = markers.find { it.lineMarkerTooltip?.startsWith(description) == true }!! - - TestCase.assertNotNull( - String.format("Can't find marker for navigation check with description \"%s\"", description), - navigateMarker) - - val handler = navigateMarker.navigationHandler - if (handler is TestableLineMarkerNavigator) { - val navigateElements = handler.getTargetsPopupDescriptor(navigateMarker.element)?.targets?.sortedBy { it.renderAsGotoImplementation() } - val actualNavigationData = NavigationTestUtils.getNavigateElementsText(myFixture.project, navigateElements) - - UsefulTestCase.assertSameLines(getExpectedNavigationText(navigationComment), actualNavigationData) - } - else { - Assert.fail("Only SuperDeclarationMarkerNavigationHandler are supported in navigate check") - } - } - } - companion object { - private val LINE_MARKER_PREFIX = "LINEMARKER:" - private val TARGETS_PREFIX = "TARGETS" + @Suppress("SpellCheckingInspection") + private const val LINE_MARKER_PREFIX = "LINEMARKER:" + private const val TARGETS_PREFIX = "TARGETS" + + fun assertNavigationElements(project: Project, file: KtFile, markers: List>) { + val navigationDataComments = KotlinTestUtils.getLastCommentsInFile( + file, KotlinTestUtils.CommentType.BLOCK_COMMENT, false + ) + if (navigationDataComments.isEmpty()) return + + for (navigationComment in navigationDataComments) { + val description = getLineMarkerDescription(navigationComment) + val navigateMarker = markers.find { it.lineMarkerTooltip?.startsWith(description) == true }!! + + TestCase.assertNotNull( + String.format("Can't find marker for navigation check with description \"%s\"", description), + navigateMarker + ) + + val handler = navigateMarker.navigationHandler + if (handler is TestableLineMarkerNavigator) { + val navigateElements = handler.getTargetsPopupDescriptor(navigateMarker.element)?.targets?.sortedBy { + it.renderAsGotoImplementation() + } + val actualNavigationData = NavigationTestUtils.getNavigateElementsText(project, navigateElements) + + UsefulTestCase.assertSameLines(getExpectedNavigationText(navigationComment), actualNavigationData) + } else { + Assert.fail("Only TestableLineMarkerNavigator are supported in navigate check") + } + } + } private fun getLineMarkerDescription(navigationComment: String): String { val firstLineEnd = navigationComment.indexOf("\n") - TestCase.assertTrue("The first line in block comment must contain description of marker for navigation check", firstLineEnd != -1) + TestCase.assertTrue( + "The first line in block comment must contain description of marker for navigation check", firstLineEnd != -1 + ) var navigationMarkerText = navigationComment.substring(0, firstLineEnd) - TestCase.assertTrue(String.format("Add %s directive in first line of comment", LINE_MARKER_PREFIX), - navigationMarkerText.startsWith(LINE_MARKER_PREFIX)) + TestCase.assertTrue( + String.format("Add %s directive in first line of comment", LINE_MARKER_PREFIX), + navigationMarkerText.startsWith(LINE_MARKER_PREFIX) + ) navigationMarkerText = navigationMarkerText.substring(LINE_MARKER_PREFIX.length) @@ -155,8 +164,9 @@ abstract class AbstractLineMarkersTest : KotlinLightCodeInsightFixtureTestCase() var expectedNavigationText = navigationComment.substring(firstLineEnd + 1) TestCase.assertTrue( - String.format("Marker %s is expected before navigation data", TARGETS_PREFIX), - expectedNavigationText.startsWith(TARGETS_PREFIX)) + String.format("Marker %s is expected before navigation data", TARGETS_PREFIX), + expectedNavigationText.startsWith(TARGETS_PREFIX) + ) expectedNavigationText = expectedNavigationText.substring(expectedNavigationText.indexOf("\n") + 1) diff --git a/idea/tests/org/jetbrains/kotlin/idea/debugger/AbstractFileRankingTest.kt b/idea/tests/org/jetbrains/kotlin/idea/debugger/AbstractFileRankingTest.kt index dc7a7370244..ec1b3e4b614 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/debugger/AbstractFileRankingTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/debugger/AbstractFileRankingTest.kt @@ -1,40 +1,74 @@ package org.jetbrains.kotlin.idea.debugger import com.sun.jdi.ThreadReference +import org.jetbrains.kotlin.codegen.ClassFileFactory import org.jetbrains.kotlin.codegen.OriginCollectingClassBuilderFactory +import org.jetbrains.kotlin.codegen.getClassFiles import org.jetbrains.kotlin.codegen.state.GenerationState import org.jetbrains.kotlin.psi.KtElement import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.org.objectweb.asm.tree.ClassNode +import org.junit.Assert abstract class AbstractFileRankingTest : LowLevelDebuggerTestBase() { override fun doTest( options: Set, mainThread: ThreadReference, factory: OriginCollectingClassBuilderFactory, + classFileFactory: ClassFileFactory, state: GenerationState ) { - val allKtFiles = factory.origins.mapNotNull { it.value.element?.containingFile as? KtFile }.distinct() + val allKtFiles = classFileFactory.inputFiles.distinct() fun getKtFiles(name: String) = allKtFiles.filter { it.name == name } val doNotCheckClassFqName = "DO_NOT_CHECK_CLASS_FQNAME" in options + val strictMode = "DISABLE_STRICT_MODE" !in options - val calculator = object : FileRankingCalculator(checkClassFqName = !doNotCheckClassFqName, strictMode = true) { + val expectedRanks: Map, Int> = allKtFiles.asSequence().flatMap { ktFile -> + ktFile.text.lines() + .asSequence() + .withIndex() + .map { + val matchResult = "^.*// (R: (-?\\d+)( L: (\\d+))?)\\s*$".toRegex().matchEntire(it.value) ?: return@map null + + val rank = matchResult.groupValues[2].toInt() + val line = matchResult.groupValues.getOrNull(4)?.takeIf { !it.isEmpty() }?.toInt() + + if (line != null && line != it.index + 1) { + throw IllegalArgumentException("Bad line in directive at ${ktFile.name}:${it.index + 1}\n${it.value}") + } + + (ktFile to it.index + 1) to rank + } + .filterNotNull() + }.toMap() + + val calculator = object : FileRankingCalculator(checkClassFqName = !doNotCheckClassFqName) { override fun analyze(element: KtElement) = state.bindingContext } val problems = mutableListOf() - val skipClasses = skipLoadingClasses(options) - for ((node, origin) in factory.origins) { - val classNode = node as? ClassNode ?: continue - val expectedFile = origin.element?.containingFile as? KtFile ?: continue - val className = classNode.name.replace('/', '.') + val classNameToKtFile = factory.origins.asSequence() + .filter { it.key is ClassNode } + .map { + val ktFile = (it.value.element?.containingFile as? KtFile) ?: return@map null + val name = (it.key as ClassNode).name.replace('/', '.') + name to ktFile + } + .filterNotNull() + .toMap() + + val skipClasses = skipLoadingClasses(options) + for (outputFile in classFileFactory.getClassFiles()) { + val className = outputFile.internalName.replace('/', '.') if (className in skipClasses) { continue } + val expectedFile = classNameToKtFile[className] ?: throw IllegalStateException("Can't find source for $className") + val jdiClass = mainThread.virtualMachine().classesByName(className).singleOrNull() ?: error("Class '$className' was not found in the debuggee process class loader") @@ -46,7 +80,27 @@ abstract class AbstractFileRankingTest : LowLevelDebuggerTestBase() { for (location in locations) { if (location.method().isBridge || location.method().isSynthetic) continue - val actualFile = calculator.findMostAppropriateSource(allFilesWithSameName, location) + val fileWithRankings: Map = calculator.rankFiles(allFilesWithSameName, location) + + for ((ktFile, rank) in fileWithRankings) { + val expectedRank = expectedRanks[ktFile to (location.lineNumber())] + if (expectedRank != null) { + Assert.assertEquals("Invalid expected rank at $location", expectedRank, rank) + } + } + + val fileWithMaxScore = fileWithRankings.maxBy { it.value }!! + val actualFile = fileWithMaxScore.key + + if (strictMode) { + require(fileWithMaxScore.value >= 0) { "Max score is negative at $location" } + + // Allow only one element with max ranking + require(fileWithRankings.filter { it.value == fileWithMaxScore.value }.count() == 1) { + "Score is the same for several files at $location" + } + } + if (actualFile != expectedFile) { problems += "Location ${location.sourceName()}:${location.lineNumber() - 1} is associated with a wrong KtFile:\n" + " - expected: ${expectedFile.virtualFilePath}\n" + diff --git a/idea/tests/org/jetbrains/kotlin/idea/debugger/FileRankingTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/debugger/FileRankingTestGenerated.java index e2ce68775ad..f39ce376f8f 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/debugger/FileRankingTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/debugger/FileRankingTestGenerated.java @@ -29,6 +29,11 @@ public class FileRankingTestGenerated extends AbstractFileRankingTest { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/debugger/fileRanking"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); } + @TestMetadata("anonymousClasses.kt") + public void testAnonymousClasses() throws Exception { + runTest("idea/testData/debugger/fileRanking/anonymousClasses.kt"); + } + @TestMetadata("differentFlags.kt") public void testDifferentFlags() throws Exception { runTest("idea/testData/debugger/fileRanking/differentFlags.kt"); diff --git a/idea/tests/org/jetbrains/kotlin/idea/debugger/KotlinDebuggerTestBase.kt b/idea/tests/org/jetbrains/kotlin/idea/debugger/KotlinDebuggerTestBase.kt index e8fd93911a5..36551918efd 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/debugger/KotlinDebuggerTestBase.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/debugger/KotlinDebuggerTestBase.kt @@ -65,7 +65,6 @@ import org.jetbrains.kotlin.test.InTextDirectivesUtils import org.jetbrains.kotlin.test.InTextDirectivesUtils.findStringWithPrefixes import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstance import java.io.File -import java.lang.AssertionError import javax.swing.SwingUtilities abstract class KotlinDebuggerTestBase : KotlinDebuggerTestCase() { @@ -113,6 +112,8 @@ abstract class KotlinDebuggerTestBase : KotlinDebuggerTestCase() { debuggerSettings.SKIP_CLASSLOADERS = fileText.getValueForSetting("SKIP_CLASSLOADERS", oldSettings!!.SKIP_CLASSLOADERS) debuggerSettings.TRACING_FILTERS_ENABLED = fileText.getValueForSetting("TRACING_FILTERS_ENABLED", oldSettings!!.TRACING_FILTERS_ENABLED) debuggerSettings.SKIP_GETTERS = fileText.getValueForSetting("SKIP_GETTERS", oldSettings!!.SKIP_GETTERS) + + DebuggerUtils.forceRanking = InTextDirectivesUtils.isDirectiveDefined(fileText, "FORCE_RANKING") } private fun String.getValueForSetting(name: String, defaultValue: Boolean): Boolean { @@ -137,6 +138,8 @@ abstract class KotlinDebuggerTestBase : KotlinDebuggerTestCase() { debuggerSettings.SKIP_CLASSLOADERS = oldSettings!!.SKIP_CLASSLOADERS debuggerSettings.TRACING_FILTERS_ENABLED = oldSettings!!.TRACING_FILTERS_ENABLED debuggerSettings.SKIP_GETTERS = oldSettings!!.SKIP_GETTERS + + DebuggerUtils.forceRanking = false } protected val dp: DebugProcessImpl diff --git a/idea/tests/org/jetbrains/kotlin/idea/debugger/LowLevelDebuggerTestBase.kt b/idea/tests/org/jetbrains/kotlin/idea/debugger/LowLevelDebuggerTestBase.kt index 4650a912940..0a6a88d8fe6 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/debugger/LowLevelDebuggerTestBase.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/debugger/LowLevelDebuggerTestBase.kt @@ -14,13 +14,12 @@ import org.jetbrains.kotlin.backend.common.output.OutputFile import org.jetbrains.kotlin.codegen.* import org.jetbrains.kotlin.codegen.state.GenerationState import org.jetbrains.kotlin.test.ConfigurationKind -import org.jetbrains.org.objectweb.asm.tree.ClassNode -import org.jetbrains.org.objectweb.asm.Type as AsmType import java.io.File import java.io.IOException import java.net.Socket import java.nio.file.Files import kotlin.properties.Delegates +import org.jetbrains.org.objectweb.asm.Type as AsmType abstract class LowLevelDebuggerTestBase : CodegenTestCase() { private companion object { @@ -34,7 +33,7 @@ abstract class LowLevelDebuggerTestBase : CodegenTestCase() { val options = wholeFile.readLines() .asSequence() - .filter { it.matches("^// ?[\\w_]+(:.*)$".toRegex()) } + .filter { it.matches("^// ?[\\w_]+(:.*)?$".toRegex()) } .map { it.drop(2).trim() } .filter { !it.startsWith("FILE:") } .toSet() @@ -63,8 +62,8 @@ abstract class LowLevelDebuggerTestBase : CodegenTestCase() { try { val mainThread = virtualMachine.allThreads().single { it.name() == "main" } - waitUntil { areCompiledClassesLoaded(mainThread, classBuilderFactory, skipLoadingClasses) } - doTest(options, mainThread, classBuilderFactory, generationState) + waitUntil { areCompiledClassesLoaded(mainThread, classFileFactory, skipLoadingClasses) } + doTest(options, mainThread, classBuilderFactory, classFileFactory, generationState) } finally { virtualMachine.exit(0) process.destroy() @@ -78,6 +77,7 @@ abstract class LowLevelDebuggerTestBase : CodegenTestCase() { options: Set, mainThread: ThreadReference, factory: OriginCollectingClassBuilderFactory, + classFileFactory: ClassFileFactory, state: GenerationState ) @@ -92,13 +92,12 @@ abstract class LowLevelDebuggerTestBase : CodegenTestCase() { private fun areCompiledClassesLoaded( mainThread: ThreadReference, - factory: OriginCollectingClassBuilderFactory, + classFileFactory: ClassFileFactory, skipLoadingClasses: Set ): Boolean { - for ((node, _) in factory.origins) { - val classNode = node as? ClassNode ?: continue - val fqName = classNode.name.replace('/', '.') + for (outputFile in classFileFactory.getClassFiles()) { + val fqName = outputFile.internalName.replace('/', '.') if (fqName in skipLoadingClasses) { continue } @@ -155,10 +154,10 @@ abstract class LowLevelDebuggerTestBase : CodegenTestCase() { File(classesDir, mainClassResourceName).mkdirAndWriteBytes(mainClassBytes) } - private val OutputFile.internalName + internal val OutputFile.internalName get() = relativePath.substringBeforeLast(".class") - private val OutputFile.qualifiedName + internal val OutputFile.qualifiedName get() = internalName.replace('/', '.') } diff --git a/j2k/build.gradle.kts.as34 b/j2k/build.gradle.kts.as34 new file mode 100644 index 00000000000..9ddc7af7f31 --- /dev/null +++ b/j2k/build.gradle.kts.as34 @@ -0,0 +1,78 @@ + +plugins { + kotlin("jvm") + id("jps-compatible") +} + +dependencies { + testRuntime(intellijDep()) + + compile(project(":kotlin-stdlib")) + compile(project(":compiler:frontend")) + compile(project(":compiler:frontend.java")) + compile(project(":compiler:light-classes")) + compile(project(":compiler:util")) + compileOnly(intellijCoreDep()) { includeJars("intellij-core") } + + testCompile(project(":idea")) + testCompile(projectTests(":idea:idea-test-framework")) + testCompile(project(":compiler:light-classes")) + testCompile(project(":kotlin-test:kotlin-test-junit")) + testCompile(commonDep("junit:junit")) + testCompileOnly(intellijDep()) { includeJars("platform-api", "platform-impl") } + testCompile(project(":idea:idea-native")) { isTransitive = false } + testCompile(project(":idea:idea-gradle-native")) { isTransitive = false } + + testRuntime(project(":kotlin-native:kotlin-native-library-reader")) { isTransitive = false } + testRuntime(project(":kotlin-native:kotlin-native-utils")) { isTransitive = false } + testRuntime(project(":plugins:kapt3-idea")) { isTransitive = false } + testRuntime(project(":idea:idea-jvm")) + testRuntime(project(":idea:idea-android")) + testRuntime(project(":plugins:android-extensions-ide")) + testRuntime(project(":sam-with-receiver-ide-plugin")) + testRuntime(project(":allopen-ide-plugin")) + testRuntime(project(":noarg-ide-plugin")) + testRuntime(project(":kotlin-scripting-idea")) + testRuntime(project(":kotlinx-serialization-ide-plugin")) + testRuntime(intellijPluginDep("properties")) + testRuntime(intellijPluginDep("gradle")) + testRuntime(intellijPluginDep("Groovy")) + testRuntime(intellijPluginDep("coverage")) + //testRuntime(intellijPluginDep("maven")) + testRuntime(intellijPluginDep("android")) + testRuntime(intellijPluginDep("smali")) + testRuntime(intellijPluginDep("junit")) + testRuntime(intellijPluginDep("testng")) + testRuntime(intellijPluginDep("IntelliLang")) + testRuntime(intellijPluginDep("testng")) + testRuntime(intellijPluginDep("copyright")) + testRuntime(intellijPluginDep("properties")) + testRuntime(intellijPluginDep("java-i18n")) + testRuntime(intellijPluginDep("java-decompiler")) +} + +sourceSets { + "main" { projectDefault() } + "test" { projectDefault() } +} + +projectTest { + dependsOn(":dist") + workingDir = rootDir +} + +testsJar() + +val testForWebDemo by task { + include("**/*JavaToKotlinConverterForWebDemoTestGenerated*") + classpath = testSourceSet.runtimeClasspath + workingDir = rootDir +} + +val test: Test by tasks +test.apply { + exclude("**/*JavaToKotlinConverterForWebDemoTestGenerated*") + dependsOn(testForWebDemo) +} + +ideaPlugin() diff --git a/jps-plugin/build.gradle.kts.as34 b/jps-plugin/build.gradle.kts.as34 new file mode 100644 index 00000000000..c8cfa68a943 --- /dev/null +++ b/jps-plugin/build.gradle.kts.as34 @@ -0,0 +1,55 @@ +plugins { + kotlin("jvm") + id("jps-compatible") +} + +val compilerModules: Array by rootProject.extra + +dependencies { + compile(project(":kotlin-build-common")) + compile(project(":core:descriptors")) + compile(project(":core:descriptors.jvm")) + compile(project(":kotlin-compiler-runner")) + compile(project(":compiler:daemon-common")) + compile(projectRuntimeJar(":kotlin-daemon-client")) + compile(project(":compiler:frontend.java")) + compile(project(":js:js.frontend")) + compile(projectRuntimeJar(":kotlin-preloader")) + compile(project(":idea:idea-jps-common")) + compileOnly(group = "org.jetbrains", name = "annotations", version = "13.0") + compileOnly(intellijDep()) { + includeJars("jdom", "trove4j", "jps-model", "openapi", "platform-api", "util", "asm-all", rootProject = rootProject) + } + compileOnly(intellijDep("jps-standalone")) { includeJars("jps-builders", "jps-builders-6") } + testCompileOnly(project(":kotlin-reflect-api")) + testCompile(project(":compiler:incremental-compilation-impl")) + testCompile(projectTests(":compiler:tests-common")) + testCompile(projectTests(":compiler:incremental-compilation-impl")) + testCompile(commonDep("junit:junit")) + testCompile(project(":kotlin-test:kotlin-test-jvm")) + testCompile(projectTests(":kotlin-build-common")) + testCompileOnly(intellijDep("jps-standalone")) { includeJars("jps-builders", "jps-builders-6") } + testCompileOnly(intellijDep()) { includeJars("openapi", "idea", "platform-api", "log4j") } + testCompile(intellijDep("jps-build-test")) + compilerModules.forEach { + testRuntime(project(it)) + } + testRuntime(intellijDep()) + testRuntime(project(":kotlin-reflect")) +} + +sourceSets { + "main" { projectDefault() } + "test" { + /*java.srcDirs("jps-tests/test" + /*, "kannotator-jps-plugin-test/test"*/ // Obsolete + )*/ + } +} + +projectTest { + dependsOn(":kotlin-compiler:dist") + workingDir = rootDir +} + +testsJar {} diff --git a/jps-plugin/src/org/jetbrains/kotlin/jps/build/ideaPlatform.kt.as34 b/jps-plugin/src/org/jetbrains/kotlin/jps/build/ideaPlatform.kt.as34 new file mode 100644 index 00000000000..c014f4b30fa --- /dev/null +++ b/jps-plugin/src/org/jetbrains/kotlin/jps/build/ideaPlatform.kt.as34 @@ -0,0 +1,13 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. 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.jps.build + +import org.jetbrains.jps.incremental.CompileContext +import org.jetbrains.jps.incremental.messages.CompilerMessage + +fun jpsReportInternalBuilderError(context: CompileContext, error: Throwable) { + KotlinBuilder.LOG.info(error) +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/groovyTraitsWithFields/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/groovyTraitsWithFields/build.gradle index 18ecef3b403..44f5030c014 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/groovyTraitsWithFields/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/groovyTraitsWithFields/build.gradle @@ -9,7 +9,6 @@ buildscript { } apply plugin: "kotlin" -apply plugin: "groovy" apply plugin: "java" repositories { @@ -19,14 +18,7 @@ repositories { dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - compile 'org.codehaus.groovy:groovy-all:2.5.3' -} - -compileGroovy.dependsOn = compileGroovy.taskDependencies.values - 'compileJava' - -compileKotlin { - dependsOn compileGroovy - classpath += files(compileGroovy.destinationDir) + compile project(":lib") } compileKotlin { diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/groovyTraitsWithFields/lib/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/groovyTraitsWithFields/lib/build.gradle new file mode 100644 index 00000000000..7c96c3e8bce --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/groovyTraitsWithFields/lib/build.gradle @@ -0,0 +1,9 @@ +apply plugin: "groovy" + +repositories { + mavenCentral() +} + +dependencies { + compile 'org.codehaus.groovy:groovy-all:2.5.3' +} diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/groovyTraitsWithFields/src/main/groovy/MyTrait.groovy b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/groovyTraitsWithFields/lib/src/main/groovy/MyTrait.groovy similarity index 100% rename from libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/groovyTraitsWithFields/src/main/groovy/MyTrait.groovy rename to libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/groovyTraitsWithFields/lib/src/main/groovy/MyTrait.groovy diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/groovyTraitsWithFields/src/main/groovy/MyTraitAccessor.groovy b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/groovyTraitsWithFields/lib/src/main/groovy/MyTraitAccessor.groovy similarity index 100% rename from libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/groovyTraitsWithFields/src/main/groovy/MyTraitAccessor.groovy rename to libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/groovyTraitsWithFields/lib/src/main/groovy/MyTraitAccessor.groovy diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/groovyTraitsWithFields/settings.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/groovyTraitsWithFields/settings.gradle new file mode 100644 index 00000000000..ea3dc068931 --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/groovyTraitsWithFields/settings.gradle @@ -0,0 +1 @@ +include ":lib" diff --git a/libraries/tools/kotlin-stdlib-gen/build.gradle b/libraries/tools/kotlin-stdlib-gen/build.gradle index e18761bffd8..f5045841fef 100644 --- a/libraries/tools/kotlin-stdlib-gen/build.gradle +++ b/libraries/tools/kotlin-stdlib-gen/build.gradle @@ -11,7 +11,7 @@ dependencies { compileKotlin { kotlinOptions { - freeCompilerArgs = ["-version", "-Xnormalize-constructor-calls=enable", "-XXLanguage:-ReleaseCoroutines"] + freeCompilerArgs = ["-version"] } } diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Filtering.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Filtering.kt index e44ea2a824a..25755a61c25 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Filtering.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Filtering.kt @@ -749,7 +749,7 @@ object Filtering : TemplateGroupBase() { typeParam("reified R") typeParam("C : MutableCollection") inline() - receiverAsterisk = true + genericStarProjection = true returns("C") body { """ @@ -766,7 +766,7 @@ object Filtering : TemplateGroupBase() { typeParam("reified R") returns("List<@kotlin.internal.NoInfer R>") inline() - receiverAsterisk = true + genericStarProjection = true body { """ return filterIsInstanceTo(ArrayList()) @@ -790,7 +790,7 @@ object Filtering : TemplateGroupBase() { include(Iterables, ArraysOfObjects, Sequences) } builder { doc { "Appends all elements that are instances of specified class to the given [destination]." } - receiverAsterisk = true + genericStarProjection = true typeParam("C : MutableCollection") typeParam("R") returns("C") @@ -808,7 +808,7 @@ object Filtering : TemplateGroupBase() { include(Iterables, ArraysOfObjects, Sequences) } builder { doc { "Returns a list containing all elements that are instances of specified class." } - receiverAsterisk= true + genericStarProjection = true typeParam("R") returns("List") body { diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Numeric.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Numeric.kt index 16e5c040679..a22e04d11c7 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Numeric.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Numeric.kt @@ -13,7 +13,6 @@ object Numeric : TemplateGroupBase() { } } - // TODO: use just numericPrimitives private val numericPrimitivesDefaultOrder = PrimitiveType.defaultPrimitives intersect PrimitiveType.numericPrimitives val f_sum = fn("sum()") { diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/dsl/MemberBuilder.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/dsl/MemberBuilder.kt index 4a4940b9dd0..c301abc612d 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/dsl/MemberBuilder.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/dsl/MemberBuilder.kt @@ -60,7 +60,7 @@ class MemberBuilder( val typeParams = mutableListOf() var primaryTypeParameter: String? = null; private set var customReceiver: String? = null; private set - var receiverAsterisk: Boolean = false // TODO: rename to genericStarProjection + var genericStarProjection: Boolean = false var toNullableT: Boolean = false var returns: String? = null; private set @@ -246,19 +246,19 @@ class MemberBuilder( return answer.toString() } - val isAsteriskOrT = if (receiverAsterisk) "*" else primaryTypeParameter + val receiverT = if (genericStarProjection) "*" else primaryTypeParameter val self = (when (family) { - Iterables -> "Iterable<$isAsteriskOrT>" - Collections -> "Collection<$isAsteriskOrT>" - Lists -> "List<$isAsteriskOrT>" + Iterables -> "Iterable<$receiverT>" + Collections -> "Collection<$receiverT>" + Lists -> "List<$receiverT>" Maps -> "Map" - Sets -> "Set<$isAsteriskOrT>" - Sequences -> "Sequence<$isAsteriskOrT>" + Sets -> "Set<$receiverT>" + Sequences -> "Sequence<$receiverT>" InvariantArraysOfObjects -> "Array<$primaryTypeParameter>" - ArraysOfObjects -> "Array<${isAsteriskOrT.replace(primaryTypeParameter, "out $primaryTypeParameter")}>" + ArraysOfObjects -> "Array<${receiverT.replace(primaryTypeParameter, "out $primaryTypeParameter")}>" Strings -> "String" CharSequences -> "CharSequence" - Ranges -> "ClosedRange<$isAsteriskOrT>" + Ranges -> "ClosedRange<$receiverT>" ArraysOfPrimitives, ArraysOfUnsigned -> primitive?.let { it.name + "Array" } ?: throw IllegalArgumentException("Primitive array should specify primitive type") RangesOfPrimitives -> primitive?.let { it.name + "Range" } ?: throw IllegalArgumentException("Primitive range should specify primitive type") ProgressionsOfPrimitives -> primitive?.let { it.name + "Progression" } ?: throw IllegalArgumentException("Primitive progression should specify primitive type") diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/dsl/TemplateGroups.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/dsl/TemplateGroups.kt index f9ff22a386c..a983ca0a1b2 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/dsl/TemplateGroups.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/dsl/TemplateGroups.kt @@ -5,7 +5,6 @@ package templates -import kotlin.coroutines.experimental.buildSequence import kotlin.reflect.KTypeProjection import kotlin.reflect.full.createType import kotlin.reflect.full.isSubtypeOf @@ -17,7 +16,7 @@ fun templateGroupOf(vararg templates: MemberTemplate): TemplateGroup = { templat abstract class TemplateGroupBase : TemplateGroup { - override fun invoke(): Sequence = buildSequence { + override fun invoke(): Sequence = sequence { with(this@TemplateGroupBase) { this::class.members.filter { it.name.startsWith("f_") }.forEach { require(it.parameters.size == 1) { "Member $it violates naming convention" } diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/dsl/Templates.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/dsl/Templates.kt index 1042dbc449f..1b91de826a2 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/dsl/Templates.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/dsl/Templates.kt @@ -5,8 +5,6 @@ package templates -import kotlin.coroutines.experimental.* - @DslMarker annotation class TemplateDsl @@ -184,7 +182,7 @@ class FamilyPrimitiveMemberDefinition : MemberTemplateDefinition } } - override fun parametrize(): Sequence> = buildSequence { + override fun parametrize(): Sequence> = sequence { for ((family, primitives) in familyPrimitives) { if (primitives.isEmpty()) yield(family to null) diff --git a/plugins/allopen/allopen-ide/src/AllOpenMavenProjectImportHandler.kt.as34 b/plugins/allopen/allopen-ide/src/AllOpenMavenProjectImportHandler.kt.as34 new file mode 100644 index 00000000000..e69de29bb2d diff --git a/plugins/android-extensions/android-extensions-idea/src/org/jetbrains/kotlin/android/model/impl/AndroidModuleInfoProviderImpl.kt.as34 b/plugins/android-extensions/android-extensions-idea/src/org/jetbrains/kotlin/android/model/impl/AndroidModuleInfoProviderImpl.kt.as34 new file mode 100644 index 00000000000..7e734004783 --- /dev/null +++ b/plugins/android-extensions/android-extensions-idea/src/org/jetbrains/kotlin/android/model/impl/AndroidModuleInfoProviderImpl.kt.as34 @@ -0,0 +1,78 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. 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.android.model.impl + +import com.android.builder.model.SourceProvider +import com.android.tools.idea.gradle.project.GradleProjectInfo +import com.android.tools.idea.gradle.project.model.AndroidModuleModel +import com.android.tools.idea.res.ResourceRepositoryManager +import com.intellij.openapi.module.Module +import com.intellij.openapi.vfs.VirtualFile +import org.jetbrains.android.facet.AndroidFacet +import org.jetbrains.kotlin.android.model.AndroidModuleInfoProvider +import java.io.File + +class AndroidModuleInfoProviderImpl(override val module: Module) : AndroidModuleInfoProvider { + private val androidFacet: AndroidFacet? + get() = AndroidFacet.getInstance(module) + + private val androidModuleModel: AndroidModuleModel? + get() = AndroidModuleModel.get(module) + + override fun isAndroidModule() = androidFacet != null + override fun isGradleModule() = GradleProjectInfo.getInstance(module.project).isBuildWithGradle + + override fun getAllResourceDirectories(): List { + return androidFacet?.allResourceDirectories ?: emptyList() + } + + override fun getApplicationPackage() = androidFacet?.manifest?.`package`?.toString() + + override fun getMainSourceProvider(): AndroidModuleInfoProvider.SourceProviderMirror? { + return androidFacet?.mainSourceProvider?.let(::SourceProviderMirrorImpl) + } + + override fun getApplicationResourceDirectories(createIfNecessary: Boolean): Collection { + return ResourceRepositoryManager.getOrCreateInstance(module)?.getAppResources(createIfNecessary)?.resourceDirs ?: emptyList() + } + + override fun getAllSourceProviders(): List { + val androidModuleModel = this.androidModuleModel ?: return emptyList() + return androidModuleModel.allSourceProviders.map(::SourceProviderMirrorImpl) + } + + override fun getActiveSourceProviders(): List { + val androidModuleModel = this.androidModuleModel ?: return emptyList() + return androidModuleModel.activeSourceProviders.map(::SourceProviderMirrorImpl) + } + + override fun getFlavorSourceProviders(): List { + val androidModuleModel = this.androidModuleModel ?: return emptyList() + + val getFlavorSourceProvidersMethod = try { + AndroidFacet::class.java.getMethod("getFlavorSourceProviders") + } catch (e: NoSuchMethodException) { + null + } + + return if (getFlavorSourceProvidersMethod != null) { + @Suppress("UNCHECKED_CAST") + val sourceProviders = getFlavorSourceProvidersMethod.invoke(androidFacet) as? List + sourceProviders?.map(::SourceProviderMirrorImpl) ?: emptyList() + } else { + androidModuleModel.flavorSourceProviders.map(::SourceProviderMirrorImpl) + } + } + + private class SourceProviderMirrorImpl(val sourceProvider: SourceProvider) : + AndroidModuleInfoProvider.SourceProviderMirror { + override val name: String + get() = sourceProvider.name + + override val resDirectories: Collection + get() = sourceProvider.resDirectories + } +} \ No newline at end of file diff --git a/plugins/annotation-based-compiler-plugins-ide-support/src/AbstractMavenImportHandler.kt.as34 b/plugins/annotation-based-compiler-plugins-ide-support/src/AbstractMavenImportHandler.kt.as34 new file mode 100644 index 00000000000..e69de29bb2d diff --git a/plugins/kapt3/kapt3-idea/src/org/jetbrains/kotlin/kapt/idea/KaptProjectResolverExtension.kt.as34 b/plugins/kapt3/kapt3-idea/src/org/jetbrains/kotlin/kapt/idea/KaptProjectResolverExtension.kt.as34 new file mode 100644 index 00000000000..846f0760428 --- /dev/null +++ b/plugins/kapt3/kapt3-idea/src/org/jetbrains/kotlin/kapt/idea/KaptProjectResolverExtension.kt.as34 @@ -0,0 +1,161 @@ +/* + * Copyright 2010-2017 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.kotlin.kapt.idea + +import com.intellij.openapi.diagnostic.Logger +import com.intellij.openapi.externalSystem.model.DataNode +import com.intellij.openapi.externalSystem.model.ProjectKeys +import com.intellij.openapi.externalSystem.model.project.* +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.tooling.model.idea.IdeaModule +import org.jetbrains.kotlin.gradle.AbstractKotlinGradleModelBuilder +import org.jetbrains.kotlin.idea.framework.GRADLE_SYSTEM_ID +import org.jetbrains.plugins.gradle.model.data.GradleSourceSetData +import org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension +import org.jetbrains.plugins.gradle.tooling.ErrorMessageBuilder +import java.io.File +import java.io.Serializable +import java.lang.Exception +import java.lang.reflect.Modifier + +interface KaptSourceSetModel : Serializable { + val sourceSetName: String + val isTest: Boolean + val generatedSourcesDir: String + val generatedClassesDir: String + val generatedKotlinSourcesDir: String + + val generatedSourcesDirFile get() = generatedSourcesDir.takeIf { it.isNotEmpty() }?.let(::File) + val generatedClassesDirFile get() = generatedClassesDir.takeIf { it.isNotEmpty() }?.let(::File) + val generatedKotlinSourcesDirFile get() = generatedKotlinSourcesDir.takeIf { it.isNotEmpty() }?.let(::File) +} + +class KaptSourceSetModelImpl( + override val sourceSetName: String, + override val isTest: Boolean, + override val generatedSourcesDir: String, + override val generatedClassesDir: String, + override val generatedKotlinSourcesDir: String +) : KaptSourceSetModel + +interface KaptGradleModel : Serializable { + val isEnabled: Boolean + val buildDirectory: File + val sourceSets: List +} + +class KaptGradleModelImpl( + override val isEnabled: Boolean, + override val buildDirectory: File, + override val sourceSets: List +) : KaptGradleModel + +@Suppress("unused") +class KaptProjectResolverExtension : AbstractProjectResolverExtension() { + private companion object { + private val LOG = Logger.getInstance(KaptProjectResolverExtension::class.java) + } + + override fun getExtraProjectModelClasses() = setOf(KaptGradleModel::class.java) + override fun getToolingExtensionsClasses() = setOf(KaptModelBuilderService::class.java, Unit::class.java) + + override fun populateModuleExtraModels(gradleModule: IdeaModule, ideModule: DataNode) { + val kaptModel = resolverCtx.getExtraProject(gradleModule, KaptGradleModel::class.java) ?: return + + if (kaptModel.isEnabled) { + for (sourceSet in kaptModel.sourceSets) { + val sourceSetDataNode = ideModule.findGradleSourceSet(sourceSet.sourceSetName) ?: continue + + fun addSourceSet(path: String, type: ExternalSystemSourceType) { + val contentRootData = ContentRootData(GRADLE_SYSTEM_ID, path) + contentRootData.storePath(type, path) + sourceSetDataNode.createChild(ProjectKeys.CONTENT_ROOT, contentRootData) + } + + val sourceType = if (sourceSet.isTest) ExternalSystemSourceType.TEST_GENERATED else ExternalSystemSourceType.SOURCE_GENERATED + sourceSet.generatedSourcesDirFile?.let { addSourceSet(it.absolutePath, sourceType) } + sourceSet.generatedKotlinSourcesDirFile?.let { addSourceSet(it.absolutePath, sourceType) } + + sourceSet.generatedClassesDirFile?.let { generatedClassesDir -> + val libraryData = LibraryData(GRADLE_SYSTEM_ID, "kaptGeneratedClasses") + libraryData.addPath(LibraryPathType.BINARY, generatedClassesDir.absolutePath) + val libraryDependencyData = LibraryDependencyData(sourceSetDataNode.data, libraryData, LibraryLevel.MODULE) + sourceSetDataNode.createChild(ProjectKeys.LIBRARY_DEPENDENCY, libraryDependencyData) + } + } + } + + super.populateModuleExtraModels(gradleModule, ideModule) + } + + private fun DataNode.findGradleSourceSet(sourceSetName: String): DataNode? { + val moduleName = data.id + for (child in children) { + val gradleSourceSetData = child.data as? GradleSourceSetData ?: continue + if (gradleSourceSetData.id == "$moduleName:$sourceSetName") { + @Suppress("UNCHECKED_CAST") + return child as DataNode? + } + } + + return null + } +} + +class KaptModelBuilderService : AbstractKotlinGradleModelBuilder() { + override fun getErrorMessageBuilder(project: Project, e: Exception): ErrorMessageBuilder { + return ErrorMessageBuilder.create(project, e, "Gradle import errors") + .withDescription("Unable to build kotlin-kapt plugin configuration") + } + + override fun canBuild(modelName: String?): Boolean = modelName == KaptGradleModel::class.java.name + + override fun buildAll(modelName: String?, project: Project): Any { + val kaptPlugin: Plugin<*>? = project.plugins.findPlugin("kotlin-kapt") + val kaptIsEnabled = kaptPlugin != null + + val sourceSets = mutableListOf() + + if (kaptIsEnabled) { + project.getAllTasks(false)[project]?.forEach { compileTask -> + if (compileTask.javaClass.name !in kotlinCompileTaskClasses) return@forEach + + val sourceSetName = compileTask.getSourceSetName() + val isTest = sourceSetName.toLowerCase().endsWith("test") + + val kaptGeneratedSourcesDir = getKaptDirectory("getKaptGeneratedSourcesDir", project, sourceSetName) + val kaptGeneratedClassesDir = getKaptDirectory("getKaptGeneratedClassesDir", project, sourceSetName) + val kaptGeneratedKotlinSourcesDir = getKaptDirectory("getKaptGeneratedKotlinSourcesDir", project, sourceSetName) + sourceSets += KaptSourceSetModelImpl( + sourceSetName, isTest, kaptGeneratedSourcesDir, kaptGeneratedClassesDir, kaptGeneratedKotlinSourcesDir) + } + } + + return KaptGradleModelImpl(kaptIsEnabled, project.buildDir, sourceSets) + } + + private fun getKaptDirectory(funName: String, project: Project, sourceSetName: String): String { + val kotlinKaptPlugin = project.plugins.findPlugin("kotlin-kapt") ?: return "" + + val targetMethod = kotlinKaptPlugin::class.java.methods.firstOrNull { + Modifier.isStatic(it.modifiers) && it.name == funName && it.parameterCount == 2 + } ?: return "" + + return (targetMethod(null, project, sourceSetName) as? File)?.absolutePath ?: "" + } +} \ No newline at end of file diff --git a/plugins/kotlin-serialization/kotlin-serialization-ide/src/org/jetbrains/kotlinx/serialization/idea/KotlinSerializationMavenImportHandler.kt.as34 b/plugins/kotlin-serialization/kotlin-serialization-ide/src/org/jetbrains/kotlinx/serialization/idea/KotlinSerializationMavenImportHandler.kt.as34 new file mode 100644 index 00000000000..e69de29bb2d diff --git a/plugins/noarg/noarg-ide/src/NoArgMavenProjectImportHandler.kt.as34 b/plugins/noarg/noarg-ide/src/NoArgMavenProjectImportHandler.kt.as34 new file mode 100644 index 00000000000..e69de29bb2d diff --git a/plugins/sam-with-receiver/sam-with-receiver-ide/src/SamWithReceiverMavenProjectImportHandler.kt.as34 b/plugins/sam-with-receiver/sam-with-receiver-ide/src/SamWithReceiverMavenProjectImportHandler.kt.as34 new file mode 100644 index 00000000000..e69de29bb2d diff --git a/prepare/compiler/build.gradle.kts.as34 b/prepare/compiler/build.gradle.kts.as34 new file mode 100644 index 00000000000..956f38d7da1 --- /dev/null +++ b/prepare/compiler/build.gradle.kts.as34 @@ -0,0 +1,155 @@ +import java.io.File +import proguard.gradle.ProGuardTask +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar +import org.gradle.api.artifacts.maven.Conf2ScopeMappingContainer.COMPILE +import org.gradle.api.file.DuplicatesStrategy + +description = "Kotlin Compiler" + +plugins { + // HACK: java plugin makes idea import dependencies on this project as source (with empty sources however), + // this prevents reindexing of kotlin-compiler.jar after build on every change in compiler modules + java +} + +// You can run Gradle with "-Pkotlin.build.proguard=true" to enable ProGuard run on kotlin-compiler.jar (on TeamCity, ProGuard always runs) +val shrink = + findProperty("kotlin.build.proguard")?.toString()?.toBoolean() + ?: hasProperty("teamcity") + +val compilerManifestClassPath = "kotlin-stdlib.jar kotlin-reflect.jar kotlin-script-runtime.jar" + +val fatJarContents by configurations.creating + +val fatJarContentsStripMetadata by configurations.creating +val fatJarContentsStripServices by configurations.creating +val fatSourcesJarContents by configurations.creating +val fatJar by configurations.creating +val compilerJar by configurations.creating +val runtimeJar by configurations.creating +val compile by configurations // maven plugin writes pom compile scope from compile configuration by default +val libraries by configurations.creating { + extendsFrom(compile) +} + +val default by configurations +default.extendsFrom(runtimeJar) + +val compilerBaseName = name + +val outputJar = fileFrom(buildDir, "libs", "$compilerBaseName.jar") + +val compilerModules: Array by rootProject.extra + +compilerModules.forEach { evaluationDependsOn(it) } + +val compiledModulesSources = compilerModules.map { + project(it).mainSourceSet.allSource +} + +dependencies { + compile(project(":kotlin-stdlib")) + compile(project(":kotlin-script-runtime")) + compile(project(":kotlin-reflect")) + + libraries(project(":kotlin-annotations-jvm")) + libraries( + files( + firstFromJavaHomeThatExists("jre/lib/rt.jar", "../Classes/classes.jar"), + firstFromJavaHomeThatExists("jre/lib/jsse.jar", "../Classes/jsse.jar"), + toolsJar() + ) + ) + + compilerModules.forEach { + fatJarContents(project(it)) { isTransitive = false } + } + + compiledModulesSources.forEach { + fatSourcesJarContents(it) + } + + fatJarContents(project(":core:builtins", configuration = "builtins")) + fatJarContents(commonDep("javax.inject")) + fatJarContents(commonDep("org.jline", "jline")) + fatJarContents(commonDep("org.fusesource.jansi", "jansi")) + fatJarContents(protobufFull()) + fatJarContents(commonDep("com.google.code.findbugs", "jsr305")) + fatJarContents(commonDep("io.javaslang", "javaslang")) + fatJarContents(commonDep("org.jetbrains.kotlinx", "kotlinx-coroutines-core")) { isTransitive = false } + + fatJarContents(intellijCoreDep()) { includeJars("intellij-core") } + fatJarContents(intellijDep()) { includeIntellijCoreJarDependencies(project, { !(it.startsWith("jdom") || it.startsWith("log4j")) }) } + fatJarContents(intellijDep()) { includeJars("jna-platform", "lz4-1.3.0") } + fatJarContentsStripServices(intellijDep("jps-standalone")) { includeJars("jps-model") } + fatJarContentsStripMetadata(intellijDep()) { includeJars("oro-2.0.8", "jdom", "log4j" ) } +} + +noDefaultJar() + +val packCompiler by task { + configurations = listOf(fatJar) + setDuplicatesStrategy(DuplicatesStrategy.EXCLUDE) + destinationDir = File(buildDir, "libs") + + setupPublicJar(compilerBaseName, "before-proguard") + + from(fatJarContents) + + dependsOn(fatJarContentsStripServices) + from { + fatJarContentsStripServices.files.map { + zipTree(it).matching { exclude("META-INF/services/**") } + } + } + + dependsOn(fatJarContentsStripMetadata) + from { + fatJarContentsStripMetadata.files.map { + zipTree(it).matching { exclude("META-INF/jb/**", "META-INF/LICENSE") } + } + } + + manifest.attributes["Class-Path"] = compilerManifestClassPath + manifest.attributes["Main-Class"] = "org.jetbrains.kotlin.cli.jvm.K2JVMCompiler" +} + +val proguard by task { + dependsOn(packCompiler) + configuration("$rootDir/compiler/compiler.pro") + + val outputJar = fileFrom(buildDir, "libs", "$compilerBaseName-after-proguard.jar") + + inputs.files(packCompiler.outputs.files.singleFile) + outputs.file(outputJar) + + // TODO: remove after dropping compatibility with ant build + doFirst { + System.setProperty("kotlin-compiler-jar-before-shrink", packCompiler.outputs.files.singleFile.canonicalPath) + System.setProperty("kotlin-compiler-jar", outputJar.canonicalPath) + } + + libraryjars(mapOf("filter" to "!META-INF/versions/**"), libraries) + + printconfiguration("$buildDir/compiler.pro.dump") +} + +val pack = if (shrink) proguard else packCompiler + +dist( + targetName = "$compilerBaseName.jar", + fromTask = pack +) + +runtimeJarArtifactBy(pack, pack.outputs.files.singleFile) { + name = compilerBaseName + classifier = "" +} + +sourcesJar { + from(fatSourcesJarContents) +} + +javadocJar() + +publish() diff --git a/prepare/jps-plugin/build.gradle.kts.as34 b/prepare/jps-plugin/build.gradle.kts.as34 new file mode 100644 index 00000000000..73c2fee4a65 --- /dev/null +++ b/prepare/jps-plugin/build.gradle.kts.as34 @@ -0,0 +1,37 @@ +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar + +description = "Kotlin JPS plugin" + +plugins { + `java-base` + id("pill-configurable") +} + +val projectsToShadow = listOf( + ":kotlin-build-common", + ":compiler:cli-common", + ":kotlin-compiler-runner", + ":compiler:daemon-common", + ":core:descriptors", + ":core:descriptors.jvm", + ":idea:idea-jps-common", + ":jps-plugin", + ":kotlin-preloader", + ":compiler:util", + ":core:util.runtime") + +dependencies { + projectsToShadow.forEach { + embeddedComponents(project(it)) { isTransitive = false } + } + embeddedComponents(projectRuntimeJar(":kotlin-daemon-client")) +} + +runtimeJar(task("jar")) { + manifest.attributes.put("Main-Class", "org.jetbrains.kotlin.runner.Main") + manifest.attributes.put("Class-Path", "kotlin-stdlib.jar") + from(files("$rootDir/resources/kotlinManifest.properties")) + fromEmbeddedComponents() +} + +ideaPlugin("lib/jps") diff --git a/versions.gradle.kts.as34 b/versions.gradle.kts.as34 index 9251a2ba5da..266d0e36db1 100644 --- a/versions.gradle.kts.as34 +++ b/versions.gradle.kts.as34 @@ -1,8 +1,8 @@ -extra["versions.intellijSdk"] = "182.4505.22" +extra["versions.intellijSdk"] = "183.2153.8" extra["versions.androidBuildTools"] = "r23.0.1" extra["versions.idea.NodeJS"] = "181.3494.12" -extra["versions.androidStudioRelease"] = "3.4.0.0" -extra["versions.androidStudioBuild"] = "182.5070326" +extra["versions.androidStudioRelease"] = "3.4.0.1" +extra["versions.androidStudioBuild"] = "183.5081642" val gradleJars = listOf( "gradle-api", @@ -153,17 +153,17 @@ when (platform) { extra["ignore.jar.lombok-ast"] = true } "AS34" -> { - extra["versions.jar.guava"] = "23.6-jre" + extra["versions.jar.guava"] = "25.1-jre" extra["versions.jar.groovy-all"] = "2.4.15" extra["versions.jar.lombok-ast"] = "0.2.3" extra["versions.jar.swingx-core"] = "1.6.2-2" extra["versions.jar.kxml2"] = "2.3.0" - extra["versions.jar.streamex"] = "0.6.5" + extra["versions.jar.streamex"] = "0.6.7" extra["versions.jar.gson"] = "2.8.4" extra["versions.jar.oro"] = "2.0.8" extra["versions.jar.picocontainer"] = "1.2" for (jar in gradleJars) { - extra["versions.jar.$jar"] = "4.4" + extra["versions.jar.$jar"] = "4.5.1" } extra["ignore.jar.snappy-in-java"] = true