Skip to content
This repository was archived by the owner on Mar 8, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions driver/normalizer/annotation.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,6 @@ var AnnotationRules = On(Any).Self(
argumentsAnn,
),

On(pyast.Attribute).Roles(uast.Identifier, uast.Expression).Children(
On(pyast.Name).Roles(uast.Qualified)),

On(pyast.Call).Roles(uast.Function, uast.Call, uast.Expression).Children(
On(HasInternalRole("args")).Roles(uast.Function, uast.Call, uast.Positional, uast.Argument, uast.Name),
On(HasInternalRole("keywords")).Roles(uast.Function, uast.Call, uast.Argument, uast.Name).Children(
Expand Down Expand Up @@ -187,6 +184,16 @@ var AnnotationRules = On(Any).Self(
On(HasInternalRole("value")).Roles(uast.Right),
),

// a.b.c ("a" and "b" will be Qualified, "c" will be just Identifier). Python does the
// reverse thing
On(pyast.Attribute).Self(
On(HasProperty("ctx", "Load")).Roles(uast.Qualified, uast.Identifier, uast.Expression),
On(HasProperty("ctx", "Store")).Roles(uast.Identifier, uast.Expression),
On(HasChild(pyast.Name)).Children(
On(Any).Roles(uast.Qualified), // Identifier and Expr added on all Name(s) below
),
),

On(pyast.Expression).Roles(uast.Expression),
On(pyast.Expr).Roles(uast.Expression),
On(pyast.Name).Roles(uast.Identifier, uast.Expression),
Expand Down
1 change: 1 addition & 0 deletions fixtures/annotations.py.native
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"status": "ok",
"language": "",
"errors": [],
"ast": {
"PY3AST": {
Expand Down
1 change: 1 addition & 0 deletions fixtures/annotations.py.uast
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Status: ok
Language:
Errors:
UAST:
Module {
Expand Down
1 change: 1 addition & 0 deletions fixtures/aritmeticops.py.native
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"status": "ok",
"language": "",
"errors": [],
"ast": {
"PY3AST": {
Expand Down
1 change: 1 addition & 0 deletions fixtures/aritmeticops.py.uast
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Status: ok
Language:
Errors:
UAST:
Module {
Expand Down
1 change: 1 addition & 0 deletions fixtures/assert_constant.py.native
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"status": "ok",
"language": "",
"errors": [],
"ast": {
"PY3AST": {
Expand Down
1 change: 1 addition & 0 deletions fixtures/assert_constant.py.uast
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Status: ok
Language:
Errors:
UAST:
Module {
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions fixtures/augassign.py.native
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"status": "ok",
"language": "",
"errors": [],
"ast": {
"PY3AST": {
Expand Down
1 change: 1 addition & 0 deletions fixtures/augassign.py.uast
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Status: ok
Language:
Errors:
UAST:
Module {
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions fixtures/bitwise.py.native
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"status": "ok",
"language": "",
"errors": [],
"ast": {
"PY3AST": {
Expand Down
1 change: 1 addition & 0 deletions fixtures/bitwise.py.uast
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Status: ok
Language:
Errors:
UAST:
Module {
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions fixtures/classdef.py.native
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"status": "ok",
"language": "",
"errors": [],
"ast": {
"PY3AST": {
Expand Down
27 changes: 14 additions & 13 deletions fixtures/classdef.py.uast
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Status: ok
Language:
Errors:
UAST:
Module {
Expand Down Expand Up @@ -87,7 +88,7 @@ Module {
. . . . . . . . . . . }
. . . . . . . . . . . Children: {
. . . . . . . . . . . . 0: Attribute {
. . . . . . . . . . . . . Roles: Identifier,Expression,Left
. . . . . . . . . . . . . Roles: Left,Identifier,Expression
. . . . . . . . . . . . . TOKEN "_a"
. . . . . . . . . . . . . StartPosition: {
. . . . . . . . . . . . . . Offset: 51
Expand Down Expand Up @@ -353,7 +354,7 @@ Module {
. . . . . . . . . . . }
. . . . . . . . . . . Children: {
. . . . . . . . . . . . 0: Attribute {
. . . . . . . . . . . . . Roles: Identifier,Expression
. . . . . . . . . . . . . Roles: Qualified,Identifier,Expression
. . . . . . . . . . . . . TOKEN "_a"
. . . . . . . . . . . . . StartPosition: {
. . . . . . . . . . . . . . Offset: 162
Expand Down Expand Up @@ -542,7 +543,7 @@ Module {
. . . . . . . . . . . }
. . . . . . . . . . . Children: {
. . . . . . . . . . . . 0: Attribute {
. . . . . . . . . . . . . Roles: Identifier,Expression,Left
. . . . . . . . . . . . . Roles: Left,Identifier,Expression
. . . . . . . . . . . . . TOKEN "_a"
. . . . . . . . . . . . . StartPosition: {
. . . . . . . . . . . . . . Offset: 210
Expand Down Expand Up @@ -608,7 +609,7 @@ Module {
. . . . . . . . . }
. . . . . . . . . Children: {
. . . . . . . . . . 0: Attribute {
. . . . . . . . . . . Roles: Identifier,Expression
. . . . . . . . . . . Roles: Qualified,Identifier,Expression
. . . . . . . . . . . TOKEN "setter"
. . . . . . . . . . . StartPosition: {
. . . . . . . . . . . . Offset: 173
Expand Down Expand Up @@ -759,7 +760,7 @@ Module {
. . . }
. . . Children: {
. . . . 0: Attribute {
. . . . . Roles: Identifier,Expression,Left
. . . . . Roles: Left,Identifier,Expression
. . . . . TOKEN "b"
. . . . . StartPosition: {
. . . . . . Offset: 236
Expand Down Expand Up @@ -827,7 +828,7 @@ Module {
. . . }
. . . Children: {
. . . . 0: Attribute {
. . . . . Roles: Identifier,Expression,Left
. . . . . Roles: Left,Identifier,Expression
. . . . . TOKEN "g"
. . . . . StartPosition: {
. . . . . . Offset: 254
Expand All @@ -845,7 +846,7 @@ Module {
. . . . . }
. . . . . Children: {
. . . . . . 0: Attribute {
. . . . . . . Roles: Identifier,Expression
. . . . . . . Roles: Qualified,Identifier,Expression
. . . . . . . TOKEN "f"
. . . . . . . StartPosition: {
. . . . . . . . Offset: 252
Expand All @@ -863,7 +864,7 @@ Module {
. . . . . . . }
. . . . . . . Children: {
. . . . . . . . 0: Attribute {
. . . . . . . . . Roles: Identifier,Expression
. . . . . . . . . Roles: Qualified,Identifier,Expression
. . . . . . . . . TOKEN "e"
. . . . . . . . . StartPosition: {
. . . . . . . . . . Offset: 250
Expand All @@ -881,7 +882,7 @@ Module {
. . . . . . . . . }
. . . . . . . . . Children: {
. . . . . . . . . . 0: Attribute {
. . . . . . . . . . . Roles: Identifier,Expression
. . . . . . . . . . . Roles: Qualified,Identifier,Expression
. . . . . . . . . . . TOKEN "d"
. . . . . . . . . . . StartPosition: {
. . . . . . . . . . . . Offset: 248
Expand All @@ -899,7 +900,7 @@ Module {
. . . . . . . . . . . }
. . . . . . . . . . . Children: {
. . . . . . . . . . . . 0: Attribute {
. . . . . . . . . . . . . Roles: Identifier,Expression
. . . . . . . . . . . . . Roles: Qualified,Identifier,Expression
. . . . . . . . . . . . . TOKEN "c"
. . . . . . . . . . . . . StartPosition: {
. . . . . . . . . . . . . . Offset: 246
Expand All @@ -917,7 +918,7 @@ Module {
. . . . . . . . . . . . . }
. . . . . . . . . . . . . Children: {
. . . . . . . . . . . . . . 0: Attribute {
. . . . . . . . . . . . . . . Roles: Identifier,Expression
. . . . . . . . . . . . . . . Roles: Qualified,Identifier,Expression
. . . . . . . . . . . . . . . TOKEN "b"
. . . . . . . . . . . . . . . StartPosition: {
. . . . . . . . . . . . . . . . Offset: 244
Expand Down Expand Up @@ -1023,7 +1024,7 @@ Module {
. . . . . . . }
. . . . . . }
. . . . . . 1: Attribute {
. . . . . . . Roles: Identifier,Expression,Call,Callee
. . . . . . . Roles: Call,Callee,Qualified,Identifier,Expression
. . . . . . . TOKEN "method"
. . . . . . . StartPosition: {
. . . . . . . . Offset: 262
Expand All @@ -1041,7 +1042,7 @@ Module {
. . . . . . . }
. . . . . . . Children: {
. . . . . . . . 0: Name {
. . . . . . . . . Roles: Qualified,Call,Receiver,Identifier,Expression
. . . . . . . . . Roles: Call,Receiver,Qualified,Identifier,Expression
. . . . . . . . . TOKEN "a"
. . . . . . . . . StartPosition: {
. . . . . . . . . . Offset: 260
Expand Down
1 change: 1 addition & 0 deletions fixtures/classdef_decorated.py.native
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"status": "ok",
"language": "",
"errors": [],
"ast": {
"PY3AST": {
Expand Down
1 change: 1 addition & 0 deletions fixtures/classdef_decorated.py.uast
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Status: ok
Language:
Errors:
UAST:
Module {
Expand Down
1 change: 1 addition & 0 deletions fixtures/classdef_inheritance.py.native
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"status": "ok",
"language": "",
"errors": [],
"ast": {
"PY3AST": {
Expand Down
1 change: 1 addition & 0 deletions fixtures/classdef_inheritance.py.uast
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Status: ok
Language:
Errors:
UAST:
Module {
Expand Down
1 change: 1 addition & 0 deletions fixtures/classdef_metaclass_py2.py.native
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"status": "ok",
"language": "",
"errors": [],
"ast": {
"PY3AST": {
Expand Down
1 change: 1 addition & 0 deletions fixtures/classdef_metaclass_py2.py.uast
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Status: ok
Language:
Errors:
UAST:
Module {
Expand Down
1 change: 1 addition & 0 deletions fixtures/classdef_metaclass_py3.py.native
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"status": "ok",
"language": "",
"errors": [],
"ast": {
"PY3AST": {
Expand Down
1 change: 1 addition & 0 deletions fixtures/classdef_metaclass_py3.py.uast
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Status: ok
Language:
Errors:
UAST:
Module {
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions fixtures/comments.py.native
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"status": "ok",
"language": "",
"errors": [],
"ast": {
"PY3AST": {
Expand Down
1 change: 1 addition & 0 deletions fixtures/comments.py.uast
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Status: ok
Language:
Errors:
UAST:
Module {
Expand Down
1 change: 1 addition & 0 deletions fixtures/comparisonop.py.native
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"status": "ok",
"language": "",
"errors": [],
"ast": {
"PY3AST": {
Expand Down
1 change: 1 addition & 0 deletions fixtures/comparisonop.py.uast
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Status: ok
Language:
Errors:
UAST:
Module {
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions fixtures/complex.py.native
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"status": "ok",
"language": "",
"errors": [],
"ast": {
"PY3AST": {
Expand Down
1 change: 1 addition & 0 deletions fixtures/complex.py.uast
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Status: ok
Language:
Errors:
UAST:
Module {
Expand Down
1 change: 1 addition & 0 deletions fixtures/comprehension_dict.py.native
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"status": "ok",
"language": "",
"errors": [],
"ast": {
"PY3AST": {
Expand Down
1 change: 1 addition & 0 deletions fixtures/comprehension_dict.py.uast
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Status: ok
Language:
Errors:
UAST:
Module {
Expand Down
1 change: 1 addition & 0 deletions fixtures/comprehension_list.py.native
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"status": "ok",
"language": "",
"errors": [],
"ast": {
"PY3AST": {
Expand Down
1 change: 1 addition & 0 deletions fixtures/comprehension_list.py.uast
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Status: ok
Language:
Errors:
UAST:
Module {
Expand Down
1 change: 1 addition & 0 deletions fixtures/comprehension_set.py.native
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"status": "ok",
"language": "",
"errors": [],
"ast": {
"PY3AST": {
Expand Down
1 change: 1 addition & 0 deletions fixtures/comprehension_set.py.uast
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Status: ok
Language:
Errors:
UAST:
Module {
Expand Down
1 change: 1 addition & 0 deletions fixtures/continue_break.py.native
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"status": "ok",
"language": "",
"errors": [],
"ast": {
"PY3AST": {
Expand Down
1 change: 1 addition & 0 deletions fixtures/continue_break.py.uast
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Status: ok
Language:
Errors:
UAST:
Module {
Expand Down
1 change: 1 addition & 0 deletions fixtures/declarations_annotated.py.native
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"status": "ok",
"language": "",
"errors": [],
"ast": {
"PY3AST": {
Expand Down
1 change: 1 addition & 0 deletions fixtures/declarations_annotated.py.uast
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Status: ok
Language:
Errors:
UAST:
Module {
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions fixtures/ellipsis.py.native
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"status": "ok",
"language": "",
"errors": [],
"ast": {
"PY3AST": {
Expand Down
1 change: 1 addition & 0 deletions fixtures/ellipsis.py.uast
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Status: ok
Language:
Errors:
UAST:
Module {
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions fixtures/empty.py.native
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"status": "ok",
"language": "",
"errors": [],
"ast": {
"PY3AST": {
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.