org.fife.ui.rsyntaxtextarea.folding.JsonFoldParser Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rsyntaxtextarea Show documentation
Show all versions of rsyntaxtextarea Show documentation
RSyntaxTextArea is the syntax highlighting text editor for Swing applications. Features include syntax highlighting for 40+ languages, code folding, code completion, regex find and replace, macros, code templates, undo/redo, line numbering and bracket matching.
/* * 12/23/2012 * * JsonFoldParser.java - Fold parser for JSON. * * This library is distributed under a modified BSD license. See the included * LICENSE file for details. */ package org.fife.ui.rsyntaxtextarea.folding; import java.util.ArrayList; import java.util.List; import java.util.Stack; import javax.swing.text.BadLocationException; import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea; import org.fife.ui.rsyntaxtextarea.Token; import org.fife.ui.rsyntaxtextarea.TokenTypes; /** * The fold parser for JSON. Objects (
. Otherwise, return"{ ... }
") and arrays * ("[ ... ]"
) that span multiple lines are considered fold * regions. * * @author Robert Futrell * @version 1.0 */ public class JsonFoldParser implements FoldParser { private static final Object OBJECT_BLOCK = new Object(); private static final Object ARRAY_BLOCK = new Object(); @Override public ListgetFolds(RSyntaxTextArea textArea) { Stack false
. * * @param stack The stack. * @param value The value to check for. * @return Whether the value was found on top of the stack. */ private static boolean popOffTop(Stack