From 6d42503acf11f2fc378930c9400379fa46f7eacd Mon Sep 17 00:00:00 2001 From: Matthew Brown Date: Thu, 27 Oct 2022 16:38:33 -0400 Subject: [PATCH 1/4] Parse non-fixme /* comments not preceded by newlines --- hphp/hack/src/parser/core/lexer.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hphp/hack/src/parser/core/lexer.rs b/hphp/hack/src/parser/core/lexer.rs index a3a24d5845157e..d1c829ce6b9518 100644 --- a/hphp/hack/src/parser/core/lexer.rs +++ b/hphp/hack/src/parser/core/lexer.rs @@ -1979,7 +1979,7 @@ where acc.push(t); return acc; } - TriviaKind::FixMe | TriviaKind::IgnoreError => { + TriviaKind::FixMe | TriviaKind::IgnoreError | TriviaKind::DelimitedComment => { return acc; } _ => { From c069eda12708b46bcd98dccc44e3d9bf0fc5aac8 Mon Sep 17 00:00:00 2001 From: Matthew Brown Date: Thu, 27 Oct 2022 20:43:59 -0400 Subject: [PATCH 2/4] Multiline comment now belongs to following node --- .../slow/parser/extension/shape_type_alias.php.expectf | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hphp/test/slow/parser/extension/shape_type_alias.php.expectf b/hphp/test/slow/parser/extension/shape_type_alias.php.expectf index 2f437ba4ca6ac9..eafa146a277310 100644 --- a/hphp/test/slow/parser/extension/shape_type_alias.php.expectf +++ b/hphp/test/slow/parser/extension/shape_type_alias.php.expectf @@ -12,16 +12,16 @@ dict(6) { string(20) "// Float description" } ["some_string"]=> - vec(4) { + vec(3) { string(11) "// Multiple" string(2) "//" string(13) "// paragraphs" - string(26) "/* - - Another paragraph.*/" } ["some_bool"]=> vec(11) { + string(26) "/* + + Another paragraph.*/" string(7) "// Long" string(17) "/* long */" string(13) "//description" From 0ad6129a6157fdecb455f6483529064b146a9c33 Mon Sep 17 00:00:00 2001 From: Matthew Brown Date: Thu, 27 Oct 2022 21:45:07 -0400 Subject: [PATCH 3/4] Fix vec size --- hphp/test/slow/parser/extension/shape_type_alias.php.expectf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hphp/test/slow/parser/extension/shape_type_alias.php.expectf b/hphp/test/slow/parser/extension/shape_type_alias.php.expectf index eafa146a277310..7a5f32007c90a0 100644 --- a/hphp/test/slow/parser/extension/shape_type_alias.php.expectf +++ b/hphp/test/slow/parser/extension/shape_type_alias.php.expectf @@ -18,7 +18,7 @@ dict(6) { string(13) "// paragraphs" } ["some_bool"]=> - vec(11) { + vec(12) { string(26) "/* Another paragraph.*/" From 3cb257f1f55639e8161184b514412bea32bff93d Mon Sep 17 00:00:00 2001 From: Matt Brown Date: Mon, 27 Feb 2023 16:29:07 -0500 Subject: [PATCH 4/4] Fix test expectations --- .../test_multi_line_comment.php.json.exp | 18 +++++++-------- .../collection_literal_trailing_comma.php.exp | 22 ++++++++++++++----- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/hphp/hack/test/full_fidelity/cases/modes/test_multi_line_comment.php.json.exp b/hphp/hack/test/full_fidelity/cases/modes/test_multi_line_comment.php.json.exp index 013c1290be6dfc..0d44a9a61051e9 100644 --- a/hphp/hack/test/full_fidelity/cases/modes/test_multi_line_comment.php.json.exp +++ b/hphp/hack/test/full_fidelity/cases/modes/test_multi_line_comment.php.json.exp @@ -5,6 +5,7 @@ "elements":[ { "kind":"markup_section", + "markup_hashbang":{"kind":"missing"}, "markup_suffix":{ "kind":"markup_suffix", "markup_suffix_less_than_question":{ @@ -29,13 +30,9 @@ "offset":2, "leading_width":0, "width":2, - "trailing_width":20, + "trailing_width":1, "leading":[], - "trailing":[ - {"kind":"whitespace","text":" ","offset":4,"width":1}, - {"kind":"delimited_comment","text":"/* stric strict */","offset":5,"width":18}, - {"kind":"end_of_line","text":"\n","offset":23,"width":1} - ], + "trailing":[{"kind":"whitespace","text":" ","offset":4,"width":1}], "line_number":1 } } @@ -48,11 +45,14 @@ "token":{ "kind":"end_of_file", "text":"", - "offset":24, - "leading_width":0, + "offset":5, + "leading_width":19, "width":0, "trailing_width":0, - "leading":[], + "leading":[ + {"kind":"delimited_comment","text":"/* stric strict */","offset":5,"width":18}, + {"kind":"end_of_line","text":"\n","offset":23,"width":1} + ], "trailing":[], "line_number":2 } diff --git a/hphp/hack/test/hackfmt/tests/collection_literal_trailing_comma.php.exp b/hphp/hack/test/hackfmt/tests/collection_literal_trailing_comma.php.exp index 8fbd81f36e603a..9863fbc3e01c05 100644 --- a/hphp/hack/test/hackfmt/tests/collection_literal_trailing_comma.php.exp +++ b/hphp/hack/test/hackfmt/tests/collection_literal_trailing_comma.php.exp @@ -29,8 +29,14 @@ $vec = Vector { $baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar, }; -$vec = Vector {$foo /* foo */}; -$vec = Vector {$foo /* foo */}; +$vec = Vector { + $foo, + /* foo */ +}; +$vec = Vector { + $foo, + /* foo */ +}; $vec = Vector { $foo, // foo @@ -43,10 +49,14 @@ $vec = Vector { , }; -$vec = - Vector {/* leading comment */ $fooooooooooooooooo /* trailing comment */}; -$vec = - Vector {/* leading comment */ $fooooooooooooooooo /* trailing comment */}; +$vec = Vector { + /* leading comment */ $fooooooooooooooooo, + /* trailing comment */ +}; +$vec = Vector { + /* leading comment */ $fooooooooooooooooo, + /* trailing comment */ +}; $vec = Vector { /* leading comment */