@@ -109,71 +109,56 @@ var AnnotationRules = On(Any).Self(
109109 // Type node Token (2 levels up) but the SDK doesn't allow this
110110 // TODO: create an issue for the SDK
111111 On (HasInternalType (pyast .FunctionDef )).Roles (FunctionDeclaration , FunctionDeclarationName ,
112- SimpleIdentifier ).Children (
113- On (HasInternalType ("FunctionDef.decorator_list" )).Roles (Call , SimpleIdentifier , Incomplete ),
114- On (HasInternalType ("FunctionDef.body" )).Roles (FunctionDeclarationBody ),
115- // FIXME: change to FunctionDeclarationArgumentS once the PR has been merged
116- On (HasInternalType (pyast .Arguments )).Roles (FunctionDeclarationArgument , Incomplete ).Children (
117- On (HasInternalRole ("args" )).Roles (FunctionDeclarationArgument , FunctionDeclarationArgumentName ),
118- On (HasInternalRole ("vararg" )).Roles (FunctionDeclarationArgument , FunctionDeclarationVarArgsList ,
119- FunctionDeclarationArgumentName ),
120- // FIXME: this is really different from vararg, change it when we have FunctionDeclarationMap
121- // or something similar in the UAST
122- On (HasInternalRole ("kwarg" )).Roles (FunctionDeclarationArgument , FunctionDeclarationVarArgsList ,
123- FunctionDeclarationArgumentName , Incomplete ),
124- // Default arguments: Python's AST puts default arguments on a sibling list to the one of
125- // arguments that must be mapped to the arguments right-aligned like:
126- // a, b=2, c=3 ->
127- // args [a,b,c],
128- // defaults [2,3]
129- // TODO: create an issue for the SDK
130- On (HasInternalType ("arguments.defaults" )).Roles (FunctionDeclarationArgumentDefaultValue , Incomplete ),
131- On (HasInternalType ("arguments.keywords" )).Roles (FunctionDeclarationArgumentDefaultValue , Incomplete ),
132- ),
133- ),
134- On (HasInternalType (pyast .AsyncFunctionDef )).Roles (FunctionDeclaration , FunctionDeclarationName , SimpleIdentifier ,
135- Incomplete ).Children (
112+ SimpleIdentifier ),
113+ On (HasInternalType (pyast .AsyncFunctionDef )).Roles (FunctionDeclaration ,
114+ FunctionDeclarationName , SimpleIdentifier , Incomplete ),
115+ On (HasInternalType ("FunctionDef.decorator_list" )).Roles (Call , SimpleIdentifier , Incomplete ),
116+ On (HasInternalType ("FunctionDef.body" )).Roles (FunctionDeclarationBody ),
117+ // FIXME: change to FunctionDeclarationArgumentS once the PR has been merged
118+ On (HasInternalType (pyast .Arguments )).Roles (FunctionDeclarationArgument , Incomplete ).Children (
119+ On (HasInternalRole ("args" )).Roles (FunctionDeclarationArgument , FunctionDeclarationArgumentName ,
120+ SimpleIdentifier ),
121+ On (HasInternalRole ("vararg" )).Roles (FunctionDeclarationArgument , FunctionDeclarationVarArgsList ,
122+ FunctionDeclarationArgumentName , SimpleIdentifier ),
123+ // FIXME: this is really different from vararg, change it when we have FunctionDeclarationMap
124+ // or something similar in the UAST
125+ On (HasInternalRole ("kwarg" )).Roles (FunctionDeclarationArgument , FunctionDeclarationVarArgsList ,
126+ FunctionDeclarationArgumentName , Incomplete , SimpleIdentifier ),
127+ // Default arguments: Python's AST puts default arguments on a sibling list to the one of
128+ // arguments that must be mapped to the arguments right-aligned like:
129+ // a, b=2, c=3 ->
130+ // args [a,b,c],
131+ // defaults [2,3]
132+ // TODO: create an issue for the SDK
133+ On (HasInternalType ("arguments.defaults" )).Roles (FunctionDeclarationArgumentDefaultValue , Incomplete ),
134+ On (HasInternalType ("arguments.keywords" )).Roles (FunctionDeclarationArgumentDefaultValue , Incomplete ),
136135 On (HasInternalType ("AsyncFunctionDef.decorator_list" )).Roles (Call , SimpleIdentifier , Incomplete ),
137136 On (HasInternalType ("AsyncFunctionDef.body" )).Roles (FunctionDeclarationBody ),
138137 // FIXME: change to FunctionDeclarationArgumentS once the PR has been merged
139- On (HasInternalType (pyast .Arguments )).Roles (FunctionDeclarationArgument , Incomplete ).Children (
140- On (HasInternalRole ("args" )).Roles (FunctionDeclarationArgument , FunctionDeclarationArgumentName ),
141- On (HasInternalRole ("vararg" )).Roles (FunctionDeclarationArgument , FunctionDeclarationVarArgsList ,
142- FunctionDeclarationArgumentName ),
143- // FIXME: this is really different from vararg, change it when we have FunctionDeclarationMap
144- // or something similar in the UAST
145- On (HasInternalRole ("kwarg" )).Roles (FunctionDeclarationArgument , FunctionDeclarationVarArgsList ,
146- FunctionDeclarationArgumentName , Incomplete ),
147- // Default arguments: Python's AST puts default arguments on a sibling list to the one of
148- // arguments that must be mapped to the arguments right-aligned like:
149- // a, b=2, c=3 ->
150- // args [a,b,c],
151- // defaults [2,3]
152- // TODO: create an issue for the SDK
153- On (HasInternalType ("arguments.defaults" )).Roles (FunctionDeclarationArgumentDefaultValue , Incomplete ),
154- On (HasInternalType ("arguments.keywords" )).Roles (FunctionDeclarationArgumentDefaultValue , Incomplete ),
155- ),
156138 ),
157139 On (HasInternalType (pyast .Lambda )).Roles (FunctionDeclaration , SimpleIdentifier , Expression ,
158- Incomplete ).Children (
140+ Incomplete ).Children (
159141 On (HasInternalType ("Lambda.body" )).Roles (FunctionDeclarationBody ),
160142 // FIXME: change to FunctionDeclarationArgumentS once the PR has been merged
161143 On (HasInternalType (pyast .Arguments )).Roles (FunctionDeclarationArgument , Incomplete ).Children (
162- On (HasInternalRole ("args" )).Roles (FunctionDeclarationArgument , FunctionDeclarationArgumentName ),
144+ On (HasInternalRole ("args" )).Roles (FunctionDeclarationArgument , FunctionDeclarationArgumentName ,
145+ SimpleIdentifier ),
163146 On (HasInternalRole ("vararg" )).Roles (FunctionDeclarationArgument , FunctionDeclarationVarArgsList ,
164- FunctionDeclarationArgumentName ),
147+ FunctionDeclarationArgumentName , SimpleIdentifier ),
165148 // FIXME: this is really different from vararg, change it when we have FunctionDeclarationMap
166149 // or something similar in the UAST
167150 On (HasInternalRole ("kwarg" )).Roles (FunctionDeclarationArgument , FunctionDeclarationVarArgsList ,
168- FunctionDeclarationArgumentName , Incomplete ),
151+ FunctionDeclarationArgumentName , Incomplete , SimpleIdentifier ),
169152 // Default arguments: Python's AST puts default arguments on a sibling list to the one of
170153 // arguments that must be mapped to the arguments right-aligned like:
171154 // a, b=2, c=3 ->
172155 // args [a,b,c],
173156 // defaults [2,3]
174157 // TODO: create an issue for the SDK
175- On (HasInternalType ("arguments.defaults" )).Roles (FunctionDeclarationArgumentDefaultValue , Incomplete ),
176- On (HasInternalType ("arguments.keywords" )).Roles (FunctionDeclarationArgumentDefaultValue , Incomplete ),
158+ On (HasInternalType ("arguments.defaults" )).Roles (FunctionDeclarationArgumentDefaultValue ,
159+ SimpleIdentifier , Incomplete ),
160+ On (HasInternalType ("arguments.keywords" )).Roles (FunctionDeclarationArgumentDefaultValue ,
161+ SimpleIdentifier , Incomplete ),
177162 ),
178163 ),
179164
@@ -189,7 +174,7 @@ var AnnotationRules = On(Any).Self(
189174 On (HasInternalType (pyast .Name )).Roles (Call ),
190175 On (HasInternalType (pyast .Attribute )).Roles (CallCallee ).Children (
191176 On (HasInternalRole ("value" )).Roles (CallReceiver ),
192- )),
177+ )),
193178 ),
194179
195180 //
@@ -208,7 +193,6 @@ var AnnotationRules = On(Any).Self(
208193 On (HasInternalRole ("value" )).Roles (AugmentedAssignmentValue ),
209194 ),
210195
211-
212196 On (HasInternalType (pyast .Expression )).Roles (Expression ),
213197 On (HasInternalType (pyast .Expr )).Roles (Expression ),
214198 On (HasInternalType (pyast .Name )).Roles (SimpleIdentifier , Expression ),
@@ -270,8 +254,13 @@ var AnnotationRules = On(Any).Self(
270254 On (HasInternalRole ("orelse" )).Roles (IfElse ),
271255 ),
272256 On (HasInternalType (pyast .Import )).Roles (ImportDeclaration , Statement ),
257+ // "y" in "from x import y" or "import y"
258+ On (HasInternalType (pyast .Alias )).Roles (ImportPath , SimpleIdentifier ),
259+ // "x" in "from x import y"
260+ On (HasInternalType ("ImportFrom.module" )).Roles (ImportPath , SimpleIdentifier ),
261+ // "y" in "import x as y"
262+ On (HasInternalType ("alias.asname" )).Roles (ImportAlias , SimpleIdentifier ),
273263 On (HasInternalType (pyast .ImportFrom )).Roles (ImportDeclaration , Statement ),
274- On (HasInternalType (pyast .Alias )).Roles (ImportAlias , SimpleIdentifier ),
275264 On (HasInternalType (pyast .ClassDef )).Roles (TypeDeclaration , SimpleIdentifier , Statement ).Children (
276265 On (HasInternalType ("ClassDef.body" )).Roles (TypeDeclarationBody ),
277266 On (HasInternalType ("ClassDef.bases" )).Roles (TypeDeclarationBases ),
@@ -360,6 +349,5 @@ var AnnotationRules = On(Any).Self(
360349 On (HasInternalType (pyast .Index )).Roles (Expression , Incomplete ),
361350 On (HasInternalType (pyast .Slice )).Roles (Expression , Incomplete ),
362351 On (HasInternalType (pyast .ExtSlice )).Roles (Expression , Incomplete ),
363-
364352 ),
365353)
0 commit comments