From 6cf0fdaf33e79f640d0b0ed54cc6e9bc5a6ee0d1 Mon Sep 17 00:00:00 2001 From: Daan Vanden Bosch Date: Sun, 25 Jul 2021 00:05:45 +0200 Subject: [PATCH] Upgraded to monaco-editor 0.26.1. --- .../web/assemblyWorker/AsmAnalyser.kt | 2 +- web/build.gradle.kts | 7 ++--- .../web/shared/messages/Messages.kt | 2 +- .../web/externals/monacoEditor/languages.kt | 30 +++---------------- .../asm/monaco/AsmCompletionItemProvider.kt | 2 +- .../asm/monaco/AsmDocumentSymbolProvider.kt | 16 ++++++---- 6 files changed, 20 insertions(+), 39 deletions(-) diff --git a/web/assembly-worker/src/main/kotlin/world/phantasmal/web/assemblyWorker/AsmAnalyser.kt b/web/assembly-worker/src/main/kotlin/world/phantasmal/web/assemblyWorker/AsmAnalyser.kt index 41face39..c052c35a 100644 --- a/web/assembly-worker/src/main/kotlin/world/phantasmal/web/assemblyWorker/AsmAnalyser.kt +++ b/web/assembly-worker/src/main/kotlin/world/phantasmal/web/assemblyWorker/AsmAnalyser.kt @@ -290,7 +290,7 @@ class AsmAnalyser { val result = bytecodeIr.segments.asSequence() .flatMap { segment -> segment.labels.mapIndexed { labelIdx, label -> - val range = segment.srcLoc.labels.getOrNull(labelIdx)?.toAsmRange() + val range = segment.srcLoc.labels[labelIdx].toAsmRange() Label(name = label, range) } } diff --git a/web/build.gradle.kts b/web/build.gradle.kts index c9a690ea..41299e86 100644 --- a/web/build.gradle.kts +++ b/web/build.gradle.kts @@ -33,15 +33,12 @@ dependencies { implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:$serializationVersion") implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.2.1") implementation(npm("golden-layout", "^1.5.9")) - // Can't upgrade monaco-editor until https://github.com/microsoft/monaco-editor/issues/2466 is - // fixed. - implementation(npm("monaco-editor", "0.20.0")) + implementation(npm("monaco-editor", "0.26.1")) implementation(npm("three", "^0.128.0")) implementation(npm("javascript-lp-solver", "0.4.17")) implementation(devNpm("file-loader", "^6.2.0")) - // Can't upgrade monaco-editor-webpack-plugin until monaco-editor is upgraded. - implementation(devNpm("monaco-editor-webpack-plugin", "1.9.1")) + implementation(devNpm("monaco-editor-webpack-plugin", "4.1.1")) testImplementation(project(":test-utils")) } diff --git a/web/shared/src/commonMain/kotlin/world/phantasmal/web/shared/messages/Messages.kt b/web/shared/src/commonMain/kotlin/world/phantasmal/web/shared/messages/Messages.kt index d5f9ad79..7fab7480 100644 --- a/web/shared/src/commonMain/kotlin/world/phantasmal/web/shared/messages/Messages.kt +++ b/web/shared/src/commonMain/kotlin/world/phantasmal/web/shared/messages/Messages.kt @@ -196,5 +196,5 @@ class AssemblyProblem( @Serializable class Label( val name: Int, - val range: AsmRange?, + val range: AsmRange, ) diff --git a/web/src/main/kotlin/world/phantasmal/web/externals/monacoEditor/languages.kt b/web/src/main/kotlin/world/phantasmal/web/externals/monacoEditor/languages.kt index 4770053c..82f91bb6 100644 --- a/web/src/main/kotlin/world/phantasmal/web/externals/monacoEditor/languages.kt +++ b/web/src/main/kotlin/world/phantasmal/web/externals/monacoEditor/languages.kt @@ -261,31 +261,9 @@ external interface IMonarchLanguageBracket { } external interface CompletionItemLabel { - /** - * The function or variable. Rendered leftmost. - */ - var name: String - - /** - * The signature without the return type. Render after `name`. - */ - var signature: String? - get() = definedExternally - set(value) = definedExternally - - /** - * The fully qualified name, like package name or file path. Rendered after `signature`. - */ - var qualifier: String? - get() = definedExternally - set(value) = definedExternally - - /** - * The return-type of a function or type of a property/variable. Rendered rightmost. - */ - var type: String? - get() = definedExternally - set(value) = definedExternally + var label: String + var detail: String? + var description: String? } external interface CompletionItemRanges { @@ -448,7 +426,7 @@ external interface CompletionItem { external interface CompletionList { var suggestions: Array - var incomplete: Boolean + var incomplete: Boolean? fun dispose() } diff --git a/web/src/main/kotlin/world/phantasmal/web/questEditor/asm/monaco/AsmCompletionItemProvider.kt b/web/src/main/kotlin/world/phantasmal/web/questEditor/asm/monaco/AsmCompletionItemProvider.kt index 0bb754e8..78be9cc7 100644 --- a/web/src/main/kotlin/world/phantasmal/web/questEditor/asm/monaco/AsmCompletionItemProvider.kt +++ b/web/src/main/kotlin/world/phantasmal/web/questEditor/asm/monaco/AsmCompletionItemProvider.kt @@ -26,7 +26,7 @@ class AsmCompletionItemProvider(private val analyser: AsmAnalyser) : val completion = completions[i] obj { - label = obj { name = completion.label } + label = obj { label = completion.label } kind = when (completion.type) { CompletionItemType.Keyword -> CompletionItemKind.Keyword CompletionItemType.Opcode -> CompletionItemKind.Function diff --git a/web/src/main/kotlin/world/phantasmal/web/questEditor/asm/monaco/AsmDocumentSymbolProvider.kt b/web/src/main/kotlin/world/phantasmal/web/questEditor/asm/monaco/AsmDocumentSymbolProvider.kt index e23a1287..09075a11 100644 --- a/web/src/main/kotlin/world/phantasmal/web/questEditor/asm/monaco/AsmDocumentSymbolProvider.kt +++ b/web/src/main/kotlin/world/phantasmal/web/questEditor/asm/monaco/AsmDocumentSymbolProvider.kt @@ -1,14 +1,16 @@ package world.phantasmal.web.questEditor.asm.monaco import kotlinx.coroutines.promise -import world.phantasmal.web.externals.monacoEditor.CancellationToken -import world.phantasmal.web.externals.monacoEditor.DocumentSymbol -import world.phantasmal.web.externals.monacoEditor.DocumentSymbolProvider -import world.phantasmal.web.externals.monacoEditor.ITextModel +import world.phantasmal.web.externals.monacoEditor.* import world.phantasmal.web.questEditor.asm.AsmAnalyser import world.phantasmal.webui.obj import kotlin.js.Promise +// Sometimes produces stack overflows in monaco perf monitoring code due to a monaco bug. Things +// still work as they should, though. +// Chrome error: "Uncaught (in promise) RangeError: Maximum call stack size exceeded" +// https://github.com/microsoft/monaco-editor/issues/2586 +// TODO: See whether monaco perf monitoring bug will get fixed or not. class AsmDocumentSymbolProvider(private val asmAnalyser: AsmAnalyser) : MonacoProvider(), DocumentSymbolProvider { override val displayName: String? = null @@ -25,7 +27,11 @@ class AsmDocumentSymbolProvider(private val asmAnalyser: AsmAnalyser) : obj { name = label.name.toString() - label.range?.let { range = it.toIRange() } + detail = "" + kind = SymbolKind.Function + tags = emptyArray() + range = label.range.toIRange() + selectionRange = range } } }