Skip to content

Commit e92acb0

Browse files
authored
Merge pull request #7 from olafurpg/ktfmt
2 parents 44ae7e1 + 04bf6b3 commit e92acb0

File tree

33 files changed

+1484
-925
lines changed

33 files changed

+1484
-925
lines changed

build.gradle.kts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,22 @@ plugins {
77
id("com.github.johnrengelman.shadow") version "6.1.0"
88
id("com.palantir.git-version") version "0.12.3"
99
id("io.github.gradle-nexus.publish-plugin") version "1.1.0"
10+
id("com.diffplug.spotless") version "5.17.0"
1011
}
1112

13+
1214
val versionDetails: Closure<VersionDetails> by extra
1315

1416
allprojects {
17+
if (name !in setOf("minimized", "semanticdb-kotlin")) {
18+
apply(plugin = "com.diffplug.spotless")
19+
spotless {
20+
kotlin {
21+
ktfmt().dropboxStyle()
22+
}
23+
}
24+
}
25+
1526
group = "com.sourcegraph"
1627
version = (project.properties["version"] as String).let {
1728
if (it != "unspecified" && !it.startsWith("refs"))
@@ -23,6 +34,7 @@ allprojects {
2334
val lastNum = tag.split(".").last().toInt() + 1
2435
"${tag.split(".").subList(0, 2).joinToString(".")}.$lastNum-SNAPSHOT"
2536
}
37+
2638
}
2739

2840
repositories {
@@ -65,4 +77,4 @@ allprojects {
6577
sourceCompatibility = "1.8"
6678
}
6779
}
68-
}
80+
}

debug-project/src/main/kotlin/sample/Main.kt

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,19 @@ class Main<T> {
1010
return null
1111
}
1212

13-
fun method(burger: String) {
14-
}
15-
16-
val helloWorld = object {
17-
val hello = "Hello"
18-
val world = "World"
13+
fun method(burger: String) {}
1914

20-
override fun toString() = "$hello $world"
21-
}
15+
val helloWorld =
16+
object {
17+
val hello = "Hello"
18+
val world = "World"
2219

20+
override fun toString() = "$hello $world"
21+
}
2322
}
2423

2524
val bananas = 1
2625

2726
fun test() = Unit
2827

29-
typealias Stringer = String
28+
typealias Stringer = String
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package snapshots;
2+
3+
public class ClassConsumer {
4+
// ^^^^^^^^^^^^^ definition snapshots/ClassConsumer# public class ClassConsumer
5+
// ^^^^^^^^^^^^^ definition snapshots/ClassConsumer#`<init>`(). public ClassConsumer()
6+
public static void run() {
7+
// ^^^ definition snapshots/ClassConsumer#run(). public static void run()
8+
System.out.println(new Class().getAsdf());
9+
// ^^^^^^ reference java/lang/System#
10+
// ^^^ reference java/lang/System#out.
11+
// ^^^^^^^ reference java/io/PrintStream#println(+9).
12+
// ^^^^^ reference snapshots/Class#`<init>`(+1).
13+
// ^^^^^^^ reference snapshots/Class#getAsdf().
14+
}
15+
}

semanticdb-kotlinc/minimized/src/generatedSnapshots/resources/java/snapshots/CompanionConsumer.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,8 @@ public class CompanionConsumer {
88
// ^^^^^^^^^^^^^^ reference snapshots/CompanionOwner#
99
// ^^^^^^^^^ reference snapshots/CompanionOwner#Companion.
1010
// ^^^^^^ reference snapshots/CompanionOwner#Companion#create().
11+
new CompanionOwner().create();
12+
// ^^^^^^^^^^^^^^ reference snapshots/CompanionOwner#`<init>`().
13+
// ^^^^^^ reference snapshots/CompanionOwner#create().
1114
}
1215
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package snapshots;
2+
3+
public class ObjectKtConsumer {
4+
// ^^^^^^^^^^^^^^^^ definition snapshots/ObjectKtConsumer# public class ObjectKtConsumer
5+
// ^^^^^^^^^^^^^^^^ definition snapshots/ObjectKtConsumer#`<init>`(). public ObjectKtConsumer()
6+
public static void run() {
7+
// ^^^ definition snapshots/ObjectKtConsumer#run(). public static void run()
8+
ObjectKt.INSTANCE.fail("boom");
9+
// ^^^^^^^^ reference snapshots/ObjectKt#
10+
// ^^^^^^^^ reference snapshots/ObjectKt#INSTANCE.
11+
// ^^^^ reference snapshots/ObjectKt#fail().
12+
}
13+
}
Lines changed: 39 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package snapshots
22
// ^^^^^^^^^ reference snapshots/
33

