If a token is of some COMMENT_* type, don't use keywords. Fixes #3532

This commit is contained in:
Federico Fissore 2015-09-17 14:28:03 +02:00
parent 9c850c36e1
commit 94d1829b87
1 changed files with 11 additions and 0 deletions

View File

@ -30,8 +30,12 @@
package processing.app.syntax;
import org.fife.ui.rsyntaxtextarea.TokenTypes;
import org.fife.ui.rsyntaxtextarea.modes.CPlusPlusTokenMaker;
import java.util.Arrays;
import java.util.List;
/**
* Controls the syntax highlighting of {@link SketchTextArea} based on the {@link PdeKeywords}
*
@ -41,6 +45,8 @@ import org.fife.ui.rsyntaxtextarea.modes.CPlusPlusTokenMaker;
*/
public class SketchTokenMaker extends CPlusPlusTokenMaker {
private static final List<Integer> COMMENT_TOKEN_TYPES = Arrays.asList(TokenTypes.COMMENT_DOCUMENTATION, TokenTypes.COMMENT_EOL, TokenTypes.COMMENT_KEYWORD, TokenTypes.COMMENT_MARKUP, TokenTypes.COMMENT_MULTILINE);
private final PdeKeywords pdeKeywords;
public SketchTokenMaker(PdeKeywords pdeKeywords) {
@ -54,6 +60,11 @@ public class SketchTokenMaker extends CPlusPlusTokenMaker {
return;
}
if (COMMENT_TOKEN_TYPES.contains(tokenType)) {
super.addToken(array, start, end, tokenType, startOffset, hyperlink);
return;
}
// This assumes all of your extra tokens would normally be scanned as IDENTIFIER.
int newType = pdeKeywords.getTokenType(array, start, end);
if (newType > -1) {