mirror of
https://github.com/DaanVandenBosch/phantasmal-world.git
synced 2025-04-04 22:58:29 +08:00
ASM problems are now shown again in the script editor.
This commit is contained in:
parent
2905fec830
commit
cd6b3dfd97
@ -15,7 +15,7 @@ class AssemblyProblem(
|
||||
cause: Throwable? = null,
|
||||
val lineNo: Int,
|
||||
val col: Int,
|
||||
val length: Int,
|
||||
val len: Int,
|
||||
) : Problem(severity, uiMessage, message, cause)
|
||||
|
||||
fun assemble(
|
||||
@ -214,7 +214,7 @@ private class Assembler(private val asm: List<String>, private val inlineStackAr
|
||||
}
|
||||
}
|
||||
|
||||
private fun addError(col: Int, length: Int, uiMessage: String, message: String? = null) {
|
||||
private fun addError(col: Int, len: Int, uiMessage: String, message: String? = null) {
|
||||
result.addProblem(
|
||||
AssemblyProblem(
|
||||
Severity.Error,
|
||||
@ -222,7 +222,7 @@ private class Assembler(private val asm: List<String>, private val inlineStackAr
|
||||
message ?: "$uiMessage At $lineNo:$col.",
|
||||
lineNo = lineNo,
|
||||
col = col,
|
||||
length = length
|
||||
len = len
|
||||
)
|
||||
)
|
||||
}
|
||||
@ -246,7 +246,7 @@ private class Assembler(private val asm: List<String>, private val inlineStackAr
|
||||
uiMessage,
|
||||
lineNo = lineNo,
|
||||
col = token.col,
|
||||
length = token.len,
|
||||
len = token.len,
|
||||
)
|
||||
)
|
||||
}
|
||||
@ -375,7 +375,9 @@ private class Assembler(private val asm: List<String>, private val inlineStackAr
|
||||
addError(
|
||||
identToken.col,
|
||||
errorLength,
|
||||
"Expected $paramCount argument ${if (paramCount == 1) "" else "s"}, got $argCount.",
|
||||
"Expected $paramCount argument${
|
||||
if (paramCount == 1) "" else "s"
|
||||
}, got $argCount.",
|
||||
)
|
||||
|
||||
return
|
||||
@ -385,7 +387,9 @@ private class Assembler(private val asm: List<String>, private val inlineStackAr
|
||||
addError(
|
||||
identToken.col,
|
||||
errorLength,
|
||||
"Expected at least $paramCount argument${if (paramCount == 1) "" else "s"}, got $argCount.",
|
||||
"Expected at least $paramCount argument${
|
||||
if (paramCount == 1) "" else "s"
|
||||
}, got $argCount.",
|
||||
)
|
||||
|
||||
return
|
||||
|
@ -158,7 +158,7 @@ class AssemblyWorker(private val sendMessage: (ServerMessage) -> Unit) {
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val problems = (assemblyResult.problems as List<AssemblerAssemblyProblem>).map {
|
||||
AssemblyProblem(it.severity, it.uiMessage)
|
||||
AssemblyProblem(it.severity, it.uiMessage, it.lineNo, it.col, it.len)
|
||||
}
|
||||
|
||||
if (problems != this.problems) {
|
||||
|
@ -157,4 +157,7 @@ class AsmChange(
|
||||
class AssemblyProblem(
|
||||
val severity: Severity,
|
||||
val message: String,
|
||||
val lineNo: Int,
|
||||
val col: Int,
|
||||
val len: Int,
|
||||
)
|
||||
|
@ -22,6 +22,11 @@ external fun createModel(
|
||||
|
||||
external fun defineTheme(themeName: String, themeData: IStandaloneThemeData)
|
||||
|
||||
/**
|
||||
* Set the markers for a model.
|
||||
*/
|
||||
external fun setModelMarkers(model: ITextModel, owner: String, markers: Array<IMarkerData>)
|
||||
|
||||
external interface IStandaloneThemeData {
|
||||
var base: String /* 'vs' | 'vs-dark' | 'hc-black' */
|
||||
var inherit: Boolean
|
||||
|
@ -1,6 +1,7 @@
|
||||
package world.phantasmal.web.questEditor.stores
|
||||
|
||||
import kotlinx.browser.window
|
||||
import world.phantasmal.core.Severity
|
||||
import world.phantasmal.core.disposable.Disposer
|
||||
import world.phantasmal.core.disposable.disposable
|
||||
import world.phantasmal.lib.asm.assemble
|
||||
@ -78,6 +79,35 @@ class AsmStore(
|
||||
observe(asmAnalyser.mapDesignations) {
|
||||
questEditorStore.currentQuest.value?.setMapDesignations(it)
|
||||
}
|
||||
|
||||
observe(problems) { problems ->
|
||||
textModel.value?.let { model ->
|
||||
val markers = Array<IMarkerData>(problems.size) {
|
||||
val problem = problems[it]
|
||||
obj {
|
||||
severity = when (problem.severity) {
|
||||
Severity.Trace, Severity.Debug -> MarkerSeverity.Hint
|
||||
Severity.Info -> MarkerSeverity.Info
|
||||
Severity.Warning -> MarkerSeverity.Warning
|
||||
Severity.Error -> MarkerSeverity.Error
|
||||
}
|
||||
message = problem.message
|
||||
startLineNumber = problem.lineNo
|
||||
startColumn = problem.col
|
||||
endLineNumber = problem.lineNo
|
||||
endColumn = problem.col + problem.len
|
||||
|
||||
// Hack: because only one warning is generated at the moment, "Unnecessary
|
||||
// section marker.", we can simply add the Unnecessary tag here.
|
||||
if (problem.severity == Severity.Warning) {
|
||||
tags = arrayOf(MarkerTag.Unnecessary)
|
||||
}
|
||||
}
|
||||
}
|
||||
// Not sure what the "owner" parameter is for.
|
||||
setModelMarkers(model, owner = ASM_LANG_ID, markers)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun makeUndoCurrent() {
|
||||
|
Loading…
Reference in New Issue
Block a user