Added code folding and formatted all files

This commit is contained in:
SuspiciousActivity committed 2018-07-08 14:39:06 +02:00
1 parent 11570d6b95
commit 66cd1dbd3e
233 files changed
+82245 -118134

No files matched your search

@@ -1,10 +1,8 @@
/*
* 03/09/2013
*
* DefaultOccurrenceMarker - Marks occurrences of the current token for most
* languages.
*
* This library is distributed under a modified BSD license. See the included
* This library is distributed under a modified BSD license. See the included
* RSyntaxTextArea.License.txt file for details.
*/
package org.fife.ui.rsyntaxtextarea;
@@ -14,48 +12,40 @@ import javax.swing.text.Caret;
import org.fife.ui.rtextarea.SmartHighlightPainter;
/**
* The default implementation of {@link OccurrenceMarker}. It goes through
* The default implementation of {@link OccurrenceMarker}. It goes through
* the document and marks all instances of the specified token.
*
* @author Robert Futrell
* @version 1.0
*/
class DefaultOccurrenceMarker implements OccurrenceMarker {
/**
* {@inheritDoc}
*/
@Override
public Token getTokenToMark(RSyntaxTextArea textArea) {
// Get the token at the caret position.
int line = textArea.getCaretLineNumber();
Token tokenList = textArea.getTokenListForLine(line);
Caret c = textArea.getCaret();
int dot = c.getDot();
Token t = RSyntaxUtilities.getTokenAtOffset(tokenList, dot);
if (t==null /* EOL */ || !isValidType(textArea, t) ||
RSyntaxUtilities.isNonWordChar(t)) {
if (t == null /* EOL */ || !isValidType(textArea, t) || RSyntaxUtilities.isNonWordChar(t)) {
// Try to the "left" of the caret.
dot--;
try {
if (dot>=textArea.getLineStartOffset(line)) {
if (dot >= textArea.getLineStartOffset(line)) {
t = RSyntaxUtilities.getTokenAtOffset(tokenList, dot);
}
} catch (BadLocationException ble) {
ble.printStackTrace(); // Never happens
}
}
return t;
}
/**
* {@inheritDoc}
*/
@@ -63,41 +53,39 @@ class DefaultOccurrenceMarker implements OccurrenceMarker {
public boolean isValidType(RSyntaxTextArea textArea, Token t) {
return textArea.getMarkOccurrencesOfTokenType(t.getType());
}
/**
* {@inheritDoc}
*/
@Override
public void markOccurrences(RSyntaxDocument doc, Token t,
RSyntaxTextAreaHighlighter h, SmartHighlightPainter p) {
public void markOccurrences(RSyntaxDocument doc, Token t, RSyntaxTextAreaHighlighter h, SmartHighlightPainter p) {
markOccurrencesOfToken(doc, t, h, p);
}
/**
* Highlights all instances of tokens identical to <code>t</code> in the
* specified document.
*
* @param doc The document.
* @param t The document whose relevant occurrences should be marked.
* @param h The highlighter to add the highlights to.
* @param p The painter for the highlights.
* @param doc
* The document.
* @param t
* The document whose relevant occurrences should be marked.
* @param h
* The highlighter to add the highlights to.
* @param p
* The painter for the highlights.
*/
public static final void markOccurrencesOfToken(RSyntaxDocument doc,
Token t, RSyntaxTextAreaHighlighter h, SmartHighlightPainter p) {
public static final void markOccurrencesOfToken(RSyntaxDocument doc, Token t, RSyntaxTextAreaHighlighter h, SmartHighlightPainter p) {
char[] lexeme = t.getLexeme().toCharArray();
int type = t.getType();
int lineCount = doc.getDefaultRootElement().getElementCount();
for (int i=0; i<lineCount; i++) {
for (int i = 0; i < lineCount; i++) {
Token temp = doc.getTokenListForLine(i);
while (temp!=null && temp.isPaintable()) {
while (temp != null && temp.isPaintable()) {
if (temp.is(type, lexeme)) {
try {
int end = temp.getEndOffset();
h.addMarkedOccurrenceHighlight(temp.getOffset(),end,p);
h.addMarkedOccurrenceHighlight(temp.getOffset(), end, p);
} catch (BadLocationException ble) {
ble.printStackTrace(); // Never happens
}
@@ -105,8 +93,5 @@ class DefaultOccurrenceMarker implements OccurrenceMarker {
temp = temp.getNextToken();
}
}
}
}
}