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

Commit 48cafaf

Browse files
author
Juanjo Alvarez
committed
Add Module to Modules. Remove Function, Declaration and Call from Arguments
1 parent 3b104f5 commit 48cafaf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+464
-99
lines changed

ANNOTATION.md

Lines changed: 365 additions & 0 deletions
Large diffs are not rendered by default.

driver/normalizer/annotation.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ var Transformers = []transformer.Tranformer{
5353
// https://godoc.org/gopkg.in/bblfsh/sdk.v1/uast/ann
5454
var AnnotationRules = On(Any).Self(
5555
On(Not(pyast.Module)).Error(errors.New("root must be uast.Module")),
56-
On(pyast.Module).Roles(uast.File).Descendants(
56+
On(pyast.Module).Roles(uast.File, uast.Module).Descendants(
5757

5858
// Binary Expressions
5959
On(pyast.BinOp).Roles(uast.Expression, uast.Binary).Children(
@@ -133,10 +133,10 @@ var AnnotationRules = On(Any).Self(
133133
On(pyast.FuncDefBody).Roles(uast.Function, uast.Declaration, uast.Body),
134134
// FIXME: arguments is a Groping node, update it we get a "Grouper" or "Container" role
135135
On(HasInternalRole("arguments")).Roles(uast.Function, uast.Declaration, uast.Argument, uast.Incomplete),
136-
On(HasInternalRole("args")).Roles(uast.Function, uast.Declaration, uast.Argument, uast.Name, uast.Identifier),
137-
On(HasInternalRole("vararg")).Roles(uast.Function, uast.Declaration, uast.Argument, uast.ArgsList, uast.Name, uast.Identifier),
138-
On(HasInternalRole("kwarg")).Roles(uast.Function, uast.Declaration, uast.Argument, uast.ArgsList, uast.Map, uast.Name, uast.Identifier),
139-
On(HasInternalRole("kwonlyargs")).Roles(uast.Function, uast.Declaration, uast.Argument, uast.ArgsList, uast.Map, uast.Name, uast.Identifier),
136+
On(HasInternalRole("args")).Roles(uast.Argument, uast.Name, uast.Identifier),
137+
On(HasInternalRole("vararg")).Roles(uast.Argument, uast.ArgsList, uast.Name, uast.Identifier),
138+
On(HasInternalRole("kwarg")).Roles(uast.Argument, uast.ArgsList, uast.Map, uast.Name, uast.Identifier),
139+
On(HasInternalRole("kwonlyargs")).Roles(uast.Argument, uast.ArgsList, uast.Map, uast.Name, uast.Identifier),
140140
// Default arguments: Python's AST puts default arguments on a sibling list to the one of
141141
// arguments that must be mapped to the arguments right-aligned like:
142142
// a, b=2, c=3 ->
@@ -155,9 +155,9 @@ var AnnotationRules = On(Any).Self(
155155
On(pyast.Name).Roles(uast.Identifier, uast.Qualified)),
156156

157157
On(pyast.Call).Roles(uast.Function, uast.Call, uast.Expression).Children(
158-
On(HasInternalRole("args")).Roles(uast.Call, uast.Argument, uast.Positional),
159-
On(HasInternalRole("keywords")).Roles(uast.Call, uast.Argument, uast.Name).Children(
160-
On(HasInternalRole("value")).Roles(uast.Call, uast.Argument, uast.Value),
158+
On(HasInternalRole("args")).Roles(uast.Argument, uast.Positional),
159+
On(HasInternalRole("keywords")).Roles(uast.Argument, uast.Name).Children(
160+
On(HasInternalRole("value")).Roles(uast.Argument, uast.Value),
161161
),
162162
On(HasInternalRole("func")).Self(
163163
On(pyast.Name).Roles(uast.Call, uast.Callee),

fixtures/annotations.py.uast

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Status: ok
22
Errors:
33
UAST:
44
Module {
5-
. Roles: File
5+
. Roles: File,Module
66
. Children: {
77
. . 0: AnnAssign {
88
. . . Roles: Operator,Binary,Assignment,Comment,Incomplete
@@ -140,15 +140,15 @@ Module {
140140
. . . }
141141
. . . Children: {
142142
. . . . 0: arguments {
143-
. . . . . Roles: Function,Declaration,Argument,Name,Identifier
143+
. . . . . Roles: Argument,Name,Identifier
144144
. . . . . Properties: {
145145
. . . . . . internalRole: args
146146
. . . . . . kwarg: <nil>
147147
. . . . . . vararg: <nil>
148148
. . . . . }
149149
. . . . . Children: {
150150
. . . . . . 0: arg {
151-
. . . . . . . Roles: Function,Declaration,Argument,Name,Identifier
151+
. . . . . . . Roles: Argument,Name,Identifier
152152
. . . . . . . TOKEN "a"
153153
. . . . . . . StartPosition: {
154154
. . . . . . . . Offset: 33
@@ -185,7 +185,7 @@ Module {
185185
. . . . . . . }
186186
. . . . . . }
187187
. . . . . . 1: arg {
188-
. . . . . . . Roles: Function,Declaration,Argument,Name,Identifier
188+
. . . . . . . Roles: Argument,Name,Identifier
189189
. . . . . . . TOKEN "b"
190190
. . . . . . . StartPosition: {
191191
. . . . . . . . Offset: 41

fixtures/aritmeticops.py.uast

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Status: ok
22
Errors:
33
UAST:
44
Module {
5-
. Roles: File
5+
. Roles: File,Module
66
. Children: {
77
. . 0: Expr {
88
. . . Roles: Expression

fixtures/assert_constant.py.uast

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Status: ok
22
Errors:
33
UAST:
44
Module {
5-
. Roles: File
5+
. Roles: File,Module
66
. Children: {
77
. . 0: Assert {
88
. . . Roles: Assert,Statement

fixtures/augassign.py.uast

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Status: ok
22
Errors:
33
UAST:
44
Module {
5-
. Roles: File
5+
. Roles: File,Module
66
. Children: {
77
. . 0: AugAssign {
88
. . . Roles: Operator,Binary,Assignment,Statement

fixtures/bitwise.py.uast

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Status: ok
22
Errors:
33
UAST:
44
Module {
5-
. Roles: File
5+
. Roles: File,Module
66
. Children: {
77
. . 0: Expr {
88
. . . Roles: Expression

fixtures/classdef_decorated.py.uast

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Status: ok
22
Errors:
33
UAST:
44
Module {
5-
. Roles: File
5+
. Roles: File,Module
66
. Children: {
77
. . 0: ClassDef {
88
. . . Roles: Type,Declaration,Identifier,Statement

fixtures/classdef_inheritance.py.uast

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Status: ok
22
Errors:
33
UAST:
44
Module {
5-
. Roles: File
5+
. Roles: File,Module
66
. Children: {
77
. . 0: ClassDef {
88
. . . Roles: Type,Declaration,Identifier,Statement

fixtures/classdef_metaclass_py2.py.uast

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Status: ok
22
Errors:
33
UAST:
44
Module {
5-
. Roles: File
5+
. Roles: File,Module
66
. Children: {
77
. . 0: ClassDef {
88
. . . Roles: Type,Declaration,Identifier,Statement

0 commit comments

Comments
 (0)