File tree Expand file tree Collapse file tree 2 files changed +26
-3
lines changed
test/library-tests/dataflow/api-graphs Expand file tree Collapse file tree 2 files changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -177,7 +177,7 @@ module API {
177
177
/**
178
178
* Gets a path of the given `length` from the root to this node.
179
179
*/
180
- string getAPath ( int length ) {
180
+ private string getAPath ( int length ) {
181
181
this instanceof Impl:: MkRoot and
182
182
length = 0 and
183
183
result = ""
@@ -191,7 +191,8 @@ module API {
191
191
// avoid producing strings longer than 1MB
192
192
result .length ( ) < 1000 * 1000
193
193
)
194
- )
194
+ ) and
195
+ length in [ 1 .. Impl:: distanceFromRoot ( this ) ]
195
196
}
196
197
197
198
/** Gets the shortest distance from the root to this node in the API graph. */
Original file line number Diff line number Diff line change @@ -37,9 +37,31 @@ class ApiUseTest extends InlineExpectationsTest {
37
37
exists ( API:: Node a , DataFlow:: Node n | relevantNode ( a , n , location ) |
38
38
tag = "use" and
39
39
element = n .toString ( ) and
40
- value = a . getAPath ( _)
40
+ value = getAPath ( a , _)
41
41
)
42
42
}
43
43
}
44
44
45
45
private int size ( AstNode n ) { not n instanceof StmtSequence and result = count ( n .getAChild * ( ) ) }
46
+
47
+ /**
48
+ * Gets a path of the given `length` from the root to the given node.
49
+ * This is a copy of `API::getAPath()` without the restriction on path length,
50
+ * which would otherwise rule out paths involving `getASubclass()`.
51
+ */
52
+ string getAPath ( API:: Node node , int length ) {
53
+ node instanceof API:: Root and
54
+ length = 0 and
55
+ result = ""
56
+ or
57
+ exists ( API:: Node pred , string lbl , string predpath |
58
+ pred .getASuccessor ( lbl ) = node and
59
+ lbl != "" and
60
+ predpath = getAPath ( pred , length - 1 ) and
61
+ exists ( string dot | if length = 1 then dot = "" else dot = "." |
62
+ result = predpath + dot + lbl and
63
+ // avoid producing strings longer than 1MB
64
+ result .length ( ) < 1000 * 1000
65
+ )
66
+ )
67
+ }
You can’t perform that action at this time.
0 commit comments