Skip to content

Commit 47cbf0b

Browse files
author
Max Schaefer
committed
JavaScript: Override Locatable.getLocation() for @files.
1 parent 6fbaa7a commit 47cbf0b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

javascript/ql/src/semmle/javascript/Locations.qll

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,15 @@ class Locatable extends @locatable {
132132
none()
133133
}
134134
}
135+
136+
/**
137+
* A `File`, considered as a `Locatable`.
138+
*
139+
* For reasons of backwards compatibility, @file is a subtype of @locatable. This class exists to
140+
* provide an override of `Locatable.getLocation()` for @files, since it would otherwise default
141+
* to `none()`, which is unhelpful.
142+
*/
143+
private class FileLocatable extends File, Locatable {
144+
override Location getLocation() { result = File.super.getLocation() }
145+
override string toString() { result = File.super.toString() }
146+
}

0 commit comments

Comments
 (0)