org.fife.ui.rsyntaxtextarea.folding.XmlFoldParser 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.
/* * 10/23/2011 * * XmlFoldParser.java - Fold parser for XML. * * 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 javax.swing.text.BadLocationException; import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea; import org.fife.ui.rsyntaxtextarea.Token; /** * Fold parser for XML. Any tags that span more than one line, as well as * comment regions spanning more than one line, are identified as foldable * regions. * * @author Robert Futrell * @version 1.0 */ public class XmlFoldParser implements FoldParser { private static final char[] MARKUP_CLOSING_TAG_START = { '<', '/' }; private static final char[] MARKUP_SHORT_TAG_END = { '/', '>' }; private static final char[] MLC_END = { '-', '-', '>' }; @Override public List
list, and is removed from that. * * @param fold The fold to remove. * @param folds The list of top-level folds. */ private static void removeFold(Fold fold, ListgetFolds(RSyntaxTextArea textArea) { List folds = new ArrayList<>(); Fold currentFold = null; int lineCount = textArea.getLineCount(); boolean inMLC = false; int mlcStart = 0; try { for (int line=0; line folds folds) { if (!fold.removeFromParent()) { folds.remove(folds.size()-1); } } }