|
7 | 7 |
|
8 | 8 | "gopkg.in/bblfsh/sdk.v1/uast" |
9 | 9 | . "gopkg.in/bblfsh/sdk.v1/uast/ann" |
| 10 | + "gopkg.in/bblfsh/sdk.v1/uast/transformer" |
| 11 | + "gopkg.in/bblfsh/sdk.v1/uast/transformer/annotatter" |
| 12 | + "gopkg.in/bblfsh/sdk.v1/uast/transformer/positioner" |
10 | 13 | ) |
11 | 14 |
|
12 | 15 | /* |
@@ -37,7 +40,17 @@ Unmarked nodes or nodes needing new features from the SDK: |
37 | 40 | (see: https://greentreesnakes.readthedocs.io/en/latest/nodes.html#Compare) |
38 | 41 | */ |
39 | 42 |
|
40 | | -// AnnotationRules for the Python driver |
| 43 | +// Transformers is the of list `transformer.Transfomer` to apply to a UAST, to |
| 44 | +// learn more about the Transformers and the available ones take a look to: |
| 45 | +// https://godoc.org/gopkg.in/bblfsh/sdk.v1/uast/transformers |
| 46 | +var Transformers = []transformer.Tranformer{ |
| 47 | + annotatter.NewAnnotatter(AnnotationRules), |
| 48 | + positioner.NewFillOffsetFromLineCol(), |
| 49 | +} |
| 50 | + |
| 51 | +// AnnotationRules describes how a UAST should be annotated with `uast.Role`. |
| 52 | +// |
| 53 | +// https://godoc.org/gopkg.in/bblfsh/sdk.v1/uast/ann |
41 | 54 | var AnnotationRules = On(Any).Self( |
42 | 55 | On(Not(pyast.Module)).Error(errors.New("root must be uast.Module")), |
43 | 56 | On(pyast.Module).Roles(uast.File).Descendants( |
@@ -239,7 +252,7 @@ var AnnotationRules = On(Any).Self( |
239 | 252 | On(pyast.AliasAsName).Roles(uast.Import, uast.Alias, uast.Identifier), |
240 | 253 | On(pyast.ImportFrom).Roles(uast.Import, uast.Declaration, uast.Statement), |
241 | 254 | On(pyast.ClassDef).Roles(uast.Type, uast.Declaration, uast.Identifier, uast.Statement).Children( |
242 | | - On(pyast.ClassDefDecorators).Roles(uast.Type, uast.Call, uast.Incomplete), |
| 255 | + On(pyast.ClassDefDecorators).Roles(uast.Type, uast.Call, uast.Incomplete), |
243 | 256 | On(pyast.ClassDefBody).Roles(uast.Type, uast.Declaration, uast.Body), |
244 | 257 | On(pyast.ClassDefBases).Roles(uast.Type, uast.Declaration, uast.Base), |
245 | 258 | On(pyast.ClassDefKeywords).Roles(uast.Incomplete).Children( |
|
0 commit comments