@@ -602,11 +602,10 @@ impl Runtime {
602602 fn fix_to_fix_with_position < ' a > (
603603 fix : & Fix < ' a > ,
604604 rope : & Rope ,
605- offset : u32 ,
606605 source_text : & str ,
607606 ) -> FixWithPosition < ' a > {
608- let start_position = offset_to_position ( rope, offset + fix. span . start , source_text) ;
609- let end_position = offset_to_position ( rope, offset + fix. span . end , source_text) ;
607+ let start_position = offset_to_position ( rope, fix. span . start , source_text) ;
608+ let end_position = offset_to_position ( rope, fix. span . end , source_text) ;
610609 FixWithPosition {
611610 content : fix. content . clone ( ) ,
612611 span : SpanPositionMessage :: new ( start_position, end_position)
@@ -629,99 +628,93 @@ impl Runtime {
629628 . into_iter ( )
630629 . zip ( section_contents. drain ( ..) )
631630 {
632- match record_result {
631+ let mut section_messages = match record_result {
633632 Err ( diagnostics) => {
634- messages. lock ( ) . unwrap ( ) . extend (
635- diagnostics. into_iter ( ) . map ( std:: convert:: Into :: into) ,
636- ) ;
633+ messages
634+ . lock ( )
635+ . unwrap ( )
636+ . extend ( diagnostics. into_iter ( ) . map ( Into :: into) ) ;
637+ continue ;
637638 }
638- Ok ( module_record) => {
639- let section_message = me. linter . run (
640- Path :: new ( & module. path ) ,
641- Rc :: new ( section. semantic . unwrap ( ) ) ,
642- Arc :: clone ( & module_record) ,
643- allocator_guard,
644- ) ;
645-
646- messages. lock ( ) . unwrap ( ) . extend ( section_message. iter ( ) . map (
647- |message| {
648- let message = message. clone_in ( allocator) ;
649-
650- let labels =
651- & message. error . labels . clone ( ) . map ( |labels| {
652- labels
653- . into_iter ( )
654- . map ( |labeled_span| {
655- let offset =
656- labeled_span. offset ( ) as u32 ;
657- let start_position = offset_to_position (
658- rope,
659- offset + section. source . start ,
660- source_text,
661- ) ;
662- let end_position = offset_to_position (
663- rope,
664- offset
665- + section. source . start
666- + labeled_span. len ( ) as u32 ,
667- source_text,
668- ) ;
669- let message =
670- labeled_span. label ( ) . map ( |label| {
671- Cow :: Owned ( label. to_string ( ) )
672- } ) ;
673-
674- SpanPositionMessage :: new (
675- start_position,
676- end_position,
677- )
678- . with_message ( message)
679- } )
680- . collect :: < Vec < _ > > ( )
681- } ) ;
682-
683- MessageWithPosition {
684- message : message. error . message . clone ( ) ,
685- severity : message. error . severity ,
686- help : message. error . help . clone ( ) ,
687- url : message. error . url . clone ( ) ,
688- code : message. error . code . clone ( ) ,
689- labels : labels. clone ( ) ,
690- fixes : match & message. fixes {
691- PossibleFixes :: None => {
692- PossibleFixesWithPosition :: None
693- }
694- PossibleFixes :: Single ( fix) => {
695- PossibleFixesWithPosition :: Single (
639+ Ok ( module_record) => me. linter . run (
640+ Path :: new ( & module. path ) ,
641+ Rc :: new ( section. semantic . unwrap ( ) ) ,
642+ Arc :: clone ( & module_record) ,
643+ allocator_guard,
644+ ) ,
645+ } ;
646+ // adjust offset for multiple source text in a single file
647+ if section. source . start != 0 {
648+ for message in & mut section_messages {
649+ message. move_offset ( section. source . start ) ;
650+ }
651+ }
652+
653+ messages. lock ( ) . unwrap ( ) . extend ( section_messages. iter ( ) . map (
654+ |message| {
655+ let message = message. clone_in ( allocator) ;
656+
657+ let labels = & message. error . labels . clone ( ) . map ( |labels| {
658+ labels
659+ . into_iter ( )
660+ . map ( |labeled_span| {
661+ let offset = labeled_span. offset ( ) as u32 ;
662+ let start_position =
663+ offset_to_position ( rope, offset, source_text) ;
664+ let end_position = offset_to_position (
665+ rope,
666+ offset + labeled_span. len ( ) as u32 ,
667+ source_text,
668+ ) ;
669+ let message = labeled_span
670+ . label ( )
671+ . map ( |label| Cow :: Owned ( label. to_string ( ) ) ) ;
672+
673+ SpanPositionMessage :: new (
674+ start_position,
675+ end_position,
676+ )
677+ . with_message ( message)
678+ } )
679+ . collect :: < Vec < _ > > ( )
680+ } ) ;
681+
682+ MessageWithPosition {
683+ message : message. error . message . clone ( ) ,
684+ severity : message. error . severity ,
685+ help : message. error . help . clone ( ) ,
686+ url : message. error . url . clone ( ) ,
687+ code : message. error . code . clone ( ) ,
688+ labels : labels. clone ( ) ,
689+ fixes : match & message. fixes {
690+ PossibleFixes :: None => PossibleFixesWithPosition :: None ,
691+ PossibleFixes :: Single ( fix) => {
692+ PossibleFixesWithPosition :: Single (
693+ fix_to_fix_with_position (
694+ fix,
695+ rope,
696+ source_text,
697+ ) ,
698+ )
699+ }
700+ PossibleFixes :: Multiple ( fixes) => {
701+ PossibleFixesWithPosition :: Multiple (
702+ fixes
703+ . iter ( )
704+ . map ( |fix| {
696705 fix_to_fix_with_position (
697706 fix,
698707 rope,
699- section. source . start ,
700708 source_text,
701- ) ,
702- )
703- }
704- PossibleFixes :: Multiple ( fixes) => {
705- PossibleFixesWithPosition :: Multiple (
706- fixes
707- . iter ( )
708- . map ( |fix| {
709- fix_to_fix_with_position (
710- fix,
711- rope,
712- section. source . start ,
713- source_text,
714- )
715- } )
716- . collect ( ) ,
717- )
718- }
719- } ,
709+ )
710+ } )
711+ . collect ( ) ,
712+ )
720713 }
721714 } ,
722- ) ) ;
723- }
724- }
715+ }
716+ } ,
717+ ) ) ;
725718 }
726719 } ,
727720 ) ;
0 commit comments