From 8d7ecb27c9cb1eb42cc5dc2afd6dea426def00ef Mon Sep 17 00:00:00 2001 From: Juanjo Alvarez Date: Wed, 8 Aug 2018 18:35:24 +0200 Subject: [PATCH 1/4] Add missing remaining flow annotations Signed-off-by: Juanjo Alvarez --- driver/normalizer/annotation.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/driver/normalizer/annotation.go b/driver/normalizer/annotation.go index 70dda73..f265122 100644 --- a/driver/normalizer/annotation.go +++ b/driver/normalizer/annotation.go @@ -540,4 +540,7 @@ var Annotations = []Mapping{ AnnotateType("VoidTypeAnnotation", nil, role.Declaration, role.Type, role.Incomplete), AnnotateType("AnyTypeAnnotation", nil, role.Declaration, role.Type, role.Incomplete), AnnotateType("NullableTypeAnnotation", nil, role.Declaration, role.Type, role.Incomplete), + AnnotateType("TypeParameterInstantiation", nil, role.Declaration, role.Type, role.Incomplete), + AnnotateType("ObjectTypeAnnotation", nil, role.Declaration, role.Type, role.Literal, role.Incomplete), + AnnotateType("ObjectTypeProperty", nil, role.Declaration, role.Type, role.Incomplete), } From fdcf7404a5894d785c087be0360c03d679076d18 Mon Sep 17 00:00:00 2001 From: Juanjo Alvarez Date: Thu, 9 Aug 2018 09:35:45 +0200 Subject: [PATCH 2/4] Tests for TypeParameterInstantiation, ObjectTypeAnnotation and ObjectTypeProperty Signed-off-by: Juanjo Alvarez --- fixtures/flow-annotations.js | 8 +- fixtures/flow-annotations.js.native | 858 +++++++++++++++++++++++--- fixtures/flow-annotations.js.sem.uast | 371 ++++++++--- fixtures/flow-annotations.js.uast | 843 ++++++++++++++++++++++--- 4 files changed, 1865 insertions(+), 215 deletions(-) diff --git a/fixtures/flow-annotations.js b/fixtures/flow-annotations.js index cbb7c14..bc1915c 100644 --- a/fixtures/flow-annotations.js +++ b/fixtures/flow-annotations.js @@ -3,9 +3,15 @@ export default class PluginPass { testfnc1(a: string, b: ?string, c: number, d: mixed, e: Object){} testfnc2(f: string | boolean, g: boolean, h: null, i: void){} - testfncd(j: "one" | "other"){} + testfnc3(j: "one" | "other"){} + testfnc_object(node: ?{ + loc?: { start: { line: number, column: number } }, + _loc?: { start: { line: number, column: number } }, + }) {} num: number = 1; s: string = "foo"; pok: File; + _map: Map = Map(); + } diff --git a/fixtures/flow-annotations.js.native b/fixtures/flow-annotations.js.native index 66bc969..f4d62f4 100644 --- a/fixtures/flow-annotations.js.native +++ b/fixtures/flow-annotations.js.native @@ -17,11 +17,11 @@ value: " @flow", }, ], - end: 277, + end: 472, loc: { end: { column: 0, - line: 12, + line: 18, }, start: { column: 0, @@ -666,13 +666,13 @@ column: 12, line: 6, }, - identifierName: "testfncd", + identifierName: "testfnc3", start: { column: 4, line: 6, }, }, - name: "testfncd", + name: "testfnc3", start: 184, type: "Identifier", }, @@ -782,71 +782,623 @@ static: false, type: "ClassMethod", }, + { + async: false, + body: { + body: [], + directives: [], + end: 367, + loc: { + end: { + column: 9, + line: 10, + }, + start: { + column: 7, + line: 10, + }, + }, + start: 365, + type: "BlockStatement", + }, + computed: false, + end: 367, + generator: false, + id: ~, + key: { + end: 233, + loc: { + end: { + column: 18, + line: 7, + }, + identifierName: "testfnc_object", + start: { + column: 4, + line: 7, + }, + }, + name: "testfnc_object", + start: 219, + type: "Identifier", + }, + kind: "method", + loc: { + end: { + column: 9, + line: 10, + }, + start: { + column: 4, + line: 7, + }, + }, + params: [ + { + end: 363, + loc: { + end: { + column: 5, + line: 10, + }, + identifierName: "node", + start: { + column: 19, + line: 7, + }, + }, + name: "node", + start: 234, + type: "Identifier", + typeAnnotation: { + end: 363, + loc: { + end: { + column: 5, + line: 10, + }, + start: { + column: 23, + line: 7, + }, + }, + start: 238, + type: "TypeAnnotation", + typeAnnotation: { + end: 363, + loc: { + end: { + column: 5, + line: 10, + }, + start: { + column: 25, + line: 7, + }, + }, + start: 240, + type: "NullableTypeAnnotation", + typeAnnotation: { + callProperties: [], + end: 363, + exact: false, + indexers: [], + loc: { + end: { + column: 5, + line: 10, + }, + start: { + column: 26, + line: 7, + }, + }, + properties: [ + { + end: 298, + key: { + end: 252, + loc: { + end: { + column: 9, + line: 8, + }, + identifierName: "loc", + start: { + column: 6, + line: 8, + }, + }, + name: "loc", + start: 249, + type: "Identifier", + }, + kind: "init", + loc: { + end: { + column: 55, + line: 8, + }, + start: { + column: 6, + line: 8, + }, + }, + optional: true, + start: 249, + static: false, + type: "ObjectTypeProperty", + value: { + callProperties: [], + end: 298, + exact: false, + indexers: [], + loc: { + end: { + column: 55, + line: 8, + }, + start: { + column: 12, + line: 8, + }, + }, + properties: [ + { + end: 296, + key: { + end: 262, + loc: { + end: { + column: 19, + line: 8, + }, + identifierName: "start", + start: { + column: 14, + line: 8, + }, + }, + name: "start", + start: 257, + type: "Identifier", + }, + kind: "init", + loc: { + end: { + column: 53, + line: 8, + }, + start: { + column: 14, + line: 8, + }, + }, + optional: false, + start: 257, + static: false, + type: "ObjectTypeProperty", + value: { + callProperties: [], + end: 296, + exact: false, + indexers: [], + loc: { + end: { + column: 53, + line: 8, + }, + start: { + column: 21, + line: 8, + }, + }, + properties: [ + { + end: 278, + key: { + end: 270, + loc: { + end: { + column: 27, + line: 8, + }, + identifierName: "line", + start: { + column: 23, + line: 8, + }, + }, + name: "line", + start: 266, + type: "Identifier", + }, + kind: "init", + loc: { + end: { + column: 35, + line: 8, + }, + start: { + column: 23, + line: 8, + }, + }, + optional: false, + start: 266, + static: false, + type: "ObjectTypeProperty", + value: { + end: 278, + loc: { + end: { + column: 35, + line: 8, + }, + start: { + column: 29, + line: 8, + }, + }, + start: 272, + type: "NumberTypeAnnotation", + }, + variance: ~, + }, + { + end: 294, + key: { + end: 286, + loc: { + end: { + column: 43, + line: 8, + }, + identifierName: "column", + start: { + column: 37, + line: 8, + }, + }, + name: "column", + start: 280, + type: "Identifier", + }, + kind: "init", + loc: { + end: { + column: 51, + line: 8, + }, + start: { + column: 37, + line: 8, + }, + }, + optional: false, + start: 280, + static: false, + type: "ObjectTypeProperty", + value: { + end: 294, + loc: { + end: { + column: 51, + line: 8, + }, + start: { + column: 45, + line: 8, + }, + }, + start: 288, + type: "NumberTypeAnnotation", + }, + variance: ~, + }, + ], + start: 264, + type: "ObjectTypeAnnotation", + }, + variance: ~, + }, + ], + start: 255, + type: "ObjectTypeAnnotation", + }, + variance: ~, + }, + { + end: 356, + key: { + end: 310, + loc: { + end: { + column: 10, + line: 9, + }, + identifierName: "_loc", + start: { + column: 6, + line: 9, + }, + }, + name: "_loc", + start: 306, + type: "Identifier", + }, + kind: "init", + loc: { + end: { + column: 56, + line: 9, + }, + start: { + column: 6, + line: 9, + }, + }, + optional: true, + start: 306, + static: false, + type: "ObjectTypeProperty", + value: { + callProperties: [], + end: 356, + exact: false, + indexers: [], + loc: { + end: { + column: 56, + line: 9, + }, + start: { + column: 13, + line: 9, + }, + }, + properties: [ + { + end: 354, + key: { + end: 320, + loc: { + end: { + column: 20, + line: 9, + }, + identifierName: "start", + start: { + column: 15, + line: 9, + }, + }, + name: "start", + start: 315, + type: "Identifier", + }, + kind: "init", + loc: { + end: { + column: 54, + line: 9, + }, + start: { + column: 15, + line: 9, + }, + }, + optional: false, + start: 315, + static: false, + type: "ObjectTypeProperty", + value: { + callProperties: [], + end: 354, + exact: false, + indexers: [], + loc: { + end: { + column: 54, + line: 9, + }, + start: { + column: 22, + line: 9, + }, + }, + properties: [ + { + end: 336, + key: { + end: 328, + loc: { + end: { + column: 28, + line: 9, + }, + identifierName: "line", + start: { + column: 24, + line: 9, + }, + }, + name: "line", + start: 324, + type: "Identifier", + }, + kind: "init", + loc: { + end: { + column: 36, + line: 9, + }, + start: { + column: 24, + line: 9, + }, + }, + optional: false, + start: 324, + static: false, + type: "ObjectTypeProperty", + value: { + end: 336, + loc: { + end: { + column: 36, + line: 9, + }, + start: { + column: 30, + line: 9, + }, + }, + start: 330, + type: "NumberTypeAnnotation", + }, + variance: ~, + }, + { + end: 352, + key: { + end: 344, + loc: { + end: { + column: 44, + line: 9, + }, + identifierName: "column", + start: { + column: 38, + line: 9, + }, + }, + name: "column", + start: 338, + type: "Identifier", + }, + kind: "init", + loc: { + end: { + column: 52, + line: 9, + }, + start: { + column: 38, + line: 9, + }, + }, + optional: false, + start: 338, + static: false, + type: "ObjectTypeProperty", + value: { + end: 352, + loc: { + end: { + column: 52, + line: 9, + }, + start: { + column: 46, + line: 9, + }, + }, + start: 346, + type: "NumberTypeAnnotation", + }, + variance: ~, + }, + ], + start: 322, + type: "ObjectTypeAnnotation", + }, + variance: ~, + }, + ], + start: 313, + type: "ObjectTypeAnnotation", + }, + variance: ~, + }, + ], + start: 241, + type: "ObjectTypeAnnotation", + }, + }, + }, + }, + ], + start: 219, + static: false, + type: "ClassMethod", + }, { computed: false, - end: 236, + end: 389, key: { - end: 223, + end: 376, loc: { end: { column: 7, - line: 8, + line: 12, }, identifierName: "num", start: { column: 4, - line: 8, + line: 12, }, }, name: "num", - start: 220, + start: 373, type: "Identifier", }, loc: { end: { column: 20, - line: 8, + line: 12, }, start: { column: 4, - line: 8, + line: 12, }, }, - start: 220, + start: 373, static: false, type: "ClassProperty", typeAnnotation: { - end: 231, + end: 384, loc: { end: { column: 15, - line: 8, + line: 12, }, start: { column: 7, - line: 8, + line: 12, }, }, - start: 223, + start: 376, type: "TypeAnnotation", typeAnnotation: { - end: 231, + end: 384, loc: { end: { column: 15, - line: 8, + line: 12, }, start: { column: 9, - line: 8, + line: 12, }, }, - start: 225, + start: 378, type: "NumberTypeAnnotation", }, }, value: { - end: 235, + end: 388, extra: { raw: "1", rawValue: 1, @@ -854,14 +1406,14 @@ loc: { end: { column: 19, - line: 8, + line: 12, }, start: { column: 18, - line: 8, + line: 12, }, }, - start: 234, + start: 387, type: "NumericLiteral", value: 1, }, @@ -869,69 +1421,69 @@ }, { computed: false, - end: 259, + end: 412, key: { - end: 242, + end: 395, loc: { end: { column: 5, - line: 9, + line: 13, }, identifierName: "s", start: { column: 4, - line: 9, + line: 13, }, }, name: "s", - start: 241, + start: 394, type: "Identifier", }, loc: { end: { column: 22, - line: 9, + line: 13, }, start: { column: 4, - line: 9, + line: 13, }, }, - start: 241, + start: 394, static: false, type: "ClassProperty", typeAnnotation: { - end: 250, + end: 403, loc: { end: { column: 13, - line: 9, + line: 13, }, start: { column: 5, - line: 9, + line: 13, }, }, - start: 242, + start: 395, type: "TypeAnnotation", typeAnnotation: { - end: 250, + end: 403, loc: { end: { column: 13, - line: 9, + line: 13, }, start: { column: 7, - line: 9, + line: 13, }, }, - start: 244, + start: 397, type: "StringTypeAnnotation", }, }, value: { - end: 258, + end: 411, extra: { raw: "\"foo\"", rawValue: "foo", @@ -939,14 +1491,14 @@ loc: { end: { column: 21, - line: 9, + line: 13, }, start: { column: 16, - line: 9, + line: 13, }, }, - start: 253, + start: 406, type: "StringLiteral", value: "foo", }, @@ -954,81 +1506,81 @@ }, { computed: false, - end: 274, + end: 427, key: { - end: 267, + end: 420, loc: { end: { column: 7, - line: 10, + line: 14, }, identifierName: "pok", start: { column: 4, - line: 10, + line: 14, }, }, name: "pok", - start: 264, + start: 417, type: "Identifier", }, loc: { end: { column: 14, - line: 10, + line: 14, }, start: { column: 4, - line: 10, + line: 14, }, }, - start: 264, + start: 417, static: false, type: "ClassProperty", typeAnnotation: { - end: 273, + end: 426, loc: { end: { column: 13, - line: 10, + line: 14, }, start: { column: 7, - line: 10, + line: 14, }, }, - start: 267, + start: 420, type: "TypeAnnotation", typeAnnotation: { - end: 273, + end: 426, id: { - end: 273, + end: 426, loc: { end: { column: 13, - line: 10, + line: 14, }, identifierName: "File", start: { column: 9, - line: 10, + line: 14, }, }, name: "File", - start: 269, + start: 422, type: "Identifier", }, loc: { end: { column: 13, - line: 10, + line: 14, }, start: { column: 9, - line: 10, + line: 14, }, }, - start: 269, + start: 422, type: "GenericTypeAnnotation", typeParameters: ~, }, @@ -1036,12 +1588,174 @@ value: ~, variance: ~, }, + { + computed: false, + end: 464, + key: { + end: 436, + loc: { + end: { + column: 8, + line: 15, + }, + identifierName: "_map", + start: { + column: 4, + line: 15, + }, + }, + name: "_map", + start: 432, + type: "Identifier", + }, + loc: { + end: { + column: 36, + line: 15, + }, + start: { + column: 4, + line: 15, + }, + }, + start: 432, + static: false, + type: "ClassProperty", + typeAnnotation: { + end: 455, + loc: { + end: { + column: 27, + line: 15, + }, + start: { + column: 8, + line: 15, + }, + }, + start: 436, + type: "TypeAnnotation", + typeAnnotation: { + end: 455, + id: { + end: 441, + loc: { + end: { + column: 13, + line: 15, + }, + identifierName: "Map", + start: { + column: 10, + line: 15, + }, + }, + name: "Map", + start: 438, + type: "Identifier", + }, + loc: { + end: { + column: 27, + line: 15, + }, + start: { + column: 10, + line: 15, + }, + }, + start: 438, + type: "GenericTypeAnnotation", + typeParameters: { + end: 455, + loc: { + end: { + column: 27, + line: 15, + }, + start: { + column: 13, + line: 15, + }, + }, + params: [ + { + end: 447, + loc: { + end: { + column: 19, + line: 15, + }, + start: { + column: 14, + line: 15, + }, + }, + start: 442, + type: "MixedTypeAnnotation", + }, + { + end: 454, + loc: { + end: { + column: 26, + line: 15, + }, + start: { + column: 21, + line: 15, + }, + }, + start: 449, + type: "MixedTypeAnnotation", + }, + ], + start: 441, + type: "TypeParameterInstantiation", + }, + }, + }, + value: { + arguments: [], + callee: { + end: 461, + loc: { + end: { + column: 33, + line: 15, + }, + identifierName: "Map", + start: { + column: 30, + line: 15, + }, + }, + name: "Map", + start: 458, + type: "Identifier", + }, + end: 463, + loc: { + end: { + column: 35, + line: 15, + }, + start: { + column: 30, + line: 15, + }, + }, + start: 458, + type: "CallExpression", + }, + variance: ~, + }, ], - end: 276, + end: 471, loc: { end: { column: 1, - line: 11, + line: 17, }, start: { column: 32, @@ -1051,7 +1765,7 @@ start: 42, type: "ClassBody", }, - end: 276, + end: 471, id: { end: 41, leadingComments: ~, @@ -1074,7 +1788,7 @@ loc: { end: { column: 1, - line: 11, + line: 17, }, start: { column: 15, @@ -1085,7 +1799,7 @@ superClass: ~, type: "ClassDeclaration", }, - end: 276, + end: 471, leadingComments: [ { end: 8, @@ -1107,7 +1821,7 @@ loc: { end: { column: 1, - line: 11, + line: 17, }, start: { column: 0, @@ -1119,11 +1833,11 @@ }, ], directives: [], - end: 277, + end: 472, loc: { end: { column: 0, - line: 12, + line: 18, }, start: { column: 0, diff --git a/fixtures/flow-annotations.js.sem.uast b/fixtures/flow-annotations.js.sem.uast index ff26b06..ebac1f2 100644 --- a/fixtures/flow-annotations.js.sem.uast +++ b/fixtures/flow-annotations.js.sem.uast @@ -7,8 +7,8 @@ col: 1, }, end: { '@type': "uast:Position", - offset: 277, - line: 12, + offset: 472, + line: 18, col: 1, }, }, @@ -42,8 +42,8 @@ col: 1, }, end: { '@type': "uast:Position", - offset: 277, - line: 12, + offset: 472, + line: 18, col: 1, }, }, @@ -57,8 +57,8 @@ col: 1, }, end: { '@type': "uast:Position", - offset: 276, - line: 11, + offset: 471, + line: 17, col: 2, }, }, @@ -71,8 +71,8 @@ col: 16, }, end: { '@type': "uast:Position", - offset: 276, - line: 11, + offset: 471, + line: 17, col: 2, }, }, @@ -85,8 +85,8 @@ col: 33, }, end: { '@type': "uast:Position", - offset: 276, - line: 11, + offset: 471, + line: 17, col: 2, }, }, @@ -393,7 +393,7 @@ col: 13, }, }, - Name: "testfncd", + Name: "testfnc3", }, kind: "method", params: [ @@ -416,17 +416,88 @@ ], static: false, }, + { '@type': "ClassMethod", + '@role': [Declaration, Function, Statement], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 219, + line: 7, + col: 5, + }, + end: { '@type': "uast:Position", + offset: 367, + line: 10, + col: 10, + }, + }, + async: false, + body: { '@type': "uast:Block", + '@role': [Body, Function, Value], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 365, + line: 10, + col: 8, + }, + end: { '@type': "uast:Position", + offset: 367, + line: 10, + col: 10, + }, + }, + Statements: [], + }, + computed: false, + generator: false, + id: ~, + key: { '@type': "uast:Identifier", + '@role': [Key, Name], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 219, + line: 7, + col: 5, + }, + end: { '@type': "uast:Position", + offset: 233, + line: 7, + col: 19, + }, + }, + Name: "testfnc_object", + }, + kind: "method", + params: [ + { '@type': "uast:Identifier", + '@role': [Argument, Function], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 234, + line: 7, + col: 20, + }, + end: { '@type': "uast:Position", + offset: 363, + line: 10, + col: 6, + }, + }, + Name: "node", + }, + ], + static: false, + }, { '@type': "ClassProperty", '@role': [Variable], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 220, - line: 8, + offset: 373, + line: 12, col: 5, }, end: { '@type': "uast:Position", - offset: 236, - line: 8, + offset: 389, + line: 12, col: 21, }, }, @@ -435,13 +506,13 @@ '@role': [Key, Name], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 220, - line: 8, + offset: 373, + line: 12, col: 5, }, end: { '@type': "uast:Position", - offset: 223, - line: 8, + offset: 376, + line: 12, col: 8, }, }, @@ -452,13 +523,13 @@ '@role': [Declaration, Type], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 223, - line: 8, + offset: 376, + line: 12, col: 8, }, end: { '@type': "uast:Position", - offset: 231, - line: 8, + offset: 384, + line: 12, col: 16, }, }, @@ -466,13 +537,13 @@ '@role': [Declaration, Number, Type], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 225, - line: 8, + offset: 378, + line: 12, col: 10, }, end: { '@type': "uast:Position", - offset: 231, - line: 8, + offset: 384, + line: 12, col: 16, }, }, @@ -483,13 +554,13 @@ '@role': [Expression, Initialization, Literal, Number, Value], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 234, - line: 8, + offset: 387, + line: 12, col: 19, }, end: { '@type': "uast:Position", - offset: 235, - line: 8, + offset: 388, + line: 12, col: 20, }, }, @@ -500,13 +571,13 @@ '@role': [Variable], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 241, - line: 9, + offset: 394, + line: 13, col: 5, }, end: { '@type': "uast:Position", - offset: 259, - line: 9, + offset: 412, + line: 13, col: 23, }, }, @@ -515,13 +586,13 @@ '@role': [Key, Name], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 241, - line: 9, + offset: 394, + line: 13, col: 5, }, end: { '@type': "uast:Position", - offset: 242, - line: 9, + offset: 395, + line: 13, col: 6, }, }, @@ -532,13 +603,13 @@ '@role': [Declaration, Type], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 242, - line: 9, + offset: 395, + line: 13, col: 6, }, end: { '@type': "uast:Position", - offset: 250, - line: 9, + offset: 403, + line: 13, col: 14, }, }, @@ -546,13 +617,13 @@ '@role': [Declaration, String, Type], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 244, - line: 9, + offset: 397, + line: 13, col: 8, }, end: { '@type': "uast:Position", - offset: 250, - line: 9, + offset: 403, + line: 13, col: 14, }, }, @@ -562,13 +633,13 @@ '@role': [Initialization, Value], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 253, - line: 9, + offset: 406, + line: 13, col: 17, }, end: { '@type': "uast:Position", - offset: 258, - line: 9, + offset: 411, + line: 13, col: 22, }, }, @@ -581,13 +652,13 @@ '@role': [Variable], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 264, - line: 10, + offset: 417, + line: 14, col: 5, }, end: { '@type': "uast:Position", - offset: 274, - line: 10, + offset: 427, + line: 14, col: 15, }, }, @@ -596,13 +667,13 @@ '@role': [Key, Name], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 264, - line: 10, + offset: 417, + line: 14, col: 5, }, end: { '@type': "uast:Position", - offset: 267, - line: 10, + offset: 420, + line: 14, col: 8, }, }, @@ -613,13 +684,13 @@ '@role': [Declaration, Type], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 267, - line: 10, + offset: 420, + line: 14, col: 8, }, end: { '@type': "uast:Position", - offset: 273, - line: 10, + offset: 426, + line: 14, col: 14, }, }, @@ -627,26 +698,26 @@ '@role': [Declaration, Type], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 269, - line: 10, + offset: 422, + line: 14, col: 10, }, end: { '@type': "uast:Position", - offset: 273, - line: 10, + offset: 426, + line: 14, col: 14, }, }, id: { '@type': "uast:Identifier", '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 269, - line: 10, + offset: 422, + line: 14, col: 10, }, end: { '@type': "uast:Position", - offset: 273, - line: 10, + offset: 426, + line: 14, col: 14, }, }, @@ -658,6 +729,164 @@ value: ~, variance: ~, }, + { '@type': "ClassProperty", + '@role': [Variable], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 432, + line: 15, + col: 5, + }, + end: { '@type': "uast:Position", + offset: 464, + line: 15, + col: 37, + }, + }, + computed: false, + key: { '@type': "uast:Identifier", + '@role': [Key, Name], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 432, + line: 15, + col: 5, + }, + end: { '@type': "uast:Position", + offset: 436, + line: 15, + col: 9, + }, + }, + Name: "_map", + }, + static: false, + typeAnnotation: { '@type': "TypeAnnotation", + '@role': [Declaration, Type], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 436, + line: 15, + col: 9, + }, + end: { '@type': "uast:Position", + offset: 455, + line: 15, + col: 28, + }, + }, + typeAnnotation: { '@type': "GenericTypeAnnotation", + '@role': [Declaration, Type], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 438, + line: 15, + col: 11, + }, + end: { '@type': "uast:Position", + offset: 455, + line: 15, + col: 28, + }, + }, + id: { '@type': "uast:Identifier", + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 438, + line: 15, + col: 11, + }, + end: { '@type': "uast:Position", + offset: 441, + line: 15, + col: 14, + }, + }, + Name: "Map", + }, + typeParameters: { '@type': "TypeParameterInstantiation", + '@role': [Declaration, Incomplete, Type], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 441, + line: 15, + col: 14, + }, + end: { '@type': "uast:Position", + offset: 455, + line: 15, + col: 28, + }, + }, + params: [ + { '@type': "MixedTypeAnnotation", + '@role': [Declaration, Type], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 442, + line: 15, + col: 15, + }, + end: { '@type': "uast:Position", + offset: 447, + line: 15, + col: 20, + }, + }, + }, + { '@type': "MixedTypeAnnotation", + '@role': [Declaration, Type], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 449, + line: 15, + col: 22, + }, + end: { '@type': "uast:Position", + offset: 454, + line: 15, + col: 27, + }, + }, + }, + ], + }, + }, + }, + value: { '@type': "CallExpression", + '@role': [Call, Expression, Initialization, Value], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 458, + line: 15, + col: 31, + }, + end: { '@type': "uast:Position", + offset: 463, + line: 15, + col: 36, + }, + }, + arguments: [], + callee: { '@type': "uast:Identifier", + '@role': [Call, Callee], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 458, + line: 15, + col: 31, + }, + end: { '@type': "uast:Position", + offset: 461, + line: 15, + col: 34, + }, + }, + Name: "Map", + }, + }, + variance: ~, + }, ], }, id: { '@type': "uast:Identifier", diff --git a/fixtures/flow-annotations.js.uast b/fixtures/flow-annotations.js.uast index f1e2e94..37bad22 100644 --- a/fixtures/flow-annotations.js.uast +++ b/fixtures/flow-annotations.js.uast @@ -7,8 +7,8 @@ col: 1, }, end: { '@type': "uast:Position", - offset: 277, - line: 12, + offset: 472, + line: 18, col: 1, }, }, @@ -39,8 +39,8 @@ col: 1, }, end: { '@type': "uast:Position", - offset: 277, - line: 12, + offset: 472, + line: 18, col: 1, }, }, @@ -54,8 +54,8 @@ col: 1, }, end: { '@type': "uast:Position", - offset: 276, - line: 11, + offset: 471, + line: 17, col: 2, }, }, @@ -68,8 +68,8 @@ col: 16, }, end: { '@type': "uast:Position", - offset: 276, - line: 11, + offset: 471, + line: 17, col: 2, }, }, @@ -82,8 +82,8 @@ col: 33, }, end: { '@type': "uast:Position", - offset: 276, - line: 11, + offset: 471, + line: 17, col: 2, }, }, @@ -714,7 +714,7 @@ generator: false, id: ~, key: { '@type': "Identifier", - '@token': "testfncd", + '@token': "testfnc3", '@role': [Expression, Identifier, Key, Name], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", @@ -814,17 +814,559 @@ ], static: false, }, + { '@type': "ClassMethod", + '@role': [Declaration, Function, Statement], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 219, + line: 7, + col: 5, + }, + end: { '@type': "uast:Position", + offset: 367, + line: 10, + col: 10, + }, + }, + async: false, + body: { '@type': "BlockStatement", + '@role': [Block, Body, Function, Scope, Statement, Value], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 365, + line: 10, + col: 8, + }, + end: { '@type': "uast:Position", + offset: 367, + line: 10, + col: 10, + }, + }, + body: [], + directives: [], + }, + computed: false, + generator: false, + id: ~, + key: { '@type': "Identifier", + '@token': "testfnc_object", + '@role': [Expression, Identifier, Key, Name], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 219, + line: 7, + col: 5, + }, + end: { '@type': "uast:Position", + offset: 233, + line: 7, + col: 19, + }, + }, + }, + kind: "method", + params: [ + { '@type': "Identifier", + '@token': "node", + '@role': [Argument, Expression, Function, Identifier], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 234, + line: 7, + col: 20, + }, + end: { '@type': "uast:Position", + offset: 363, + line: 10, + col: 6, + }, + }, + typeAnnotation: { '@type': "TypeAnnotation", + '@role': [Declaration, Type], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 238, + line: 7, + col: 24, + }, + end: { '@type': "uast:Position", + offset: 363, + line: 10, + col: 6, + }, + }, + typeAnnotation: { '@type': "NullableTypeAnnotation", + '@role': [Declaration, Incomplete, Type], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 240, + line: 7, + col: 26, + }, + end: { '@type': "uast:Position", + offset: 363, + line: 10, + col: 6, + }, + }, + typeAnnotation: { '@type': "ObjectTypeAnnotation", + '@role': [Declaration, Incomplete, Literal, Type], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 241, + line: 7, + col: 27, + }, + end: { '@type': "uast:Position", + offset: 363, + line: 10, + col: 6, + }, + }, + callProperties: [], + exact: false, + indexers: [], + properties: [ + { '@type': "ObjectTypeProperty", + '@role': [Declaration, Incomplete, Type], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 249, + line: 8, + col: 7, + }, + end: { '@type': "uast:Position", + offset: 298, + line: 8, + col: 56, + }, + }, + key: { '@type': "Identifier", + '@token': "loc", + '@role': [Expression, Identifier], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 249, + line: 8, + col: 7, + }, + end: { '@type': "uast:Position", + offset: 252, + line: 8, + col: 10, + }, + }, + }, + kind: "init", + optional: true, + static: false, + value: { '@type': "ObjectTypeAnnotation", + '@role': [Declaration, Incomplete, Literal, Type], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 255, + line: 8, + col: 13, + }, + end: { '@type': "uast:Position", + offset: 298, + line: 8, + col: 56, + }, + }, + callProperties: [], + exact: false, + indexers: [], + properties: [ + { '@type': "ObjectTypeProperty", + '@role': [Declaration, Incomplete, Type], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 257, + line: 8, + col: 15, + }, + end: { '@type': "uast:Position", + offset: 296, + line: 8, + col: 54, + }, + }, + key: { '@type': "Identifier", + '@token': "start", + '@role': [Expression, Identifier], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 257, + line: 8, + col: 15, + }, + end: { '@type': "uast:Position", + offset: 262, + line: 8, + col: 20, + }, + }, + }, + kind: "init", + optional: false, + static: false, + value: { '@type': "ObjectTypeAnnotation", + '@role': [Declaration, Incomplete, Literal, Type], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 264, + line: 8, + col: 22, + }, + end: { '@type': "uast:Position", + offset: 296, + line: 8, + col: 54, + }, + }, + callProperties: [], + exact: false, + indexers: [], + properties: [ + { '@type': "ObjectTypeProperty", + '@role': [Declaration, Incomplete, Type], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 266, + line: 8, + col: 24, + }, + end: { '@type': "uast:Position", + offset: 278, + line: 8, + col: 36, + }, + }, + key: { '@type': "Identifier", + '@token': "line", + '@role': [Expression, Identifier], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 266, + line: 8, + col: 24, + }, + end: { '@type': "uast:Position", + offset: 270, + line: 8, + col: 28, + }, + }, + }, + kind: "init", + optional: false, + static: false, + value: { '@type': "NumberTypeAnnotation", + '@role': [Declaration, Number, Type], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 272, + line: 8, + col: 30, + }, + end: { '@type': "uast:Position", + offset: 278, + line: 8, + col: 36, + }, + }, + }, + variance: ~, + }, + { '@type': "ObjectTypeProperty", + '@role': [Declaration, Incomplete, Type], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 280, + line: 8, + col: 38, + }, + end: { '@type': "uast:Position", + offset: 294, + line: 8, + col: 52, + }, + }, + key: { '@type': "Identifier", + '@token': "column", + '@role': [Expression, Identifier], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 280, + line: 8, + col: 38, + }, + end: { '@type': "uast:Position", + offset: 286, + line: 8, + col: 44, + }, + }, + }, + kind: "init", + optional: false, + static: false, + value: { '@type': "NumberTypeAnnotation", + '@role': [Declaration, Number, Type], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 288, + line: 8, + col: 46, + }, + end: { '@type': "uast:Position", + offset: 294, + line: 8, + col: 52, + }, + }, + }, + variance: ~, + }, + ], + }, + variance: ~, + }, + ], + }, + variance: ~, + }, + { '@type': "ObjectTypeProperty", + '@role': [Declaration, Incomplete, Type], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 306, + line: 9, + col: 7, + }, + end: { '@type': "uast:Position", + offset: 356, + line: 9, + col: 57, + }, + }, + key: { '@type': "Identifier", + '@token': "_loc", + '@role': [Expression, Identifier], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 306, + line: 9, + col: 7, + }, + end: { '@type': "uast:Position", + offset: 310, + line: 9, + col: 11, + }, + }, + }, + kind: "init", + optional: true, + static: false, + value: { '@type': "ObjectTypeAnnotation", + '@role': [Declaration, Incomplete, Literal, Type], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 313, + line: 9, + col: 14, + }, + end: { '@type': "uast:Position", + offset: 356, + line: 9, + col: 57, + }, + }, + callProperties: [], + exact: false, + indexers: [], + properties: [ + { '@type': "ObjectTypeProperty", + '@role': [Declaration, Incomplete, Type], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 315, + line: 9, + col: 16, + }, + end: { '@type': "uast:Position", + offset: 354, + line: 9, + col: 55, + }, + }, + key: { '@type': "Identifier", + '@token': "start", + '@role': [Expression, Identifier], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 315, + line: 9, + col: 16, + }, + end: { '@type': "uast:Position", + offset: 320, + line: 9, + col: 21, + }, + }, + }, + kind: "init", + optional: false, + static: false, + value: { '@type': "ObjectTypeAnnotation", + '@role': [Declaration, Incomplete, Literal, Type], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 322, + line: 9, + col: 23, + }, + end: { '@type': "uast:Position", + offset: 354, + line: 9, + col: 55, + }, + }, + callProperties: [], + exact: false, + indexers: [], + properties: [ + { '@type': "ObjectTypeProperty", + '@role': [Declaration, Incomplete, Type], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 324, + line: 9, + col: 25, + }, + end: { '@type': "uast:Position", + offset: 336, + line: 9, + col: 37, + }, + }, + key: { '@type': "Identifier", + '@token': "line", + '@role': [Expression, Identifier], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 324, + line: 9, + col: 25, + }, + end: { '@type': "uast:Position", + offset: 328, + line: 9, + col: 29, + }, + }, + }, + kind: "init", + optional: false, + static: false, + value: { '@type': "NumberTypeAnnotation", + '@role': [Declaration, Number, Type], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 330, + line: 9, + col: 31, + }, + end: { '@type': "uast:Position", + offset: 336, + line: 9, + col: 37, + }, + }, + }, + variance: ~, + }, + { '@type': "ObjectTypeProperty", + '@role': [Declaration, Incomplete, Type], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 338, + line: 9, + col: 39, + }, + end: { '@type': "uast:Position", + offset: 352, + line: 9, + col: 53, + }, + }, + key: { '@type': "Identifier", + '@token': "column", + '@role': [Expression, Identifier], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 338, + line: 9, + col: 39, + }, + end: { '@type': "uast:Position", + offset: 344, + line: 9, + col: 45, + }, + }, + }, + kind: "init", + optional: false, + static: false, + value: { '@type': "NumberTypeAnnotation", + '@role': [Declaration, Number, Type], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 346, + line: 9, + col: 47, + }, + end: { '@type': "uast:Position", + offset: 352, + line: 9, + col: 53, + }, + }, + }, + variance: ~, + }, + ], + }, + variance: ~, + }, + ], + }, + variance: ~, + }, + ], + }, + }, + }, + }, + ], + static: false, + }, { '@type': "ClassProperty", '@role': [Variable], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 220, - line: 8, + offset: 373, + line: 12, col: 5, }, end: { '@type': "uast:Position", - offset: 236, - line: 8, + offset: 389, + line: 12, col: 21, }, }, @@ -834,13 +1376,13 @@ '@role': [Expression, Identifier, Key, Name], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 220, - line: 8, + offset: 373, + line: 12, col: 5, }, end: { '@type': "uast:Position", - offset: 223, - line: 8, + offset: 376, + line: 12, col: 8, }, }, @@ -850,13 +1392,13 @@ '@role': [Declaration, Type], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 223, - line: 8, + offset: 376, + line: 12, col: 8, }, end: { '@type': "uast:Position", - offset: 231, - line: 8, + offset: 384, + line: 12, col: 16, }, }, @@ -864,13 +1406,13 @@ '@role': [Declaration, Number, Type], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 225, - line: 8, + offset: 378, + line: 12, col: 10, }, end: { '@type': "uast:Position", - offset: 231, - line: 8, + offset: 384, + line: 12, col: 16, }, }, @@ -881,13 +1423,13 @@ '@role': [Expression, Initialization, Literal, Number, Value], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 234, - line: 8, + offset: 387, + line: 12, col: 19, }, end: { '@type': "uast:Position", - offset: 235, - line: 8, + offset: 388, + line: 12, col: 20, }, }, @@ -898,13 +1440,13 @@ '@role': [Variable], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 241, - line: 9, + offset: 394, + line: 13, col: 5, }, end: { '@type': "uast:Position", - offset: 259, - line: 9, + offset: 412, + line: 13, col: 23, }, }, @@ -914,13 +1456,13 @@ '@role': [Expression, Identifier, Key, Name], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 241, - line: 9, + offset: 394, + line: 13, col: 5, }, end: { '@type': "uast:Position", - offset: 242, - line: 9, + offset: 395, + line: 13, col: 6, }, }, @@ -930,13 +1472,13 @@ '@role': [Declaration, Type], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 242, - line: 9, + offset: 395, + line: 13, col: 6, }, end: { '@type': "uast:Position", - offset: 250, - line: 9, + offset: 403, + line: 13, col: 14, }, }, @@ -944,13 +1486,13 @@ '@role': [Declaration, String, Type], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 244, - line: 9, + offset: 397, + line: 13, col: 8, }, end: { '@type': "uast:Position", - offset: 250, - line: 9, + offset: 403, + line: 13, col: 14, }, }, @@ -961,13 +1503,13 @@ '@role': [Expression, Initialization, Literal, String, Value], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 253, - line: 9, + offset: 406, + line: 13, col: 17, }, end: { '@type': "uast:Position", - offset: 258, - line: 9, + offset: 411, + line: 13, col: 22, }, }, @@ -978,13 +1520,13 @@ '@role': [Variable], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 264, - line: 10, + offset: 417, + line: 14, col: 5, }, end: { '@type': "uast:Position", - offset: 274, - line: 10, + offset: 427, + line: 14, col: 15, }, }, @@ -994,13 +1536,13 @@ '@role': [Expression, Identifier, Key, Name], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 264, - line: 10, + offset: 417, + line: 14, col: 5, }, end: { '@type': "uast:Position", - offset: 267, - line: 10, + offset: 420, + line: 14, col: 8, }, }, @@ -1010,13 +1552,13 @@ '@role': [Declaration, Type], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 267, - line: 10, + offset: 420, + line: 14, col: 8, }, end: { '@type': "uast:Position", - offset: 273, - line: 10, + offset: 426, + line: 14, col: 14, }, }, @@ -1024,13 +1566,13 @@ '@role': [Declaration, Type], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 269, - line: 10, + offset: 422, + line: 14, col: 10, }, end: { '@type': "uast:Position", - offset: 273, - line: 10, + offset: 426, + line: 14, col: 14, }, }, @@ -1039,13 +1581,13 @@ '@role': [Expression, Identifier], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 269, - line: 10, + offset: 422, + line: 14, col: 10, }, end: { '@type': "uast:Position", - offset: 273, - line: 10, + offset: 426, + line: 14, col: 14, }, }, @@ -1056,6 +1598,165 @@ value: ~, variance: ~, }, + { '@type': "ClassProperty", + '@role': [Variable], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 432, + line: 15, + col: 5, + }, + end: { '@type': "uast:Position", + offset: 464, + line: 15, + col: 37, + }, + }, + computed: false, + key: { '@type': "Identifier", + '@token': "_map", + '@role': [Expression, Identifier, Key, Name], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 432, + line: 15, + col: 5, + }, + end: { '@type': "uast:Position", + offset: 436, + line: 15, + col: 9, + }, + }, + }, + static: false, + typeAnnotation: { '@type': "TypeAnnotation", + '@role': [Declaration, Type], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 436, + line: 15, + col: 9, + }, + end: { '@type': "uast:Position", + offset: 455, + line: 15, + col: 28, + }, + }, + typeAnnotation: { '@type': "GenericTypeAnnotation", + '@role': [Declaration, Type], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 438, + line: 15, + col: 11, + }, + end: { '@type': "uast:Position", + offset: 455, + line: 15, + col: 28, + }, + }, + id: { '@type': "Identifier", + '@token': "Map", + '@role': [Expression, Identifier], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 438, + line: 15, + col: 11, + }, + end: { '@type': "uast:Position", + offset: 441, + line: 15, + col: 14, + }, + }, + }, + typeParameters: { '@type': "TypeParameterInstantiation", + '@role': [Declaration, Incomplete, Type], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 441, + line: 15, + col: 14, + }, + end: { '@type': "uast:Position", + offset: 455, + line: 15, + col: 28, + }, + }, + params: [ + { '@type': "MixedTypeAnnotation", + '@role': [Declaration, Type], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 442, + line: 15, + col: 15, + }, + end: { '@type': "uast:Position", + offset: 447, + line: 15, + col: 20, + }, + }, + }, + { '@type': "MixedTypeAnnotation", + '@role': [Declaration, Type], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 449, + line: 15, + col: 22, + }, + end: { '@type': "uast:Position", + offset: 454, + line: 15, + col: 27, + }, + }, + }, + ], + }, + }, + }, + value: { '@type': "CallExpression", + '@role': [Call, Expression, Initialization, Value], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 458, + line: 15, + col: 31, + }, + end: { '@type': "uast:Position", + offset: 463, + line: 15, + col: 36, + }, + }, + arguments: [], + callee: { '@type': "Identifier", + '@token': "Map", + '@role': [Call, Callee, Expression, Identifier], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 458, + line: 15, + col: 31, + }, + end: { '@type': "uast:Position", + offset: 461, + line: 15, + col: 34, + }, + }, + }, + }, + variance: ~, + }, ], }, id: { '@type': "Identifier", From 3171a3007876be32274b6012f149d282e69e1e91 Mon Sep 17 00:00:00 2001 From: Juanjo Alvarez Date: Thu, 9 Aug 2018 09:46:57 +0200 Subject: [PATCH 3/4] Add TypeofTypeAnnotation plus test Signed-off-by: Juanjo Alvarez --- driver/normalizer/annotation.go | 2 + fixtures/flow-annotations.js | 1 + fixtures/flow-annotations.js.native | 358 ++++++++++++++++++-------- fixtures/flow-annotations.js.sem.uast | 291 +++++++++++++-------- fixtures/flow-annotations.js.uast | 355 +++++++++++++++++-------- 5 files changed, 677 insertions(+), 330 deletions(-) diff --git a/driver/normalizer/annotation.go b/driver/normalizer/annotation.go index f265122..f827cda 100644 --- a/driver/normalizer/annotation.go +++ b/driver/normalizer/annotation.go @@ -543,4 +543,6 @@ var Annotations = []Mapping{ AnnotateType("TypeParameterInstantiation", nil, role.Declaration, role.Type, role.Incomplete), AnnotateType("ObjectTypeAnnotation", nil, role.Declaration, role.Type, role.Literal, role.Incomplete), AnnotateType("ObjectTypeProperty", nil, role.Declaration, role.Type, role.Incomplete), + AnnotateType("TypeofTypeAnnotation", nil, role.Declaration, role.Type, role.Incomplete), + AnnotateType("FunctionTypeAnnotation", nil, role.Declaration, role.Type, role.Incomplete), } diff --git a/fixtures/flow-annotations.js b/fixtures/flow-annotations.js index bc1915c..1090392 100644 --- a/fixtures/flow-annotations.js +++ b/fixtures/flow-annotations.js @@ -8,6 +8,7 @@ export default class PluginPass { loc?: { start: { line: number, column: number } }, _loc?: { start: { line: number, column: number } }, }) {} + testfnc_typeof(Error?: typeof Error) {} num: number = 1; s: string = "foo"; diff --git a/fixtures/flow-annotations.js.native b/fixtures/flow-annotations.js.native index f4d62f4..98db8fc 100644 --- a/fixtures/flow-annotations.js.native +++ b/fixtures/flow-annotations.js.native @@ -17,11 +17,11 @@ value: " @flow", }, ], - end: 472, + end: 516, loc: { end: { column: 0, - line: 18, + line: 19, }, start: { column: 0, @@ -1335,70 +1335,208 @@ type: "ClassMethod", }, { + async: false, + body: { + body: [], + directives: [], + end: 411, + loc: { + end: { + column: 43, + line: 11, + }, + start: { + column: 41, + line: 11, + }, + }, + start: 409, + type: "BlockStatement", + }, computed: false, - end: 389, + end: 411, + generator: false, + id: ~, key: { - end: 376, + end: 386, + loc: { + end: { + column: 18, + line: 11, + }, + identifierName: "testfnc_typeof", + start: { + column: 4, + line: 11, + }, + }, + name: "testfnc_typeof", + start: 372, + type: "Identifier", + }, + kind: "method", + loc: { + end: { + column: 43, + line: 11, + }, + start: { + column: 4, + line: 11, + }, + }, + params: [ + { + end: 407, + loc: { + end: { + column: 39, + line: 11, + }, + identifierName: "Error", + start: { + column: 19, + line: 11, + }, + }, + name: "Error", + optional: true, + start: 387, + type: "Identifier", + typeAnnotation: { + end: 407, + loc: { + end: { + column: 39, + line: 11, + }, + start: { + column: 25, + line: 11, + }, + }, + start: 393, + type: "TypeAnnotation", + typeAnnotation: { + argument: { + end: 407, + id: { + end: 407, + loc: { + end: { + column: 39, + line: 11, + }, + identifierName: "Error", + start: { + column: 34, + line: 11, + }, + }, + name: "Error", + start: 402, + type: "Identifier", + }, + loc: { + end: { + column: 39, + line: 11, + }, + start: { + column: 34, + line: 11, + }, + }, + start: 402, + type: "GenericTypeAnnotation", + typeParameters: ~, + }, + end: 407, + loc: { + end: { + column: 39, + line: 11, + }, + start: { + column: 27, + line: 11, + }, + }, + start: 395, + type: "TypeofTypeAnnotation", + }, + }, + }, + ], + start: 372, + static: false, + type: "ClassMethod", + }, + { + computed: false, + end: 433, + key: { + end: 420, loc: { end: { column: 7, - line: 12, + line: 13, }, identifierName: "num", start: { column: 4, - line: 12, + line: 13, }, }, name: "num", - start: 373, + start: 417, type: "Identifier", }, loc: { end: { column: 20, - line: 12, + line: 13, }, start: { column: 4, - line: 12, + line: 13, }, }, - start: 373, + start: 417, static: false, type: "ClassProperty", typeAnnotation: { - end: 384, + end: 428, loc: { end: { column: 15, - line: 12, + line: 13, }, start: { column: 7, - line: 12, + line: 13, }, }, - start: 376, + start: 420, type: "TypeAnnotation", typeAnnotation: { - end: 384, + end: 428, loc: { end: { column: 15, - line: 12, + line: 13, }, start: { column: 9, - line: 12, + line: 13, }, }, - start: 378, + start: 422, type: "NumberTypeAnnotation", }, }, value: { - end: 388, + end: 432, extra: { raw: "1", rawValue: 1, @@ -1406,14 +1544,14 @@ loc: { end: { column: 19, - line: 12, + line: 13, }, start: { column: 18, - line: 12, + line: 13, }, }, - start: 387, + start: 431, type: "NumericLiteral", value: 1, }, @@ -1421,69 +1559,69 @@ }, { computed: false, - end: 412, + end: 456, key: { - end: 395, + end: 439, loc: { end: { column: 5, - line: 13, + line: 14, }, identifierName: "s", start: { column: 4, - line: 13, + line: 14, }, }, name: "s", - start: 394, + start: 438, type: "Identifier", }, loc: { end: { column: 22, - line: 13, + line: 14, }, start: { column: 4, - line: 13, + line: 14, }, }, - start: 394, + start: 438, static: false, type: "ClassProperty", typeAnnotation: { - end: 403, + end: 447, loc: { end: { column: 13, - line: 13, + line: 14, }, start: { column: 5, - line: 13, + line: 14, }, }, - start: 395, + start: 439, type: "TypeAnnotation", typeAnnotation: { - end: 403, + end: 447, loc: { end: { column: 13, - line: 13, + line: 14, }, start: { column: 7, - line: 13, + line: 14, }, }, - start: 397, + start: 441, type: "StringTypeAnnotation", }, }, value: { - end: 411, + end: 455, extra: { raw: "\"foo\"", rawValue: "foo", @@ -1491,14 +1629,14 @@ loc: { end: { column: 21, - line: 13, + line: 14, }, start: { column: 16, - line: 13, + line: 14, }, }, - start: 406, + start: 450, type: "StringLiteral", value: "foo", }, @@ -1506,81 +1644,81 @@ }, { computed: false, - end: 427, + end: 471, key: { - end: 420, + end: 464, loc: { end: { column: 7, - line: 14, + line: 15, }, identifierName: "pok", start: { column: 4, - line: 14, + line: 15, }, }, name: "pok", - start: 417, + start: 461, type: "Identifier", }, loc: { end: { column: 14, - line: 14, + line: 15, }, start: { column: 4, - line: 14, + line: 15, }, }, - start: 417, + start: 461, static: false, type: "ClassProperty", typeAnnotation: { - end: 426, + end: 470, loc: { end: { column: 13, - line: 14, + line: 15, }, start: { column: 7, - line: 14, + line: 15, }, }, - start: 420, + start: 464, type: "TypeAnnotation", typeAnnotation: { - end: 426, + end: 470, id: { - end: 426, + end: 470, loc: { end: { column: 13, - line: 14, + line: 15, }, identifierName: "File", start: { column: 9, - line: 14, + line: 15, }, }, name: "File", - start: 422, + start: 466, type: "Identifier", }, loc: { end: { column: 13, - line: 14, + line: 15, }, start: { column: 9, - line: 14, + line: 15, }, }, - start: 422, + start: 466, type: "GenericTypeAnnotation", typeParameters: ~, }, @@ -1590,127 +1728,127 @@ }, { computed: false, - end: 464, + end: 508, key: { - end: 436, + end: 480, loc: { end: { column: 8, - line: 15, + line: 16, }, identifierName: "_map", start: { column: 4, - line: 15, + line: 16, }, }, name: "_map", - start: 432, + start: 476, type: "Identifier", }, loc: { end: { column: 36, - line: 15, + line: 16, }, start: { column: 4, - line: 15, + line: 16, }, }, - start: 432, + start: 476, static: false, type: "ClassProperty", typeAnnotation: { - end: 455, + end: 499, loc: { end: { column: 27, - line: 15, + line: 16, }, start: { column: 8, - line: 15, + line: 16, }, }, - start: 436, + start: 480, type: "TypeAnnotation", typeAnnotation: { - end: 455, + end: 499, id: { - end: 441, + end: 485, loc: { end: { column: 13, - line: 15, + line: 16, }, identifierName: "Map", start: { column: 10, - line: 15, + line: 16, }, }, name: "Map", - start: 438, + start: 482, type: "Identifier", }, loc: { end: { column: 27, - line: 15, + line: 16, }, start: { column: 10, - line: 15, + line: 16, }, }, - start: 438, + start: 482, type: "GenericTypeAnnotation", typeParameters: { - end: 455, + end: 499, loc: { end: { column: 27, - line: 15, + line: 16, }, start: { column: 13, - line: 15, + line: 16, }, }, params: [ { - end: 447, + end: 491, loc: { end: { column: 19, - line: 15, + line: 16, }, start: { column: 14, - line: 15, + line: 16, }, }, - start: 442, + start: 486, type: "MixedTypeAnnotation", }, { - end: 454, + end: 498, loc: { end: { column: 26, - line: 15, + line: 16, }, start: { column: 21, - line: 15, + line: 16, }, }, - start: 449, + start: 493, type: "MixedTypeAnnotation", }, ], - start: 441, + start: 485, type: "TypeParameterInstantiation", }, }, @@ -1718,44 +1856,44 @@ value: { arguments: [], callee: { - end: 461, + end: 505, loc: { end: { column: 33, - line: 15, + line: 16, }, identifierName: "Map", start: { column: 30, - line: 15, + line: 16, }, }, name: "Map", - start: 458, + start: 502, type: "Identifier", }, - end: 463, + end: 507, loc: { end: { column: 35, - line: 15, + line: 16, }, start: { column: 30, - line: 15, + line: 16, }, }, - start: 458, + start: 502, type: "CallExpression", }, variance: ~, }, ], - end: 471, + end: 515, loc: { end: { column: 1, - line: 17, + line: 18, }, start: { column: 32, @@ -1765,7 +1903,7 @@ start: 42, type: "ClassBody", }, - end: 471, + end: 515, id: { end: 41, leadingComments: ~, @@ -1788,7 +1926,7 @@ loc: { end: { column: 1, - line: 17, + line: 18, }, start: { column: 15, @@ -1799,7 +1937,7 @@ superClass: ~, type: "ClassDeclaration", }, - end: 471, + end: 515, leadingComments: [ { end: 8, @@ -1821,7 +1959,7 @@ loc: { end: { column: 1, - line: 17, + line: 18, }, start: { column: 0, @@ -1833,11 +1971,11 @@ }, ], directives: [], - end: 472, + end: 516, loc: { end: { column: 0, - line: 18, + line: 19, }, start: { column: 0, diff --git a/fixtures/flow-annotations.js.sem.uast b/fixtures/flow-annotations.js.sem.uast index ebac1f2..5a0cac3 100644 --- a/fixtures/flow-annotations.js.sem.uast +++ b/fixtures/flow-annotations.js.sem.uast @@ -7,8 +7,8 @@ col: 1, }, end: { '@type': "uast:Position", - offset: 472, - line: 18, + offset: 516, + line: 19, col: 1, }, }, @@ -42,8 +42,8 @@ col: 1, }, end: { '@type': "uast:Position", - offset: 472, - line: 18, + offset: 516, + line: 19, col: 1, }, }, @@ -57,8 +57,8 @@ col: 1, }, end: { '@type': "uast:Position", - offset: 471, - line: 17, + offset: 515, + line: 18, col: 2, }, }, @@ -71,8 +71,8 @@ col: 16, }, end: { '@type': "uast:Position", - offset: 471, - line: 17, + offset: 515, + line: 18, col: 2, }, }, @@ -85,8 +85,8 @@ col: 33, }, end: { '@type': "uast:Position", - offset: 471, - line: 17, + offset: 515, + line: 18, col: 2, }, }, @@ -487,17 +487,88 @@ ], static: false, }, + { '@type': "ClassMethod", + '@role': [Declaration, Function, Statement], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 372, + line: 11, + col: 5, + }, + end: { '@type': "uast:Position", + offset: 411, + line: 11, + col: 44, + }, + }, + async: false, + body: { '@type': "uast:Block", + '@role': [Body, Function, Value], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 409, + line: 11, + col: 42, + }, + end: { '@type': "uast:Position", + offset: 411, + line: 11, + col: 44, + }, + }, + Statements: [], + }, + computed: false, + generator: false, + id: ~, + key: { '@type': "uast:Identifier", + '@role': [Key, Name], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 372, + line: 11, + col: 5, + }, + end: { '@type': "uast:Position", + offset: 386, + line: 11, + col: 19, + }, + }, + Name: "testfnc_typeof", + }, + kind: "method", + params: [ + { '@type': "uast:Identifier", + '@role': [Argument, Function], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 387, + line: 11, + col: 20, + }, + end: { '@type': "uast:Position", + offset: 407, + line: 11, + col: 40, + }, + }, + Name: "Error", + }, + ], + static: false, + }, { '@type': "ClassProperty", '@role': [Variable], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 373, - line: 12, + offset: 417, + line: 13, col: 5, }, end: { '@type': "uast:Position", - offset: 389, - line: 12, + offset: 433, + line: 13, col: 21, }, }, @@ -506,13 +577,13 @@ '@role': [Key, Name], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 373, - line: 12, + offset: 417, + line: 13, col: 5, }, end: { '@type': "uast:Position", - offset: 376, - line: 12, + offset: 420, + line: 13, col: 8, }, }, @@ -523,13 +594,13 @@ '@role': [Declaration, Type], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 376, - line: 12, + offset: 420, + line: 13, col: 8, }, end: { '@type': "uast:Position", - offset: 384, - line: 12, + offset: 428, + line: 13, col: 16, }, }, @@ -537,13 +608,13 @@ '@role': [Declaration, Number, Type], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 378, - line: 12, + offset: 422, + line: 13, col: 10, }, end: { '@type': "uast:Position", - offset: 384, - line: 12, + offset: 428, + line: 13, col: 16, }, }, @@ -554,13 +625,13 @@ '@role': [Expression, Initialization, Literal, Number, Value], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 387, - line: 12, + offset: 431, + line: 13, col: 19, }, end: { '@type': "uast:Position", - offset: 388, - line: 12, + offset: 432, + line: 13, col: 20, }, }, @@ -571,13 +642,13 @@ '@role': [Variable], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 394, - line: 13, + offset: 438, + line: 14, col: 5, }, end: { '@type': "uast:Position", - offset: 412, - line: 13, + offset: 456, + line: 14, col: 23, }, }, @@ -586,13 +657,13 @@ '@role': [Key, Name], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 394, - line: 13, + offset: 438, + line: 14, col: 5, }, end: { '@type': "uast:Position", - offset: 395, - line: 13, + offset: 439, + line: 14, col: 6, }, }, @@ -603,13 +674,13 @@ '@role': [Declaration, Type], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 395, - line: 13, + offset: 439, + line: 14, col: 6, }, end: { '@type': "uast:Position", - offset: 403, - line: 13, + offset: 447, + line: 14, col: 14, }, }, @@ -617,13 +688,13 @@ '@role': [Declaration, String, Type], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 397, - line: 13, + offset: 441, + line: 14, col: 8, }, end: { '@type': "uast:Position", - offset: 403, - line: 13, + offset: 447, + line: 14, col: 14, }, }, @@ -633,13 +704,13 @@ '@role': [Initialization, Value], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 406, - line: 13, + offset: 450, + line: 14, col: 17, }, end: { '@type': "uast:Position", - offset: 411, - line: 13, + offset: 455, + line: 14, col: 22, }, }, @@ -652,13 +723,13 @@ '@role': [Variable], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 417, - line: 14, + offset: 461, + line: 15, col: 5, }, end: { '@type': "uast:Position", - offset: 427, - line: 14, + offset: 471, + line: 15, col: 15, }, }, @@ -667,13 +738,13 @@ '@role': [Key, Name], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 417, - line: 14, + offset: 461, + line: 15, col: 5, }, end: { '@type': "uast:Position", - offset: 420, - line: 14, + offset: 464, + line: 15, col: 8, }, }, @@ -684,13 +755,13 @@ '@role': [Declaration, Type], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 420, - line: 14, + offset: 464, + line: 15, col: 8, }, end: { '@type': "uast:Position", - offset: 426, - line: 14, + offset: 470, + line: 15, col: 14, }, }, @@ -698,26 +769,26 @@ '@role': [Declaration, Type], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 422, - line: 14, + offset: 466, + line: 15, col: 10, }, end: { '@type': "uast:Position", - offset: 426, - line: 14, + offset: 470, + line: 15, col: 14, }, }, id: { '@type': "uast:Identifier", '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 422, - line: 14, + offset: 466, + line: 15, col: 10, }, end: { '@type': "uast:Position", - offset: 426, - line: 14, + offset: 470, + line: 15, col: 14, }, }, @@ -733,13 +804,13 @@ '@role': [Variable], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 432, - line: 15, + offset: 476, + line: 16, col: 5, }, end: { '@type': "uast:Position", - offset: 464, - line: 15, + offset: 508, + line: 16, col: 37, }, }, @@ -748,13 +819,13 @@ '@role': [Key, Name], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 432, - line: 15, + offset: 476, + line: 16, col: 5, }, end: { '@type': "uast:Position", - offset: 436, - line: 15, + offset: 480, + line: 16, col: 9, }, }, @@ -765,13 +836,13 @@ '@role': [Declaration, Type], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 436, - line: 15, + offset: 480, + line: 16, col: 9, }, end: { '@type': "uast:Position", - offset: 455, - line: 15, + offset: 499, + line: 16, col: 28, }, }, @@ -779,26 +850,26 @@ '@role': [Declaration, Type], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 438, - line: 15, + offset: 482, + line: 16, col: 11, }, end: { '@type': "uast:Position", - offset: 455, - line: 15, + offset: 499, + line: 16, col: 28, }, }, id: { '@type': "uast:Identifier", '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 438, - line: 15, + offset: 482, + line: 16, col: 11, }, end: { '@type': "uast:Position", - offset: 441, - line: 15, + offset: 485, + line: 16, col: 14, }, }, @@ -808,13 +879,13 @@ '@role': [Declaration, Incomplete, Type], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 441, - line: 15, + offset: 485, + line: 16, col: 14, }, end: { '@type': "uast:Position", - offset: 455, - line: 15, + offset: 499, + line: 16, col: 28, }, }, @@ -823,13 +894,13 @@ '@role': [Declaration, Type], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 442, - line: 15, + offset: 486, + line: 16, col: 15, }, end: { '@type': "uast:Position", - offset: 447, - line: 15, + offset: 491, + line: 16, col: 20, }, }, @@ -838,13 +909,13 @@ '@role': [Declaration, Type], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 449, - line: 15, + offset: 493, + line: 16, col: 22, }, end: { '@type': "uast:Position", - offset: 454, - line: 15, + offset: 498, + line: 16, col: 27, }, }, @@ -857,13 +928,13 @@ '@role': [Call, Expression, Initialization, Value], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 458, - line: 15, + offset: 502, + line: 16, col: 31, }, end: { '@type': "uast:Position", - offset: 463, - line: 15, + offset: 507, + line: 16, col: 36, }, }, @@ -872,13 +943,13 @@ '@role': [Call, Callee], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 458, - line: 15, + offset: 502, + line: 16, col: 31, }, end: { '@type': "uast:Position", - offset: 461, - line: 15, + offset: 505, + line: 16, col: 34, }, }, diff --git a/fixtures/flow-annotations.js.uast b/fixtures/flow-annotations.js.uast index 37bad22..6275fd8 100644 --- a/fixtures/flow-annotations.js.uast +++ b/fixtures/flow-annotations.js.uast @@ -7,8 +7,8 @@ col: 1, }, end: { '@type': "uast:Position", - offset: 472, - line: 18, + offset: 516, + line: 19, col: 1, }, }, @@ -39,8 +39,8 @@ col: 1, }, end: { '@type': "uast:Position", - offset: 472, - line: 18, + offset: 516, + line: 19, col: 1, }, }, @@ -54,8 +54,8 @@ col: 1, }, end: { '@type': "uast:Position", - offset: 471, - line: 17, + offset: 515, + line: 18, col: 2, }, }, @@ -68,8 +68,8 @@ col: 16, }, end: { '@type': "uast:Position", - offset: 471, - line: 17, + offset: 515, + line: 18, col: 2, }, }, @@ -82,8 +82,8 @@ col: 33, }, end: { '@type': "uast:Position", - offset: 471, - line: 17, + offset: 515, + line: 18, col: 2, }, }, @@ -1356,17 +1356,152 @@ ], static: false, }, + { '@type': "ClassMethod", + '@role': [Declaration, Function, Statement], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 372, + line: 11, + col: 5, + }, + end: { '@type': "uast:Position", + offset: 411, + line: 11, + col: 44, + }, + }, + async: false, + body: { '@type': "BlockStatement", + '@role': [Block, Body, Function, Scope, Statement, Value], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 409, + line: 11, + col: 42, + }, + end: { '@type': "uast:Position", + offset: 411, + line: 11, + col: 44, + }, + }, + body: [], + directives: [], + }, + computed: false, + generator: false, + id: ~, + key: { '@type': "Identifier", + '@token': "testfnc_typeof", + '@role': [Expression, Identifier, Key, Name], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 372, + line: 11, + col: 5, + }, + end: { '@type': "uast:Position", + offset: 386, + line: 11, + col: 19, + }, + }, + }, + kind: "method", + params: [ + { '@type': "Identifier", + '@token': "Error", + '@role': [Argument, Expression, Function, Identifier], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 387, + line: 11, + col: 20, + }, + end: { '@type': "uast:Position", + offset: 407, + line: 11, + col: 40, + }, + }, + optional: true, + typeAnnotation: { '@type': "TypeAnnotation", + '@role': [Declaration, Type], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 393, + line: 11, + col: 26, + }, + end: { '@type': "uast:Position", + offset: 407, + line: 11, + col: 40, + }, + }, + typeAnnotation: { '@type': "TypeofTypeAnnotation", + '@role': [Declaration, Incomplete, Type], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 395, + line: 11, + col: 28, + }, + end: { '@type': "uast:Position", + offset: 407, + line: 11, + col: 40, + }, + }, + argument: { '@type': "GenericTypeAnnotation", + '@role': [Declaration, Type], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 402, + line: 11, + col: 35, + }, + end: { '@type': "uast:Position", + offset: 407, + line: 11, + col: 40, + }, + }, + id: { '@type': "Identifier", + '@token': "Error", + '@role': [Expression, Identifier], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 402, + line: 11, + col: 35, + }, + end: { '@type': "uast:Position", + offset: 407, + line: 11, + col: 40, + }, + }, + }, + typeParameters: ~, + }, + }, + }, + }, + ], + static: false, + }, { '@type': "ClassProperty", '@role': [Variable], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 373, - line: 12, + offset: 417, + line: 13, col: 5, }, end: { '@type': "uast:Position", - offset: 389, - line: 12, + offset: 433, + line: 13, col: 21, }, }, @@ -1376,13 +1511,13 @@ '@role': [Expression, Identifier, Key, Name], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 373, - line: 12, + offset: 417, + line: 13, col: 5, }, end: { '@type': "uast:Position", - offset: 376, - line: 12, + offset: 420, + line: 13, col: 8, }, }, @@ -1392,13 +1527,13 @@ '@role': [Declaration, Type], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 376, - line: 12, + offset: 420, + line: 13, col: 8, }, end: { '@type': "uast:Position", - offset: 384, - line: 12, + offset: 428, + line: 13, col: 16, }, }, @@ -1406,13 +1541,13 @@ '@role': [Declaration, Number, Type], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 378, - line: 12, + offset: 422, + line: 13, col: 10, }, end: { '@type': "uast:Position", - offset: 384, - line: 12, + offset: 428, + line: 13, col: 16, }, }, @@ -1423,13 +1558,13 @@ '@role': [Expression, Initialization, Literal, Number, Value], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 387, - line: 12, + offset: 431, + line: 13, col: 19, }, end: { '@type': "uast:Position", - offset: 388, - line: 12, + offset: 432, + line: 13, col: 20, }, }, @@ -1440,13 +1575,13 @@ '@role': [Variable], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 394, - line: 13, + offset: 438, + line: 14, col: 5, }, end: { '@type': "uast:Position", - offset: 412, - line: 13, + offset: 456, + line: 14, col: 23, }, }, @@ -1456,13 +1591,13 @@ '@role': [Expression, Identifier, Key, Name], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 394, - line: 13, + offset: 438, + line: 14, col: 5, }, end: { '@type': "uast:Position", - offset: 395, - line: 13, + offset: 439, + line: 14, col: 6, }, }, @@ -1472,13 +1607,13 @@ '@role': [Declaration, Type], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 395, - line: 13, + offset: 439, + line: 14, col: 6, }, end: { '@type': "uast:Position", - offset: 403, - line: 13, + offset: 447, + line: 14, col: 14, }, }, @@ -1486,13 +1621,13 @@ '@role': [Declaration, String, Type], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 397, - line: 13, + offset: 441, + line: 14, col: 8, }, end: { '@type': "uast:Position", - offset: 403, - line: 13, + offset: 447, + line: 14, col: 14, }, }, @@ -1503,13 +1638,13 @@ '@role': [Expression, Initialization, Literal, String, Value], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 406, - line: 13, + offset: 450, + line: 14, col: 17, }, end: { '@type': "uast:Position", - offset: 411, - line: 13, + offset: 455, + line: 14, col: 22, }, }, @@ -1520,13 +1655,13 @@ '@role': [Variable], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 417, - line: 14, + offset: 461, + line: 15, col: 5, }, end: { '@type': "uast:Position", - offset: 427, - line: 14, + offset: 471, + line: 15, col: 15, }, }, @@ -1536,13 +1671,13 @@ '@role': [Expression, Identifier, Key, Name], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 417, - line: 14, + offset: 461, + line: 15, col: 5, }, end: { '@type': "uast:Position", - offset: 420, - line: 14, + offset: 464, + line: 15, col: 8, }, }, @@ -1552,13 +1687,13 @@ '@role': [Declaration, Type], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 420, - line: 14, + offset: 464, + line: 15, col: 8, }, end: { '@type': "uast:Position", - offset: 426, - line: 14, + offset: 470, + line: 15, col: 14, }, }, @@ -1566,13 +1701,13 @@ '@role': [Declaration, Type], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 422, - line: 14, + offset: 466, + line: 15, col: 10, }, end: { '@type': "uast:Position", - offset: 426, - line: 14, + offset: 470, + line: 15, col: 14, }, }, @@ -1581,13 +1716,13 @@ '@role': [Expression, Identifier], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 422, - line: 14, + offset: 466, + line: 15, col: 10, }, end: { '@type': "uast:Position", - offset: 426, - line: 14, + offset: 470, + line: 15, col: 14, }, }, @@ -1602,13 +1737,13 @@ '@role': [Variable], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 432, - line: 15, + offset: 476, + line: 16, col: 5, }, end: { '@type': "uast:Position", - offset: 464, - line: 15, + offset: 508, + line: 16, col: 37, }, }, @@ -1618,13 +1753,13 @@ '@role': [Expression, Identifier, Key, Name], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 432, - line: 15, + offset: 476, + line: 16, col: 5, }, end: { '@type': "uast:Position", - offset: 436, - line: 15, + offset: 480, + line: 16, col: 9, }, }, @@ -1634,13 +1769,13 @@ '@role': [Declaration, Type], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 436, - line: 15, + offset: 480, + line: 16, col: 9, }, end: { '@type': "uast:Position", - offset: 455, - line: 15, + offset: 499, + line: 16, col: 28, }, }, @@ -1648,13 +1783,13 @@ '@role': [Declaration, Type], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 438, - line: 15, + offset: 482, + line: 16, col: 11, }, end: { '@type': "uast:Position", - offset: 455, - line: 15, + offset: 499, + line: 16, col: 28, }, }, @@ -1663,13 +1798,13 @@ '@role': [Expression, Identifier], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 438, - line: 15, + offset: 482, + line: 16, col: 11, }, end: { '@type': "uast:Position", - offset: 441, - line: 15, + offset: 485, + line: 16, col: 14, }, }, @@ -1678,13 +1813,13 @@ '@role': [Declaration, Incomplete, Type], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 441, - line: 15, + offset: 485, + line: 16, col: 14, }, end: { '@type': "uast:Position", - offset: 455, - line: 15, + offset: 499, + line: 16, col: 28, }, }, @@ -1693,13 +1828,13 @@ '@role': [Declaration, Type], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 442, - line: 15, + offset: 486, + line: 16, col: 15, }, end: { '@type': "uast:Position", - offset: 447, - line: 15, + offset: 491, + line: 16, col: 20, }, }, @@ -1708,13 +1843,13 @@ '@role': [Declaration, Type], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 449, - line: 15, + offset: 493, + line: 16, col: 22, }, end: { '@type': "uast:Position", - offset: 454, - line: 15, + offset: 498, + line: 16, col: 27, }, }, @@ -1727,13 +1862,13 @@ '@role': [Call, Expression, Initialization, Value], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 458, - line: 15, + offset: 502, + line: 16, col: 31, }, end: { '@type': "uast:Position", - offset: 463, - line: 15, + offset: 507, + line: 16, col: 36, }, }, @@ -1743,13 +1878,13 @@ '@role': [Call, Callee, Expression, Identifier], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 458, - line: 15, + offset: 502, + line: 16, col: 31, }, end: { '@type': "uast:Position", - offset: 461, - line: 15, + offset: 505, + line: 16, col: 34, }, }, From f8805f85ef9a6a82a3cb67f061487e574e5b433c Mon Sep 17 00:00:00 2001 From: Juanjo Alvarez Date: Thu, 9 Aug 2018 09:55:04 +0200 Subject: [PATCH 4/4] Declare-Classes Signed-off-by: Juanjo Alvarez --- driver/normalizer/annotation.go | 4 + fixtures/flow-annotations.js | 3 + fixtures/flow-annotations.js.native | 190 ++++++++++++++++++++++++-- fixtures/flow-annotations.js.sem.uast | 182 ++++++++++++++++++++++-- fixtures/flow-annotations.js.uast | 186 +++++++++++++++++++++++-- 5 files changed, 535 insertions(+), 30 deletions(-) diff --git a/driver/normalizer/annotation.go b/driver/normalizer/annotation.go index f827cda..1362dbb 100644 --- a/driver/normalizer/annotation.go +++ b/driver/normalizer/annotation.go @@ -545,4 +545,8 @@ var Annotations = []Mapping{ AnnotateType("ObjectTypeProperty", nil, role.Declaration, role.Type, role.Incomplete), AnnotateType("TypeofTypeAnnotation", nil, role.Declaration, role.Type, role.Incomplete), AnnotateType("FunctionTypeAnnotation", nil, role.Declaration, role.Type, role.Incomplete), + + // Flow Declare-Classes + AnnotateType("DeclareClass", nil, role.Declaration, role.Type, role.Incomplete), + AnnotateType("InterfaceExtends", nil, role.Declaration, role.Type, role.Subtype, role.Incomplete), } diff --git a/fixtures/flow-annotations.js b/fixtures/flow-annotations.js index 1090392..3e0091f 100644 --- a/fixtures/flow-annotations.js +++ b/fixtures/flow-annotations.js @@ -14,5 +14,8 @@ export default class PluginPass { s: string = "foo"; pok: File; _map: Map = Map(); + } + +declare class A mixins B, C {} diff --git a/fixtures/flow-annotations.js.native b/fixtures/flow-annotations.js.native index 98db8fc..3f2007c 100644 --- a/fixtures/flow-annotations.js.native +++ b/fixtures/flow-annotations.js.native @@ -17,11 +17,11 @@ value: " @flow", }, ], - end: 516, + end: 552, loc: { end: { column: 0, - line: 19, + line: 22, }, start: { column: 0, @@ -1889,11 +1889,11 @@ variance: ~, }, ], - end: 515, + end: 516, loc: { end: { column: 1, - line: 18, + line: 19, }, start: { column: 32, @@ -1903,7 +1903,7 @@ start: 42, type: "ClassBody", }, - end: 515, + end: 516, id: { end: 41, leadingComments: ~, @@ -1926,7 +1926,7 @@ loc: { end: { column: 1, - line: 18, + line: 19, }, start: { column: 15, @@ -1937,7 +1937,7 @@ superClass: ~, type: "ClassDeclaration", }, - end: 515, + end: 516, leadingComments: [ { end: 8, @@ -1959,7 +1959,7 @@ loc: { end: { column: 1, - line: 18, + line: 19, }, start: { column: 0, @@ -1969,13 +1969,183 @@ start: 10, type: "ExportDefaultDeclaration", }, + { + body: { + callProperties: [], + end: 551, + exact: false, + indexers: [], + loc: { + end: { + column: 33, + line: 21, + }, + start: { + column: 31, + line: 21, + }, + }, + properties: [], + start: 549, + type: "ObjectTypeAnnotation", + }, + end: 551, + extends: [], + id: { + end: 533, + loc: { + end: { + column: 15, + line: 21, + }, + identifierName: "A", + start: { + column: 14, + line: 21, + }, + }, + name: "A", + start: 532, + type: "Identifier", + }, + loc: { + end: { + column: 33, + line: 21, + }, + start: { + column: 0, + line: 21, + }, + }, + mixins: [ + { + end: 545, + id: { + end: 542, + loc: { + end: { + column: 24, + line: 21, + }, + identifierName: "B", + start: { + column: 23, + line: 21, + }, + }, + name: "B", + start: 541, + type: "Identifier", + }, + loc: { + end: { + column: 27, + line: 21, + }, + start: { + column: 23, + line: 21, + }, + }, + start: 541, + type: "InterfaceExtends", + typeParameters: { + end: 545, + loc: { + end: { + column: 27, + line: 21, + }, + start: { + column: 24, + line: 21, + }, + }, + params: [ + { + end: 544, + id: { + end: 544, + loc: { + end: { + column: 26, + line: 21, + }, + identifierName: "T", + start: { + column: 25, + line: 21, + }, + }, + name: "T", + start: 543, + type: "Identifier", + }, + loc: { + end: { + column: 26, + line: 21, + }, + start: { + column: 25, + line: 21, + }, + }, + start: 543, + type: "GenericTypeAnnotation", + typeParameters: ~, + }, + ], + start: 542, + type: "TypeParameterInstantiation", + }, + }, + { + end: 548, + id: { + end: 548, + loc: { + end: { + column: 30, + line: 21, + }, + identifierName: "C", + start: { + column: 29, + line: 21, + }, + }, + name: "C", + start: 547, + type: "Identifier", + }, + loc: { + end: { + column: 30, + line: 21, + }, + start: { + column: 29, + line: 21, + }, + }, + start: 547, + type: "InterfaceExtends", + typeParameters: ~, + }, + ], + start: 518, + type: "DeclareClass", + typeParameters: ~, + }, ], directives: [], - end: 516, + end: 552, loc: { end: { column: 0, - line: 19, + line: 22, }, start: { column: 0, diff --git a/fixtures/flow-annotations.js.sem.uast b/fixtures/flow-annotations.js.sem.uast index 5a0cac3..cbc78c9 100644 --- a/fixtures/flow-annotations.js.sem.uast +++ b/fixtures/flow-annotations.js.sem.uast @@ -7,8 +7,8 @@ col: 1, }, end: { '@type': "uast:Position", - offset: 516, - line: 19, + offset: 552, + line: 22, col: 1, }, }, @@ -42,8 +42,8 @@ col: 1, }, end: { '@type': "uast:Position", - offset: 516, - line: 19, + offset: 552, + line: 22, col: 1, }, }, @@ -57,8 +57,8 @@ col: 1, }, end: { '@type': "uast:Position", - offset: 515, - line: 18, + offset: 516, + line: 19, col: 2, }, }, @@ -71,8 +71,8 @@ col: 16, }, end: { '@type': "uast:Position", - offset: 515, - line: 18, + offset: 516, + line: 19, col: 2, }, }, @@ -85,8 +85,8 @@ col: 33, }, end: { '@type': "uast:Position", - offset: 515, - line: 18, + offset: 516, + line: 19, col: 2, }, }, @@ -1001,6 +1001,168 @@ }, ], }, + { '@type': "DeclareClass", + '@role': [Declaration, Incomplete, Type], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 518, + line: 21, + col: 1, + }, + end: { '@type': "uast:Position", + offset: 551, + line: 21, + col: 34, + }, + }, + body: { '@type': "ObjectTypeAnnotation", + '@role': [Declaration, Incomplete, Literal, Type], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 549, + line: 21, + col: 32, + }, + end: { '@type': "uast:Position", + offset: 551, + line: 21, + col: 34, + }, + }, + callProperties: [], + exact: false, + indexers: [], + properties: [], + }, + extends: [], + id: { '@type': "uast:Identifier", + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 532, + line: 21, + col: 15, + }, + end: { '@type': "uast:Position", + offset: 533, + line: 21, + col: 16, + }, + }, + Name: "A", + }, + mixins: [ + { '@type': "InterfaceExtends", + '@role': [Declaration, Incomplete, Subtype, Type], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 541, + line: 21, + col: 24, + }, + end: { '@type': "uast:Position", + offset: 545, + line: 21, + col: 28, + }, + }, + id: { '@type': "uast:Identifier", + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 541, + line: 21, + col: 24, + }, + end: { '@type': "uast:Position", + offset: 542, + line: 21, + col: 25, + }, + }, + Name: "B", + }, + typeParameters: { '@type': "TypeParameterInstantiation", + '@role': [Declaration, Incomplete, Type], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 542, + line: 21, + col: 25, + }, + end: { '@type': "uast:Position", + offset: 545, + line: 21, + col: 28, + }, + }, + params: [ + { '@type': "GenericTypeAnnotation", + '@role': [Declaration, Type], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 543, + line: 21, + col: 26, + }, + end: { '@type': "uast:Position", + offset: 544, + line: 21, + col: 27, + }, + }, + id: { '@type': "uast:Identifier", + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 543, + line: 21, + col: 26, + }, + end: { '@type': "uast:Position", + offset: 544, + line: 21, + col: 27, + }, + }, + Name: "T", + }, + typeParameters: ~, + }, + ], + }, + }, + { '@type': "InterfaceExtends", + '@role': [Declaration, Incomplete, Subtype, Type], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 547, + line: 21, + col: 30, + }, + end: { '@type': "uast:Position", + offset: 548, + line: 21, + col: 31, + }, + }, + id: { '@type': "uast:Identifier", + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 547, + line: 21, + col: 30, + }, + end: { '@type': "uast:Position", + offset: 548, + line: 21, + col: 31, + }, + }, + Name: "C", + }, + typeParameters: ~, + }, + ], + typeParameters: ~, + }, ], directives: [], sourceType: "module", diff --git a/fixtures/flow-annotations.js.uast b/fixtures/flow-annotations.js.uast index 6275fd8..18c837c 100644 --- a/fixtures/flow-annotations.js.uast +++ b/fixtures/flow-annotations.js.uast @@ -7,8 +7,8 @@ col: 1, }, end: { '@type': "uast:Position", - offset: 516, - line: 19, + offset: 552, + line: 22, col: 1, }, }, @@ -39,8 +39,8 @@ col: 1, }, end: { '@type': "uast:Position", - offset: 516, - line: 19, + offset: 552, + line: 22, col: 1, }, }, @@ -54,8 +54,8 @@ col: 1, }, end: { '@type': "uast:Position", - offset: 515, - line: 18, + offset: 516, + line: 19, col: 2, }, }, @@ -68,8 +68,8 @@ col: 16, }, end: { '@type': "uast:Position", - offset: 515, - line: 18, + offset: 516, + line: 19, col: 2, }, }, @@ -82,8 +82,8 @@ col: 33, }, end: { '@type': "uast:Position", - offset: 515, - line: 18, + offset: 516, + line: 19, col: 2, }, }, @@ -1933,6 +1933,172 @@ }, ], }, + { '@type': "DeclareClass", + '@role': [Declaration, Incomplete, Type], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 518, + line: 21, + col: 1, + }, + end: { '@type': "uast:Position", + offset: 551, + line: 21, + col: 34, + }, + }, + body: { '@type': "ObjectTypeAnnotation", + '@role': [Declaration, Incomplete, Literal, Type], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 549, + line: 21, + col: 32, + }, + end: { '@type': "uast:Position", + offset: 551, + line: 21, + col: 34, + }, + }, + callProperties: [], + exact: false, + indexers: [], + properties: [], + }, + extends: [], + id: { '@type': "Identifier", + '@token': "A", + '@role': [Expression, Identifier], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 532, + line: 21, + col: 15, + }, + end: { '@type': "uast:Position", + offset: 533, + line: 21, + col: 16, + }, + }, + }, + mixins: [ + { '@type': "InterfaceExtends", + '@role': [Declaration, Incomplete, Subtype, Type], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 541, + line: 21, + col: 24, + }, + end: { '@type': "uast:Position", + offset: 545, + line: 21, + col: 28, + }, + }, + id: { '@type': "Identifier", + '@token': "B", + '@role': [Expression, Identifier], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 541, + line: 21, + col: 24, + }, + end: { '@type': "uast:Position", + offset: 542, + line: 21, + col: 25, + }, + }, + }, + typeParameters: { '@type': "TypeParameterInstantiation", + '@role': [Declaration, Incomplete, Type], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 542, + line: 21, + col: 25, + }, + end: { '@type': "uast:Position", + offset: 545, + line: 21, + col: 28, + }, + }, + params: [ + { '@type': "GenericTypeAnnotation", + '@role': [Declaration, Type], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 543, + line: 21, + col: 26, + }, + end: { '@type': "uast:Position", + offset: 544, + line: 21, + col: 27, + }, + }, + id: { '@type': "Identifier", + '@token': "T", + '@role': [Expression, Identifier], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 543, + line: 21, + col: 26, + }, + end: { '@type': "uast:Position", + offset: 544, + line: 21, + col: 27, + }, + }, + }, + typeParameters: ~, + }, + ], + }, + }, + { '@type': "InterfaceExtends", + '@role': [Declaration, Incomplete, Subtype, Type], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 547, + line: 21, + col: 30, + }, + end: { '@type': "uast:Position", + offset: 548, + line: 21, + col: 31, + }, + }, + id: { '@type': "Identifier", + '@token': "C", + '@role': [Expression, Identifier], + '@pos': { '@type': "uast:Positions", + start: { '@type': "uast:Position", + offset: 547, + line: 21, + col: 30, + }, + end: { '@type': "uast:Position", + offset: 548, + line: 21, + col: 31, + }, + }, + }, + typeParameters: ~, + }, + ], + typeParameters: ~, + }, ], directives: [], sourceType: "module",