mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-24 04:57:50 -04:00
fix dead end error with executable literal nodes
This commit is contained in:
parent
7191fdcb76
commit
d1451bd863
@ -48,6 +48,18 @@ abstract class ExecutableNode(
|
|||||||
super.execute(reader, stack)
|
super.execute(reader, stack)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun getSuggestions(reader: CommandReader, stack: CommandStack): List<Any?> {
|
||||||
|
if (!reader.canPeek()) {
|
||||||
|
// empty string
|
||||||
|
if (executable) {
|
||||||
|
return emptyList()
|
||||||
|
} else {
|
||||||
|
checkForDeadEnd(reader)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return super.getSuggestions(reader, stack)
|
||||||
|
}
|
||||||
|
|
||||||
override fun executeChild(child: CommandNode, reader: CommandReader, stack: CommandStack) {
|
override fun executeChild(child: CommandNode, reader: CommandReader, stack: CommandStack) {
|
||||||
super.executeChild(child, reader, stack)
|
super.executeChild(child, reader, stack)
|
||||||
if (!onlyDirectExecution) {
|
if (!onlyDirectExecution) {
|
||||||
|
@ -35,7 +35,7 @@ internal class SuggestionChildReadingTest {
|
|||||||
.addChild(
|
.addChild(
|
||||||
LiteralNode("1_literal")
|
LiteralNode("1_literal")
|
||||||
.addChild(LiteralNode("1_literal_2"))
|
.addChild(LiteralNode("1_literal_2"))
|
||||||
.addChild(LiteralNode("2_literal_2"))
|
.addChild(LiteralNode("2_literal_2", executable = true))
|
||||||
)
|
)
|
||||||
.addChild(LiteralNode("2_literal"))
|
.addChild(LiteralNode("2_literal"))
|
||||||
.addChild(
|
.addChild(
|
||||||
@ -152,4 +152,9 @@ internal class SuggestionChildReadingTest {
|
|||||||
fun testStringOptionalArguments() {
|
fun testStringOptionalArguments() {
|
||||||
assertDoesNotThrow { createCommand().getSuggestions(CommandReader("3_literal string"), CommandStack()) }
|
assertDoesNotThrow { createCommand().getSuggestions(CommandReader("3_literal string"), CommandStack()) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testNoSuggestionsErrors() {
|
||||||
|
assertEquals(createCommand().getSuggestions(CommandReader("1_literal 2_literal_2"), CommandStack()), emptyList())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user