@@ -58,65 +58,54 @@ fn parse_compiler_diagnostic(msg string) ?inspections.Report {
5858}
5959
6060fn exec_compiler_diagnostics (compiler_path string , uri lsp.DocumentUri) ? []inspections.Report {
61- mut reports := []inspections.Report{}
62-
6361 dir_path := uri.dir_path ()
6462 filepath := uri.path ()
6563 is_module := ! filepath.ends_with ('.vv' )
6664 input_path := if is_module { dir_path } else { filepath }
6765
68- mut p := os.new_process (compiler_path)
69- p.set_args (['-enable-globals' , '-shared' , '-check' , input_path])
70- p.set_redirect_stdio ()
66+ res := os.execute ('${compiler_path} -enable-globals -shared -check ${input_path} ' )
7167
72- defer {
73- p.wait ()
74- p.close ()
75- }
76- p.run ()
77- if p.code == 0 {
68+ if res.exit_code == 0 {
7869 return none
7970 }
8071
81- output_lines := p. stderr_slurp () .split_into_lines ().map (term.strip_ansi (it ))
72+ output_lines := res.output .split_into_lines ().map (term.strip_ansi (it ))
8273 errors := split_lines_to_errors (output_lines)
8374
75+ mut reports := []inspections.Report{}
76+
8477 for error in errors {
85- mut report := parse_compiler_diagnostic (error) or { continue }
78+ report := parse_compiler_diagnostic (error) or { continue }
79+
80+ // ignore this error
81+ if report.message.contains ('unexpected eof' ) {
82+ continue
83+ }
84+
8685 file_dir_path := os.dir (report.filepath)
8786
88- if os.is_abs_path (file_dir_path) {
87+ report_filepath := if os.is_abs_path (file_dir_path) {
8988 // do nothing
89+ report.filepath
9090 } else if file_dir_path == '..' {
91- report = inspections.Report{
92- ...report
93- filepath: os.join_path_single (dir_path, report.filepath)
94- }
91+ os.join_path_single (dir_path, report.filepath)
9592 } else if start_idx := dir_path.last_index (file_dir_path) {
9693 // reported file appears to be in a subdirectory of dir_path
97- report = inspections.Report{
98- ...report
99- filepath: dir_path[..start_idx] + report.filepath
100- }
94+ dir_path[..start_idx] + report.filepath
10195 } else {
10296 // reported file appears to be in a parent directory of dir_path
103- report = inspections.Report{
104- ...report
105- filepath: os.join_path_single (dir_path, report.filepath)
106- }
97+ os.join_path_single (dir_path, report.filepath)
10798 }
10899
109- if report.message. contains ( 'unexpected eof' ) {
110- // ignore this error
100+ // ignore errors in other files
101+ if report_filepath != uri. path () {
111102 continue
112103 }
113104
114- if report.filepath != uri. path () {
115- // ignore errors in other files
116- continue
105+ reports << inspections.Report {
106+ ...report
107+ filepath: report_filepath
117108 }
118-
119- reports << report
120109 }
121110 return reports
122111}
0 commit comments