Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions buildSrc/src/main/kotlin/commons.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import internal.java
import internal.kotlin
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

// Java version
Expand All @@ -7,19 +8,23 @@ java {
targetCompatibility = JavaVersion.VERSION_1_8
}

kotlin {
explicitApi()
}

repositories {
jcenter()
}

dependencies {
"implementation"(kotlin("stdlib-jdk8"))
"implementation"("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.3")
"implementation"("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.2")
}

tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
jvmTarget = "1.8"
apiVersion = "1.3"
languageVersion = "1.3"
apiVersion = "1.4"
languageVersion = "1.4"
}
}
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const val sentry = "io.sentry:sentry:1.7.29"

object fuel {
private const val group = "com.github.kittinunf.fuel"
private const val version = "2.2.1"
private const val version = "2.3.1"
const val self = "$group:fuel:$version"
const val coroutines = "$group:fuel-coroutines:$version"
}
5 changes: 5 additions & 0 deletions buildSrc/src/main/kotlin/internal/accessors.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ package internal
import org.gradle.api.Project
import org.gradle.api.plugins.JavaPluginExtension
import org.gradle.kotlin.dsl.configure
import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension

internal fun Project.java(configure: JavaPluginExtension.() -> Unit) {
extensions.configure(configure)
}

internal fun Project.kotlin(configure: KotlinProjectExtension.() -> Unit) {
extensions.configure(configure)
}
6 changes: 0 additions & 6 deletions inspector-api/src/main/kotlin/Annotations.kt

This file was deleted.

