Skip to content

Commit 0e5f90a

Browse files
committed
refactor: Enable explicitApi
1 parent da39add commit 0e5f90a

33 files changed

Lines changed: 194 additions & 264 deletions

buildSrc/src/main/kotlin/commons.gradle.kts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import internal.java
2+
import internal.kotlin
23
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
34

45
// Java version
@@ -7,6 +8,10 @@ java {
78
targetCompatibility = JavaVersion.VERSION_1_8
89
}
910

11+
kotlin {
12+
explicitApi()
13+
}
14+
1015
repositories {
1116
jcenter()
1217
}

buildSrc/src/main/kotlin/internal/accessors.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@ package internal
33
import org.gradle.api.Project
44
import org.gradle.api.plugins.JavaPluginExtension
55
import org.gradle.kotlin.dsl.configure
6+
import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension
67

78
internal fun Project.java(configure: JavaPluginExtension.() -> Unit) {
89
extensions.configure(configure)
910
}
11+
12+
internal fun Project.kotlin(configure: KotlinProjectExtension.() -> Unit) {
13+
extensions.configure(configure)
14+
}

inspector-api/src/main/kotlin/Annotations.kt

Lines changed: 0 additions & 6 deletions
This file was deleted.

inspector-api/src/main/kotlin/dsl/Markdown.kt

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ internal class Line(private val text: String) : Element {
1414
internal annotation class MarkdownMarker
1515

1616
@MarkdownMarker
17-
abstract class Group(
17+
public abstract class Group internal constructor(
1818
private val indent: String,
1919
private val firstLine: String?,
20-
private val lastLine: String? = firstLine
20+
private val lastLine: String? = firstLine,
2121
) : Element {
2222
private val children = arrayListOf<Element>()
2323

@@ -35,11 +35,11 @@ abstract class Group(
3535
lastLine?.let { builder.append("$it\n") }
3636
}
3737

38-
operator fun String?.unaryPlus() {
38+
public operator fun String?.unaryPlus() {
3939
children.add(Line(this ?: ""))
4040
}
4141

42-
operator fun List<String>?.unaryPlus() {
42+
public operator fun List<String>?.unaryPlus() {
4343
this?.forEach { +it }
4444
}
4545

@@ -50,27 +50,21 @@ abstract class Group(
5050
}
5151
}
5252

53-
abstract class TextGroup : Group(indent = "", firstLine = null) {
53+
public abstract class TextGroup internal constructor() : Group(indent = "", firstLine = null) {
5454

55-
fun b(text: String): String {
56-
return "**$text**"
57-
}
55+
public fun b(text: String): String = "**$text**"
5856

59-
fun it(text: String): String {
60-
return "*$text*"
61-
}
57+
public fun it(text: String): String = "*$text*"
6258

63-
fun hr(): String {
64-
return "---"
65-
}
59+
public fun hr(): String = "---"
6660
}
6761

68-
class Markdown : TextGroup() {
69-
fun code(lang: String = "", init: Code.() -> Unit) = initGroup(Code(lang), init)
62+
public class Markdown internal constructor() : TextGroup() {
63+
public fun code(lang: String = "", init: Code.() -> Unit): Code = initGroup(Code(lang), init)
7064
}
7165

72-
class Code(lang: String) : Group(indent = "", firstLine = "```$lang", lastLine = "```")
66+
public class Code internal constructor(lang: String) : Group(indent = "", firstLine = "```$lang", lastLine = "```")
7367

74-
fun markdown(init: Markdown.() -> Unit): Markdown {
68+
public fun markdown(init: Markdown.() -> Unit): Markdown {
7569
return Markdown().also(init)
7670
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package ru.endlesscode.inspector

inspector-api/src/main/kotlin/report/CachingReporter.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import ru.endlesscode.inspector.util.similarTo
99
/**
1010
* Reporter that filters if he already reported similar exception.
1111
*/
12-
abstract class CachingReporter : Reporter {
12+
public abstract class CachingReporter : Reporter {
1313

1414
private val reportedCauses = mutableListOf<Throwable>()
1515
private val handlers = CompoundReportHandler()
@@ -52,10 +52,10 @@ abstract class CachingReporter : Reporter {
5252
* @param onSuccess Will be called on successful report
5353
* @param onError Will be called on error during report
5454
*/
55-
abstract suspend fun report(
55+
public abstract suspend fun report(
5656
title: String,
5757
exceptionData: ExceptionData,
5858
onSuccess: (String, ExceptionData) -> Unit,
59-
onError: (Throwable) -> Unit
59+
onError: (Throwable) -> Unit,
6060
)
6161
}

inspector-api/src/main/kotlin/report/CompoundReportHandler.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package ru.endlesscode.inspector.report
33
/**
44
* Handler that dispatches events to many handlers.
55
*/
6-
class CompoundReportHandler : ReportHandler {
6+
public class CompoundReportHandler : ReportHandler {
77

88
private val handlers = mutableListOf<ReportHandler>()
99

@@ -22,7 +22,7 @@ class CompoundReportHandler : ReportHandler {
2222
/**
2323
* Add given [handler] to list of handlers that should receive events.
2424
*/
25-
fun addHandler(handler: ReportHandler) {
25+
public fun addHandler(handler: ReportHandler) {
2626
handlers.add(handler)
2727
}
2828
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package ru.endlesscode.inspector.report
22

3-
class ExceptionData(
4-
val exception: Exception,
5-
var times: Int = 1
3+
public class ExceptionData(
4+
public val exception: Exception,
5+
public var times: Int = 1,
66
)
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package ru.endlesscode.inspector.report
22

3-
interface ReportEnvironment {
3+
public interface ReportEnvironment {
44

5-
companion object {
6-
val EMPTY = object : ReportEnvironment {
5+
public companion object {
6+
public val EMPTY: ReportEnvironment = object : ReportEnvironment {
77
override val appVersion: String = ""
88
override val reporterId: String = ""
99
override val fields: Map<String, ReportField> = emptyMap()
@@ -14,20 +14,20 @@ interface ReportEnvironment {
1414
/**
1515
* Version of app that uses Inspector.
1616
*/
17-
val appVersion: String
17+
public val appVersion: String
1818

1919
/**
2020
* Unique identifier of reporter.
2121
*/
22-
val reporterId: String
22+
public val reporterId: String
2323

2424
/**
2525
* Environment-related [fields][ReportField]. Stored as relation "name -> field".
2626
*/
27-
val fields: Map<String, ReportField>
27+
public val fields: Map<String, ReportField>
2828

2929
/**
3030
* Indicates that inspector enabled.
3131
*/
32-
val isInspectorEnabled: Boolean
32+
public val isInspectorEnabled: Boolean
3333
}

inspector-api/src/main/kotlin/report/ReportFields.kt

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
package ru.endlesscode.inspector.report
22

3-
interface ReportField {
3+
public interface ReportField {
44

5-
companion object {
5+
public companion object {
66
private const val HIDDEN_FIELD_VALUE = "<value hidden by user>"
77
}
88

9-
val name: String
10-
val shortValue: String
11-
val value: String
12-
val show: Boolean
9+
public val name: String
10+
public val shortValue: String
11+
public val value: String
12+
public val show: Boolean
1313

14-
fun render(
14+
public fun render(
1515
short: Boolean = true,
1616
separator: String = ": ",
1717
prepareName: (String) -> String = { it },
18-
prepareValue: (String) -> String = { it }
18+
prepareValue: (String) -> String = { it },
1919
): String {
2020
val selectedValue = if (show) {
2121
if (short) shortValue else value
@@ -27,10 +27,10 @@ interface ReportField {
2727
}
2828
}
2929

30-
open class TextField(
30+
public open class TextField(
3131
override val name: String,
3232
override val shortValue: String,
33-
override val value: String = shortValue
33+
override val value: String = shortValue,
3434
) : ReportField {
3535

3636
private var shouldShow: TextField.() -> Boolean = { true }
@@ -39,16 +39,16 @@ open class TextField(
3939
get() = shouldShow()
4040

4141
/** Adds predicate to show or hide field. */
42-
fun showOnlyIf(predicate: TextField.() -> Boolean): ReportField {
42+
public fun showOnlyIf(predicate: TextField.() -> Boolean): ReportField {
4343
shouldShow = predicate
4444
return this
4545
}
4646
}
4747

48-
open class ListField<T>(
48+
public open class ListField<T>(
4949
override val name: String,
5050
private val produceList: () -> List<T>,
51-
private val getSummary: (List<T>) -> String
51+
private val getSummary: (List<T>) -> String,
5252
) : ReportField {
5353

5454
override val shortValue: String
@@ -66,7 +66,7 @@ open class ListField<T>(
6666
private var shouldShow: ListField<T>.() -> Boolean = { true }
6767

6868
/** Adds predicate to show or hide field. */
69-
fun showOnlyIf(predicate: ListField<T>.() -> Boolean): ListField<T> {
69+
public fun showOnlyIf(predicate: ListField<T>.() -> Boolean): ListField<T> {
7070
shouldShow = predicate
7171
return this
7272
}

0 commit comments

Comments
 (0)