4-
class Class constructor(private var banana: Int, apple: String): Throwable(banana.toString()) {
4+
class Class constructor(private var banana: Int, apple: String) :
55
// ^^^^^ definition snapshots/Class# Class
66
// ^^^^^^^^^^^ definition snapshots/Class#`<init>`(). Class
77
// ^^^^^^ definition snapshots/Class#banana. banana
@@ -11,40 +11,48 @@ class Class constructor(private var banana: Int, apple: String): Throwable(banan
1111
// ^^^ reference kotlin/Int#
1212
// ^^^^^ definition snapshots/Class#`<init>`().(apple) apple
1313
// ^^^^^^ reference kotlin/String#
14-
// ^^^^^^^^^ reference kotlin/Throwable#`<init>`().
15-
// ^^^^^^ reference snapshots/Class#`<init>`().(banana)
16-
// ^^^^^^^^ reference kotlin/Int#toString().
17-
init {
18-
println("")
19-
// ^^^^^^^ reference kotlin/io/ConsoleKt#println(+1).
20-
}
14+
Throwable(banana.toString() + apple) {
15+
// ^^^^^^^^^ reference kotlin/Throwable#`<init>`().
16+
// ^^^^^^ reference snapshots/Class#`<init>`().(banana)
17+
// ^^^^^^^^ reference kotlin/Int#toString().
18+
// ^ reference kotlin/String#plus().
19+
// ^^^^^ reference snapshots/Class#`<init>`().(apple)
20+
init {
21+
println("")
22+
// ^^^^^^^ reference kotlin/io/ConsoleKt#println(+1).
23+
}
2124

22-
val asdf = object {
23-
// ^^^^ definition snapshots/Class#asdf. asdf
24-
// ^^^^ definition snapshots/Class#getAsdf(). asdf
25+
val asdf =
26+
// ^^^^ definition snapshots/Class#asdf. asdf
27+
// ^^^^ definition snapshots/Class#getAsdf(). asdf
28+
object {
2529
fun doStuff() = Unit
2630
// ^^^^^^^ definition local0 doStuff
2731
// ^^^^ reference kotlin/Unit#
28-
}
32+
}
2933

30-
constructor(): this(1, "")
31-
// ^^^^^^^^^^^ definition snapshots/Class#`<init>`(+1). Class
34+
constructor() : this(1, "")
35+
//^^^^^^^^^^^ definition snapshots/Class#`<init>`(+1). Class
3236

33-
constructor(banana: Int): this(banana, "")
34-
// ^^^^^^^^^^^ definition snapshots/Class#`<init>`(+2). Class
35-
// ^^^^^^ definition snapshots/Class#`<init>`(+2).(banana) banana
36-
// ^^^ reference kotlin/Int#
37-
// ^^^^^^ reference snapshots/Class#`<init>`(+2).(banana)
37+
constructor(banana: Int) : this(banana, "")
38+
//^^^^^^^^^^^ definition snapshots/Class#`<init>`(+2). Class
39+
// ^^^^^^ definition snapshots/Class#`<init>`(+2).(banana) banana
40+
// ^^^ reference kotlin/Int#
41+
// ^^^^^^ reference snapshots/Class#`<init>`(+2).(banana)
3842

39-
fun run() {
40-
// ^^^ definition snapshots/Class#run(). run
41-
println(Class::class)
42-
// ^^^^^^^ reference kotlin/io/ConsoleKt#println(+1).
43-
// ^^^^^ reference snapshots/Class#
44-
println("I eat $banana for lunch")
45-
// ^^^^^^^ reference kotlin/io/ConsoleKt#println(+1).
46-
// ^^^^^^ reference snapshots/Class#banana.
47-
// ^^^^^^ reference snapshots/Class#getBanana().
48-
// ^^^^^^ reference snapshots/Class#setBanana().
49-
}
50-
}
43+
fun run() {
44+
// ^^^ definition snapshots/Class#run(). run
45+
println(Class::class)
46+
// ^^^^^^^ reference kotlin/io/ConsoleKt#println(+1).
47+
// ^^^^^ reference snapshots/Class#
48+
println("I eat $banana for lunch")
49+
// ^^^^^^^ reference kotlin/io/ConsoleKt#println(+1).
50+
// ^^^^^^ reference snapshots/Class#banana.
51+
// ^^^^^^ reference snapshots/Class#getBanana().
52+
// ^^^^^^ reference snapshots/Class#setBanana().
53+
banana = 42
54+
// ^^^^^^ reference snapshots/Class#banana.
55+
// ^^^^^^ reference snapshots/Class#getBanana().
56+
// ^^^^^^ reference snapshots/Class#setBanana().
57+
}
58+
}

semanticdb-kotlinc/minimized/src/generatedSnapshots/resources/kotlin/snapshots/CompanionOwner.kt

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,17 @@ package snapshots
44
class CompanionOwner {
55
// ^^^^^^^^^^^^^^ definition snapshots/CompanionOwner# CompanionOwner
66
// ^^^^^^^^^^^^^^ definition snapshots/CompanionOwner#`<init>`(). CompanionOwner
7-
companion object {
8-
fun create(): CompanionOwner = CompanionOwner()
9-
// ^^^^^^ definition snapshots/CompanionOwner#Companion#create(). create
10-
// ^^^^^^^^^^^^^^ reference snapshots/CompanionOwner#
11-
// ^^^^^^^^^^^^^^ reference snapshots/CompanionOwner#`<init>`().
12-
}
13-
}
7+
companion object {
8+
// ^^^^^^^^^ definition snapshots/CompanionOwner#Companion# Companion
9+
fun create(): CompanionOwner = CompanionOwner()
10+
// ^^^^^^ definition snapshots/CompanionOwner#Companion#create(). create
11+
// ^^^^^^^^^^^^^^ reference snapshots/CompanionOwner#
12+
// ^^^^^^^^^^^^^^ reference snapshots/CompanionOwner#`<init>`().
13+
}
14+
fun create(): Int = CompanionOwner.create().hashCode()
15+
// ^^^^^^ definition snapshots/CompanionOwner#create(). create
16+
// ^^^ reference kotlin/Int#
17+
// ^^^^^^^^^^^^^^ reference snapshots/CompanionOwner#Companion#
18+
// ^^^^^^ reference snapshots/CompanionOwner#Companion#create().
19+
// ^^^^^^^^ reference snapshots/CompanionOwner#hashCode(+-1).
20+
}

