1
1
/**
2
2
* @name Missing Elements
3
- * @description List all elements in the source code directory that weren't extracted due to unimplemented features or parse errors.
3
+ * @description List all elements that weren't extracted due to unimplemented features or parse errors.
4
4
* @id rust/diagnostics/missing-elements
5
5
*/
6
6
@@ -16,6 +16,16 @@ Location getUnimplementedLocation(Unimplemented node) {
16
16
result instanceof EmptyLocation
17
17
}
18
18
19
+ /**
20
+ * Gets `l.toString()`, but with any locations outside of the source location prefix cleaned up.
21
+ */
22
+ bindingset [ l]
23
+ string cleanLocationString ( Location l ) {
24
+ if exists ( l .getFile ( ) .getRelativePath ( ) ) or l instanceof EmptyLocation
25
+ then result = l .toString ( )
26
+ else l .getFile ( ) .getParentContainer ( ) .getAbsolutePath ( ) + result = l .toString ( ) // remove the directory from the string
27
+ }
28
+
19
29
/**
20
30
* Gets a string along the lines of " (x2)", corresponding to the number `i`. For `i = 1`, the result is the empty string.
21
31
*/
@@ -29,33 +39,23 @@ string multipleString(int i) {
29
39
query predicate listUnimplemented ( string location , string msg ) {
30
40
// something that is not extracted yet
31
41
exists ( int c |
32
- c =
33
- strictcount ( Unimplemented n |
34
- exists ( getUnimplementedLocation ( n ) .getFile ( ) .getRelativePath ( ) ) and
35
- getUnimplementedLocation ( n ) .toString ( ) = location
36
- ) and
42
+ c = strictcount ( Unimplemented n | cleanLocationString ( getUnimplementedLocation ( n ) ) = location ) and
37
43
msg = "Not yet implemented" + multipleString ( c ) + "."
38
44
)
39
45
}
40
46
41
47
query predicate listMissingExpr ( string location , string msg ) {
42
48
// gaps in the AST due to parse errors
43
49
exists ( int c |
44
- c =
45
- strictcount ( MissingExpr e |
46
- exists ( e .getFile ( ) .getRelativePath ( ) ) and e .getLocation ( ) .toString ( ) = location
47
- ) and
50
+ c = strictcount ( MissingExpr e | cleanLocationString ( e .getLocation ( ) ) = location ) and
48
51
msg = "Missing expression" + multipleString ( c ) + "."
49
52
)
50
53
}
51
54
52
55
query predicate listMissingPat ( string location , string msg ) {
53
56
// gaps in the AST due to parse errors
54
57
exists ( int c |
55
- c =
56
- strictcount ( MissingPat p |
57
- exists ( p .getFile ( ) .getRelativePath ( ) ) and p .getLocation ( ) .toString ( ) = location
58
- ) and
58
+ c = strictcount ( MissingPat p | cleanLocationString ( p .getLocation ( ) ) = location ) and
59
59
msg = "Missing pattern" + multipleString ( c ) + "."
60
60
)
61
61
}
0 commit comments