Skip to content

Commit 94d1829

Browse files
author
Federico Fissore
committed
If a token is of some COMMENT_* type, don't use keywords. Fixes #3532
1 parent 9c850c3 commit 94d1829

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

app/src/processing/app/syntax/SketchTokenMaker.java

+11
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,12 @@
3030

3131
package processing.app.syntax;
3232

33+
import org.fife.ui.rsyntaxtextarea.TokenTypes;
3334
import org.fife.ui.rsyntaxtextarea.modes.CPlusPlusTokenMaker;
3435

36+
import java.util.Arrays;
37+
import java.util.List;
38+
3539
/**
3640
* Controls the syntax highlighting of {@link SketchTextArea} based on the {@link PdeKeywords}
3741
*
@@ -41,6 +45,8 @@
4145
*/
4246
public class SketchTokenMaker extends CPlusPlusTokenMaker {
4347

48+
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);
49+
4450
private final PdeKeywords pdeKeywords;
4551

4652
public SketchTokenMaker(PdeKeywords pdeKeywords) {
@@ -54,6 +60,11 @@ public void addToken(char[] array, int start, int end, int tokenType, int startO
5460
return;
5561
}
5662

63+
if (COMMENT_TOKEN_TYPES.contains(tokenType)) {
64+
super.addToken(array, start, end, tokenType, startOffset, hyperlink);
65+
return;
66+
}
67+
5768
// This assumes all of your extra tokens would normally be scanned as IDENTIFIER.
5869
int newType = pdeKeywords.getTokenType(array, start, end);
5970
if (newType > -1) {

0 commit comments

Comments
 (0)