more robust: avoid sporadic crash of JEditBuffer.tokenMarker.getMainRuleSet().getModeName();
--- a/src/Tools/jEdit/src/jedit_bibtex.scala Sun May 02 17:38:49 2021 +0200
+++ b/src/Tools/jEdit/src/jedit_bibtex.scala Sun May 02 20:51:21 2021 +0200
@@ -20,7 +20,7 @@
import org.gjt.sp.jedit.Buffer
import org.gjt.sp.jedit.textarea.{JEditTextArea, TextArea}
-import org.gjt.sp.jedit.syntax.{Token => JEditToken, TokenMarker, TokenHandler, ParserRuleSet}
+import org.gjt.sp.jedit.syntax.{Token => JEditToken, TokenMarker, TokenHandler}
import sidekick.{SideKickParser, SideKickParsedData}
@@ -82,10 +82,10 @@
/* line context */
- private val context_rules = new ParserRuleSet("bibtex", "MAIN")
+ private val mode_rule_set = Token_Markup.mode_rule_set("bibtex")
private class Line_Context(val context: Option[Bibtex.Line_Context])
- extends TokenMarker.LineContext(context_rules, null)
+ extends TokenMarker.LineContext(mode_rule_set, null)
{
override def hashCode: Int = context.hashCode
override def equals(that: Any): Boolean =
@@ -100,6 +100,8 @@
class Token_Marker extends TokenMarker
{
+ addRuleSet(mode_rule_set)
+
override def markTokens(context: TokenMarker.LineContext,
handler: TokenHandler, raw_line: Segment): TokenMarker.LineContext =
{
--- a/src/Tools/jEdit/src/token_markup.scala Sun May 02 17:38:49 2021 +0200
+++ b/src/Tools/jEdit/src/token_markup.scala Sun May 02 20:51:21 2021 +0200
@@ -22,6 +22,9 @@
{
/* line context */
+ def mode_rule_set(mode: String): ParserRuleSet =
+ new ParserRuleSet(mode, "MAIN")
+
object Line_Context
{
def init(mode: String): Line_Context =
@@ -50,7 +53,7 @@
val mode: String,
val context: Option[Scan.Line_Context],
val structure: Line_Structure)
- extends TokenMarker.LineContext(new ParserRuleSet(mode, "MAIN"), null)
+ extends TokenMarker.LineContext(mode_rule_set(mode), null)
{
def get_context: Scan.Line_Context = context.getOrElse(Scan.Finished)
@@ -216,6 +219,8 @@
protected val mode: String,
protected val opt_buffer: Option[Buffer]) extends TokenMarker
{
+ addRuleSet(mode_rule_set(mode))
+
override def hashCode: Int = (mode, opt_buffer).hashCode
override def equals(that: Any): Boolean =
that match {