semanticdb-kotlinc/minimized/src/generatedSnapshots/resources/kotlin/snapshots/Functions.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ fun sampleText(x: String = "") {
55
// ^^^^^^^^^^ definition snapshots/FunctionsKt#sampleText(). sampleText
66
// ^ definition snapshots/FunctionsKt#sampleText().(x) x
77
// ^^^^^^ reference kotlin/String#
8-
println(x)
9-
// ^^^^^^^ reference kotlin/io/ConsoleKt#println(+1).
10-
// ^ reference snapshots/FunctionsKt#sampleText().(x)
11-
}
8+
println(x)
9+
//^^^^^^^ reference kotlin/io/ConsoleKt#println(+1).
10+
// ^ reference snapshots/FunctionsKt#sampleText().(x)
11+
}
Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,31 @@
11
package snapshots
22
// ^^^^^^^^^ reference snapshots/
33

4-
val x = arrayListOf<String>().forEachIndexed { i, s ->
4+
val x = arrayListOf<String>().forEachIndexed { i, s -> println("$i $s") }
55
// ^ definition snapshots/LambdasKt#x. x
66
// ^ definition snapshots/LambdasKt#getX(). x
77
// ^^^^^^^^^^^ reference kotlin/collections/CollectionsKt#arrayListOf().
88
// ^^^^^^ reference kotlin/String#
99
// ^^^^^^^^^^^^^^ reference kotlin/collections/CollectionsKt#forEachIndexed(+9).
1010
// ^ definition local0 i
1111
// ^ definition local1 s
12-
println("$i $s")
13-
// ^^^^^^^ reference kotlin/io/ConsoleKt#println(+1).
14-
// ^ reference local0
15-
// ^ reference local1
16-
}
12+
// ^^^^^^^ reference kotlin/io/ConsoleKt#println(+1).
13+
// ^ reference local0
14+
// ^ reference local1
1715

