mirror of
https://github.com/github/codeql.git
synced 2026-05-01 03:35:13 +02:00
Python: Make sure packages have locations, so they can be displayed, even if those locations are meaningless.
This commit is contained in:
@@ -391,10 +391,14 @@ class Location extends @location {
|
||||
|
||||
/** Gets the file for this location */
|
||||
File getFile() {
|
||||
result = this.getPath()
|
||||
}
|
||||
|
||||
private Container getPath() {
|
||||
locations_default(this, result, _, _, _, _)
|
||||
or
|
||||
exists(Module m | locations_ast(this, m, _, _, _, _) |
|
||||
result = m.getFile()
|
||||
result = m.getPath()
|
||||
)
|
||||
}
|
||||
|
||||
@@ -423,7 +427,7 @@ class Location extends @location {
|
||||
}
|
||||
|
||||
string toString() {
|
||||
result = this.getFile().getName() + ":" + this.getStartLine().toString()
|
||||
result = this.getPath().getName() + ":" + this.getStartLine().toString()
|
||||
}
|
||||
|
||||
predicate hasLocationInfo(string filepath, int bl, int bc, int el, int ec) {
|
||||
|
||||
@@ -115,6 +115,9 @@ class Module extends Module_, Scope, AstNode {
|
||||
|
||||
override Location getLocation() {
|
||||
py_scope_location(result, this)
|
||||
or
|
||||
not py_scope_location(_, this) and
|
||||
locations_ast(result, this, 0, 0, 0, 0)
|
||||
}
|
||||
|
||||
/** Gets a child module or package of this package */
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -21,16 +21,18 @@ class DerivedClass(BaseClass):
|
||||
self.inst_attr
|
||||
self.shadowing
|
||||
|
||||
#ODASA-3836
|
||||
|
||||
def comprehensions_and_generators(seq):
|
||||
[y*y for y in seq]
|
||||
(y*y for y in seq)
|
||||
{y*y for y in seq}
|
||||
{y:y*y for y in seq}
|
||||
|
||||
#ODASA-5391
|
||||
|
||||
@decorator(x)
|
||||
class Decorated(object):
|
||||
pass
|
||||
|
||||
d = Decorated()
|
||||
|
||||
import package
|
||||
|
||||
Reference in New Issue
Block a user