Skip to content

Commit bb42382

Browse files
authored
Merge pull request github#5025 from asgerf/js/slow-xml-parent-upgrade-script
Approved by erik-krogh
2 parents 988c1bc + 5a89fa3 commit bb42382

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

javascript/upgrades/c8859f3725d4b070a877f8792214582d517c8a9b/toplevel_parent_xml_node.ql

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,37 @@
1+
class Location extends @location {
2+
string toString() { none() }
3+
4+
predicate startsAtLine(@file file, int line) { locations_default(this, file, line, _, _, _) }
5+
}
6+
17
class TopLevel extends @toplevel {
28
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) }
314
}
415

516
class XmlNode extends @xmllocatable {
617
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) }
723
}
824

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.
1027
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
1330
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
1635
locations_default(l1, f, sl1, sc1, el1, ec1) and
1736
locations_default(l2, f, sl2, sc2, el2, ec2) and
1837
(

0 commit comments

Comments
 (0)