Rename ScriptSource to SourceCode, extract location to another i-face...
other related refactorings. The goal - make interface terminologically more suitable for usage in REPL.
This commit is contained in:
+4
-4
@@ -9,7 +9,7 @@ package kotlin.script.experimental.jvm.compat
|
||||
import kotlin.script.dependencies.ScriptContents
|
||||
import kotlin.script.dependencies.ScriptDependenciesResolver
|
||||
import kotlin.script.experimental.api.ScriptDiagnostic
|
||||
import kotlin.script.experimental.api.ScriptSource
|
||||
import kotlin.script.experimental.api.SourceCode
|
||||
import kotlin.script.experimental.dependencies.ScriptReport
|
||||
|
||||
fun mapLegacyDiagnosticSeverity(severity: ScriptDependenciesResolver.ReportSeverity): ScriptDiagnostic.Severity = when (severity) {
|
||||
@@ -28,8 +28,8 @@ fun mapToLegacyScriptReportSeverity(severity: ScriptDiagnostic.Severity): Script
|
||||
ScriptDiagnostic.Severity.DEBUG -> ScriptReport.Severity.DEBUG
|
||||
}
|
||||
|
||||
fun mapLegacyScriptPosition(pos: ScriptContents.Position?): ScriptSource.Location? =
|
||||
pos?.let { ScriptSource.Location(ScriptSource.Position(pos.line, pos.col)) }
|
||||
fun mapLegacyScriptPosition(pos: ScriptContents.Position?): SourceCode.Location? =
|
||||
pos?.let { SourceCode.Location(SourceCode.Position(pos.line, pos.col)) }
|
||||
|
||||
fun mapToLegacyScriptReportPosition(pos: ScriptSource.Location?): ScriptReport.Position? =
|
||||
fun mapToLegacyScriptReportPosition(pos: SourceCode.Location?): ScriptReport.Position? =
|
||||
pos?.let { ScriptReport.Position(pos.start.line, pos.start.col) }
|
||||
|
||||
+1
-1
@@ -84,7 +84,7 @@ class BridgeDependenciesResolver(
|
||||
internal fun List<ScriptDiagnostic>.mapScriptReportsToDiagnostics() =
|
||||
map { ScriptReport(it.message, mapToLegacyScriptReportSeverity(it.severity), mapToLegacyScriptReportPosition(it.location)) }
|
||||
|
||||
internal fun ScriptContents.toScriptSource(): ScriptSource = when {
|
||||
internal fun ScriptContents.toScriptSource(): SourceCode = when {
|
||||
text != null -> text!!.toString().toScriptSource()
|
||||
file != null -> file!!.toScriptSource()
|
||||
else -> throw IllegalArgumentException("Unable to convert script contents $this into script source")
|
||||
|
||||
Reference in New Issue
Block a user