@@ -611,7 +611,8 @@ impl<'a, 'b> InternalDelphiLogicalLineParser<'a, 'b> {
611611 |parser| {
612612 parser. parse_structures ( ) ;
613613 parser. finish_logical_line ( ) ;
614- parser. take_individual_comments ( ) ;
614+ // Comments after the `if` content are seen to be referring to the `else`
615+ parser. take_individual_comments ( Some ( LLT :: ParentLineChildComment ) ) ;
615616 } ,
616617 ) ;
617618
@@ -809,7 +810,7 @@ impl<'a, 'b> InternalDelphiLogicalLineParser<'a, 'b> {
809810 self . current_line . pop ( ) ;
810811 }
811812
812- fn take_individual_comments ( & mut self ) {
813+ fn take_individual_comments ( & mut self , line_type : Option < LogicalLineType > ) {
813814 trace ! ( "Take individual comments" ) ;
814815 while let Some ( TT :: Comment (
815816 CommentKind :: IndividualBlock
@@ -819,7 +820,9 @@ impl<'a, 'b> InternalDelphiLogicalLineParser<'a, 'b> {
819820 {
820821 trace ! ( "Taking individual comment line" ) ;
821822 self . next_token ( ) ;
822- self . set_logical_line_type ( LLT :: TrailingChildComment ) ;
823+ if let Some ( line_type) = line_type {
824+ self . set_logical_line_type ( line_type) ;
825+ }
823826 self . finish_logical_line ( ) ;
824827 }
825828 }
@@ -1230,7 +1233,7 @@ impl<'a, 'b> InternalDelphiLogicalLineParser<'a, 'b> {
12301233 }
12311234 }
12321235
1233- self . take_individual_comments ( ) ;
1236+ self . take_individual_comments ( None ) ;
12341237 }
12351238 fn parse_block ( & mut self , context : ParserContext ) {
12361239 self . do_with_context ( context, |parser| {
@@ -1718,7 +1721,7 @@ impl<'a, 'b> InternalDelphiLogicalLineParser<'a, 'b> {
17181721 self . next_token ( ) ; // Begin
17191722 self . parse_statement_list_block ( ParserContext {
17201723 context_type : ContextType :: StatementBlock ( BlockKind :: Begin ) ,
1721- context_ending_predicate : CEP :: Opaque ( end ) ,
1724+ context_ending_predicate : CEP :: Opaque ( statement_list_end ) ,
17221725 level : context_level,
17231726 } ) ;
17241727 self . next_token ( ) ; // End
0 commit comments