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

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

Go to download

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.

There is a newer version: 3.5.1
Show 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 boolean foundEndKeyword(char[] keyword, Token t, Stack endWordStack) { return t.is(Token.RESERVED_WORD, keyword) && !endWordStack.isEmpty() && keyword==endWordStack.peek(); } /** * {@inheritDoc} */ @Override 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