@@ -50,33 +50,33 @@ var AnnotationRules = On(Any).Self(
5050 ),
5151
5252 // Comparison operators
53- On (pyast .Eq ).Roles (uast .Operator , uast .Equal ),
54- On (pyast .NotEq ).Roles (uast .Operator , uast .Equal , uast .Not ),
55- On (pyast .Lt ).Roles (uast .Operator , uast .LessThan ),
56- On (pyast .LtE ).Roles (uast .Operator , uast .LessThanOrEqual ),
57- On (pyast .Gt ).Roles (uast .Operator , uast .GreaterThan ),
58- On (pyast .GtE ).Roles (uast .Operator , uast .GreaterThanOrEqual ),
59- On (pyast .Is ).Roles (uast .Operator , uast .Identical ),
60- On (pyast .IsNot ).Roles (uast .Operator , uast .Identical , uast .Not ),
61- On (pyast .In ).Roles (uast .Operator , uast .Contains ),
62- On (pyast .NotIn ).Roles (uast .Operator , uast .Contains , uast .Not ),
53+ On (pyast .Eq ).Roles (uast .Binary , uast . Operator , uast .Equal ),
54+ On (pyast .NotEq ).Roles (uast .Binary , uast . Operator , uast .Equal , uast .Not ),
55+ On (pyast .Lt ).Roles (uast .Binary , uast . Operator , uast .LessThan ),
56+ On (pyast .LtE ).Roles (uast .Binary , uast . Operator , uast .LessThanOrEqual ),
57+ On (pyast .Gt ).Roles (uast .Binary , uast . Operator , uast .GreaterThan ),
58+ On (pyast .GtE ).Roles (uast .Binary , uast . Operator , uast .GreaterThanOrEqual ),
59+ On (pyast .Is ).Roles (uast .Binary , uast . Operator , uast .Identical ),
60+ On (pyast .IsNot ).Roles (uast .Binary , uast . Operator , uast .Identical , uast .Not ),
61+ On (pyast .In ).Roles (uast .Binary , uast . Operator , uast .Contains ),
62+ On (pyast .NotIn ).Roles (uast .Binary , uast . Operator , uast .Contains , uast .Not ),
6363
6464 // Aritmetic operators
65- On (pyast .Add ).Roles (uast .Add ),
66- On (pyast .Sub ).Roles (uast .Substract ),
67- On (pyast .Mult ).Roles (uast .Multiply ),
68- On (pyast .Div ).Roles (uast .Divide ),
69- On (pyast .Mod ).Roles (uast .Modulo ),
70- On (pyast .FloorDiv ).Roles (uast .Divide , uast .Incomplete ),
71- On (pyast .Pow ).Roles (uast .Incomplete ),
72- On (pyast .MatMult ).Roles (uast .Multiply , uast .Incomplete ),
65+ On (pyast .Add ).Roles (uast .Binary , uast . Operator , uast . Add ),
66+ On (pyast .Sub ).Roles (uast .Binary , uast . Operator , uast . Substract ),
67+ On (pyast .Mult ).Roles (uast .Binary , uast . Operator , uast . Multiply ),
68+ On (pyast .Div ).Roles (uast .Binary , uast . Operator , uast . Divide ),
69+ On (pyast .Mod ).Roles (uast .Binary , uast . Operator , uast . Modulo ),
70+ On (pyast .FloorDiv ).Roles (uast .Binary , uast . Operator , uast . Divide , uast .Incomplete ),
71+ On (pyast .Pow ).Roles (uast .Binary , uast . Operator , uast . Incomplete ),
72+ On (pyast .MatMult ).Roles (uast .Binary , uast . Operator , uast . Multiply , uast .Incomplete ),
7373
7474 // Bitwise operators
75- On (pyast .LShift ).Roles (uast .Bitwise , uast .LeftShift ),
76- On (pyast .RShift ).Roles (uast .Bitwise , uast .RightShift ),
77- On (pyast .BitOr ).Roles (uast .Bitwise , uast .Or ),
78- On (pyast .BitXor ).Roles (uast .Bitwise , uast .Xor ),
79- On (pyast .BitAnd ).Roles (uast .Bitwise , uast .And ),
75+ On (pyast .LShift ).Roles (uast .Binary , uast . Operator , uast . Bitwise , uast .LeftShift ),
76+ On (pyast .RShift ).Roles (uast .Binary , uast . Operator , uast . Bitwise , uast .RightShift ),
77+ On (pyast .BitOr ).Roles (uast .Binary , uast . Operator , uast . Bitwise , uast .Or ),
78+ On (pyast .BitXor ).Roles (uast .Binary , uast . Operator , uast . Bitwise , uast .Xor ),
79+ On (pyast .BitAnd ).Roles (uast .Binary , uast . Operator , uast . Bitwise , uast .And ),
8080
8181 // Boolean operators
8282 // Not applying the "Binary" role since even while in the Python code
@@ -116,22 +116,22 @@ var AnnotationRules = On(Any).Self(
116116 // Type node Token (2 levels up) but the SDK doesn't allow this
117117 On (pyast .FunctionDef ).Roles (uast .Function , uast .Declaration , uast .Name , uast .Identifier ),
118118 On (pyast .AsyncFunctionDef ).Roles (uast .Function , uast .Declaration , uast .Name , uast .Identifier , uast .Incomplete ),
119- On (pyast .FuncDecorators ).Roles (uast .Function , uast .Call , uast .Incomplete ),
119+ On (pyast .FuncDecorators ).Roles (uast .Function , uast .Declaration , uast . Call , uast .Incomplete ),
120120 On (pyast .FuncDefBody ).Roles (uast .Function , uast .Declaration , uast .Body ),
121121 // FIXME: arguments is a Groping node, update it we get a "Grouper" or "Container" role
122- On (HasInternalRole ("arguments" )).Roles (uast .Argument , uast .Incomplete ),
123- On (HasInternalRole ("args" )).Roles (uast .Argument , uast .Name , uast .Identifier ),
124- On (HasInternalRole ("vararg" )).Roles (uast .Argument , uast .ArgsList , uast .Name , uast .Identifier ),
125- On (HasInternalRole ("kwarg" )).Roles (uast .Argument , uast .ArgsList , uast .Map , uast .Name , uast .Identifier ),
126- On (HasInternalRole ("kwonlyargs" )).Roles (uast .Argument , uast .ArgsList , uast .Map , uast .Name , uast .Identifier ),
122+ On (HasInternalRole ("arguments" )).Roles (uast .Function , uast . Declaration , uast . Argument , uast .Incomplete ),
123+ On (HasInternalRole ("args" )).Roles (uast .Function , uast . Declaration , uast . Argument , uast .Name , uast .Identifier ),
124+ On (HasInternalRole ("vararg" )).Roles (uast .Function , uast . Declaration , uast . Argument , uast .ArgsList , uast .Name , uast .Identifier ),
125+ On (HasInternalRole ("kwarg" )).Roles (uast .Function , uast . Declaration , uast . Argument , uast .ArgsList , uast .Map , uast .Name , uast .Identifier ),
126+ On (HasInternalRole ("kwonlyargs" )).Roles (uast .Function , uast . Declaration , uast . Argument , uast .ArgsList , uast .Map , uast .Name , uast .Identifier ),
127127 // Default arguments: Python's AST puts default arguments on a sibling list to the one of
128128 // arguments that must be mapped to the arguments right-aligned like:
129129 // a, b=2, c=3 ->
130130 // args [a,b,c],
131131 // defaults [2,3]
132132 // TODO: create an issue for the SDK
133133 On (pyast .ArgumentDefaults ).Roles (uast .Function , uast .Declaration , uast .Argument , uast .Value , uast .Incomplete ),
134- On (pyast .AsyncFuncDecorators ).Roles (uast .Function , uast .Call , uast .Incomplete ),
134+ On (pyast .AsyncFuncDecorators ).Roles (uast .Function , uast .Declaration , uast . Call , uast .Incomplete ),
135135 On (pyast .AsyncFuncDefBody ).Roles (uast .Function , uast .Declaration , uast .Body ),
136136 // FIXME: change to Function, Declaration, ArgumentS once the PR has been merged
137137 On (pyast .Lambda ).Roles (uast .Function , uast .Declaration , uast .Expression , uast .Incomplete ).Children (
@@ -191,7 +191,7 @@ var AnnotationRules = On(Any).Self(
191191 ),
192192 On (pyast .TryExcept ).Roles (uast .Try , uast .Catch , uast .Statement ), // py2
193193 On (pyast .ExceptHandler ).Roles (uast .Try , uast .Catch , uast .Statement ), // py3
194- On (pyast .ExceptHandlerName ).Roles (uast .Identifier ),
194+ On (pyast .ExceptHandlerName ).Roles (uast .Try , uast . Catch , uast . Identifier ),
195195 On (pyast .TryFinally ).Roles (uast .Try , uast .Finally , uast .Statement ),
196196 On (pyast .Raise ).Roles (uast .Throw , uast .Statement ),
197197 // FIXME: review, add path for the body and items childs
@@ -300,9 +300,9 @@ var AnnotationRules = On(Any).Self(
300300 // uast.List/uast.Map/uast.Set comprehensions. We map the "for x in y" to uast.For, uast.Iterator (foreach)
301301 // roles and the "if something" to uast.If* roles. FIXME: missing the top comprehension
302302 // roles in the UAST, change once they've been merged
303- On (pyast .ListComp ).Roles (uast .Literal , uast . List , uast .For , uast .Expression , uast .Incomplete ),
304- On (pyast .DictComp ).Roles (uast .Literal , uast . Map , uast .For , uast .Expression , uast .Incomplete ),
305- On (pyast .SetComp ).Roles (uast .Literal , uast . Set , uast .For , uast .Expression , uast .Incomplete ),
303+ On (pyast .ListComp ).Roles (uast .List , uast .For , uast .Expression , uast .Incomplete ),
304+ On (pyast .DictComp ).Roles (uast .Map , uast .For , uast .Expression , uast .Incomplete ),
305+ On (pyast .SetComp ).Roles (uast .Set , uast .For , uast .Expression , uast .Incomplete ),
306306 On (pyast .Comprehension ).Roles (uast .For , uast .Iterator , uast .Expression ).Children (
307307 On (HasInternalRole ("iter" )).Roles (uast .For , uast .Update , uast .Statement ),
308308 On (HasInternalRole ("target" )).Roles (uast .For , uast .Expression ),
0 commit comments