-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ebe197b
commit 453d665
Showing
11 changed files
with
59 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
SKIE/kotlin-compiler/core/src/commonMain/kotlin/co/touchlab/skie/util/KirReporter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package co.touchlab.skie.util | ||
|
||
import co.touchlab.skie.kir.element.KirElement | ||
|
||
class KirReporter : Reporter<KirElement>() |
15 changes: 7 additions & 8 deletions
15
SKIE/kotlin-compiler/core/src/commonMain/kotlin/co/touchlab/skie/util/Reporter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,28 @@ | ||
package co.touchlab.skie.util | ||
|
||
import co.touchlab.skie.kir.element.KirElement | ||
import java.util.Collections | ||
|
||
class Reporter { | ||
abstract class Reporter<T> { | ||
|
||
private val mutableReports = Collections.synchronizedList(mutableListOf<Report>()) | ||
private val mutableReports = Collections.synchronizedList(mutableListOf<Report<T>>()) | ||
|
||
val reports: List<Report> by ::mutableReports | ||
val reports: List<Report<T>> by ::mutableReports | ||
|
||
fun report(severity: Severity, message: String, source: KirElement? = null) { | ||
fun report(severity: Severity, message: String, source: T? = null) { | ||
mutableReports.add(Report(message, severity, source)) | ||
} | ||
|
||
fun error(message: String, source: KirElement? = null) { | ||
fun error(message: String, source: T? = null) { | ||
report(Severity.Error, message, source) | ||
} | ||
|
||
fun warning(message: String, source: KirElement? = null) { | ||
fun warning(message: String, source: T? = null) { | ||
report(Severity.Warning, message, source) | ||
} | ||
|
||
enum class Severity { | ||
Error, Warning | ||
} | ||
|
||
data class Report(val message: String, val severity: Severity, val source: KirElement?) | ||
data class Report<T>(val message: String, val severity: Severity, val source: T?) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
...-compiler/linker-plugin/src/kgp_common/kotlin/co/touchlab/skie/phases/InitPhase+linker.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
package co.touchlab.skie.phases | ||
|
||
import co.touchlab.skie.context.InitPhaseContext | ||
import co.touchlab.skie.util.DescriptorReporter | ||
import org.jetbrains.kotlin.config.CompilerConfiguration | ||
|
||
val InitPhase.Context.compilerConfiguration: CompilerConfiguration | ||
get() = typedContext.compilerConfiguration | ||
|
||
val InitPhase.Context.descriptorReporter: DescriptorReporter | ||
get() = typedContext.descriptorReporter | ||
|
||
private val InitPhase.Context.typedContext: InitPhaseContext | ||
get() = context as InitPhaseContext |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
...-compiler/linker-plugin/src/kgp_common/kotlin/co/touchlab/skie/util/DescriptorReporter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package co.touchlab.skie.util | ||
|
||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor | ||
|
||
class DescriptorReporter : Reporter<DeclarationDescriptor>() |