File tree Expand file tree Collapse file tree 8 files changed +45
-9
lines changed Expand file tree Collapse file tree 8 files changed +45
-9
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ category : minorAnalysis
3+ ---
4+ * Added ` ExtractedFile::hasSemantics ` and ` ExtractedFile::isSkippedByCompilation ` predicates.
Original file line number Diff line number Diff line change @@ -71,6 +71,25 @@ class File extends Container, Impl::File {
7171 */
7272class ExtractedFile extends File {
7373 ExtractedFile ( ) { this .fromSource ( ) }
74+
75+ private Diagnostic getNoSemanticsDiagnostic ( ) {
76+ result .getTag ( ) = "semantics" and result .getLocation ( ) .getFile ( ) = this
77+ }
78+
79+ /**
80+ * Holds if we have semantical information about this file, which means
81+ * we should be able to
82+ * * expand any macros
83+ * * skip any blocks that are conditionally compiled out
84+ */
85+ predicate hasSemantics ( ) { not exists ( Diagnostic d | d = this .getNoSemanticsDiagnostic ( ) ) }
86+
87+ /**
88+ * Holds if we know this file was skipped by conditional compilation.
89+ * This is not the same as `not this.hasSemantics()`, as a file
90+ * might not have semantics because of some error.
91+ */
92+ predicate isSkippedByCompilation ( ) { this .getNoSemanticsDiagnostic ( ) .getSeverityText ( ) = "Info" }
7493}
7594
7695/**
Original file line number Diff line number Diff line change 1- | Cargo.toml:0:0:0:0 | Cargo.toml | fromSource: no |
2- | a_file.rs:0:0:0:0 | a_file.rs | fromSource: yes |
3- | another_file.rs:0:0:0:0 | another_file.rs | fromSource: yes |
4- | lib.rs:0:0:0:0 | lib.rs | fromSource: yes |
5- | nested.rs:0:0:0:0 | nested.rs | fromSource: yes |
6- | nested/file.rs:0:0:0:0 | nested/file.rs | fromSource: yes |
1+ | Cargo.toml:0:0:0:0 | Cargo.toml | fromSource: no | hasSemantics: no | isSkippedByCompilation: no |
2+ | a_file.rs:0:0:0:0 | a_file.rs | fromSource: yes | hasSemantics: yes | isSkippedByCompilation: no |
3+ | another_file.rs:0:0:0:0 | another_file.rs | fromSource: yes | hasSemantics: yes | isSkippedByCompilation: no |
4+ | bad_cargo/Cargo.toml:0:0:0:0 | bad_cargo/Cargo.toml | fromSource: no | hasSemantics: no | isSkippedByCompilation: no |
5+ | bad_cargo/src/no_semantics.rs:0:0:0:0 | bad_cargo/src/no_semantics.rs | fromSource: yes | hasSemantics: no | isSkippedByCompilation: no |
6+ | lib.rs:0:0:0:0 | lib.rs | fromSource: yes | hasSemantics: yes | isSkippedByCompilation: no |
7+ | nested.rs:0:0:0:0 | nested.rs | fromSource: yes | hasSemantics: yes | isSkippedByCompilation: no |
8+ | nested/file.rs:0:0:0:0 | nested/file.rs | fromSource: yes | hasSemantics: yes | isSkippedByCompilation: no |
9+ | nested/not_compiled.rs:0:0:0:0 | nested/not_compiled.rs | fromSource: yes | hasSemantics: no | isSkippedByCompilation: yes |
Original file line number Diff line number Diff line change 11import rust
22
3- from File f , string fromSource
3+ from File f , string fromSource , string hasSemantics , string isSkippedByCompilation
44where
55 exists ( f .getRelativePath ( ) ) and
6- if f .fromSource ( ) then fromSource = "fromSource: yes" else fromSource = "fromSource: no"
7- select f , fromSource
6+ ( if f .fromSource ( ) then fromSource = "fromSource: yes" else fromSource = "fromSource: no" ) and
7+ (
8+ if f .( ExtractedFile ) .hasSemantics ( )
9+ then hasSemantics = "hasSemantics: yes"
10+ else hasSemantics = "hasSemantics: no"
11+ ) and
12+ if f .( ExtractedFile ) .isSkippedByCompilation ( )
13+ then isSkippedByCompilation = "isSkippedByCompilation: yes"
14+ else isSkippedByCompilation = "isSkippedByCompilation: no"
15+ select f , fromSource , hasSemantics , isSkippedByCompilation
Original file line number Diff line number Diff line change 1+ ! /Cargo.toml
Original file line number Diff line number Diff line change 1+ wrong
You can’t perform that action at this time.
0 commit comments