|
| 1 | +class Location extends @location { |
| 2 | + string toString() { none() } |
| 3 | + |
| 4 | + predicate startsAtLine(@file file, int line) { locations_default(this, file, line, _, _, _) } |
| 5 | +} |
| 6 | + |
1 | 7 | class TopLevel extends @toplevel {
|
2 | 8 | string toString() { none() }
|
| 9 | + |
| 10 | + Location getLocation() { hasLocation(this, result) } |
| 11 | + |
| 12 | + pragma[nomagic] |
| 13 | + predicate startsAtLine(@file file, int line) { getLocation().startsAtLine(file, line) } |
3 | 14 | }
|
4 | 15 |
|
5 | 16 | class XmlNode extends @xmllocatable {
|
6 | 17 | string toString() { none() }
|
| 18 | + |
| 19 | + Location getLocation() { xmllocations(this, result) } |
| 20 | + |
| 21 | + pragma[nomagic] |
| 22 | + predicate startsAtLine(@file file, int line) { getLocation().startsAtLine(file, line) } |
7 | 23 | }
|
8 | 24 |
|
9 |
| -// Based on previous implementation on HTMLNode.getCodeInAttribute and getInlineScript |
| 25 | +// Based on previous implementation on HTMLNode.getCodeInAttribute and getInlineScript, |
| 26 | +// with `startsAtLine` added for performance reasons. |
10 | 27 | from
|
11 |
| - TopLevel top, XmlNode xml, @file f, @location l1, int sl1, int sc1, int el1, int ec1, |
12 |
| - @location l2, int sl2, int sc2, int el2, int ec2 |
| 28 | + TopLevel top, XmlNode xml, @file f, Location l1, int sl1, int sc1, int el1, int ec1, Location l2, |
| 29 | + int sl2, int sc2, int el2, int ec2 |
13 | 30 | where
|
14 |
| - xmllocations(xml, l1) and |
15 |
| - hasLocation(top, l2) and |
| 31 | + l1 = xml.getLocation() and |
| 32 | + l2 = top.getLocation() and |
| 33 | + xml.startsAtLine(f, sl1) and |
| 34 | + top.startsAtLine(f, [sl1, sl1 + 1]) and |
16 | 35 | locations_default(l1, f, sl1, sc1, el1, ec1) and
|
17 | 36 | locations_default(l2, f, sl2, sc2, el2, ec2) and
|
18 | 37 | (
|
|
0 commit comments