fix(gui): use simple token maker as default to avoid parsing error (#2669)
This commit is contained in:
@@ -71,6 +71,8 @@ public abstract class AbstractCodeArea extends RSyntaxTextArea {
|
||||
if (tokenMakerFactory instanceof AbstractTokenMakerFactory) {
|
||||
AbstractTokenMakerFactory atmf = (AbstractTokenMakerFactory) tokenMakerFactory;
|
||||
atmf.putMapping(SYNTAX_STYLE_SMALI, "jadx.gui.ui.codearea.SmaliTokenMaker");
|
||||
// use simple token maker instead default PlainTextTokenMaker to avoid parse errors
|
||||
atmf.putMapping(SYNTAX_STYLE_NONE, "jadx.gui.ui.codearea.SimpleTokenMaker");
|
||||
} else {
|
||||
throw new JadxRuntimeException("Unexpected TokenMakerFactory instance: " + tokenMakerFactory.getClass());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package jadx.gui.ui.codearea;
|
||||
|
||||
import javax.swing.text.Segment;
|
||||
|
||||
import org.fife.ui.rsyntaxtextarea.Token;
|
||||
import org.fife.ui.rsyntaxtextarea.TokenImpl;
|
||||
import org.fife.ui.rsyntaxtextarea.TokenMakerBase;
|
||||
import org.fife.ui.rsyntaxtextarea.TokenTypes;
|
||||
|
||||
/**
|
||||
* Very simple token maker to use only one token per line without any parsing
|
||||
*/
|
||||
@SuppressWarnings("unused") // class registered by name in {@link AbstractCodeArea}
|
||||
public class SimpleTokenMaker extends TokenMakerBase {
|
||||
private final TokenImpl token;
|
||||
|
||||
public SimpleTokenMaker() {
|
||||
token = new TokenImpl();
|
||||
token.setType(TokenTypes.IDENTIFIER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Token getTokenList(Segment segment, int initialTokenType, int startOffset) {
|
||||
token.text = segment.array;
|
||||
token.textOffset = startOffset;
|
||||
token.textCount = segment.count;
|
||||
token.setOffset(startOffset);
|
||||
return token;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user