18-
val y = "fdsa".run {
16+
val y = "fdsa".run { this.toByteArray() }
1917
// ^ definition snapshots/LambdasKt#y. y
2018
// ^ definition snapshots/LambdasKt#getY(). y
2119
// ^^^ reference kotlin/StandardKt#run(+1).
22-
this.toByteArray()
23-
// ^^^^ reference
24-
// ^^^^^^^^^^^ reference kotlin/text/StringsKt#toByteArray().
25-
}
20+
// ^^^^ reference
21+
// ^^^^^^^^^^^ reference kotlin/text/StringsKt#toByteArray().
2622

27-
val z = y.let {
23+
val z = y.let { it.size }
2824
// ^ definition snapshots/LambdasKt#z. z
2925
// ^ definition snapshots/LambdasKt#getZ(). z
3026
// ^ reference snapshots/LambdasKt#y.
3127
// ^ reference snapshots/LambdasKt#getY().
3228
// ^^^ reference kotlin/StandardKt#let().
33-
it.size
34-
// ^^ reference local2
35-
// ^^^^ reference kotlin/ByteArray#size.
36-
// ^^^^ reference kotlin/ByteArray#getSize().
37-
}
29+
// ^^ reference local2
30+
// ^^^^ reference kotlin/ByteArray#size.
31+
// ^^^^ reference kotlin/ByteArray#getSize().
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package snapshots
2+
// ^^^^^^^^^ reference snapshots/
3+
4+
import java.lang.RuntimeException
5+
// ^^^^ reference java/
6+
// ^^^^ reference java/lang/
7+
// ^^^^^^^^^^^^^^^^ reference java/lang/RuntimeException#
8+
9+
object ObjectKt {
10+
// ^^^^^^^^ definition snapshots/ObjectKt# ObjectKt
11+
fun fail(message: String?): Nothing {
12+
// ^^^^ definition snapshots/ObjectKt#fail(). fail
13+
// ^^^^^^^ definition snapshots/ObjectKt#fail().(message) message
14+
// ^^^^^^ reference kotlin/String#
15+
// ^^^^^^^ reference kotlin/Nothing#
16+
throw RuntimeException(message)
17+
// ^^^^^^^^^^^^^^^^ reference java/lang/RuntimeException#`<init>`(+1).
18+
// ^^^^^^^ reference snapshots/ObjectKt#fail().(message)
19+
}
20+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package snapshots;
2+
3+
public class ClassConsumer {
4+
public static void run() {
5+
System.out.println(new Class().getAsdf());
6+
}
7+
}

semanticdb-kotlinc/minimized/src/main/java/snapshots/CompanionConsumer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
public class CompanionConsumer {
44
CompanionConsumer() {
55
CompanionOwner.Companion.create();
6+
new CompanionOwner().create();
67
}
78
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package snapshots;
2+
3+
public class ObjectKtConsumer {
4+
public static void run() {
5+
ObjectKt.INSTANCE.fail("boom");
6+
}
7+
}
Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
1-
package snapshots
2-
3-
class Class constructor(private var banana: Int, apple: String): Throwable(banana.toString()) {
4-
init {
5-
println("")
6-
}
7-
8-
val asdf = object {
9-
fun doStuff() = Unit
10-
}
11-
12-
constructor(): this(1, "")
13-
14-
constructor(banana: Int): this(banana, "")
15-
16-
fun run() {
17-
println(Class::class)
18-
println("I eat $banana for lunch")
19-
}
20-
}
1+
package snapshots
2+
3+
class Class constructor(private var banana: Int, apple: String) :
4+
Throwable(banana.toString() + apple) {
5+
init {
6+
println("")
7+
}
8+
9+
val asdf =
10+
object {
11+
fun doStuff() = Unit
12+
}
13+
14+
constructor() : this(1, "")
15+
16+
constructor(banana: Int) : this(banana, "")
17+
18+
fun run() {
19+
println(Class::class)
20+
println("I eat $banana for lunch")
21+
banana = 42
22+
}
23+
}
Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
package snapshots
2-
3-
class CompanionOwner {
4-
companion object {
5-
fun create(): CompanionOwner = CompanionOwner()
6-
}
7-
}
1+
package snapshots
2+
3+
class CompanionOwner {
4+
companion object {
5+
fun create(): CompanionOwner = CompanionOwner()
6+
}
7+
fun create(): Int = CompanionOwner.create().hashCode()
8+
}

0 commit comments

Comments
 (0)