tests: apply official code style

#KT-38632 Fixed
This commit is contained in:
Dmitry Gridin
2020-04-28 15:51:57 +07:00
parent d8f9643650
commit 11a3482970
406 changed files with 1785 additions and 1525 deletions
@@ -4,8 +4,8 @@ interface I {
class CCCC( class CCCC(
over<caret> over<caret>
private val v1: Int, private val v1: Int,
private val v2: Int private val v2: Int
) : I ) : I
// ELEMENT_TEXT: "override val p: Int" // ELEMENT_TEXT: "override val p: Int"
@@ -3,9 +3,9 @@ interface I {
} }
class CCCC( class CCCC(
override val p: Int<caret> override val p: Int<caret>
private val v1: Int, private val v1: Int,
private val v2: Int private val v2: Int
) : I ) : I
// ELEMENT_TEXT: "override val p: Int" // ELEMENT_TEXT: "override val p: Int"
@@ -115,8 +115,10 @@ class SmartEnterCompletionTest : KotlinLightCodeInsightFixtureTestCase() {
fun foo(p:Int) {} fun foo(p:Int) {}
fun test() { fun test() {
foo(1 + foo(
2)<caret> 1 +
2
)<caret>
} }
""" """
) )
@@ -1,5 +1,5 @@
/* /*
* Copyright 2000-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. * Copyright 2000-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/ */
@@ -40,6 +40,7 @@ import org.jetbrains.kotlin.idea.KotlinFileType
import org.jetbrains.kotlin.idea.compiler.configuration.KotlinCommonCompilerArgumentsHolder import org.jetbrains.kotlin.idea.compiler.configuration.KotlinCommonCompilerArgumentsHolder
import org.jetbrains.kotlin.idea.compiler.configuration.KotlinCompilerSettings import org.jetbrains.kotlin.idea.compiler.configuration.KotlinCompilerSettings
import org.jetbrains.kotlin.idea.facet.* import org.jetbrains.kotlin.idea.facet.*
import org.jetbrains.kotlin.idea.formatter.KotlinStyleGuideCodeStyle
import org.jetbrains.kotlin.idea.inspections.UnusedSymbolInspection import org.jetbrains.kotlin.idea.inspections.UnusedSymbolInspection
import org.jetbrains.kotlin.idea.test.CompilerTestDirectives.COMPILER_ARGUMENTS_DIRECTIVE import org.jetbrains.kotlin.idea.test.CompilerTestDirectives.COMPILER_ARGUMENTS_DIRECTIVE
import org.jetbrains.kotlin.idea.test.CompilerTestDirectives.JVM_TARGET_DIRECTIVE import org.jetbrains.kotlin.idea.test.CompilerTestDirectives.JVM_TARGET_DIRECTIVE
@@ -76,6 +77,8 @@ abstract class KotlinLightCodeInsightFixtureTestCase : KotlinLightCodeInsightFix
override fun setUp() { override fun setUp() {
super.setUp() super.setUp()
enableKotlinOfficialCodeStyle(project)
// We do it here to avoid possible initialization problems // We do it here to avoid possible initialization problems
// UnusedSymbolInspection() calls IDEA UnusedDeclarationInspection() in static initializer, // UnusedSymbolInspection() calls IDEA UnusedDeclarationInspection() in static initializer,
// which in turn registers some extensions provoking "modifications aren't allowed during highlighting" // which in turn registers some extensions provoking "modifications aren't allowed during highlighting"
@@ -101,7 +104,7 @@ abstract class KotlinLightCodeInsightFixtureTestCase : KotlinLightCodeInsightFix
override fun tearDown() { override fun tearDown() {
LoggedErrorProcessor.restoreDefaultProcessor() LoggedErrorProcessor.restoreDefaultProcessor()
disableKotlinOfficialCodeStyle(project)
super.tearDown() super.tearDown()
if (exceptions.isNotEmpty()) { if (exceptions.isNotEmpty()) {
@@ -312,6 +315,14 @@ fun configureCodeStyleAndRun(
} }
} }
fun enableKotlinOfficialCodeStyle(project: Project) {
KotlinStyleGuideCodeStyle.apply(CodeStyle.getSettings(project))
}
fun disableKotlinOfficialCodeStyle(project: Project) {
CodeStyle.getSettings(project)
}
private fun rollbackCompilerOptions(project: Project, module: Module, removeFacet: Boolean) { private fun rollbackCompilerOptions(project: Project, module: Module, removeFacet: Boolean) {
KotlinCompilerSettings.getInstance(project).update { this.additionalArguments = DEFAULT_ADDITIONAL_ARGUMENTS } KotlinCompilerSettings.getInstance(project).update { this.additionalArguments = DEFAULT_ADDITIONAL_ARGUMENTS }
KotlinCommonCompilerArgumentsHolder.getInstance(project).update { this.languageVersion = LanguageVersion.LATEST_STABLE.versionString } KotlinCommonCompilerArgumentsHolder.getInstance(project).update { this.languageVersion = LanguageVersion.LATEST_STABLE.versionString }
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/ */
@@ -17,12 +17,14 @@ import kotlin.reflect.full.findAnnotation
abstract class KotlinLightPlatformCodeInsightFixtureTestCase : LightPlatformCodeInsightFixtureTestCase() { abstract class KotlinLightPlatformCodeInsightFixtureTestCase : LightPlatformCodeInsightFixtureTestCase() {
override fun setUp() { override fun setUp() {
super.setUp() super.setUp()
enableKotlinOfficialCodeStyle(project)
(StartupManager.getInstance(project) as StartupManagerImpl).runPostStartupActivities() (StartupManager.getInstance(project) as StartupManagerImpl).runPostStartupActivities()
VfsRootAccess.allowRootAccess(KotlinTestUtils.getHomeDirectory()) VfsRootAccess.allowRootAccess(KotlinTestUtils.getHomeDirectory())
invalidateLibraryCache(project) invalidateLibraryCache(project)
} }
override fun tearDown() { override fun tearDown() {
disableKotlinOfficialCodeStyle(project)
VfsRootAccess.disallowRootAccess(KotlinTestUtils.getHomeDirectory()) VfsRootAccess.disallowRootAccess(KotlinTestUtils.getHomeDirectory())
super.tearDown() super.tearDown()
@@ -13,4 +13,14 @@ import com.intellij.testFramework.LightPlatformCodeInsightTestCase
abstract class KotlinLightPlatformCodeInsightTestCase : LightPlatformCodeInsightTestCase() { abstract class KotlinLightPlatformCodeInsightTestCase : LightPlatformCodeInsightTestCase() {
protected inline val project_: Project get() = project protected inline val project_: Project get() = project
protected inline val editor_: Editor get() = editor protected inline val editor_: Editor get() = editor
override fun setUp() {
super.setUp()
enableKotlinOfficialCodeStyle(project_)
}
override fun tearDown() {
disableKotlinOfficialCodeStyle(project_)
super.tearDown()
}
} }
@@ -15,4 +15,13 @@ abstract class KotlinLightPlatformCodeInsightTestCase : LightPlatformCodeInsight
protected inline val project_: Project get() = LightPlatformTestCase.getProject() protected inline val project_: Project get() = LightPlatformTestCase.getProject()
protected inline val editor_: Editor get() = LightPlatformCodeInsightTestCase.getEditor() protected inline val editor_: Editor get() = LightPlatformCodeInsightTestCase.getEditor()
override fun setUp() {
super.setUp()
enableKotlinOfficialCodeStyle(project_)
}
override fun tearDown() {
disableKotlinOfficialCodeStyle(project_)
super.tearDown()
}
} }
@@ -1,3 +1,4 @@
fun foo(p: Dependency): Double { fun foo(p: Dependency): Double {
return p.getInt().toDouble() // explicit conversion to Double must be added on conversion (if type Dependency) is correctly resolved return p.getInt()
.toDouble() // explicit conversion to Double must be added on conversion (if type Dependency) is correctly resolved
} }
@@ -5,16 +5,17 @@ class A {
var element = element var element = element
element = JetPsiUtil.ascendIfPropertyAccessor(element) element = JetPsiUtil.ascendIfPropertyAccessor(element)
if (element is JetNamedFunction || element is JetProperty) { if (element is JetNamedFunction || element is JetProperty) {
val bindingContext = AnalyzerFacadeWithCache.analyzeFileWithCache(element.getContainingJetFile()).getBindingContext() val bindingContext =
AnalyzerFacadeWithCache.analyzeFileWithCache(element.getContainingJetFile()).getBindingContext()
val declarationDescriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, element) val declarationDescriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, element)
if (declarationDescriptor is CallableMemberDescriptor) { if (declarationDescriptor is CallableMemberDescriptor) {
val containingDescriptor = declarationDescriptor.getContainingDeclaration() val containingDescriptor = declarationDescriptor.getContainingDeclaration()
if (containingDescriptor is ClassDescriptor) { if (containingDescriptor is ClassDescriptor) {
return JetBundle.message( return JetBundle.message(
"override.declaration.x.in.y", "override.declaration.x.in.y",
DescriptorRenderer.COMPACT.render(declarationDescriptor), DescriptorRenderer.COMPACT.render(declarationDescriptor),
IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_NO_ANNOTATIONS.render(containingDescriptor) IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_NO_ANNOTATIONS.render(containingDescriptor)
) )
} }
} }
@@ -20,8 +20,10 @@ class Target {
} }
var ambiguousKotlin: IAmbiguousKotlin = AmbiguousKotlin() // Should not add import in case of 2 declarations in Kotlin var ambiguousKotlin: IAmbiguousKotlin =
var ambiguous: IAmbiguous = Ambiguous() // Should not add import in case of ambiguous declarations in Kotlin and in Java AmbiguousKotlin() // Should not add import in case of 2 declarations in Kotlin
var ambiguous: IAmbiguous =
Ambiguous() // Should not add import in case of ambiguous declarations in Kotlin and in Java
var ambiguousJava: IAmbiguousJava = AmbiguousJava() // Should not add import in case of 2 declarations in Java var ambiguousJava: IAmbiguousJava = AmbiguousJava() // Should not add import in case of 2 declarations in Java
fun workWithStatics() { fun workWithStatics() {
@@ -1,7 +1,7 @@
fun test() { fun test() {
var a = 1 var a = 1
a = a =
<caret> <caret>
} }
// SET_TRUE: ALIGN_MULTILINE_BINARY_OPERATION // SET_TRUE: ALIGN_MULTILINE_BINARY_OPERATION
@@ -1,7 +1,7 @@
fun test() { fun test() {
var a = 1 var a = 1
a = a =
<caret> <caret>
} }
// SET_TRUE: ALIGN_MULTILINE_BINARY_OPERATION // SET_TRUE: ALIGN_MULTILINE_BINARY_OPERATION
@@ -1,4 +1,4 @@
fun testParam( fun testParam(
<caret> <caret>
) { ) {
} }
@@ -1,2 +1,2 @@
fun test() = fun test() =
<caret> <caret>
@@ -5,4 +5,4 @@ interface A1
open class B1 open class B1
class Simpleclass() : B1(), class Simpleclass() : B1(),
<caret>A1 <caret>A1
@@ -1,3 +1,3 @@
val a: (String) -> String = { val a: (String) -> String = {
<caret>some -> <caret>some ->
} }
@@ -1,4 +1,4 @@
fun test() { fun test() {
val (a, b) = val (a, b) =
<caret> <caret>
} }
@@ -1,2 +1,2 @@
val a = val a =
<caret> <caret>
@@ -1,6 +1,6 @@
fun foo(arg: Any): Int { fun foo(arg: Any): Int {
// 1 // 1
return arg as? Int return arg as? Int
// 2 // 2
?: 10 ?: 10
} }
@@ -6,5 +6,5 @@ val xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
fun main() { fun main() {
val c = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx val c = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
?: "abcdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdf" ?: "abcdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdf"
} }
@@ -2,37 +2,37 @@
fun test(list: List<Int>): List<Pair<IndexedValue<List<Int>>, IndexedValue<List<Int>>>> { fun test(list: List<Int>): List<Pair<IndexedValue<List<Int>>, IndexedValue<List<Int>>>> {
return list return list
.asSequence() .asSequence()
.chunked(1) .chunked(1)
.distinct() .distinct()
.distinctBy { it } .distinctBy { it }
.drop(1) .drop(1)
.dropWhile { true } .dropWhile { true }
.filter { true } .filter { true }
.filterIndexed { index, list -> true } .filterIndexed { index, list -> true }
.filterIsInstance<Int>() .filterIsInstance<Int>()
.filterNot { true } .filterNot { true }
.filterNotNull() .filterNotNull()
.map { it } .map { it }
.mapIndexed { index, i -> i } .mapIndexed { index, i -> i }
.mapIndexedNotNull { index, i -> i } .mapIndexedNotNull { index, i -> i }
.mapNotNull { it } .mapNotNull { it }
.minus(1) .minus(1)
.minusElement(1) .minusElement(1)
.onEach {} .onEach {}
.plus(1) .plus(1)
.plusElement(1) .plusElement(1)
.requireNoNulls() .requireNoNulls()
.sorted() .sorted()
.sortedBy { it } .sortedBy { it }
.sortedByDescending { it } .sortedByDescending { it }
.sortedDescending() .sortedDescending()
.sortedWith(Comparator { o1, o2 -> 0 }) .sortedWith(Comparator { o1, o2 -> 0 })
.take(1) .take(1)
.takeWhile { true } .takeWhile { true }
.windowed(1, 1, true) .windowed(1, 1, true)
.withIndex() .withIndex()
.zipWithNext() .zipWithNext()
.zipWithNext { a, b -> a } .zipWithNext { a, b -> a }
.toList() .toList()
} }
@@ -2,7 +2,7 @@
fun test(list: List<Int>): Int { fun test(list: List<Int>): Int {
return list // comment1 return list // comment1
.<caret>filter { it > 1 } // comment2 .<caret>filter { it > 1 } // comment2
.map { it * 2 } // comment3 .map { it * 2 } // comment3
.sum() // comment4 .sum() // comment4
} }
@@ -2,8 +2,8 @@
fun test(list: List<Int>): Int { fun test(list: List<Int>): Int {
return list // comment1 return list // comment1
.asSequence() .asSequence()
.filter { it > 1 } // comment2 .filter { it > 1 } // comment2
.map { it * 2 } // comment3 .map { it * 2 } // comment3
.sum() // comment4 .sum() // comment4
} }
@@ -2,6 +2,6 @@
fun test(list: List<Int>): List<Int> { fun test(list: List<Int>): List<Int> {
return list // comment1 return list // comment1
.<caret>filter { it > 1 } // comment2 .<caret>filter { it > 1 } // comment2
.map { it * 2 } // comment3 .map { it * 2 } // comment3
} }
@@ -2,8 +2,8 @@
fun test(list: List<Int>): List<Int> { fun test(list: List<Int>): List<Int> {
return list // comment1 return list // comment1
.asSequence() .asSequence()
.filter { it > 1 } // comment2 .filter { it > 1 } // comment2
.map { it * 2 } .map { it * 2 }
.toList() // comment3 .toList() // comment3
} }
@@ -2,7 +2,7 @@
fun test(list: List<List<Int>>): List<Int> { fun test(list: List<List<Int>>): List<Int> {
return list return list
.<caret>filter { it.count() > 2 } .<caret>filter { it.count() > 2 }
.map { it + it } .map { it + it }
.flatMap { it + it } .flatMap { it + it }
} }
@@ -2,9 +2,9 @@
fun test(list: List<List<Int>>): List<Int> { fun test(list: List<List<Int>>): List<Int> {
return list return list
.asSequence() .asSequence()
.filter { it.count() > 2 } .filter { it.count() > 2 }
.map { it + it } .map { it + it }
.toList() .toList()
.flatMap { it + it } .flatMap { it + it }
} }
@@ -2,9 +2,9 @@
fun test(): Int { fun test(): Int {
return listOf(1, 2, 3) return listOf(1, 2, 3)
.<caret>filter { it > 1 } .<caret>filter { it > 1 }
.map { it * 2 } .map { it * 2 }
.let { .let {
it.binarySearch(1) it.binarySearch(1)
} }
} }
@@ -2,11 +2,11 @@
fun test(): Int { fun test(): Int {
return listOf(1, 2, 3) return listOf(1, 2, 3)
.asSequence() .asSequence()
.filter { it > 1 } .filter { it > 1 }
.map { it * 2 } .map { it * 2 }
.toList() .toList()
.let { .let {
it.binarySearch(1) it.binarySearch(1)
} }
} }
@@ -2,8 +2,8 @@
fun test(list: List<Int>?): List<Int>? { fun test(list: List<Int>?): List<Int>? {
return list return list
?.asSequence() ?.asSequence()
?.filter { it > 1 } ?.filter { it > 1 }
?.map { it * 2 } ?.map { it * 2 }
?.toList() ?.toList()
} }
@@ -2,11 +2,11 @@
fun test(list: List<Int>): List<Int> { fun test(list: List<Int>): List<Int> {
return list return list
.asSequence() .asSequence()
.filter { it > 1 } .filter { it > 1 }
.mapNotNull { .mapNotNull {
if (it == 2) return@mapNotNull null if (it == 2) return@mapNotNull null
it * 2 it * 2
} }
.toList() .toList()
} }
@@ -3,5 +3,6 @@
// WITH_RUNTIME // WITH_RUNTIME
fun test(): List<Int> { fun test(): List<Int> {
return listOf(1, 2, 3).asSequence().filter { it > 1 }.map { it * 2 }.map { it * 3 }.map { it * 4 }.map { it * 5 }.toList() return listOf(1, 2, 3).asSequence().filter { it > 1 }.map { it * 2 }.map { it * 3 }.map { it * 4 }.map { it * 5 }
.toList()
} }
@@ -3,8 +3,8 @@
fun test(list: List<Int>): List<Int> { fun test(list: List<Int>): List<Int> {
return list return list
.filter<caret> { it > 1 } .filter<caret> { it > 1 }
.map { it * 2 } .map { it * 2 }
.map { it * 3 } .map { it * 3 }
.map { it * 4 } .map { it * 4 }
} }
@@ -3,10 +3,10 @@
fun test(list: List<Int>): List<Int> { fun test(list: List<Int>): List<Int> {
return list return list
.asSequence() .asSequence()
.filter { it > 1 } .filter { it > 1 }
.map { it * 2 } .map { it * 2 }
.map { it * 3 } .map { it * 3 }
.map { it * 4 } .map { it * 4 }
.toList() .toList()
} }
@@ -2,9 +2,9 @@
fun test(list: List<Int>): List<Int> { fun test(list: List<Int>): List<Int> {
return list return list
.reversed() .reversed()
.<caret>map { it + 1 } .<caret>map { it + 1 }
.map { it + 1 } .map { it + 1 }
.dropLast(1) .dropLast(1)
.takeLast(2) .takeLast(2)
} }
@@ -2,11 +2,11 @@
fun test(list: List<Int>): List<Int> { fun test(list: List<Int>): List<Int> {
return list return list
.reversed() .reversed()
.asSequence() .asSequence()
.map { it + 1 } .map { it + 1 }
.map { it + 1 } .map { it + 1 }
.toList() .toList()
.dropLast(1) .dropLast(1)
.takeLast(2) .takeLast(2)
} }
@@ -2,10 +2,10 @@
fun test(foo: Foo): List<Int> { fun test(foo: Foo): List<Int> {
return foo.getList() return foo.getList()
.asSequence() .asSequence()
.filter { it > 1 } .filter { it > 1 }
.map { it * 2 } .map { it * 2 }
.toList() .toList()
} }
class Foo { class Foo {
@@ -1,5 +1,6 @@
// WITH_RUNTIME // WITH_RUNTIME
fun test(list: List<Int>) { fun test(list: List<Int>) {
val filterIndexedTo: MutableList<Int> = list.asSequence().filter { it > 1 }.filterIndexedTo(mutableListOf()) { index, it -> true } val filterIndexedTo: MutableList<Int> = list.asSequence().filter { it > 1 }
.filterIndexedTo(mutableListOf()) { index, it -> true }
} }
@@ -1,5 +1,6 @@
// WITH_RUNTIME // WITH_RUNTIME
fun test(list: List<Int>) { fun test(list: List<Int>) {
val mapIndexedNotNullTo: MutableList<Int> = list.asSequence().filter { it > 1 }.mapIndexedNotNullTo(mutableListOf()) { index, i -> i } val mapIndexedNotNullTo: MutableList<Int> = list.asSequence().filter { it > 1 }
.mapIndexedNotNullTo(mutableListOf()) { index, i -> i }
} }
@@ -1,12 +1,12 @@
// WITH_RUNTIME // WITH_RUNTIME
val x = listOf(1, 2, 3).joinToString( val x = listOf(1, 2, 3).joinToString(
// comment2 // comment2
prefix = "= ", prefix = "= ",
// comment3 // comment3
separator = " + " separator = " + "
// comment4 // comment4
, ,
// comment1 // comment1
transform = Int::toString transform = Int::toString
) )
@@ -2,11 +2,11 @@
val sb = StringBuilder() val sb = StringBuilder()
val x = listOf(1, 2, 3).joinTo( val x = listOf(1, 2, 3).joinTo(
// comment1 // comment1
buffer = sb, buffer = sb,
// comment2 // comment2
prefix = "= ", prefix = "= ",
// comment3 // comment3
separator = " + " separator = " + "
// comment4 // comment4
) { "$it*$it" } ) { "$it*$it" }
@@ -2,7 +2,7 @@
fun test() { fun test() {
<caret>listOfNotNull( <caret>listOfNotNull(
true, // comment1 true, // comment1
null // comment2 null // comment2
).first() ).first()
} }
@@ -1,3 +1,3 @@
// WITH_RUNTIME // WITH_RUNTIME
val v1 = // Some Comment val v1 = // Some Comment
listOf(1, 2, 3, 11, 33, 25, 100).any { it % 2 == 0 } // Some Additional Comment listOf(1, 2, 3, 11, 33, 25, 100).any { it % 2 == 0 } // Some Additional Comment
@@ -1,3 +1,3 @@
// WITH_RUNTIME // WITH_RUNTIME
val v1 = // Some Comment val v1 = // Some Comment
listOf(1, 2, 3, 11, 33, 25, 100).any { it % 2 == 0 } listOf(1, 2, 3, 11, 33, 25, 100).any { it % 2 == 0 }
@@ -1,6 +1,6 @@
fun foo(p: List<String?>): Int { fun foo(p: List<String?>): Int {
val v = p[0] val v = p[0]
?: // return -1 if null ?: // return -1 if null
<caret>return -1 <caret>return -1
return v.length return v.length
} }
@@ -1,8 +1,8 @@
fun foo(p: List<String?>): Int { fun foo(p: List<String?>): Int {
val v = p[0] val v = p[0]
?: // v is null ?: // v is null
// we should do something with it // we should do something with it
return -1 // let's return -1 return -1 // let's return -1
// end of if // end of if
return v.length return v.length
} }
@@ -1,6 +1,6 @@
fun foo(): Any { fun foo(): Any {
val yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy = 7 val yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy = 7
val xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx = 24 val xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx = 24
?: return yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy ?: return yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
return 42 return 42
} }
@@ -1,6 +1,6 @@
@Suppress( @Suppress(
"HEADER_CLASS_CONSTRUCTOR_DELEGATION_CALL", "HEADER_CLASS_CONSTRUCTOR_DELEGATION_CALL",
<caret>"HEADER_CLASS_CONSTRUCTOR_PROPERTY_PARAMETER", <caret>"HEADER_CLASS_CONSTRUCTOR_PROPERTY_PARAMETER",
"HEADER_ENUM_CONSTRUCTOR" "HEADER_ENUM_CONSTRUCTOR"
) )
class Dummy class Dummy
@@ -1,6 +1,6 @@
@Suppress( @Suppress(
"HEADER_CLASS_CONSTRUCTOR_DELEGATION_CALL", "HEADER_CLASS_CONSTRUCTOR_DELEGATION_CALL",
"EXPECTED_CLASS_CONSTRUCTOR_PROPERTY_PARAMETER", "EXPECTED_CLASS_CONSTRUCTOR_PROPERTY_PARAMETER",
"HEADER_ENUM_CONSTRUCTOR" "HEADER_ENUM_CONSTRUCTOR"
) )
class Dummy class Dummy
@@ -2,6 +2,6 @@
// FIX: Add trailing comma // FIX: Add trailing comma
fun a( fun a(
i: Int, i: Int,
b: Boolean, b: Boolean,
) = Unit ) = Unit
@@ -2,6 +2,6 @@
// FIX: Add trailing comma // FIX: Add trailing comma
fun a( fun a(
i: Int, i: Int,
b: Boolean, b: Boolean,
) = Unit ) = Unit
@@ -2,6 +2,6 @@
// FIX: Add trailing comma // FIX: Add trailing comma
fun a( fun a(
i: Int, i: Int,
b: Boolean, b: Boolean,
) = Unit ) = Unit
@@ -2,9 +2,9 @@
// FIX: Add trailing comma // FIX: Add trailing comma
val x = { val x = {
x: String, x: String,
y y
: String, : String,
-> ->
val a = 2 val a = 2
} }
@@ -2,7 +2,7 @@
// FIX: Fix comma position // FIX: Fix comma position
fun a( fun a(
i: Int, /* i: Int, /*
*/ */
b: Boolean, b: Boolean,
) = Unit ) = Unit
@@ -2,7 +2,7 @@
// FIX: Fix comma position // FIX: Fix comma position
fun a( fun a(
i: Int, /* i: Int, /*
*/ */
b: Boolean, b: Boolean,
) = Unit ) = Unit
@@ -2,8 +2,8 @@
// FIX: Fix comma position // FIX: Fix comma position
val x = { val x = {
x: Comparable<Comparable<Number>>, x: Comparable<Comparable<Number>>,
y: String, y: String,
-> ->
val a = 42 val a = 42
} }
@@ -2,6 +2,6 @@
// FIX: Add line break // FIX: Add line break
fun a( fun a(
i: Int, i: Int,
b: Boolean, b: Boolean,
) = Unit ) = Unit
@@ -2,6 +2,6 @@
// FIX: Add line break // FIX: Add line break
fun a( fun a(
i: Int, i: Int,
b: Boolean, b: Boolean,
) = Unit ) = Unit
@@ -2,6 +2,6 @@
// FIX: Add line break // FIX: Add line break
fun a( fun a(
i: Int, i: Int,
b: Boolean, b: Boolean,
) = Unit ) = Unit
@@ -1,2 +1,2 @@
fun getText(): String =// let's return xxx fun getText(): String =// let's return xxx
"xxx" //TODO "xxx" //TODO
@@ -1,2 +1,2 @@
fun getText(): String =// let's return xxx fun getText(): String =// let's return xxx
"xxx" "xxx"
@@ -1,2 +1,2 @@
fun getText(): String =/* let's return xxx */ fun getText(): String =/* let's return xxx */
"xxx" /* TODO */ "xxx" /* TODO */
@@ -1,9 +1,9 @@
// HIGHLIGHT: INFORMATION // HIGHLIGHT: INFORMATION
fun abs(x: Int): Int =// No highlighting here fun abs(x: Int): Int =// No highlighting here
if (x > 0) { if (x > 0) {
x x
} }
else { else {
-x -x
} }
@@ -1,4 +1,4 @@
fun foo(s1: String, s2: String) = s1 + s2 fun foo(s1: String, s2: String) = s1 + s2
fun bar(): String = fun bar(): String =
foo("gjahkrgkjuyrtetyuairytoiuyareoihuyitouy897304hkdjgnba", "uiyiuye987130423toiuywtuiyrwityriwyhw") foo("gjahkrgkjuyrtetyuairytoiuyareoihuyitouy897304hkdjgnba", "uiyiuye987130423toiuywtuiyrwityriwyhw")
@@ -1,9 +1,12 @@
// WITH_RUNTIME // WITH_RUNTIME
fun main(args: Array<String>) { fun main(args: Array<String>) {
val doSomething = doSomething("one" + 1, val doSomething = doSomething(
"two", "one" + 1,
3 * 4) "two",
val t = if (doSomething != null) doSomething else throw NullPointerException("Expression 'doSomething(\"one\" + 1, ...' must not be null") 3 * 4
)
val t = if (doSomething != null
) doSomething else throw NullPointerException("Expression 'doSomething(\"one\" + 1, ...' must not be null")
} }
fun doSomething(vararg a: Any): Any? = null fun doSomething(vararg a: Any): Any? = null
@@ -2,7 +2,7 @@ fun foo(arg: Int): Int {
// 1 // 1
when (arg) { when (arg) {
0 -> return 0 0 -> return 0
// 2 // 2
else -> return -1 else -> return -1
} }
} }
@@ -4,17 +4,17 @@ fun foo(arg: Any?): Int {
is Int -> { is Int -> {
return arg // 2 return arg // 2
} }
// 3 // 3
is String -> { is String -> {
return 42 // 4 return 42 // 4
} }
// 5 // 5
null -> { null -> {
// 6 // 6
return 0 return 0
} }
// 7 // 7
// 8 // 8
else -> return -1 else -> return -1
} }
} }
@@ -1,5 +1,5 @@
fun foo(b: Boolean) { fun foo(b: Boolean) {
if (// comment 1 if (// comment 1
b) 1 // comment 2 b) 1 // comment 2
else 2 else 2
} }
@@ -1,7 +1,8 @@
fun foo(a: Int) { fun foo(a: Int) {
if (a if (a
// some comment // some comment
== 0) bar(a) == 0
) bar(a)
// another comment // another comment
else if (a == 1) bar(a) else if (a == 1) bar(a)
@@ -1,8 +1,8 @@
fun f() { fun f() {
foo( foo(
1, 1,
"a", "a",
2 2
) )
} }
@@ -3,9 +3,9 @@
fun f() { fun f() {
foo( foo(
1, 1,
"a", "a",
2, 2,
) )
} }
@@ -1,6 +1,6 @@
fun foo( fun foo(
p: Int, p: Int,
c: Char, c: Char,
b: <caret>Boolean b: <caret>Boolean
) { ) {
} }
@@ -1,8 +1,8 @@
// SET_TRUE: ALLOW_TRAILING_COMMA // SET_TRUE: ALLOW_TRAILING_COMMA
fun foo( fun foo(
p: Int, p: Int,
c: Char, c: Char,
b: <caret>Boolean, b: <caret>Boolean,
) { ) {
} }
@@ -1,6 +1,6 @@
fun foo( fun foo(
p: Int, p: Int,
c: Char, c: Char,
b: <caret>Boolean b: <caret>Boolean
) { ) {
} }
@@ -1,6 +1,6 @@
fun foo( fun foo(
p: Int, p: Int,
c: Char, c: Char,
b: <caret>Boolean b: <caret>Boolean
) { ) {
} }
@@ -1,5 +1,5 @@
fun foo( fun foo(
p: Int, p: Int,
<caret> c: Char <caret> c: Char
) { ) {
} }
@@ -2,9 +2,10 @@ class WithComments/* Some parameter */
/** /**
* A constructor * A constructor
*/( */(
/** /**
* A very important property * A very important property
*/ */
val veryImportant: Any) { val veryImportant: Any
) {
} }
@@ -2,7 +2,9 @@ annotation class AnnParam
annotation class AnnProperty annotation class AnnProperty
abstract class WithComposedModifiers(@AnnParam vararg @AnnProperty abstract class WithComposedModifiers(
open val x: String) { @AnnParam vararg @AnnProperty
open val x: String
) {
} }
+2 -2
View File
@@ -3,7 +3,7 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterNotNull().sum()'" // INTENTION_TEXT_2: "Replace with 'asSequence().filterNotNull().sum()'"
fun f(list: List<Int?>): Int{ fun f(list: List<Int?>): Int{
val r = list val r = list
.filterNotNull() .filterNotNull()
.sum() .sum()
return r return r
} }
+3 -3
View File
@@ -3,8 +3,8 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterNotNull().sum()'" // INTENTION_TEXT_2: "Replace with 'asSequence().filterNotNull().sum()'"
fun f(list: List<Int?>): Int{ fun f(list: List<Int?>): Int{
val r = list val r = list
.asSequence() .asSequence()
.filterNotNull() .filterNotNull()
.sum() .sum()
return r return r
} }
@@ -3,6 +3,6 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.any()'" // INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.any()'"
fun foo(list: List<String>) { fun foo(list: List<String>) {
val <caret>found = list val <caret>found = list
.filterIndexed { index, s -> s.length > index } .filterIndexed { index, s -> s.length > index }
.any() .any()
} }
@@ -3,7 +3,7 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.any()'" // INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.any()'"
fun foo(list: List<String>) { fun foo(list: List<String>) {
val <caret>found = list val <caret>found = list
.asSequence() .asSequence()
.filterIndexed { index, s -> s.length > index } .filterIndexed { index, s -> s.length > index }
.any() .any()
} }
@@ -4,9 +4,9 @@
fun getMaxLineWidth(lineCount: Int): Float { fun getMaxLineWidth(lineCount: Int): Float {
var max_width = 0.0f var max_width = 0.0f
<caret>(0..lineCount - 1) <caret>(0..lineCount - 1)
.asSequence() .asSequence()
.filter { getLineWidth(it) > max_width } .filter { getLineWidth(it) > max_width }
.forEach { max_width = getLineWidth(it) } .forEach { max_width = getLineWidth(it) }
return max_width return max_width
} }
@@ -4,7 +4,7 @@
fun foo(list: List<String>): Long { fun foo(list: List<String>): Long {
var count = 0L var count = 0L
list list
.filter { it.length > 10 } .filter { it.length > 10 }
.forEach { count++ } .forEach { count++ }
return count return count
} }
@@ -4,8 +4,8 @@
fun foo(list: List<String>): Long { fun foo(list: List<String>): Long {
var count = 0L var count = 0L
list list
.asSequence() .asSequence()
.filter { it.length > 10 } .filter { it.length > 10 }
.forEach { count++ } .forEach { count++ }
return count return count
} }
@@ -4,8 +4,8 @@
fun foo(list: List<String>): Int { fun foo(list: List<String>): Int {
var count = 0 var count = 0
list list
.asSequence() .asSequence()
.filter { it.length > count } .filter { it.length > count }
.forEach { count++ } .forEach { count++ }
return count return count
} }
@@ -5,7 +5,7 @@ import java.util.ArrayList
fun foo(list: List<String>): MutableList<String> { fun foo(list: List<String>): MutableList<String> {
val <caret>result = list val <caret>result = list
.filter { it.length > 0 } .filter { it.length > 0 }
.toMutableList() .toMutableList()
return result return result
} }
@@ -5,8 +5,8 @@ import java.util.ArrayList
fun foo(list: List<String>): MutableList<String> { fun foo(list: List<String>): MutableList<String> {
val <caret>result = list val <caret>result = list
.asSequence() .asSequence()
.filter { it.length > 0 } .filter { it.length > 0 }
.toMutableList() .toMutableList()
return result return result
} }
@@ -3,6 +3,6 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.forEach{}'" // INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.forEach{}'"
fun foo(list: List<String?>){ fun foo(list: List<String?>){
list list
.filter { it != null && it.startsWith("IMG:") } .filter { it != null && it.startsWith("IMG:") }
.forEach { println(it) } .forEach { println(it) }
} }
@@ -3,7 +3,7 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.forEach{}'" // INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.forEach{}'"
fun foo(list: List<String?>){ fun foo(list: List<String?>){
list list
.asSequence() .asSequence()
.filter { it != null && it.startsWith("IMG:") } .filter { it != null && it.startsWith("IMG:") }
.forEach { println(it) } .forEach { println(it) }
} }
@@ -3,6 +3,6 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'" // INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'"
fun foo(list: List<String>): String? { fun foo(list: List<String>): String? {
<caret>return list <caret>return list
.filterIndexed { index, s -> s.length > index } .filterIndexed { index, s -> s.length > index }
.firstOrNull() .firstOrNull()
} }
@@ -3,7 +3,7 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'" // INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'"
fun foo(list: List<String>): String? { fun foo(list: List<String>): String? {
<caret>return list <caret>return list
.asSequence() .asSequence()
.filterIndexed { index, s -> s.length > index } .filterIndexed { index, s -> s.length > index }
.firstOrNull() .firstOrNull()
} }
@@ -3,6 +3,6 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'" // INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'"
fun foo(list: List<String>): String? { fun foo(list: List<String>): String? {
<caret>return list <caret>return list
.filterIndexed { i, s -> s.length > i } .filterIndexed { i, s -> s.length > i }
.firstOrNull() .firstOrNull()
} }
@@ -3,7 +3,7 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'" // INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'"
fun foo(list: List<String>): String? { fun foo(list: List<String>): String? {
<caret>return list <caret>return list
.asSequence() .asSequence()
.filterIndexed { i, s -> s.length > i } .filterIndexed { i, s -> s.length > i }
.firstOrNull() .firstOrNull()
} }
@@ -3,8 +3,8 @@
// INTENTION_TEXT_2: "Replace with 'asSequence()...flatMap{}.filter{}.mapTo(){}'" // INTENTION_TEXT_2: "Replace with 'asSequence()...flatMap{}.filter{}.mapTo(){}'"
fun foo(list: List<String>, target: MutableCollection<String>) { fun foo(list: List<String>, target: MutableCollection<String>) {
<caret>list <caret>list
.filterIndexed { i, s -> i % 10 != 0 } .filterIndexed { i, s -> i % 10 != 0 }
.flatMap { it.indices } .flatMap { it.indices }
.filter { it != 10 } .filter { it != 10 }
.mapTo(target) { it.toString() } .mapTo(target) { it.toString() }
} }
@@ -3,9 +3,9 @@
// INTENTION_TEXT_2: "Replace with 'asSequence()...flatMap{}.filter{}.mapTo(){}'" // INTENTION_TEXT_2: "Replace with 'asSequence()...flatMap{}.filter{}.mapTo(){}'"
fun foo(list: List<String>, target: MutableCollection<String>) { fun foo(list: List<String>, target: MutableCollection<String>) {
<caret>list <caret>list
.asSequence() .asSequence()
.filterIndexed { i, s -> i % 10 != 0 } .filterIndexed { i, s -> i % 10 != 0 }
.flatMap { it.indices.asSequence() } .flatMap { it.indices.asSequence() }
.filter { it != 10 } .filter { it != 10 }
.mapTo(target) { it.toString() } .mapTo(target) { it.toString() }
} }
@@ -3,6 +3,6 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'" // INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'"
fun foo(list: List<String>): String? { fun foo(list: List<String>): String? {
<caret>return list <caret>return list
.filterIndexed { index, s -> s.length <= index * 10 && s.length > index } .filterIndexed { index, s -> s.length <= index * 10 && s.length > index }
.firstOrNull() .firstOrNull()
} }
@@ -3,7 +3,7 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'" // INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'"
fun foo(list: List<String>): String? { fun foo(list: List<String>): String? {
<caret>return list <caret>return list
.asSequence() .asSequence()
.filterIndexed { index, s -> s.length <= index * 10 && s.length > index } .filterIndexed { index, s -> s.length <= index * 10 && s.length > index }
.firstOrNull() .firstOrNull()
} }
@@ -3,6 +3,6 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'" // INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'"
fun foo(list: List<String>): String? { fun foo(list: List<String>): String? {
<caret>return list <caret>return list
.filterIndexed { index, s -> !s.isBlank() && s.length > index } .filterIndexed { index, s -> !s.isBlank() && s.length > index }
.firstOrNull() .firstOrNull()
} }
@@ -3,7 +3,7 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'" // INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'"
fun foo(list: List<String>): String? { fun foo(list: List<String>): String? {
<caret>return list <caret>return list
.asSequence() .asSequence()
.filterIndexed { index, s -> !s.isBlank() && s.length > index } .filterIndexed { index, s -> !s.isBlank() && s.length > index }
.firstOrNull() .firstOrNull()
} }

Some files were not shown because too many files have changed in this diff Show More