Skip to content
This repository was archived by the owner on Mar 8, 2020. It is now read-only.

Commit 56f549a

Browse files
authored
Merge pull request #23 from juanjux/fix/more_simpleidentifier
Fix/more simpleidentifier
2 parents 8de4427 + fd68bed commit 56f549a

16 files changed

+36
-37
lines changed

driver/normalizer/annotation.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ var AnnotationRules = On(Any).Self(
165165
// FIXME: the FunctionDeclarationReceiver is not set for methods; it should be taken from the parent
166166
// Type node Token (2 levels up) but the SDK doesn't allow this
167167
// TODO: create an issue for the SDK
168-
On(HasInternalType(pyast.FunctionDef)).Roles(FunctionDeclaration, FunctionDeclarationName).Children(
168+
On(HasInternalType(pyast.FunctionDef)).Roles(FunctionDeclaration, FunctionDeclarationName, SimpleIdentifier).Children(
169169
On(HasInternalType("FunctionDef.body")).Roles(FunctionDeclarationBody),
170170
// FIXME: change to FunctionDeclarationArgumentS once the PR has been merged
171171
On(HasInternalType("arguments")).Roles(FunctionDeclarationArgument).Children(
@@ -194,7 +194,7 @@ var AnnotationRules = On(Any).Self(
194194
On(HasInternalRole("func")).Self(On(HasInternalRole("id"))).Roles(CallCallee),
195195
On(HasInternalRole("func")).Self(On(HasInternalRole("attr"))).Roles(CallCallee),
196196
On(HasInternalRole("func")).Self(On(HasInternalType(pyast.Attribute))).Children(
197-
On(HasInternalRole("id")).Roles(CallReceiver),
197+
On(HasInternalRole("id")).Roles(CallReceiver, SimpleIdentifier),
198198
),
199199
),
200200

@@ -280,8 +280,8 @@ var AnnotationRules = On(Any).Self(
280280
On(HasInternalType(pyast.IfExp)).Roles(If),
281281
On(HasInternalType(pyast.Import)).Roles(ImportDeclaration),
282282
On(HasInternalType(pyast.ImportFrom)).Roles(ImportDeclaration),
283-
On(HasInternalType(pyast.Alias)).Roles(ImportAlias),
284-
On(HasInternalType(pyast.ClassDef)).Roles(TypeDeclaration).Children(
283+
On(HasInternalType(pyast.Alias)).Roles(ImportAlias, SimpleIdentifier),
284+
On(HasInternalType(pyast.ClassDef)).Roles(TypeDeclaration, SimpleIdentifier).Children(
285285
On(HasInternalType("ClassDef.body")).Roles(TypeDeclarationBody),
286286
On(HasInternalType("ClassDef.bases")).Roles(TypeDeclarationBases),
287287
),
@@ -313,7 +313,7 @@ var AnnotationRules = On(Any).Self(
313313
),
314314
// Repr already comes as a Call \o/
315315
// Print as a function too.
316-
On(HasInternalType(pyast.Print)).Roles(Call, CallCallee).Children(
316+
On(HasInternalType(pyast.Print)).Roles(Call, CallCallee, SimpleIdentifier).Children(
317317
On(HasInternalRole("dest")).Roles(CallPositionalArgument),
318318
On(HasInternalRole("nl")).Roles(CallPositionalArgument),
319319
On(HasInternalRole("values")).Roles(CallPositionalArgument).Children(
@@ -346,6 +346,5 @@ var AnnotationRules = On(Any).Self(
346346
On(HasInternalRole("left")).Roles(BinaryExpressionLeft),
347347
),
348348
),
349-
350349
),
351350
)

tests/classdef.py.uast

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Module {
1010
. }
1111
. Children: {
1212
. . 0: ClassDef {
13-
. . . Roles: TypeDeclaration
13+
. . . Roles: TypeDeclaration,SimpleIdentifier
1414
. . . TOKEN "Animal"
1515
. . . StartPosition: {
1616
. . . . Offset: 0
@@ -28,7 +28,7 @@ Module {
2828
. . . . . }
2929
. . . . . Children: {
3030
. . . . . . 0: FunctionDef {
31-
. . . . . . . Roles: FunctionDeclaration,FunctionDeclarationName
31+
. . . . . . . Roles: FunctionDeclaration,FunctionDeclarationName,SimpleIdentifier
3232
. . . . . . . TOKEN "__init__"
3333
. . . . . . . StartPosition: {
3434
. . . . . . . . Offset: 0
@@ -165,7 +165,7 @@ Module {
165165
. . . . . . . }
166166
. . . . . . }
167167
. . . . . . 1: FunctionDef {
168-
. . . . . . . Roles: FunctionDeclaration,FunctionDeclarationName
168+
. . . . . . . Roles: FunctionDeclaration,FunctionDeclarationName,SimpleIdentifier
169169
. . . . . . . TOKEN "method"
170170
. . . . . . . StartPosition: {
171171
. . . . . . . . Offset: 0
@@ -265,7 +265,7 @@ Module {
265265
. . . . . . . }
266266
. . . . . . }
267267
. . . . . . 2: FunctionDef {
268-
. . . . . . . Roles: FunctionDeclaration,FunctionDeclarationName
268+
. . . . . . . Roles: FunctionDeclaration,FunctionDeclarationName,SimpleIdentifier
269269
. . . . . . . TOKEN "a"
270270
. . . . . . . StartPosition: {
271271
. . . . . . . . Offset: 0
@@ -386,7 +386,7 @@ Module {
386386
. . . . . . . }
387387
. . . . . . }
388388
. . . . . . 3: FunctionDef {
389-
. . . . . . . Roles: FunctionDeclaration,FunctionDeclarationName
389+
. . . . . . . Roles: FunctionDeclaration,FunctionDeclarationName,SimpleIdentifier
390390
. . . . . . . TOKEN "a"
391391
. . . . . . . StartPosition: {
392392
. . . . . . . . Offset: 0

tests/classdef_inheritance.py.uast

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Module {
1010
. }
1111
. Children: {
1212
. . 0: ClassDef {
13-
. . . Roles: TypeDeclaration
13+
. . . Roles: TypeDeclaration,SimpleIdentifier
1414
. . . TOKEN "Dog"
1515
. . . StartPosition: {
1616
. . . . Offset: 0
@@ -60,7 +60,7 @@ Module {
6060
. . . }
6161
. . }
6262
. . 1: ClassDef {
63-
. . . Roles: TypeDeclaration
63+
. . . Roles: TypeDeclaration,SimpleIdentifier
6464
. . . TOKEN "RobotDog"
6565
. . . StartPosition: {
6666
. . . . Offset: 0

tests/classdef_metaclass_py2.py.uast

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Module {
1010
. }
1111
. Children: {
1212
. . 0: ClassDef {
13-
. . . Roles: TypeDeclaration
13+
. . . Roles: TypeDeclaration,SimpleIdentifier
1414
. . . TOKEN "MySingleton"
1515
. . . StartPosition: {
1616
. . . . Offset: 0

tests/classdef_metaclass_py3.py.uast

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Module {
1010
. }
1111
. Children: {
1212
. . 0: ClassDef {
13-
. . . Roles: TypeDeclaration
13+
. . . Roles: TypeDeclaration,SimpleIdentifier
1414
. . . TOKEN "MySingleton"
1515
. . . StartPosition: {
1616
. . . . Offset: 0
@@ -70,7 +70,7 @@ Module {
7070
. . . }
7171
. . }
7272
. . 1: ClassDef {
73-
. . . Roles: TypeDeclaration
73+
. . . Roles: TypeDeclaration,SimpleIdentifier
7474
. . . TOKEN "MySingleton"
7575
. . . StartPosition: {
7676
. . . . Offset: 0

tests/functiondef_annotated.py.uast

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Module {
1010
. }
1111
. Children: {
1212
. . 0: FunctionDef {
13-
. . . Roles: FunctionDeclaration,FunctionDeclarationName
13+
. . . Roles: FunctionDeclaration,FunctionDeclarationName,SimpleIdentifier
1414
. . . TOKEN "someFunc"
1515
. . . StartPosition: {
1616
. . . . Offset: 0

tests/functiondef_decorated.py.uast

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Module {
1010
. }
1111
. Children: {
1212
. . 0: FunctionDef {
13-
. . . Roles: FunctionDeclaration,FunctionDeclarationName
13+
. . . Roles: FunctionDeclaration,FunctionDeclarationName,SimpleIdentifier
1414
. . . TOKEN "someFunc"
1515
. . . StartPosition: {
1616
. . . . Offset: 0
@@ -76,7 +76,7 @@ Module {
7676
. . . }
7777
. . }
7878
. . 1: FunctionDef {
79-
. . . Roles: FunctionDeclaration,FunctionDeclarationName
79+
. . . Roles: FunctionDeclaration,FunctionDeclarationName,SimpleIdentifier
8080
. . . TOKEN "someFunc"
8181
. . . StartPosition: {
8282
. . . . Offset: 0

tests/functiondef_defaultparams.py.uast

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Module {
1010
. }
1111
. Children: {
1212
. . 0: FunctionDef {
13-
. . . Roles: FunctionDeclaration,FunctionDeclarationName
13+
. . . Roles: FunctionDeclaration,FunctionDeclarationName,SimpleIdentifier
1414
. . . TOKEN "someFunc"
1515
. . . StartPosition: {
1616
. . . . Offset: 0

tests/functiondef_docstring.py.uast

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Module {
1010
. }
1111
. Children: {
1212
. . 0: FunctionDef {
13-
. . . Roles: FunctionDeclaration,FunctionDeclarationName
13+
. . . Roles: FunctionDeclaration,FunctionDeclarationName,SimpleIdentifier
1414
. . . TOKEN "someFunc"
1515
. . . StartPosition: {
1616
. . . . Offset: 0

tests/functiondef_kwarg.py.uast

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Module {
1010
. }
1111
. Children: {
1212
. . 0: FunctionDef {
13-
. . . Roles: FunctionDeclaration,FunctionDeclarationName
13+
. . . Roles: FunctionDeclaration,FunctionDeclarationName,SimpleIdentifier
1414
. . . TOKEN "someFunc"
1515
. . . StartPosition: {
1616
. . . . Offset: 0
@@ -94,7 +94,7 @@ Module {
9494
. . . }
9595
. . }
9696
. . 1: FunctionDef {
97-
. . . Roles: FunctionDeclaration,FunctionDeclarationName
97+
. . . Roles: FunctionDeclaration,FunctionDeclarationName,SimpleIdentifier
9898
. . . TOKEN "someVarMapFunc"
9999
. . . StartPosition: {
100100
. . . . Offset: 0

0 commit comments

Comments
 (0)