@@ -5,7 +5,7 @@ use mago_codex::metadata::CodebaseMetadata;
55use mago_codex:: ttype:: resolution:: TypeResolutionContext ;
66use mago_collector:: Collector ;
77use mago_database:: file:: File ;
8- use mago_docblock:: document:: Document ;
8+ use mago_docblock:: document:: Element ;
99use mago_names:: ResolvedNames ;
1010use mago_names:: scope:: NamespaceScope ;
1111use mago_reporting:: Annotation ;
@@ -137,46 +137,44 @@ impl<'ctx, 'arena> Context<'ctx, 'arena> {
137137 }
138138 }
139139
140- pub fn get_docblock ( & self ) -> Option < & ' arena Trivia < ' arena > > {
141- comments:: docblock:: get_docblock_before_position (
142- self . source_file ,
143- self . comments ,
144- self . statement_span . start . offset ,
145- )
146- }
147-
148- pub fn get_parsed_docblock ( & mut self ) -> Option < Document < ' arena > > {
149- let trivia = self . get_docblock ( ) ?;
150-
151- match mago_docblock:: parse_trivia ( self . arena , trivia) {
152- Ok ( document) => Some ( document) ,
153- Err ( error) => {
154- let error_span = error. span ( ) ;
140+ pub fn get_parsed_docblocks ( & mut self ) -> Vec < Element < ' arena > > {
141+ let mut elements = vec ! [ ] ;
142+ let mut start = self . statement_span . start . offset ;
143+ while let Some ( trivia) =
144+ comments:: docblock:: get_docblock_before_position ( self . source_file , self . comments , start)
145+ {
146+ match mago_docblock:: parse_trivia ( self . arena , trivia) {
147+ Ok ( document) => elements. extend ( document. elements ) ,
148+ Err ( error) => {
149+ let error_span = error. span ( ) ;
150+
151+ let mut issue = Issue :: error ( error. to_string ( ) )
152+ . with_annotation (
153+ Annotation :: primary ( error_span)
154+ . with_message ( "This part of the docblock has a syntax error" ) ,
155+ )
156+ . with_note ( error. note ( ) ) ;
157+
158+ if trivia. span != error_span {
159+ issue = issue. with_annotation (
160+ Annotation :: secondary ( trivia. span ) . with_message ( "The error is within this docblock" ) ,
161+ ) ;
162+ }
155163
156- let mut issue = Issue :: error ( error. to_string ( ) )
157- . with_annotation (
158- Annotation :: primary ( error_span) . with_message ( "This part of the docblock has a syntax error" ) ,
159- )
160- . with_note ( error. note ( ) ) ;
161-
162- if trivia. span != error_span {
163164 issue = issue. with_annotation (
164- Annotation :: secondary ( trivia. span ) . with_message ( "The error is within this docblock" ) ,
165+ Annotation :: secondary ( self . statement_span )
166+ . with_message ( "This docblock is associated with the following statement" ) ,
165167 ) ;
166- }
167168
168- issue = issue. with_annotation (
169- Annotation :: secondary ( self . statement_span )
170- . with_message ( "This docblock is associated with the following statement" ) ,
171- ) ;
169+ issue = issue. with_help ( error. help ( ) ) ;
172170
173- issue = issue. with_help ( error. help ( ) ) ;
174-
175- self . collector . report_with_code ( IssueCode :: InvalidDocblock , issue) ;
176-
177- None
171+ self . collector . report_with_code ( IssueCode :: InvalidDocblock , issue) ;
172+ }
178173 }
174+ start = trivia. span . start . offset ;
179175 }
176+
177+ elements
180178 }
181179
182180 pub fn record < T > ( & mut self , callback : impl FnOnce ( & mut Context < ' ctx , ' arena > ) -> T ) -> ( T , IssueCollection ) {
0 commit comments