tests: apply official code style
#KT-38632 Fixed
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
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
|
||||
}
|
||||
|
||||
+11
-6
@@ -5,20 +5,25 @@ class A {
|
||||
var element: PsiElement = element
|
||||
element = JetPsiUtil.ascendIfPropertyAccessor(element)
|
||||
if (element is JetNamedFunction || element is JetProperty) {
|
||||
val bindingContext: BindingContext = AnalyzerFacadeWithCache.analyzeFileWithCache(element.getContainingJetFile()).getBindingContext()
|
||||
val declarationDescriptor: DeclarationDescriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, element)
|
||||
val bindingContext: BindingContext =
|
||||
AnalyzerFacadeWithCache.analyzeFileWithCache(element.getContainingJetFile()).getBindingContext()
|
||||
val declarationDescriptor: DeclarationDescriptor =
|
||||
bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, element)
|
||||
if (declarationDescriptor is CallableMemberDescriptor) {
|
||||
val containingDescriptor: DeclarationDescriptor = declarationDescriptor.getContainingDeclaration()
|
||||
if (containingDescriptor is ClassDescriptor) {
|
||||
return JetBundle.message(
|
||||
"override.declaration.x.in.y",
|
||||
DescriptorRenderer.COMPACT.render(declarationDescriptor),
|
||||
IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_NO_ANNOTATIONS.render(containingDescriptor)
|
||||
"override.declaration.x.in.y",
|
||||
DescriptorRenderer.COMPACT.render(declarationDescriptor),
|
||||
IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_NO_ANNOTATIONS.render(containingDescriptor)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
assert(element is PsiMethod) { "Method accepts only kotlin functions/properties and java methods, but '" + element.getText().toString() + "' was found" }
|
||||
assert(element is PsiMethod) {
|
||||
"Method accepts only kotlin functions/properties and java methods, but '" + element.getText()
|
||||
.toString() + "' was found"
|
||||
}
|
||||
return JetRefactoringUtil.formatPsiMethod(element as PsiMethod, true, false)
|
||||
}
|
||||
|
||||
|
||||
@@ -18,9 +18,11 @@ class Target {
|
||||
|
||||
fun acceptJavaClass(tbi: ToBeImportedJava?) {}
|
||||
|
||||
var ambiguousKotlin: IAmbiguousKotlin = AmbiguousKotlin() // Should not add import in case of 2 declarations in Kotlin
|
||||
var ambiguousKotlin: IAmbiguousKotlin =
|
||||
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 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
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
fun a(
|
||||
l0: /*T1@*/MutableCollection</*T0@*/Int>,
|
||||
l1: /*T3@*/MutableCollection</*T2@*/Int>,
|
||||
l2: /*T5@*/MutableCollection</*T4@*/Int>,
|
||||
l3: /*T7@*/MutableCollection</*T6@*/Int>,
|
||||
l4: /*T9@*/MutableCollection</*T8@*/Int>
|
||||
l0: /*T1@*/MutableCollection</*T0@*/Int>,
|
||||
l1: /*T3@*/MutableCollection</*T2@*/Int>,
|
||||
l2: /*T5@*/MutableCollection</*T4@*/Int>,
|
||||
l3: /*T7@*/MutableCollection</*T6@*/Int>,
|
||||
l4: /*T9@*/MutableCollection</*T8@*/Int>
|
||||
) {
|
||||
l0/*T1@MutableCollection<T0@Int>*/.add(1/*LIT*/)
|
||||
l1/*T3@MutableCollection<T2@Int>*/.addAll(l1/*T3@MutableCollection<T2@Int>*/)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
fun a(
|
||||
l0: /*T1@*/MutableListIterator</*T0@*/Int>,
|
||||
l1: /*T3@*/MutableListIterator</*T2@*/Int>,
|
||||
l2: /*T5@*/MutableListIterator</*T4@*/Int>
|
||||
l0: /*T1@*/MutableListIterator</*T0@*/Int>,
|
||||
l1: /*T3@*/MutableListIterator</*T2@*/Int>,
|
||||
l2: /*T5@*/MutableListIterator</*T4@*/Int>
|
||||
) {
|
||||
l0/*T1@MutableListIterator<T0@Int>*/.add(1/*LIT*/)
|
||||
l1/*T3@MutableListIterator<T2@Int>*/.remove()
|
||||
|
||||
+8
-8
@@ -1,12 +1,12 @@
|
||||
fun a(
|
||||
l0: /*T1@*/MutableList</*T0@*/Int>,
|
||||
l1: /*T3@*/MutableList</*T2@*/Int>,
|
||||
l2: /*T5@*/MutableList</*T4@*/Int>,
|
||||
l3: /*T7@*/MutableList</*T6@*/Int>,
|
||||
l4: /*T9@*/MutableList</*T8@*/Int>,
|
||||
l5: /*T11@*/MutableList</*T10@*/Int>,
|
||||
l6: /*T13@*/MutableList</*T12@*/Int>,
|
||||
l7: /*T15@*/MutableList</*T14@*/Int>
|
||||
l0: /*T1@*/MutableList</*T0@*/Int>,
|
||||
l1: /*T3@*/MutableList</*T2@*/Int>,
|
||||
l2: /*T5@*/MutableList</*T4@*/Int>,
|
||||
l3: /*T7@*/MutableList</*T6@*/Int>,
|
||||
l4: /*T9@*/MutableList</*T8@*/Int>,
|
||||
l5: /*T11@*/MutableList</*T10@*/Int>,
|
||||
l6: /*T13@*/MutableList</*T12@*/Int>,
|
||||
l7: /*T15@*/MutableList</*T14@*/Int>
|
||||
) {
|
||||
l0/*T1@MutableList<T0@Int>*/.add(1/*LIT*/)
|
||||
l1/*T3@MutableList<T2@Int>*/.addAll(1/*LIT*/, l1/*T3@MutableList<T2@Int>*/)
|
||||
|
||||
+4
-4
@@ -1,8 +1,8 @@
|
||||
fun a(
|
||||
l0: /*T2@*/MutableMap</*T0@*/Int, /*T1@*/String>,
|
||||
l1: /*T5@*/MutableMap</*T3@*/Int, /*T4@*/String>,
|
||||
l2: /*T8@*/MutableMap</*T6@*/Int, /*T7@*/String>,
|
||||
l3: /*T11@*/MutableMap</*T9@*/Int, /*T10@*/String>
|
||||
l0: /*T2@*/MutableMap</*T0@*/Int, /*T1@*/String>,
|
||||
l1: /*T5@*/MutableMap</*T3@*/Int, /*T4@*/String>,
|
||||
l2: /*T8@*/MutableMap</*T6@*/Int, /*T7@*/String>,
|
||||
l3: /*T11@*/MutableMap</*T9@*/Int, /*T10@*/String>
|
||||
) {
|
||||
l0/*T2@MutableMap<T0@Int, T1@String>*/.put(1)
|
||||
l1/*T5@MutableMap<T3@Int, T4@String>*/.remove(1/*LIT*/, l1)
|
||||
|
||||
+5
-5
@@ -1,9 +1,9 @@
|
||||
fun a(
|
||||
l0: /*T1@*/MutableSet</*T0@*/Int>,
|
||||
l1: /*T3@*/MutableSet</*T2@*/Int>,
|
||||
l2: /*T5@*/MutableSet</*T4@*/Int>,
|
||||
l3: /*T7@*/MutableSet</*T6@*/Int>,
|
||||
l4: /*T9@*/MutableSet</*T8@*/Int>
|
||||
l0: /*T1@*/MutableSet</*T0@*/Int>,
|
||||
l1: /*T3@*/MutableSet</*T2@*/Int>,
|
||||
l2: /*T5@*/MutableSet</*T4@*/Int>,
|
||||
l3: /*T7@*/MutableSet</*T6@*/Int>,
|
||||
l4: /*T9@*/MutableSet</*T8@*/Int>
|
||||
) {
|
||||
l0/*T1@MutableSet<T0@Int>*/.add(1/*LIT*/)
|
||||
l1/*T3@MutableSet<T2@Int>*/.addAll(l1/*T3@MutableSet<T2@Int>*/)
|
||||
|
||||
@@ -4,7 +4,11 @@ annotation class Ann(vararg val value: Inner, val test1: Array<InnerParam> = [In
|
||||
annotation class Inner
|
||||
annotation class InnerParam(val value: KClass<*>)
|
||||
|
||||
@Ann(value = [Inner(), Inner()], test1 = [InnerParam(C::class)])
|
||||
@Ann(
|
||||
value = [Inner(), Inner()], test1 = [InnerParam(
|
||||
C::class
|
||||
)]
|
||||
)
|
||||
class C
|
||||
|
||||
@Ann(Inner(), Inner())
|
||||
|
||||
+12
-1
@@ -1,5 +1,16 @@
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
annotation class Ann(val i: Int = 1, val i2: IntArray = [1], val i3: IntArray = [1], val klass: KClass<*> = A::class, val klass2: Array<KClass<*>> = [A::class], val klass3: Array<KClass<*>> = [A::class], val ann: Inner = Inner(), val ann2: Array<Inner> = [Inner()], val ann3: Array<Inner> = [Inner(), Inner()])
|
||||
annotation class Ann(
|
||||
val i: Int = 1,
|
||||
val i2: IntArray = [1],
|
||||
val i3: IntArray = [1],
|
||||
val klass: KClass<*> = A::class,
|
||||
val klass2: Array<KClass<*>> = [A::class],
|
||||
val klass3: Array<KClass<*>> = [A::class],
|
||||
val ann: Inner = Inner(),
|
||||
val ann2: Array<Inner> = [Inner()],
|
||||
val ann3: Array<Inner> = [Inner(), Inner()]
|
||||
)
|
||||
|
||||
class A
|
||||
annotation class Inner
|
||||
@@ -1,5 +1,7 @@
|
||||
internal annotation class Anon(val stringArray: Array<String>, val intArray: IntArray, // string
|
||||
val string: String)
|
||||
internal annotation class Anon(
|
||||
val stringArray: Array<String>, val intArray: IntArray, // string
|
||||
val string: String
|
||||
)
|
||||
|
||||
@Anon(string = "a", stringArray = ["a", "b"], intArray = [1, 2])
|
||||
@Target(AnnotationTarget.CONSTRUCTOR, AnnotationTarget.FIELD)
|
||||
|
||||
+3
-1
@@ -17,7 +17,9 @@ import javaApi.E
|
||||
@Anon4("x", "y")
|
||||
@Anon5(1)
|
||||
@Anon6("x", "y")
|
||||
@Anon7(String::class, StringBuilder::class)
|
||||
@Anon7(
|
||||
String::class, StringBuilder::class
|
||||
)
|
||||
@Anon8(classes = [String::class, StringBuilder::class])
|
||||
internal class C {
|
||||
@Anon5(1)
|
||||
|
||||
+2
-1
@@ -1,7 +1,8 @@
|
||||
import javaApi.SpecialExternal
|
||||
|
||||
//Annotation class:
|
||||
annotation class Special(val names: Array<String> //array is used
|
||||
annotation class Special(
|
||||
val names: Array<String> //array is used
|
||||
) //Class with annotation:
|
||||
|
||||
@Special(names = ["name1"])
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
/*pre*/5 /*operand '5'*/ shl /*left shift*/16 /*operand '16'*/ or ( /*or*/1 /*operand '1'*/ shr /*right shift*/8 /*operand '8'*/) or /*or*/0 /*operand '0'*/ /*post comment*/
|
||||
/*pre*/
|
||||
5 /*operand '5'*/ shl /*left shift*/16 /*operand '16'*/ or ( /*or*/1 /*operand '1'*/ shr /*right shift*/8 /*operand '8'*/) or /*or*/0 /*operand '0'*/ /*post comment*/
|
||||
+2
-1
@@ -1 +1,2 @@
|
||||
val constrArgTypes = arrayOf<Class<*>>(Array<String>::class.java, String::class.java, Int::class.java, Double::class.java)
|
||||
val constrArgTypes =
|
||||
arrayOf<Class<*>>(Array<String>::class.java, String::class.java, Int::class.java, Double::class.java)
|
||||
+2
-2
@@ -5,8 +5,8 @@ object Test {
|
||||
fun main(args: Array<String>) {
|
||||
println() // Comment
|
||||
foo() // Comment1
|
||||
// Comment2
|
||||
.indexOf("s")
|
||||
// Comment2
|
||||
.indexOf("s")
|
||||
}
|
||||
|
||||
fun foo(): String {
|
||||
|
||||
@@ -11,7 +11,7 @@ internal class A // this is a primary constructor
|
||||
|
||||
internal class B // this constructor will disappear
|
||||
// end of constructor body
|
||||
(private val x: Int) {
|
||||
(private val x: Int) {
|
||||
fun foo() {}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
internal class C(// field p1
|
||||
private val p1: Int /* parameter p1 */,
|
||||
/**
|
||||
* Field myP2
|
||||
*/
|
||||
private val myP2: Int, /* Field p3 */
|
||||
var p3: Int)
|
||||
private val p1: Int /* parameter p1 */,
|
||||
/**
|
||||
* Field myP2
|
||||
*/
|
||||
private val myP2: Int, /* Field p3 */
|
||||
var p3: Int
|
||||
)
|
||||
+3
-3
@@ -36,9 +36,9 @@ internal class CustomerBuilder {
|
||||
object User {
|
||||
fun main() {
|
||||
val customer = CustomerBuilder()
|
||||
.WithFirstName("Homer")
|
||||
.WithLastName("Simpson")
|
||||
.Build()
|
||||
.WithFirstName("Homer")
|
||||
.WithLastName("Simpson")
|
||||
.Build()
|
||||
println(customer.firstName)
|
||||
println(customer.lastName)
|
||||
}
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
internal open class Base(o: Any?, l: Int)
|
||||
internal class C(private val string: String) : Base(string, string.length)
|
||||
internal class C(private val string: String) : Base(
|
||||
string, string.length
|
||||
)
|
||||
+5
-1
@@ -1,4 +1,8 @@
|
||||
// ERROR: This annotation is not applicable to target 'value parameter' and use site target '@field'
|
||||
// ERROR: This annotation is not applicable to target 'value parameter' and use site target '@param'
|
||||
// ERROR: This annotation is not applicable to target 'value parameter' and use site target '@param'
|
||||
internal class C(@field:Deprecated("") private val p1: Int, @param:Deprecated("") private val myP2: Int, @param:Deprecated("") var p3: Int)
|
||||
internal class C(
|
||||
@field:Deprecated("") private val p1: Int,
|
||||
@param:Deprecated("") private val myP2: Int,
|
||||
@param:Deprecated("") var p3: Int
|
||||
)
|
||||
@@ -1,11 +1,17 @@
|
||||
internal class C1(arg1: Int,
|
||||
arg2: Int,
|
||||
arg3: Int) {
|
||||
constructor(x: Int,
|
||||
y: Int) : this(x, x + y, 0) {
|
||||
internal class C1(
|
||||
arg1: Int,
|
||||
arg2: Int,
|
||||
arg3: Int
|
||||
) {
|
||||
constructor(
|
||||
x: Int,
|
||||
y: Int
|
||||
) : this(x, x + y, 0) {
|
||||
}
|
||||
}
|
||||
|
||||
internal class C2(private val arg1: Int,
|
||||
private val arg2: Int,
|
||||
arg3: Int)
|
||||
internal class C2(
|
||||
private val arg1: Int,
|
||||
private val arg2: Int,
|
||||
arg3: Int
|
||||
)
|
||||
+4
-3
@@ -1,7 +1,8 @@
|
||||
internal class A( // comment for field2 setter
|
||||
// comment for field2 getter
|
||||
var field2 // comment for field2
|
||||
: Int) {
|
||||
// comment for field2 getter
|
||||
var field2 // comment for field2
|
||||
: Int
|
||||
) {
|
||||
/**
|
||||
* Comment for field1 setter
|
||||
*/
|
||||
|
||||
@@ -2,6 +2,8 @@ internal annotation class TestAnnotationField
|
||||
internal annotation class TestAnnotationParam
|
||||
internal annotation class TestAnnotationGet
|
||||
internal annotation class TestAnnotationSet
|
||||
class Test(@field:TestAnnotationField @set:TestAnnotationSet
|
||||
@get:TestAnnotationGet
|
||||
@param:TestAnnotationParam var arg: String)
|
||||
class Test(
|
||||
@field:TestAnnotationField @set:TestAnnotationSet
|
||||
@get:TestAnnotationGet
|
||||
@param:TestAnnotationParam var arg: String
|
||||
)
|
||||
@@ -1,3 +1,3 @@
|
||||
class Nya /*comment before*/
|
||||
/* comment after*/ // and after again
|
||||
( /*1*/ /*3*/ /*4*/private val i: Int)
|
||||
( /*1*/ /*3*/ /*4*/private val i: Int)
|
||||
@@ -1,7 +1,9 @@
|
||||
@Deprecated("""Ph'nglui mglw'nafh
|
||||
@Deprecated(
|
||||
"""Ph'nglui mglw'nafh
|
||||
Cthulhu R'lyeh wgah'nagl fhtagn.
|
||||
'In His House at R'lyeh
|
||||
Dead Cthulhu waits dreaming,
|
||||
yet He shall rise and His kingdom
|
||||
shall cover the Earth.'""")
|
||||
shall cover the Earth.'"""
|
||||
)
|
||||
class TestDeprecatedInJavadocWithMultilineMessage
|
||||
+4
-2
@@ -2,7 +2,9 @@ internal enum class Color : Runnable {
|
||||
WHITE, BLACK, RED, YELLOW, BLUE;
|
||||
|
||||
override fun run() {
|
||||
println("name()=" + name +
|
||||
", toString()=" + toString())
|
||||
println(
|
||||
"name()=" + name +
|
||||
", toString()=" + toString()
|
||||
)
|
||||
}
|
||||
}
|
||||
+19
-1
@@ -19,7 +19,25 @@ internal enum class EE {
|
||||
}
|
||||
|
||||
internal class X {
|
||||
fun foo(i1: I?, i2: I?, s1: String, s2: String, c1: C, c2: C, i: Int, o1: O, o2: O, e1: E, e2: E, bb1: BB, bb2: BB, arr1: IntArray, arr2: IntArray, ee1: EE?, ee2: EE) {
|
||||
fun foo(
|
||||
i1: I?,
|
||||
i2: I?,
|
||||
s1: String,
|
||||
s2: String,
|
||||
c1: C,
|
||||
c2: C,
|
||||
i: Int,
|
||||
o1: O,
|
||||
o2: O,
|
||||
e1: E,
|
||||
e2: E,
|
||||
bb1: BB,
|
||||
bb2: BB,
|
||||
arr1: IntArray,
|
||||
arr2: IntArray,
|
||||
ee1: EE?,
|
||||
ee2: EE
|
||||
) {
|
||||
if (i1 === i2) return
|
||||
if (s1 === s2) return
|
||||
if (c1 == c2) return
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@ class C {
|
||||
fun foo() {
|
||||
val builder = StringBuilder()
|
||||
builder.append(1)
|
||||
.append(2).append(3)
|
||||
.append(4)
|
||||
.append(2).append(3)
|
||||
.append(4)
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,10 @@
|
||||
internal class F {
|
||||
fun f1(p1: Int, p2: Int, p3: Int, p4: Int, vararg p5: Int) {}
|
||||
fun f2(array: IntArray) {
|
||||
f1(1, 2,
|
||||
3, 4,
|
||||
*array
|
||||
f1(
|
||||
1, 2,
|
||||
3, 4,
|
||||
*array
|
||||
)
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
interface Aaa {
|
||||
fun foo(
|
||||
e1: String?,
|
||||
e2: String?
|
||||
e1: String?,
|
||||
e2: String?
|
||||
)
|
||||
}
|
||||
@@ -1,17 +1,20 @@
|
||||
internal class C {
|
||||
fun foo1(p1: Int, p2: Int) {}
|
||||
fun foo2(
|
||||
p1: Int,
|
||||
p2: Int) {
|
||||
p1: Int,
|
||||
p2: Int
|
||||
) {
|
||||
}
|
||||
|
||||
fun foo3(p1: Int,
|
||||
p2: Int) {
|
||||
fun foo3(
|
||||
p1: Int,
|
||||
p2: Int
|
||||
) {
|
||||
}
|
||||
|
||||
fun foo4(
|
||||
p1: Int, p2: Int,
|
||||
p3: Int, p4: Int
|
||||
p1: Int, p2: Int,
|
||||
p3: Int, p4: Int
|
||||
) {
|
||||
}
|
||||
}
|
||||
+4
-2
@@ -1,6 +1,8 @@
|
||||
class TestJavaBoxedPrimitives {
|
||||
fun foo(x1: Boolean, x2: Byte, x3: Short, x4: Int,
|
||||
x5: Long, x6: Float, x7: Double, x8: Char): Array<Any> {
|
||||
fun foo(
|
||||
x1: Boolean, x2: Byte, x3: Short, x4: Int,
|
||||
x5: Long, x6: Float, x7: Double, x8: Char
|
||||
): Array<Any> {
|
||||
return arrayOf(x1, x2, x3, x4, x5, x6, x7, x8)
|
||||
}
|
||||
}
|
||||
|
||||
+13
-1
@@ -1,5 +1,17 @@
|
||||
object ArrayInitializerBugKt {
|
||||
private val GREETING = byteArrayOf('H'.toByte(), 'e'.toByte(), 'l'.toByte(), 'l'.toByte(), 'o'.toByte(), ','.toByte(), ' '.toByte(), 'b'.toByte(), 'u'.toByte(), 'g'.toByte(), '!'.toByte())
|
||||
private val GREETING = byteArrayOf(
|
||||
'H'.toByte(),
|
||||
'e'.toByte(),
|
||||
'l'.toByte(),
|
||||
'l'.toByte(),
|
||||
'o'.toByte(),
|
||||
','.toByte(),
|
||||
' '.toByte(),
|
||||
'b'.toByte(),
|
||||
'u'.toByte(),
|
||||
'g'.toByte(),
|
||||
'!'.toByte()
|
||||
)
|
||||
|
||||
@JvmStatic
|
||||
fun main(args: Array<String>) {
|
||||
|
||||
+12
-12
@@ -5,23 +5,23 @@ import java.util.stream.Stream
|
||||
internal class Test {
|
||||
fun main(lst: List<String>) {
|
||||
val streamOfList = lst.stream()
|
||||
.map { x: String -> x + "e" }
|
||||
.collect(Collectors.toList())
|
||||
.map { x: String -> x + "e" }
|
||||
.collect(Collectors.toList())
|
||||
val streamOfElements = Stream.of(1, 2, 3)
|
||||
.map { x: Int -> x + 1 }
|
||||
.collect(Collectors.toList())
|
||||
.map { x: Int -> x + 1 }
|
||||
.collect(Collectors.toList())
|
||||
val array = arrayOf(1, 2, 3)
|
||||
val streamOfArray = Arrays.stream(array)
|
||||
.map { x: Int -> x + 1 }
|
||||
.collect(Collectors.toList())
|
||||
.map { x: Int -> x + 1 }
|
||||
.collect(Collectors.toList())
|
||||
val streamOfArray2 = Stream.of(*array)
|
||||
.map { x: Int -> x + 1 }
|
||||
.collect(Collectors.toList())
|
||||
.map { x: Int -> x + 1 }
|
||||
.collect(Collectors.toList())
|
||||
val streamIterate = Stream.iterate(2, { v: Int -> v * 2 })
|
||||
.map { x: Int -> x + 1 }
|
||||
.collect(Collectors.toList())
|
||||
.map { x: Int -> x + 1 }
|
||||
.collect(Collectors.toList())
|
||||
val streamGenerate = Stream.generate { 42 }
|
||||
.map { x: Int -> x + 1 }
|
||||
.collect(Collectors.toList())
|
||||
.map { x: Int -> x + 1 }
|
||||
.collect(Collectors.toList())
|
||||
}
|
||||
}
|
||||
+7
-6
@@ -4,11 +4,12 @@ import java.util.stream.Collectors
|
||||
internal class Test {
|
||||
fun main(lst: List<Int>) {
|
||||
val newLst = /*before list*/lst /*after list*/.stream /*before stream*/() /* after stream*/
|
||||
.filter { x: Int -> x > 10 }
|
||||
.map { x: Int -> x + 2 } /*some comment*/.distinct /*another comment*/() /* one more comment */.sorted() /*another one comment*/
|
||||
.sorted(Comparator.naturalOrder())
|
||||
.peek { x: Int? -> println(x) }.limit(1)
|
||||
.skip(42) /*skipped*/ /*collecting one*/
|
||||
.collect /*collecting two */(Collectors.toList()) /* cool */
|
||||
.filter { x: Int -> x > 10 }
|
||||
.map { x: Int -> x + 2 } /*some comment*/.distinct /*another comment*/() /* one more comment */
|
||||
.sorted() /*another one comment*/
|
||||
.sorted(Comparator.naturalOrder())
|
||||
.peek { x: Int? -> println(x) }.limit(1)
|
||||
.skip(42) /*skipped*/ /*collecting one*/
|
||||
.collect /*collecting two */(Collectors.toList()) /* cool */
|
||||
}
|
||||
}
|
||||
+12
-12
@@ -4,18 +4,18 @@ import java.util.stream.Stream
|
||||
internal class Test {
|
||||
fun main() {
|
||||
val activities = Stream.of("12")
|
||||
.map { v: String -> v + "nya" }
|
||||
.filter { v: String? -> v != null }
|
||||
.flatMap { v: String ->
|
||||
Stream.of(v)
|
||||
.flatMap { s: String -> Stream.of(s) }
|
||||
}.filter { v: String ->
|
||||
val name = v.javaClass.name
|
||||
if (name == "name") {
|
||||
return@filter false
|
||||
}
|
||||
name != "other_name"
|
||||
.map { v: String -> v + "nya" }
|
||||
.filter { v: String? -> v != null }
|
||||
.flatMap { v: String ->
|
||||
Stream.of(v)
|
||||
.flatMap { s: String -> Stream.of(s) }
|
||||
}.filter { v: String ->
|
||||
val name = v.javaClass.name
|
||||
if (name == "name") {
|
||||
return@filter false
|
||||
}
|
||||
.collect(Collectors.toList())
|
||||
name != "other_name"
|
||||
}
|
||||
.collect(Collectors.toList())
|
||||
}
|
||||
}
|
||||
+9
-9
@@ -4,14 +4,14 @@ import java.util.stream.Collectors
|
||||
internal class Test {
|
||||
fun main(lst: List<Int>) {
|
||||
val newLst = lst.stream()
|
||||
.filter { x: Int -> x > 10 }
|
||||
.map { x: Int -> x + 2 }
|
||||
.distinct()
|
||||
.sorted()
|
||||
.sorted(Comparator.naturalOrder())
|
||||
.peek { x: Int? -> println(x) }
|
||||
.limit(1)
|
||||
.skip(42)
|
||||
.collect(Collectors.toList())
|
||||
.filter { x: Int -> x > 10 }
|
||||
.map { x: Int -> x + 2 }
|
||||
.distinct()
|
||||
.sorted()
|
||||
.sorted(Comparator.naturalOrder())
|
||||
.peek { x: Int? -> println(x) }
|
||||
.limit(1)
|
||||
.skip(42)
|
||||
.collect(Collectors.toList())
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
class Exponent {
|
||||
private val doubles = doubleArrayOf(
|
||||
5e5, +5e5, -5e5, 5e+5, 5e-5,
|
||||
5E5, +5E5, -5E5, 5E+5, 5E-5,
|
||||
2.5e5, +2.5e5, -2.5e5, 2.5e+5, 2.5e-5,
|
||||
2.5E5, +2.5E5, -2.5E5, 2.5E+5, 2.5E-5, 5e5, 5e5, 5e5, 5e5,
|
||||
5e-6, 7e+8, 9e-1, 2e+3, 4e5, 6e7
|
||||
5e5, +5e5, -5e5, 5e+5, 5e-5,
|
||||
5E5, +5E5, -5E5, 5E+5, 5E-5,
|
||||
2.5e5, +2.5e5, -2.5e5, 2.5e+5, 2.5e-5,
|
||||
2.5E5, +2.5E5, -2.5E5, 2.5E+5, 2.5E-5, 5e5, 5e5, 5e5, 5e5,
|
||||
5e-6, 7e+8, 9e-1, 2e+3, 4e5, 6e7
|
||||
)
|
||||
}
|
||||
+6
-6
@@ -1,10 +1,10 @@
|
||||
class Exponent {
|
||||
private val floats = floatArrayOf(
|
||||
5e5f, +5e5f, -5e5f, 5e+5f, 5e-5f,
|
||||
5E5f, +5E5f, -5E5f, 5E+5f, 5E-5f,
|
||||
2.5e5f, +2.5e5f, -2.5e5f, 2.5e+5f, 2.5e-5f,
|
||||
2.5E5f, +2.5E5f, -2.5E5f, 2.5E+5f, 2.5E-5f,
|
||||
5e5f, 5e5f,
|
||||
5e-6f, 7e+8f, 9e-1f, 2e+3f, 4e5f, 6e7f
|
||||
5e5f, +5e5f, -5e5f, 5e+5f, 5e-5f,
|
||||
5E5f, +5E5f, -5E5f, 5E+5f, 5E-5f,
|
||||
2.5e5f, +2.5e5f, -2.5e5f, 2.5e+5f, 2.5e-5f,
|
||||
2.5E5f, +2.5E5f, -2.5E5f, 2.5E+5f, 2.5E-5f,
|
||||
5e5f, 5e5f,
|
||||
5e-6f, 7e+8f, 9e-1f, 2e+3f, 4e5f, 6e7f
|
||||
)
|
||||
}
|
||||
+11
-9
@@ -66,16 +66,18 @@ internal class A {
|
||||
val s = "test string"
|
||||
s == "test"
|
||||
s.equals(
|
||||
"tesT", ignoreCase = true)
|
||||
"tesT", ignoreCase = true
|
||||
)
|
||||
s.compareTo("Test", ignoreCase = true)
|
||||
s.regionMatches(
|
||||
0,
|
||||
"TE",
|
||||
0,
|
||||
2, ignoreCase = true)
|
||||
0,
|
||||
"TE",
|
||||
0,
|
||||
2, ignoreCase = true
|
||||
)
|
||||
s.regionMatches(0, "st", 1, 2)
|
||||
s.replace("\\w+".toRegex(), "---")
|
||||
.replaceFirst("([s-t])".toRegex(), "A$1")
|
||||
.replaceFirst("([s-t])".toRegex(), "A$1")
|
||||
/* TODO
|
||||
s.matches("\\w+");
|
||||
useSplit(s.split("\\s+"));
|
||||
@@ -102,9 +104,9 @@ internal class A {
|
||||
3.14.toString()
|
||||
Any().toString()
|
||||
String.format(
|
||||
Locale.FRENCH,
|
||||
"Je ne mange pas %d jours",
|
||||
6
|
||||
Locale.FRENCH,
|
||||
"Je ne mange pas %d jours",
|
||||
6
|
||||
)
|
||||
String.format("Operation completed with %s", "success")
|
||||
val chars = charArrayOf('a', 'b', 'c')
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
internal class A<T> {
|
||||
fun foo(nonMutableCollection: Collection<String?>?,
|
||||
mutableCollection: MutableCollection<String?>,
|
||||
mutableSet: MutableSet<T?>,
|
||||
mutableMap: MutableMap<String?, T>) {
|
||||
fun foo(
|
||||
nonMutableCollection: Collection<String?>?,
|
||||
mutableCollection: MutableCollection<String?>,
|
||||
mutableSet: MutableSet<T?>,
|
||||
mutableMap: MutableMap<String?, T>
|
||||
) {
|
||||
mutableCollection.addAll(nonMutableCollection!!)
|
||||
mutableSet.add(mutableMap.remove("a"))
|
||||
}
|
||||
|
||||
+4
-1
@@ -3,7 +3,10 @@ package javaApi
|
||||
import kotlinApi.KotlinClass
|
||||
|
||||
abstract class C(field: Int) : KotlinClass(field) {
|
||||
override fun foo(mutableCollection: MutableCollection<String>, nullableCollection: Collection<Int>?): MutableList<Any> {
|
||||
override fun foo(
|
||||
mutableCollection: MutableCollection<String>,
|
||||
nullableCollection: Collection<Int>?
|
||||
): MutableList<Any> {
|
||||
return super.foo(mutableCollection, nullableCollection)
|
||||
}
|
||||
}
|
||||
+5
-3
@@ -1,8 +1,10 @@
|
||||
internal class C(p1: Int, p2: Int, p3: Int)
|
||||
internal class User {
|
||||
fun foo() {
|
||||
C(1,
|
||||
2,
|
||||
3)
|
||||
C(
|
||||
1,
|
||||
2,
|
||||
3
|
||||
)
|
||||
}
|
||||
}
|
||||
+9
-1
@@ -22,7 +22,15 @@ class Test {
|
||||
private get() = 1
|
||||
|
||||
@JvmOverloads
|
||||
fun foo(a: Boolean = this.a, b: Boolean = this.b, c: Boolean = c(), isD: Boolean = this.isD, e: Boolean = this.e.ee, f: Boolean = F().f, g: Int = this.g) {
|
||||
fun foo(
|
||||
a: Boolean = this.a,
|
||||
b: Boolean = this.b,
|
||||
c: Boolean = c(),
|
||||
isD: Boolean = this.isD,
|
||||
e: Boolean = this.e.ee,
|
||||
f: Boolean = F().f,
|
||||
g: Int = this.g
|
||||
) {
|
||||
}
|
||||
|
||||
@JvmOverloads
|
||||
|
||||
@@ -3,7 +3,7 @@ import java.util.stream.Collectors
|
||||
class Test {
|
||||
private fun addPackages(packages: Collection<Number>) {
|
||||
val sorted = packages.stream()
|
||||
.filter { repoPackage: Number? -> repoPackage != null }
|
||||
.collect(Collectors.toList())
|
||||
.filter { repoPackage: Number? -> repoPackage != null }
|
||||
.collect(Collectors.toList())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user