org.fife.ui.rsyntaxtextarea.folding.XmlFoldParser Maven / Gradle / Ivy
The newest version!
/* * 10/23/2011 * * XmlFoldParser.java - Fold parser for XML. * * This library is distributed under a modified BSD license. See the included * RSyntaxTextArea.License.txt 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 = { '-', '-', '>' }; /** * {@inheritDoc} */ public List
list, and is removed from that. * * @param fold The fold to remove. * @param folds The list of top-level folds. */ private static final 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); } } }