mirror of
https://github.com/github/codeql.git
synced 2026-04-27 17:55:19 +02:00
Merge pull request #13941 from yoff/python/test-nice-location
Python: fix nice locations for import aliases
This commit is contained in:
@@ -492,9 +492,14 @@ class NiceLocationExpr extends Expr {
|
||||
// for `import xxx` or for `import xxx as yyy`.
|
||||
this.(ImportExpr).getLocation().hasLocationInfo(f, bl, bc, el, ec)
|
||||
or
|
||||
/* Show y for `y` in `from xxx import y` */
|
||||
exists(string name |
|
||||
name = this.(ImportMember).getName() and
|
||||
// Show y for `y` in `from xxx import y`
|
||||
// and y for `yyy as y` in `from xxx import yyy as y`.
|
||||
exists(string name, Alias alias |
|
||||
// This alias will always exist, as `from xxx import y`
|
||||
// is expanded to `from xxx imprt y as y`.
|
||||
this = alias.getValue() and
|
||||
name = alias.getAsname().(Name).getId()
|
||||
|
|
||||
this.(ImportMember).getLocation().hasLocationInfo(f, _, _, el, ec) and
|
||||
bl = el and
|
||||
bc = ec - name.length() + 1
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
---
|
||||
category: fix
|
||||
---
|
||||
* Fixed the computation of locations for imports with aliases in jump-to-definition.
|
||||
@@ -0,0 +1,4 @@
|
||||
from nova.api.openstack.placement import microversion
|
||||
from nova.api.openstack.placement.objects import resource_provider as rp_obj
|
||||
from nova.api.openstack.placement.policies import allocation_candidate as \
|
||||
policies
|
||||
@@ -0,0 +1,6 @@
|
||||
| import_statements.py | 1 | 6 | 1 | 33 |
|
||||
| import_statements.py | 1 | 42 | 1 | 53 |
|
||||
| import_statements.py | 2 | 6 | 2 | 41 |
|
||||
| import_statements.py | 2 | 71 | 2 | 76 |
|
||||
| import_statements.py | 3 | 6 | 3 | 42 |
|
||||
| import_statements.py | 4 | 5 | 4 | 12 |
|
||||
@@ -0,0 +1,6 @@
|
||||
import python
|
||||
import analysis.DefinitionTracking
|
||||
|
||||
from NiceLocationExpr expr, string f, int bl, int bc, int el, int ec
|
||||
where expr.hasLocationInfo(f, bl, bc, el, ec)
|
||||
select f, bl, bc, el, ec
|
||||
Reference in New Issue
Block a user