@@ -19,7 +19,11 @@ use super::{
19
19
} ;
20
20
use crate :: {
21
21
ast:: Project ,
22
- translation_unit:: TranslationUnit ,
22
+ standard_library:: StandardLibrary ,
23
+ translation_unit:: {
24
+ Owner ,
25
+ TranslationUnit ,
26
+ } ,
23
27
} ;
24
28
25
29
pub struct SpriteDiagnostics {
@@ -29,11 +33,11 @@ pub struct SpriteDiagnostics {
29
33
}
30
34
31
35
impl SpriteDiagnostics {
32
- pub fn new ( path : PathBuf ) -> Self {
36
+ pub fn new ( path : PathBuf , stdlib : & StandardLibrary ) -> Self {
33
37
let sprite_name = path. file_stem ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) . to_string ( ) ;
34
38
let mut translation_unit = TranslationUnit :: new ( path) ;
35
39
let mut diagnostics = vec ! [ ] ;
36
- if let Err ( diagnostic) = translation_unit. pre_process ( ) {
40
+ if let Err ( diagnostic) = translation_unit. pre_process ( stdlib ) {
37
41
diagnostics. extend ( diagnostic) ;
38
42
}
39
43
Self {
@@ -63,13 +67,12 @@ impl SpriteDiagnostics {
63
67
let ( start, include) = self
64
68
. translation_unit
65
69
. translate_position ( diagnostic. span . start ) ;
66
- // Do not display diagnostics for standard library headers.
67
- let Some ( include_path) = & include. path else {
70
+ if !matches ! ( include. owner, Owner :: Local ) {
68
71
continue ;
69
- } ;
72
+ }
70
73
// TODO: memoize this using a memoization crate.
71
- let text = fs:: read_to_string ( include_path ) . unwrap ( ) ;
72
- let include_path = include_path . to_str ( ) . unwrap ( ) ;
74
+ let text = fs:: read_to_string ( & include . path ) . unwrap ( ) ;
75
+ let include_path = include . path . to_str ( ) . unwrap ( ) ;
73
76
if diagnostic. span . start == 0 && diagnostic. span . end == 0 {
74
77
let mut message = level
75
78
. title ( & title)
0 commit comments