Java Lexer: Name vs. Type

Create issue
Issue #1523 new
Andriy Miranskyy created an issue

This may be an RTFM issue, but I wonder if it is a bug or a feature. Consider this Java code snippet:

String hw = "Hello, World";

I would expect that the String word would be recognized as Type. Instead, it is recognized as Name.

Here is a code snippet for the repro:

from pygments import highlight
from pygments.formatters import RawTokenFormatter
from pygments.lexers.jvm import JavaLexer
src = 'String hw = "Hello, World";'
parsed_data = highlight(src, JavaLexer(), RawTokenFormatter())


Token.Name  'String'
Token.Text  ' '
Token.Name  'hw'
Token.Text  ' '
Token.Operator  '='
Token.Text  ' '
Token.Literal.String    '"Hello, World"'
Token.Operator  ';'
Token.Text  '\n'

Comments (0)

  1. Log in to comment