Skip to content

Commit

Permalink
Avoid accessing TokenType constants via Token instances
Browse files Browse the repository at this point in the history
Signed-off-by: Johannes Schindelin <[email protected]>
  • Loading branch information
dscho committed Jun 25, 2014
1 parent aa3f8e0 commit fd36ee1
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/main/java/net/imagej/ui/swing/script/TokenFunctions.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

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

/**
* TODO
Expand All @@ -57,7 +58,7 @@ public TokenFunctions(RSyntaxTextArea textArea) {
}

public static boolean tokenEquals(Token token, char[] text) {
if (token.getType() != token.RESERVED_WORD ||
if (token.getType() != TokenTypes.RESERVED_WORD ||
token.length() != text.length)
return false;
final char[] tokenText = token.getTextArray();
Expand All @@ -70,7 +71,7 @@ public static boolean tokenEquals(Token token, char[] text) {
}

public static boolean isIdentifier(Token token) {
if (token.getType() != token.IDENTIFIER)
if (token.getType() != TokenTypes.IDENTIFIER)
return false;
final char[] tokenText = token.getTextArray();
final int textOffset = token.getTextOffset();
Expand Down Expand Up @@ -135,7 +136,7 @@ public Iterator<Token> iterator() {
}

public static boolean isDot(Token token) {
if (token.getType() != token.IDENTIFIER) return false;
if (token.getType() != TokenTypes.IDENTIFIER) return false;
final char[] tokenText = token.getTextArray();
return tokenText != null && token.length() == 1 && tokenText[token.getTextOffset()] == '.';
}
Expand Down Expand Up @@ -216,7 +217,7 @@ Token skipNonCode(TokenIterator iter, Token current) {
int skipToEOL(TokenIterator iter, Token current) {
int end = textArea.getDocument().getLength();
for (;;) {
if (current.getType() == current.NULL || !iter.hasNext())
if (current.getType() == TokenTypes.NULL || !iter.hasNext())
return end;
end = current.getEndOffset();
current = iter.next();
Expand Down Expand Up @@ -308,7 +309,7 @@ public void addImport(String className) {
boolean insertLF = false;
while (iter.hasNext()) {
Token token = iter.next();
if (token.getType() != token.RESERVED_WORD) {
if (token.getType() != TokenTypes.RESERVED_WORD) {
insertLF = false;
continue;
}
Expand Down

0 comments on commit fd36ee1

Please sign in to comment.