File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,6 @@ use rayon::prelude::*;
12
12
use solar:: interface:: source_map:: FileName ;
13
13
use std:: {
14
14
cmp:: Ordering ,
15
- fmt:: Debug ,
16
15
fs,
17
16
path:: { Path , PathBuf } ,
18
17
} ;
Original file line number Diff line number Diff line change @@ -81,7 +81,25 @@ impl ParseItem {
81
81
///
82
82
/// The parameter should be the full source file where this parse item originated from.
83
83
pub fn with_code ( mut self , source : & str ) -> Self {
84
- self . code = source[ self . source . range ( ) ] . to_string ( ) ;
84
+ let mut code = source[ self . source . range ( ) ] . to_string ( ) ;
85
+
86
+ // Special function case, add `;` at the end of definition.
87
+ if let ParseSource :: Function ( _) = self . source {
88
+ code. push ( ';' ) ;
89
+ }
90
+
91
+ // Remove extra indent from source lines.
92
+ self . code = code
93
+ . lines ( )
94
+ . map ( |line| {
95
+ if line. chars ( ) . take_while ( |c| c. is_whitespace ( ) ) . count ( ) > 4 {
96
+ line. strip_prefix ( " " ) . unwrap_or ( line)
97
+ } else {
98
+ line
99
+ }
100
+ } )
101
+ . collect :: < Vec < _ > > ( )
102
+ . join ( "\n " ) ;
85
103
self
86
104
}
87
105
You can’t perform that action at this time.
0 commit comments