30 changes: 12 additions & 18 deletions inspector-api/src/main/kotlin/dsl/Markdown.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ internal class Line(private val text: String) : Element {
internal annotation class MarkdownMarker

@MarkdownMarker
abstract class Group(
public abstract class Group internal constructor(
private val indent: String,
private val firstLine: String?,
private val lastLine: String? = firstLine
private val lastLine: String? = firstLine,
) : Element {
private val children = arrayListOf<Element>()

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

operator fun String?.unaryPlus() {
public operator fun String?.unaryPlus() {
children.add(Line(this ?: ""))
}

operator fun List<String>?.unaryPlus() {
public operator fun List<String>?.unaryPlus() {
this?.forEach { +it }
}

Expand All @@ -50,27 +50,21 @@ abstract class Group(
}
}

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

fun b(text: String): String {
return "**$text**"
}
public fun b(text: String): String = "**$text**"

fun it(text: String): String {
return "*$text*"
}
public fun it(text: String): String = "*$text*"

fun hr(): String {
return "---"
}
public fun hr(): String = "---"
}

class Markdown : TextGroup() {
fun code(lang: String = "", init: Code.() -> Unit) = initGroup(Code(lang), init)
public class Markdown internal constructor() : TextGroup() {
public fun code(lang: String = "", init: Code.() -> Unit): Code = initGroup(Code(lang), init)
}

class Code(lang: String) : Group(indent = "", firstLine = "```$lang", lastLine = "```")
public class Code internal constructor(lang: String) : Group(indent = "", firstLine = "```$lang", lastLine = "```")

fun markdown(init: Markdown.() -> Unit): Markdown {
public fun markdown(init: Markdown.() -> Unit): Markdown {
return Markdown().also(init)
}
1 change: 1 addition & 0 deletions inspector-api/src/main/kotlin/package.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package ru.endlesscode.inspector
6 changes: 3 additions & 3 deletions inspector-api/src/main/kotlin/report/CachingReporter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import ru.endlesscode.inspector.util.similarTo
/**
* Reporter that filters if he already reported similar exception.
*/
abstract class CachingReporter : Reporter {
public abstract class CachingReporter : Reporter {

private val reportedCauses = mutableListOf<Throwable>()
private val handlers = CompoundReportHandler()
Expand Down Expand Up @@ -52,10 +52,10 @@ abstract class CachingReporter : Reporter {
* @param onSuccess Will be called on successful report
* @param onError Will be called on error during report
*/
abstract suspend fun report(
public abstract suspend fun report(
title: String,
exceptionData: ExceptionData,
onSuccess: (String, ExceptionData) -> Unit,
onError: (Throwable) -> Unit
onError: (Throwable) -> Unit,
)
}
4 changes: 2 additions & 2 deletions inspector-api/src/main/kotlin/report/CompoundReportHandler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package ru.endlesscode.inspector.report
/**
* Handler that dispatches events to many handlers.
*/
class CompoundReportHandler : ReportHandler {
public class CompoundReportHandler : ReportHandler {

private val handlers = mutableListOf<ReportHandler>()

Expand All @@ -22,7 +22,7 @@ class CompoundReportHandler : ReportHandler {
/**
* Add given [handler] to list of handlers that should receive events.
*/
fun addHandler(handler: ReportHandler) {
public fun addHandler(handler: ReportHandler) {
handlers.add(handler)
}
}
6 changes: 3 additions & 3 deletions inspector-api/src/main/kotlin/report/ExceptionData.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package ru.endlesscode.inspector.report

class ExceptionData(
val exception: Exception,
var times: Int = 1
public class ExceptionData(
public val exception: Exception,
public var times: Int = 1,
)
14 changes: 7 additions & 7 deletions inspector-api/src/main/kotlin/report/ReportEnvironment.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package ru.endlesscode.inspector.report

interface ReportEnvironment {
public interface ReportEnvironment {

companion object {
val EMPTY = object : ReportEnvironment {
public companion object {
public val EMPTY: ReportEnvironment = object : ReportEnvironment {
override val appVersion: String = ""
override val reporterId: String = ""
override val fields: Map<String, ReportField> = emptyMap()
Expand All @@ -14,20 +14,20 @@ interface ReportEnvironment {
/**
* Version of app that uses Inspector.
*/
val appVersion: String
public val appVersion: String

/**
* Unique identifier of reporter.
*/
val reporterId: String
public val reporterId: String

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

/**
* Indicates that inspector enabled.
*/
val isInspectorEnabled: Boolean
public val isInspectorEnabled: Boolean
}
28 changes: 14 additions & 14 deletions inspector-api/src/main/kotlin/report/ReportFields.kt
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
package ru.endlesscode.inspector.report

interface ReportField {
public interface ReportField {

companion object {
public companion object {
private const val HIDDEN_FIELD_VALUE = "<value hidden by user>"
}

val name: String
val shortValue: String
val value: String
val show: Boolean
public val name: String
public val shortValue: String
public val value: String
public val show: Boolean

fun render(
public fun render(
short: Boolean = true,
separator: String = ": ",
prepareName: (String) -> String = { it },
prepareValue: (String) -> String = { it }
prepareValue: (String) -> String = { it },
): String {
val selectedValue = if (show) {
if (short) shortValue else value
Expand All @@ -27,10 +27,10 @@ interface ReportField {
}
}

open class TextField(
public open class TextField(
override val name: String,
override val shortValue: String,
override val value: String = shortValue
override val value: String = shortValue,
) : ReportField {

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

/** Adds predicate to show or hide field. */
fun showOnlyIf(predicate: TextField.() -> Boolean): ReportField {
public fun showOnlyIf(predicate: TextField.() -> Boolean): ReportField {
shouldShow = predicate
return this
}
}

open class ListField<T>(
public open class ListField<T>(
override val name: String,
private val produceList: () -> List<T>,
private val getSummary: (List<T>) -> String
private val getSummary: (List<T>) -> String,
) : ReportField {

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

/** Adds predicate to show or hide field. */
fun showOnlyIf(predicate: ListField<T>.() -> Boolean): ListField<T> {
public fun showOnlyIf(predicate: ListField<T>.() -> Boolean): ListField<T> {
shouldShow = predicate
return this
}
Expand Down
10 changes: 5 additions & 5 deletions inspector-api/src/main/kotlin/report/ReportHandler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,28 @@ package ru.endlesscode.inspector.report
/**
* Report handler. Used for tracking report process.
*/
interface ReportHandler {
public interface ReportHandler {

/**
* Called before report sent.
*
* @param message Report message
* @param exceptionData Exception data that will be reported
*/
fun beforeReport(message: String, exceptionData: ExceptionData)
public fun beforeReport(message: String, exceptionData: ExceptionData)

/**
* Called on successfully report.
*
* @param message Report message
* @param exceptionData Exception data that was reported
*/
fun onSuccess(message: String, exceptionData: ExceptionData)
public fun onSuccess(message: String, exceptionData: ExceptionData)

/**
* Called when an exception occurs while attempting to report an error.
*
* @param throwable The exception that occured on report
* @param throwable The exception that occurred on report
*/
fun onError(throwable: Throwable)
public fun onError(throwable: Throwable)
}
2 changes: 1 addition & 1 deletion inspector-api/src/main/kotlin/report/ReportedException.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package ru.endlesscode.inspector.report

class ReportedException(cause: Throwable) : RuntimeException("Exception reported with Inspector", cause)
public class ReportedException(cause: Throwable) : RuntimeException("Exception reported with Inspector", cause)
Loading