All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.fife.ui.rsyntaxtextarea.folding.NsisFoldParser Maven / Gradle / Ivy

The newest version!
/*
 * 10/07/2012
 *
 * NsisFoldParser.java - Fold parser for NSIS.
 * 
 * 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 java.util.Stack;
import javax.swing.text.BadLocationException;

import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
import org.fife.ui.rsyntaxtextarea.Token;


/**
 * A fold parser NSIS.

* * Note that this class may impose somewhat of a performance penalty on large * source files, since it re-parses the entire document each time folds are * reevaluated. * * @author Robert Futrell * @version 1.0 */ public class NsisFoldParser implements FoldParser { private static final char[] KEYWORD_FUNCTION = "Function".toCharArray(); private static final char[] KEYWORD_FUNCTION_END = "FunctionEnd".toCharArray(); private static final char[] KEYWORD_SECTION = "Section".toCharArray(); private static final char[] KEYWORD_SECTION_END = "SectionEnd".toCharArray(); protected static final char[] C_MLC_END = "*/".toCharArray(); private static final boolean foundEndKeyword(char[] keyword, Token t, Stack endWordStack) { return t.is(Token.RESERVED_WORD, keyword) && !endWordStack.isEmpty() && keyword==endWordStack.peek(); } /** * {@inheritDoc} */ public List getFolds(RSyntaxTextArea textArea) { List folds = new ArrayList(); Fold currentFold = null; int lineCount = textArea.getLineCount(); boolean inMLC = false; int mlcStart = 0; Stack endWordStack = new Stack(); try { for (int line=0; line





© 2015 - 2024 Weber Informatics LLC | Privacy Policy