Commits

Jan Lahoda committed 71e5b40

Lexer should accept multi-letter variables.

Comments (0)

Files changed (2)

file/src/org/netbeans/modules/jackpot30/file/DeclarativeHintLexer.java

         return fact.createToken(DeclarativeHintTokenId.TYPE);
     }
 
-    private static final Pattern VARIABLE_WITH_TYPE_RE = Pattern.compile("\\$[A-Za-z0-9_]\\{");
+    private static final Pattern VARIABLE_WITH_TYPE_RE = Pattern.compile("\\$[A-Za-z0-9_]+\\{");
 
     private static final class State {
         private final int state;

file/test/unit/src/org/netbeans/modules/jackpot30/file/DeclarativeHintLexerTest.java

         assertFalse(ts.moveNext());
     }
 
+    @Test
+    public void testLongVariables() {
+        String text = " $this{int} + $that{int} => 1 + 1;; ";
+        TokenHierarchy<?> hi = TokenHierarchy.create(text, language());
+        TokenSequence<?> ts = hi.tokenSequence();
+        assertNextTokenEquals(ts, PATTERN, PartType.START, " $this");
+        assertNextTokenEquals(ts, TYPE,  "{int}");
+        assertNextTokenEquals(ts, PATTERN, PartType.MIDDLE, " + $that");
+        assertNextTokenEquals(ts, TYPE,  "{int}");
+        assertNextTokenEquals(ts, PATTERN, PartType.END, " ");
+        assertNextTokenEquals(ts, LEADS_TO, "=>");
+        assertNextTokenEquals(ts, PATTERN, " 1 + 1");
+        assertNextTokenEquals(ts, DOUBLE_SEMICOLON, ";;");
+        assertNextTokenEquals(ts, WHITESPACE, " ");
+
+        assertFalse(ts.moveNext());
+    }
+
     public static void assertNextTokenEquals(TokenSequence<?> ts, DeclarativeHintTokenId id, String text) {
         assertNextTokenEquals(ts, id, PartType.COMPLETE, text);
     }