From bd58840220226759dc5836f3d4f814050db5fdb7 Mon Sep 17 00:00:00 2001 From: epriestley Date: Fri, 5 Oct 2018 10:49:23 -0700 Subject: [PATCH] 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 --- src/lexer/PhutilJavaFragmentLexer.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lexer/PhutilJavaFragmentLexer.php b/src/lexer/PhutilJavaFragmentLexer.php index bec9a6d1..aff850cc 100644 --- a/src/lexer/PhutilJavaFragmentLexer.php +++ b/src/lexer/PhutilJavaFragmentLexer.php @@ -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'),