Skip to content

Commit f2ae73b

Browse files
authored
Merge pull request #9738 from geoffw0/misc
Swift: Add a Locatable.getFile() shortcut similar to the one in CPP.
2 parents b812518 + ff06e3c commit f2ae73b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

swift/ql/lib/codeql/swift/elements/Locatable.qll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
private import codeql.swift.generated.Locatable
2+
private import codeql.swift.elements.File
23

34
class Locatable extends LocatableBase {
45
pragma[nomagic]
@@ -7,4 +8,9 @@ class Locatable extends LocatableBase {
78
or
89
not exists(LocatableBase.super.getLocation()) and result instanceof UnknownLocation
910
}
11+
12+
/**
13+
* Gets the primary file where this element occurs.
14+
*/
15+
File getFile() { result = getLocation().getFile() }
1016
}

0 commit comments

Comments
 (0)