1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-12-27 16:00:58 +01:00

Fix two issues with the Java syntax highlighter lexer

Summary:
Ref T13202. See PHI886. Two minor issues here:

  - I translated the double quoted string regexp incorrectly; we don't need to include backslash ("\") in the last character class. With it included, we failed to match `"\n"`. We now match `"\n"` as a complete string literal correctly.
  - The class for "t" should be "kt", i.e. "Keyword.Type". For now, this is pretty informal; some day it will presumably be better formalized.

Test Plan:
Got proper highlighting output for this snippet:

{F5919823}

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13202

Differential Revision: https://secure.phabricator.com/D19731
This commit is contained in:
epriestley 2018-10-05 10:49:23 -07:00
parent 79d3692f66
commit bd58840220

View file

@ -77,11 +77,11 @@ final class PhutilJavaFragmentLexer extends PhutilLexer {
array('('.implode('|', $keywords).')\\b', 'k'),
array('@[^\\W\\d][\\w.]*', 'nd'),
array('('.implode('|', $declarations).')\\b', 'k'),
array('('.implode('|', $types).')\\b', 't'),
array('('.implode('|', $types).')\\b', 'kt'),
array('(package|import\\s+static|import)\\b', 'kn', 'import'),
array('('.implode('|', $constants).')\\b', 'kc'),
array('(class|interface)\\b', 'kd', 'class'),
array('"(\\\\\\\\|\\\\"|[^"\\\\]+)*"', 's'),
array('"(\\\\\\\\|\\\\"|[^"]+)*"', 's'),
array("'(\\\\.|[^\\\\]|\\\\u[0-9a-f-A-F]{4})'", 's'),
array('([^\\W\\d]|\\$)[\\w$]*:', 'nl'),
array('([^\\W\\d]|\\$)[\\w$]*', 'n'),