Upgraded to monaco-editor 0.26.1.

This commit is contained in:
Daan Vanden Bosch 2021-07-25 00:05:45 +02:00
parent 295dd6a253
commit 6cf0fdaf33
6 changed files with 20 additions and 39 deletions

View File

@ -290,7 +290,7 @@ class AsmAnalyser {
val result = bytecodeIr.segments.asSequence() val result = bytecodeIr.segments.asSequence()
.flatMap { segment -> .flatMap { segment ->
segment.labels.mapIndexed { labelIdx, label -> segment.labels.mapIndexed { labelIdx, label ->
val range = segment.srcLoc.labels.getOrNull(labelIdx)?.toAsmRange() val range = segment.srcLoc.labels[labelIdx].toAsmRange()
Label(name = label, range) Label(name = label, range)
} }
} }

View File

@ -33,15 +33,12 @@ dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:$serializationVersion") implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:$serializationVersion")
implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.2.1") implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.2.1")
implementation(npm("golden-layout", "^1.5.9")) implementation(npm("golden-layout", "^1.5.9"))
// Can't upgrade monaco-editor until https://github.com/microsoft/monaco-editor/issues/2466 is implementation(npm("monaco-editor", "0.26.1"))
// fixed.
implementation(npm("monaco-editor", "0.20.0"))
implementation(npm("three", "^0.128.0")) implementation(npm("three", "^0.128.0"))
implementation(npm("javascript-lp-solver", "0.4.17")) implementation(npm("javascript-lp-solver", "0.4.17"))
implementation(devNpm("file-loader", "^6.2.0")) 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", "4.1.1"))
implementation(devNpm("monaco-editor-webpack-plugin", "1.9.1"))
testImplementation(project(":test-utils")) testImplementation(project(":test-utils"))
} }

View File

@ -196,5 +196,5 @@ class AssemblyProblem(
@Serializable @Serializable
class Label( class Label(
val name: Int, val name: Int,
val range: AsmRange?, val range: AsmRange,
) )

View File

@ -261,31 +261,9 @@ external interface IMonarchLanguageBracket {
} }
external interface CompletionItemLabel { external interface CompletionItemLabel {
/** var label: String
* The function or variable. Rendered leftmost. var detail: String?
*/ var description: String?
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
} }
external interface CompletionItemRanges { external interface CompletionItemRanges {
@ -448,7 +426,7 @@ external interface CompletionItem {
external interface CompletionList { external interface CompletionList {
var suggestions: Array<CompletionItem> var suggestions: Array<CompletionItem>
var incomplete: Boolean var incomplete: Boolean?
fun dispose() fun dispose()
} }

View File

@ -26,7 +26,7 @@ class AsmCompletionItemProvider(private val analyser: AsmAnalyser) :
val completion = completions[i] val completion = completions[i]
obj { obj {
label = obj { name = completion.label } label = obj { label = completion.label }
kind = when (completion.type) { kind = when (completion.type) {
CompletionItemType.Keyword -> CompletionItemKind.Keyword CompletionItemType.Keyword -> CompletionItemKind.Keyword
CompletionItemType.Opcode -> CompletionItemKind.Function CompletionItemType.Opcode -> CompletionItemKind.Function

View File

@ -1,14 +1,16 @@
package world.phantasmal.web.questEditor.asm.monaco package world.phantasmal.web.questEditor.asm.monaco
import kotlinx.coroutines.promise import kotlinx.coroutines.promise
import world.phantasmal.web.externals.monacoEditor.CancellationToken import world.phantasmal.web.externals.monacoEditor.*
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.questEditor.asm.AsmAnalyser import world.phantasmal.web.questEditor.asm.AsmAnalyser
import world.phantasmal.webui.obj import world.phantasmal.webui.obj
import kotlin.js.Promise 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) : class AsmDocumentSymbolProvider(private val asmAnalyser: AsmAnalyser) :
MonacoProvider(), DocumentSymbolProvider { MonacoProvider(), DocumentSymbolProvider {
override val displayName: String? = null override val displayName: String? = null
@ -25,7 +27,11 @@ class AsmDocumentSymbolProvider(private val asmAnalyser: AsmAnalyser) :
obj { obj {
name = label.name.toString() name = label.name.toString()
label.range?.let { range = it.toIRange() } detail = ""
kind = SymbolKind.Function
tags = emptyArray()
range = label.range.toIRange()
selectionRange = range
} }
} }
} }