I'm experimenting with Kanvas, trying to reproduce the code from here:
https://tomassetti.me/kanvas-generating-simple-ide-antlr-grammar/
Given the following Kotlin code:
import me.tomassetti.kanvas.BaseLanguageSupport
import me.tomassetti.kanvas.AntlrLexerFactory
import me.tomassetti.kanvas.ParserData
import me.tomassetti.kanvas.Kanvas
import me.tomassetti.kanvas.languageSupportRegistry
import javax.swing.SwingUtilities
import org.antlr.v4.runtime.Lexer
import XParser
import XLexer
import com.strumenta.kolasu.model.Node
class KanvasEditorExpt {
object langSupport : BaseLanguageSupport<Node>() {
override val antlrLexerFactory: AntlrLexerFactory
get() = object : AntlrLexerFactory {
override fun create(code: String) : Lexer =
XLexer(org.antlr.v4.runtime.ANTLRInputStream(code))
}
override val parserData: ParserData?
get() =
ParserData(XParser.ruleNames, XParser.VOCABULARY, XParser._ATN)
}
fun main(args: Array<String>) {
languageSupportRegistry.register("X", langSupport)
val kanvas = Kanvas()
SwingUtilities.invokeLater {
kanvas.createAndShowKanvasGUI()
kanvas.addTab("My X", languageSupport = langSupport)
}
}
}
I see this error:
Object 'langSupport' is not abstract and does not implement abstract base class member public abstract val
parser: Parser<Node> defined in me.tomassetti.kanvas.BaseLanguageSupport
I built the .jar
files below via Gradle:
I’ve cloned from GitHub and built what I think are the relevant libraries (note the versions):
- kanvas-core-0.2.4.jar
- kolasu-core-1.3.11.jar
- rsyntaxtextarea-3.1.3.jar
I saw a different error before using BaseLanguageSupport<Node>
instead of BaseLanguageSupport
.
Note that with the following in Java:
class MyLanguageSupport extends BaseLanguageSupport<Node> {
}
I see a slightly different Parser related error:
The type com.strumenta.kolasu.parsing.Parser cannot be resolved. It is indirectly referenced from required .class files
I suspect I should be using something other than Node
here, but I need more docs/examples.
A minimal complete example in GitHub including imports and dependencies would help.
Advice welcome. Thanks.
Apologies for what feels like a newbie error. I am only just beginning to work with Kotlin and gradle, and tend to work with Java and Ant mostly.
See also my post on the Strumenta Language Workbench forum re: this.
Thanks.