From 655ef3b45c7f22bebc5da0bd366f6fa968c24c3a Mon Sep 17 00:00:00 2001 From: Patrick Thomson Date: Tue, 14 Mar 2017 16:04:08 -0400 Subject: [PATCH] update test cases --- fixtures/expressions/addition/addition.json | 52 +- fixtures/expressions/chancast/chan.json | 54 ++- .../expressions/doublequalifier/double.json | 60 +-- fixtures/expressions/logicalor/logicalor.json | 28 +- fixtures/expressions/mapliteral/map.json | 142 +++--- fixtures/expressions/parenintype/paren.json | 64 +-- fixtures/expressions/ptrcast/ptr.json | 66 +-- .../expressions/singlequalifier/single.json | 34 +- fixtures/expressions/slicecast/slice.json | 106 ++-- fixtures/packages/emptyfor/empty.json | 56 +-- fixtures/packages/helloworld/helloworld.json | 128 ++--- .../packages/interface_type/interface.json | 280 ++++++----- fixtures/packages/methoddecl/method.json | 458 +++++++++--------- .../packages/qualifiedtype/qualified.json | 190 ++++---- fixtures/packages/select/select.json | 88 ++-- .../simpletypealias/simpletypealias.json | 124 ++--- fixtures/packages/untypedvar/untyped.json | 72 +-- goblin.go | 48 +- 18 files changed, 1074 insertions(+), 976 deletions(-) diff --git a/fixtures/expressions/addition/addition.json b/fixtures/expressions/addition/addition.json index 5882564..4883d6b 100644 --- a/fixtures/expressions/addition/addition.json +++ b/fixtures/expressions/addition/addition.json @@ -1 +1,51 @@ -{"kind":"binary","left":{"kind":"expression","position":{"column":0,"filename":"","line":0,"offset":0},"type":"identifier","value":{"kind":"ident","position":{"column":0,"filename":"","line":0,"offset":0},"value":"ill"}},"operator":"+","position":{"column":0,"filename":"","line":0,"offset":0},"right":{"kind":"expression","position":{"column":0,"filename":"","line":0,"offset":0},"type":"identifier","value":{"kind":"ident","position":{"column":0,"filename":"","line":0,"offset":0},"value":"matic"}},"type":"expression"} +{ + "left" : { + "type" : "identifier", + "kind" : "expression", + "position" : { + "column" : 0, + "offset" : 0, + "line" : 0, + "filename" : "" + }, + "value" : { + "kind" : "ident", + "position" : { + "filename" : "", + "offset" : 0, + "line" : 0, + "column" : 0 + }, + "value" : "ill" + } + }, + "operator" : "+", + "right" : { + "value" : { + "value" : "matic", + "kind" : "ident", + "position" : { + "filename" : "", + "line" : 0, + "offset" : 0, + "column" : 0 + } + }, + "kind" : "expression", + "position" : { + "offset" : 0, + "line" : 0, + "column" : 0, + "filename" : "" + }, + "type" : "identifier" + }, + "position" : { + "column" : 0, + "line" : 0, + "offset" : 0, + "filename" : "" + }, + "kind" : "binary", + "type" : "expression" +} diff --git a/fixtures/expressions/chancast/chan.json b/fixtures/expressions/chancast/chan.json index e3c259f..2361c9a 100644 --- a/fixtures/expressions/chancast/chan.json +++ b/fixtures/expressions/chancast/chan.json @@ -2,54 +2,60 @@ "type" : "cast", "target" : { "kind" : "expression", + "type" : "identifier", "position" : { "line" : 0, - "offset" : 0, + "filename" : "", "column" : 0, - "filename" : "" + "offset" : 0 }, "value" : { "position" : { - "filename" : "", "offset" : 0, "column" : 0, + "filename" : "", "line" : 0 }, - "kind" : "ident", - "value" : "foo" - }, - "type" : "identifier" - }, - "position" : { - "line" : 0, - "filename" : "", - "offset" : 0, - "column" : 0 + "value" : "foo", + "kind" : "ident" + } }, - "kind" : "expression", "coerced-to" : { + "position" : { + "filename" : "", + "line" : 0, + "column" : 0, + "offset" : 0 + }, "value" : { "type" : "identifier", + "kind" : "type", "value" : { - "kind" : "ident", + "value" : "int", "position" : { - "line" : 0, - "filename" : "", "offset" : 0, - "column" : 0 + "column" : 0, + "line" : 0, + "filename" : "" }, - "value" : "int" + "kind" : "ident" }, - "kind" : "type", "position" : { - "line" : 0, - "filename" : "", "column" : 0, - "offset" : 0 + "offset" : 0, + "line" : 0, + "filename" : "" } }, - "direction" : "both", "kind" : "type", + "direction" : "both", "type" : "chan" + }, + "kind" : "expression", + "position" : { + "line" : 0, + "filename" : "", + "offset" : 0, + "column" : 0 } } diff --git a/fixtures/expressions/doublequalifier/double.json b/fixtures/expressions/doublequalifier/double.json index fb637df..93d2178 100644 --- a/fixtures/expressions/doublequalifier/double.json +++ b/fixtures/expressions/doublequalifier/double.json @@ -1,50 +1,50 @@ { - "kind" : "expression", - "field" : { - "value" : "baz", - "kind" : "ident", - "position" : { - "filename" : "", - "offset" : 0, - "line" : 0, - "column" : 0 - } - }, - "type" : "selector", "target" : { "position" : { + "line" : 0, "column" : 0, "filename" : "", - "offset" : 0, - "line" : 0 + "offset" : 0 }, + "kind" : "expression", "type" : "identifier", - "value" : { - "value" : "bar", - "kind" : "ident", + "qualifier" : { "position" : { "column" : 0, "filename" : "", - "line" : 0, - "offset" : 0 - } + "offset" : 0, + "line" : 0 + }, + "kind" : "ident", + "value" : "foo" }, - "kind" : "expression", - "qualifier" : { + "value" : { + "value" : "bar", + "kind" : "ident", "position" : { + "column" : 0, "filename" : "", "offset" : 0, - "line" : 0, - "column" : 0 - }, - "value" : "foo", - "kind" : "ident" + "line" : 0 + } } }, + "type" : "selector", "position" : { + "column" : 0, "offset" : 0, - "line" : 0, "filename" : "", - "column" : 0 - } + "line" : 0 + }, + "field" : { + "value" : "baz", + "position" : { + "line" : 0, + "column" : 0, + "offset" : 0, + "filename" : "" + }, + "kind" : "ident" + }, + "kind" : "expression" } diff --git a/fixtures/expressions/logicalor/logicalor.json b/fixtures/expressions/logicalor/logicalor.json index cbd2110..a7011fc 100644 --- a/fixtures/expressions/logicalor/logicalor.json +++ b/fixtures/expressions/logicalor/logicalor.json @@ -1,33 +1,33 @@ { - "position" : { - "offset" : 0, - "line" : 0, - "column" : 0, - "filename" : "" - }, + "type" : "expression", "right" : { - "type" : "BOOL", - "value" : "true", - "kind" : "literal", "position" : { "offset" : 0, "column" : 0, "line" : 0, "filename" : "" - } + }, + "value" : "true", + "type" : "BOOL", + "kind" : "literal" + }, + "position" : { + "column" : 0, + "offset" : 0, + "filename" : "", + "line" : 0 }, "left" : { - "type" : "BOOL", "position" : { "offset" : 0, - "filename" : "", "column" : 0, + "filename" : "", "line" : 0 }, "value" : "false", + "type" : "BOOL", "kind" : "literal" }, - "kind" : "binary", "operator" : "||", - "type" : "expression" + "kind" : "binary" } diff --git a/fixtures/expressions/mapliteral/map.json b/fixtures/expressions/mapliteral/map.json index 5883896..4de2037 100644 --- a/fixtures/expressions/mapliteral/map.json +++ b/fixtures/expressions/mapliteral/map.json @@ -2,133 +2,139 @@ "values" : [ { "type" : "key-value", - "kind" : "expression", "value" : { - "value" : "1989", "position" : { "column" : 0, + "line" : 0, "offset" : 0, - "filename" : "", - "line" : 0 + "filename" : "" }, - "kind" : "literal", - "type" : "INT" + "type" : "INT", + "value" : "1989", + "kind" : "literal" }, + "kind" : "expression", "key" : { "position" : { - "filename" : "", - "line" : 0, + "column" : 0, "offset" : 0, - "column" : 0 + "filename" : "", + "line" : 0 }, + "value" : "\"Bleach\"", "type" : "STRING", - "kind" : "literal", - "value" : "\"Bleach\"" + "kind" : "literal" } }, { + "value" : { + "position" : { + "line" : 0, + "filename" : "", + "offset" : 0, + "column" : 0 + }, + "value" : "1991", + "type" : "INT", + "kind" : "literal" + }, + "type" : "key-value", "key" : { - "value" : "\"Nevermind\"", "position" : { "column" : 0, - "offset" : 0, "line" : 0, + "offset" : 0, "filename" : "" }, - "kind" : "literal", - "type" : "STRING" + "type" : "STRING", + "value" : "\"Nevermind\"", + "kind" : "literal" }, + "kind" : "expression" + }, + { "value" : { + "type" : "INT", + "value" : "1993", "position" : { - "filename" : "", "line" : 0, + "filename" : "", "offset" : 0, "column" : 0 }, - "kind" : "literal", - "type" : "INT", - "value" : "1991" + "kind" : "literal" }, - "kind" : "expression", - "type" : "key-value" - }, - { + "type" : "key-value", "key" : { + "kind" : "literal", "value" : "\"In Utero\"", "type" : "STRING", - "kind" : "literal", "position" : { "column" : 0, - "offset" : 0, "line" : 0, + "offset" : 0, "filename" : "" } }, - "value" : { - "value" : "1993", - "kind" : "literal", - "type" : "INT", - "position" : { - "column" : 0, - "line" : 0, - "filename" : "", - "offset" : 0 - } - }, - "type" : "key-value", "kind" : "expression" } ], - "position" : { - "filename" : "", - "line" : 0, - "offset" : 0, - "column" : 0 - }, + "kind" : "literal", "declared" : { - "kind" : "type", + "position" : { + "offset" : 0, + "filename" : "", + "line" : 0, + "column" : 0 + }, "type" : "map", - "key" : { + "value" : { + "value" : { + "kind" : "ident", + "position" : { + "line" : 0, + "filename" : "", + "offset" : 0, + "column" : 0 + }, + "value" : "int8" + }, "type" : "identifier", - "kind" : "type", "position" : { - "offset" : 0, + "column" : 0, "line" : 0, "filename" : "", - "column" : 0 + "offset" : 0 }, + "kind" : "type" + }, + "key" : { + "type" : "identifier", "value" : { + "value" : "string", "position" : { "column" : 0, "offset" : 0, "filename" : "", "line" : 0 }, - "kind" : "ident", - "value" : "string" - } - }, - "value" : { - "value" : { - "kind" : "ident", - "position" : { - "offset" : 0, - "filename" : "", - "line" : 0, - "column" : 0 - }, - "value" : "int8" + "kind" : "ident" }, "position" : { - "column" : 0, "filename" : "", + "offset" : 0, "line" : 0, - "offset" : 0 + "column" : 0 }, - "type" : "identifier", "kind" : "type" - } + }, + "kind" : "type" }, - "kind" : "literal", - "type" : "composite" + "type" : "composite", + "position" : { + "column" : 0, + "line" : 0, + "filename" : "", + "offset" : 0 + } } diff --git a/fixtures/expressions/parenintype/paren.json b/fixtures/expressions/parenintype/paren.json index 663e915..7f78715 100644 --- a/fixtures/expressions/parenintype/paren.json +++ b/fixtures/expressions/parenintype/paren.json @@ -1,65 +1,71 @@ { + "position" : { + "filename" : "", + "offset" : 0, + "column" : 0, + "line" : 0 + }, "coerced-to" : { + "kind" : "type", + "type" : "array", "length" : { - "value" : "2", "type" : "INT", "kind" : "literal", + "value" : "2", "position" : { "column" : 0, - "line" : 0, + "offset" : 0, "filename" : "", - "offset" : 0 + "line" : 0 } }, + "position" : { + "line" : 0, + "offset" : 0, + "column" : 0, + "filename" : "" + }, "element" : { + "kind" : "type", + "type" : "identifier", "position" : { - "offset" : 0, "filename" : "", - "line" : 0, - "column" : 0 + "offset" : 0, + "column" : 0, + "line" : 0 }, - "type" : "identifier", - "kind" : "type", "value" : { - "kind" : "ident", "position" : { "filename" : "", - "offset" : 0, "column" : 0, + "offset" : 0, "line" : 0 }, - "value" : "int" + "value" : "int", + "kind" : "ident" } - }, - "type" : "array", - "kind" : "type" - }, - "position" : { - "filename" : "", - "offset" : 0, - "column" : 0, - "line" : 0 + } }, + "type" : "cast", + "kind" : "expression", "target" : { "kind" : "expression", "type" : "identifier", "position" : { "offset" : 0, + "column" : 0, "filename" : "", - "line" : 0, - "column" : 0 + "line" : 0 }, "value" : { - "value" : "beakman", "kind" : "ident", "position" : { "offset" : 0, + "column" : 0, "filename" : "", - "line" : 0, - "column" : 0 - } + "line" : 0 + }, + "value" : "beakman" } - }, - "type" : "cast", - "kind" : "expression" + } } diff --git a/fixtures/expressions/ptrcast/ptr.json b/fixtures/expressions/ptrcast/ptr.json index f042517..3aefc9d 100644 --- a/fixtures/expressions/ptrcast/ptr.json +++ b/fixtures/expressions/ptrcast/ptr.json @@ -1,57 +1,57 @@ { - "kind" : "expression", "target" : { - "position" : { - "line" : 0, - "offset" : 0, - "column" : 0, - "filename" : "" - }, - "kind" : "expression", "type" : "call", - "arguments" : [ - { - "kind" : "expression", + "kind" : "expression", + "function" : { + "type" : "identifier", + "kind" : "expression", + "position" : { + "line" : 0, + "offset" : 0, + "filename" : "", + "column" : 0 + }, + "value" : { + "kind" : "ident", + "value" : "int8", "position" : { "line" : 0, "offset" : 0, "filename" : "", "column" : 0 - }, + } + } + }, + "arguments" : [ + { "value" : { - "value" : "biggie", + "kind" : "ident", "position" : { "filename" : "", - "offset" : 0, "column" : 0, - "line" : 0 + "line" : 0, + "offset" : 0 }, - "kind" : "ident" + "value" : "biggie" }, - "type" : "identifier" - } - ], - "function" : { - "type" : "identifier", - "kind" : "expression", - "position" : { - "offset" : 0, - "filename" : "", - "column" : 0, - "line" : 0 - }, - "value" : { - "value" : "int8", - "kind" : "ident", "position" : { + "column" : 0, "filename" : "", "offset" : 0, - "column" : 0, "line" : 0 - } + }, + "type" : "identifier", + "kind" : "expression" } + ], + "position" : { + "filename" : "", + "column" : 0, + "line" : 0, + "offset" : 0 }, "ellipsis" : false }, + "kind" : "expression", "type" : "star" } diff --git a/fixtures/expressions/singlequalifier/single.json b/fixtures/expressions/singlequalifier/single.json index 35b0de4..76b10c1 100644 --- a/fixtures/expressions/singlequalifier/single.json +++ b/fixtures/expressions/singlequalifier/single.json @@ -1,30 +1,30 @@ { + "kind" : "expression", + "type" : "identifier", + "qualifier" : { + "value" : "foo", + "position" : { + "line" : 0, + "column" : 0, + "offset" : 0, + "filename" : "" + }, + "kind" : "ident" + }, "position" : { "offset" : 0, - "column" : 0, "filename" : "", + "column" : 0, "line" : 0 }, "value" : { "value" : "bar", "position" : { - "offset" : 0, - "filename" : "", + "line" : 0, "column" : 0, - "line" : 0 + "offset" : 0, + "filename" : "" }, "kind" : "ident" - }, - "qualifier" : { - "kind" : "ident", - "value" : "foo", - "position" : { - "filename" : "", - "column" : 0, - "line" : 0, - "offset" : 0 - } - }, - "type" : "identifier", - "kind" : "expression" + } } diff --git a/fixtures/expressions/slicecast/slice.json b/fixtures/expressions/slicecast/slice.json index ad2eeb2..5eb76b2 100644 --- a/fixtures/expressions/slicecast/slice.json +++ b/fixtures/expressions/slicecast/slice.json @@ -1,54 +1,60 @@ { - "coerced-to": { - "element": { - "kind": "type", - "position": { - "column": 0, - "filename": "", - "line": 0, - "offset": 0 + "type" : "cast", + "target" : { + "value" : { + "position" : { + "filename" : "", + "offset" : 0, + "column" : 0, + "line" : 0 + }, + "kind" : "ident", + "value" : "foo" }, - "type": "identifier", - "value": { - "kind": "ident", - "position": { - "column": 0, - "filename": "", - "line": 0, - "offset": 0 - }, - "value": "int" - } - }, - "kind": "type", - "type": "slice" - }, - "kind": "expression", - "position": { - "column": 0, - "filename": "", - "line": 0, - "offset": 0 - }, - "target": { - "kind": "expression", - "position": { - "column": 0, - "filename": "", - "line": 0, - "offset": 0 - }, - "type": "identifier", - "value": { - "kind": "ident", - "position": { - "column": 0, - "filename": "", - "line": 0, - "offset": 0 + "type" : "identifier", + "position" : { + "line" : 0, + "column" : 0, + "offset" : 0, + "filename" : "" + }, + "kind" : "expression" + }, + "position" : { + "column" : 0, + "line" : 0, + "filename" : "", + "offset" : 0 + }, + "kind" : "expression", + "coerced-to" : { + "element" : { + "type" : "identifier", + "value" : { + "value" : "int", + "kind" : "ident", + "position" : { + "offset" : 0, + "filename" : "", + "line" : 0, + "column" : 0 + } + }, + "position" : { + "offset" : 0, + "filename" : "", + "line" : 0, + "column" : 0 + }, + "kind" : "type" }, - "value": "foo" - } - }, - "type": "cast" + "type" : "slice", + "kind" : "type", + "position" : { + "filename" : "", + "offset" : 0, + "column" : 0, + "line" : 0 + } + } } diff --git a/fixtures/packages/emptyfor/empty.json b/fixtures/packages/emptyfor/empty.json index a582eea..9d93ebe 100644 --- a/fixtures/packages/emptyfor/empty.json +++ b/fixtures/packages/emptyfor/empty.json @@ -1,57 +1,57 @@ { - "imports" : [], - "name" : { - "value" : "main", - "kind" : "ident", - "position" : { - "filename" : "fixtures/packages/emptyfor/empty.go", - "line" : 1, - "offset" : 8, - "column" : 9 - } - }, "all-comments" : [], - "comments" : [], "declarations" : [ { + "kind" : "decl", "name" : { "kind" : "ident", "position" : { - "line" : 3, - "filename" : "fixtures/packages/emptyfor/empty.go", "column" : 6, - "offset" : 19 + "line" : 3, + "offset" : 19, + "filename" : "fixtures/packages/emptyfor/empty.go" }, "value" : "main" }, - "results" : null, - "type" : "function", - "comments" : [], "position" : { + "column" : 1, "filename" : "fixtures/packages/emptyfor/empty.go", - "line" : 3, "offset" : 14, - "column" : 1 + "line" : 3 }, - "kind" : "decl", + "type" : "function", + "params" : [], + "comments" : [], "body" : [ { + "body" : [], + "type" : "for", "position" : { "column" : 2, + "filename" : "fixtures/packages/emptyfor/empty.go", "offset" : 29, - "line" : 4, - "filename" : "fixtures/packages/emptyfor/empty.go" + "line" : 4 }, + "init" : null, "post" : null, - "body" : [], - "type" : "for", "kind" : "statement", - "init" : null, "condition" : null } ], - "params" : [] + "results" : null } ], - "kind" : "file" + "name" : { + "kind" : "ident", + "position" : { + "column" : 9, + "offset" : 8, + "filename" : "fixtures/packages/emptyfor/empty.go", + "line" : 1 + }, + "value" : "main" + }, + "kind" : "file", + "imports" : [], + "comments" : [] } diff --git a/fixtures/packages/helloworld/helloworld.json b/fixtures/packages/helloworld/helloworld.json index 48ee1b5..78c1a37 100644 --- a/fixtures/packages/helloworld/helloworld.json +++ b/fixtures/packages/helloworld/helloworld.json @@ -1,91 +1,91 @@ { + "comments" : [], + "imports" : [], + "name" : { + "value" : "main", + "kind" : "ident", + "position" : { + "offset" : 8, + "filename" : "fixtures/packages/helloworld/helloworld.go", + "line" : 1, + "column" : 9 + } + }, "declarations" : [ { - "results" : null, - "position" : { - "line" : 3, - "column" : 1, - "filename" : "fixtures/packages/helloworld/helloworld.go", - "offset" : 14 - }, - "params" : [], - "name" : { - "value" : "main", - "position" : { - "offset" : 19, - "filename" : "fixtures/packages/helloworld/helloworld.go", - "column" : 6, - "line" : 3 - }, - "kind" : "ident" - }, - "type" : "function", - "kind" : "decl", - "comments" : [], "body" : [ { - "type" : "expression", "kind" : "statement", "value" : { - "kind" : "expression", - "type" : "call", + "function" : { + "type" : "identifier", + "value" : { + "position" : { + "filename" : "fixtures/packages/helloworld/helloworld.go", + "offset" : 29, + "line" : 4, + "column" : 2 + }, + "kind" : "ident", + "value" : "println" + }, + "kind" : "expression", + "position" : { + "column" : 2, + "line" : 4, + "offset" : 29, + "filename" : "fixtures/packages/helloworld/helloworld.go" + } + }, "position" : { "line" : 4, + "column" : 2, "offset" : 29, - "filename" : "fixtures/packages/helloworld/helloworld.go", - "column" : 2 + "filename" : "fixtures/packages/helloworld/helloworld.go" }, + "kind" : "expression", "arguments" : [ { - "kind" : "literal", "type" : "STRING", + "value" : "\"Hello, world!\"", "position" : { "filename" : "fixtures/packages/helloworld/helloworld.go", "offset" : 37, "column" : 10, "line" : 4 }, - "value" : "\"Hello, world!\"" + "kind" : "literal" } ], - "function" : { - "position" : { - "line" : 4, - "column" : 2, - "filename" : "fixtures/packages/helloworld/helloworld.go", - "offset" : 29 - }, - "type" : "identifier", - "kind" : "expression", - "value" : { - "value" : "println", - "kind" : "ident", - "position" : { - "column" : 2, - "filename" : "fixtures/packages/helloworld/helloworld.go", - "offset" : 29, - "line" : 4 - } - } - }, - "ellipsis" : false - } + "ellipsis" : false, + "type" : "call" + }, + "type" : "expression" } - ] + ], + "results" : null, + "kind" : "decl", + "name" : { + "value" : "main", + "position" : { + "line" : 3, + "column" : 6, + "offset" : 19, + "filename" : "fixtures/packages/helloworld/helloworld.go" + }, + "kind" : "ident" + }, + "position" : { + "filename" : "fixtures/packages/helloworld/helloworld.go", + "offset" : 14, + "line" : 3, + "column" : 1 + }, + "type" : "function", + "comments" : [], + "params" : [] } ], - "comments" : [], - "all-comments" : [], - "imports" : [], "kind" : "file", - "name" : { - "position" : { - "line" : 1, - "offset" : 8, - "filename" : "fixtures/packages/helloworld/helloworld.go", - "column" : 9 - }, - "kind" : "ident", - "value" : "main" - } + "all-comments" : [] } diff --git a/fixtures/packages/interface_type/interface.json b/fixtures/packages/interface_type/interface.json index 4c621f6..5f9f695 100644 --- a/fixtures/packages/interface_type/interface.json +++ b/fixtures/packages/interface_type/interface.json @@ -1,144 +1,181 @@ { + "name" : { + "position" : { + "offset" : 8, + "line" : 1, + "column" : 9, + "filename" : "fixtures/packages/interface_type/interface.go" + }, + "value" : "main", + "kind" : "ident" + }, "kind" : "file", - "comments" : [], "declarations" : [ { - "comments" : [], "kind" : "decl", - "params" : [], + "name" : { + "value" : "main", + "kind" : "ident", + "position" : { + "filename" : "fixtures/packages/interface_type/interface.go", + "column" : 6, + "line" : 3, + "offset" : 19 + } + }, + "comments" : [], + "results" : null, + "type" : "function", + "position" : { + "filename" : "fixtures/packages/interface_type/interface.go", + "column" : 1, + "line" : 3, + "offset" : 14 + }, "body" : [ { - "kind" : "statement", - "position" : { - "line" : 4, - "column" : 2, - "offset" : 29, - "filename" : "fixtures/packages/interface_type/interface.go" - }, "type" : "define", "right" : [ { "values" : [ { + "key" : { + "value" : "\"foo\"", + "position" : { + "column" : 3, + "line" : 5, + "offset" : 63, + "filename" : "fixtures/packages/interface_type/interface.go" + }, + "kind" : "literal", + "type" : "STRING" + }, + "type" : "key-value", "value" : { "value" : "\"bar\"", - "type" : "STRING", "position" : { - "filename" : "fixtures/packages/interface_type/interface.go", - "column" : 10, "offset" : 70, - "line" : 5 + "line" : 5, + "column" : 10, + "filename" : "fixtures/packages/interface_type/interface.go" }, - "kind" : "literal" + "kind" : "literal", + "type" : "STRING" }, - "type" : "key-value", + "kind" : "expression" + }, + { "kind" : "expression", - "key" : { + "value" : { + "value" : "400", "kind" : "literal", "position" : { "filename" : "fixtures/packages/interface_type/interface.go", - "offset" : 63, - "column" : 3, - "line" : 5 + "offset" : 86, + "line" : 6, + "column" : 10 }, - "type" : "STRING", - "value" : "\"foo\"" - } - }, - { + "type" : "INT" + }, + "type" : "key-value", "key" : { - "kind" : "literal", "type" : "STRING", "value" : "\"baz\"", + "kind" : "literal", "position" : { - "filename" : "fixtures/packages/interface_type/interface.go", "line" : 6, + "column" : 3, "offset" : 79, - "column" : 3 - } - }, - "kind" : "expression", - "type" : "key-value", - "value" : { - "kind" : "literal", - "value" : "400", - "type" : "INT", - "position" : { - "filename" : "fixtures/packages/interface_type/interface.go", - "column" : 10, - "offset" : 86, - "line" : 6 + "filename" : "fixtures/packages/interface_type/interface.go" } } } ], - "kind" : "literal", "declared" : { - "kind" : "type", "key" : { "kind" : "type", - "position" : { - "filename" : "fixtures/packages/interface_type/interface.go", - "column" : 14, - "offset" : 41, - "line" : 4 - }, - "type" : "identifier", "value" : { + "value" : "string", + "kind" : "ident", "position" : { - "filename" : "fixtures/packages/interface_type/interface.go", "offset" : 41, "column" : 14, - "line" : 4 - }, - "value" : "string", - "kind" : "ident" - } + "line" : 4, + "filename" : "fixtures/packages/interface_type/interface.go" + } + }, + "position" : { + "offset" : 41, + "line" : 4, + "column" : 14, + "filename" : "fixtures/packages/interface_type/interface.go" + }, + "type" : "identifier" + }, + "position" : { + "offset" : 37, + "column" : 10, + "line" : 4, + "filename" : "fixtures/packages/interface_type/interface.go" }, - "type" : "map", "value" : { + "position" : { + "filename" : "fixtures/packages/interface_type/interface.go", + "line" : 4, + "column" : 21, + "offset" : 48 + }, + "kind" : "type", "type" : "interface", "methods" : [], - "incomplete" : false, - "kind" : "type" - } + "incomplete" : false + }, + "kind" : "type", + "type" : "map" }, + "type" : "composite", "position" : { "column" : 10, - "offset" : 37, "line" : 4, + "offset" : 37, "filename" : "fixtures/packages/interface_type/interface.go" }, - "type" : "composite" + "kind" : "literal" } ], + "kind" : "statement", + "position" : { + "offset" : 29, + "column" : 2, + "line" : 4, + "filename" : "fixtures/packages/interface_type/interface.go" + }, "left" : [ { - "kind" : "expression", - "position" : { - "line" : 4, - "offset" : 29, - "column" : 2, - "filename" : "fixtures/packages/interface_type/interface.go" - }, + "type" : "identifier", "value" : { + "value" : "item", "kind" : "ident", "position" : { "filename" : "fixtures/packages/interface_type/interface.go", - "line" : 4, + "offset" : 29, "column" : 2, - "offset" : 29 - }, - "value" : "item" + "line" : 4 + } + }, + "position" : { + "offset" : 29, + "column" : 2, + "line" : 4, + "filename" : "fixtures/packages/interface_type/interface.go" }, - "type" : "identifier" + "kind" : "expression" } ] }, { - "kind" : "statement", + "type" : "expression", "value" : { - "type" : "call", "position" : { "filename" : "fixtures/packages/interface_type/interface.go", "offset" : 96, @@ -146,104 +183,79 @@ "line" : 9 }, "kind" : "expression", - "ellipsis" : false, "function" : { - "kind" : "expression", "type" : "identifier", "value" : { "kind" : "ident", + "value" : "println", "position" : { + "offset" : 96, "line" : 9, "column" : 2, - "offset" : 96, "filename" : "fixtures/packages/interface_type/interface.go" - }, - "value" : "println" + } }, "position" : { - "filename" : "fixtures/packages/interface_type/interface.go", - "column" : 2, "offset" : 96, - "line" : 9 - } + "line" : 9, + "column" : 2, + "filename" : "fixtures/packages/interface_type/interface.go" + }, + "kind" : "expression" }, "arguments" : [ { "kind" : "expression", + "position" : { + "column" : 10, + "line" : 9, + "offset" : 104, + "filename" : "fixtures/packages/interface_type/interface.go" + }, + "type" : "index", "index" : { + "type" : "STRING", "position" : { - "filename" : "fixtures/packages/interface_type/interface.go", "column" : 15, + "line" : 9, "offset" : 109, - "line" : 9 + "filename" : "fixtures/packages/interface_type/interface.go" }, - "type" : "STRING", "value" : "\"foo\"", "kind" : "literal" }, - "type" : "index", "target" : { - "kind" : "expression", - "type" : "identifier", "value" : { "position" : { "filename" : "fixtures/packages/interface_type/interface.go", "column" : 10, - "offset" : 104, - "line" : 9 + "line" : 9, + "offset" : 104 }, "value" : "item", "kind" : "ident" }, + "kind" : "expression", "position" : { - "filename" : "fixtures/packages/interface_type/interface.go", - "column" : 10, "offset" : 104, - "line" : 9 - } - }, - "position" : { - "line" : 9, - "column" : 10, - "offset" : 104, - "filename" : "fixtures/packages/interface_type/interface.go" + "column" : 10, + "line" : 9, + "filename" : "fixtures/packages/interface_type/interface.go" + }, + "type" : "identifier" } } - ] + ], + "type" : "call", + "ellipsis" : false }, - "type" : "expression" + "kind" : "statement" } ], - "results" : null, - "type" : "function", - "name" : { - "kind" : "ident", - "value" : "main", - "position" : { - "filename" : "fixtures/packages/interface_type/interface.go", - "line" : 3, - "offset" : 19, - "column" : 6 - } - }, - "position" : { - "filename" : "fixtures/packages/interface_type/interface.go", - "offset" : 14, - "column" : 1, - "line" : 3 - } + "params" : [] } ], "all-comments" : [], - "name" : { - "position" : { - "column" : 9, - "offset" : 8, - "line" : 1, - "filename" : "fixtures/packages/interface_type/interface.go" - }, - "value" : "main", - "kind" : "ident" - }, - "imports" : [] + "imports" : [], + "comments" : [] } diff --git a/fixtures/packages/methoddecl/method.json b/fixtures/packages/methoddecl/method.json index 03f9f89..167fe19 100644 --- a/fixtures/packages/methoddecl/method.json +++ b/fixtures/packages/methoddecl/method.json @@ -1,327 +1,325 @@ { - "kind" : "file", - "imports" : [], "declarations" : [ { + "kind" : "decl", + "name" : { + "position" : { + "line" : 3, + "filename" : "fixtures/packages/methoddecl/method.go", + "offset" : 19, + "column" : 6 + }, + "value" : "Thing", + "kind" : "ident" + }, "comments" : [], + "type" : "type-alias", "value" : { - "kind" : "type", "type" : "struct", + "position" : { + "column" : 12, + "offset" : 25, + "filename" : "fixtures/packages/methoddecl/method.go", + "line" : 3 + }, "fields" : [ { "names" : [ { "kind" : "ident", + "value" : "count", "position" : { - "filename" : "fixtures/packages/methoddecl/method.go", - "offset" : 35, "column" : 2, - "line" : 4 - }, - "value" : "count" + "offset" : 35, + "line" : 4, + "filename" : "fixtures/packages/methoddecl/method.go" + } } ], + "tag" : null, "kind" : "field", "declared-type" : { - "type" : "identifier", "kind" : "type", + "type" : "identifier", "position" : { - "filename" : "fixtures/packages/methoddecl/method.go", "offset" : 41, - "column" : 8, - "line" : 4 + "filename" : "fixtures/packages/methoddecl/method.go", + "line" : 4, + "column" : 8 }, "value" : { - "kind" : "ident", + "value" : "int8", "position" : { - "filename" : "fixtures/packages/methoddecl/method.go", - "offset" : 41, "column" : 8, - "line" : 4 + "offset" : 41, + "line" : 4, + "filename" : "fixtures/packages/methoddecl/method.go" }, - "value" : "int8" + "kind" : "ident" } - }, - "tag" : null + } } - ] + ], + "kind" : "type" }, "position" : { - "offset" : 19, + "column" : 6, "filename" : "fixtures/packages/methoddecl/method.go", "line" : 3, - "column" : 6 - }, - "type" : "type-alias", - "kind" : "decl", - "name" : { - "position" : { - "filename" : "fixtures/packages/methoddecl/method.go", - "offset" : 19, - "column" : 6, - "line" : 3 - }, - "value" : "Thing", - "kind" : "ident" + "offset" : 19 } }, { + "params" : [], + "type" : "method", + "comments" : [], + "position" : { + "line" : 7, + "filename" : "fixtures/packages/methoddecl/method.go", + "offset" : 49, + "column" : 1 + }, "kind" : "decl", "body" : [ { - "kind" : "statement", + "operator" : "+", + "position" : { + "offset" : 73, + "filename" : "fixtures/packages/methoddecl/method.go", + "line" : 8, + "column" : 2 + }, "type" : "assign-operator", "left" : [ { - "type" : "identifier", "kind" : "expression", "value" : { + "kind" : "ident", "value" : "count", "position" : { + "filename" : "fixtures/packages/methoddecl/method.go", "line" : 8, - "column" : 4, "offset" : 75, - "filename" : "fixtures/packages/methoddecl/method.go" - }, - "kind" : "ident" - }, - "position" : { - "filename" : "fixtures/packages/methoddecl/method.go", - "offset" : 73, - "column" : 2, - "line" : 8 + "column" : 4 + } }, "qualifier" : { "kind" : "ident", + "value" : "t", "position" : { - "filename" : "fixtures/packages/methoddecl/method.go", "offset" : 73, - "column" : 2, - "line" : 8 - }, - "value" : "t" - } + "line" : 8, + "filename" : "fixtures/packages/methoddecl/method.go", + "column" : 2 + } + }, + "position" : { + "offset" : 73, + "line" : 8, + "filename" : "fixtures/packages/methoddecl/method.go", + "column" : 2 + }, + "type" : "identifier" } ], - "position" : { - "filename" : "fixtures/packages/methoddecl/method.go", - "offset" : 73, - "column" : 2, - "line" : 8 - }, + "kind" : "statement", "right" : [ { + "kind" : "literal", "position" : { - "offset" : 84, + "column" : 13, "filename" : "fixtures/packages/methoddecl/method.go", "line" : 8, - "column" : 13 + "offset" : 84 }, "value" : "1", - "kind" : "literal", "type" : "INT" } - ], - "operator" : "+" + ] } ], - "name" : { - "kind" : "ident", - "value" : "Inc", - "position" : { - "column" : 16, - "line" : 7, - "filename" : "fixtures/packages/methoddecl/method.go", - "offset" : 64 - } - }, - "type" : "method", "receiver" : { - "names" : [ - { - "kind" : "ident", + "declared-type" : { + "kind" : "type", + "value" : { "position" : { "filename" : "fixtures/packages/methoddecl/method.go", - "offset" : 55, - "column" : 7, - "line" : 7 + "line" : 7, + "offset" : 57, + "column" : 9 }, - "value" : "t" - } - ], - "kind" : "field", - "tag" : null, - "declared-type" : { - "type" : "identifier", - "kind" : "type", + "value" : "Thing", + "kind" : "ident" + }, "position" : { + "filename" : "fixtures/packages/methoddecl/method.go", "line" : 7, - "column" : 9, "offset" : 57, - "filename" : "fixtures/packages/methoddecl/method.go" + "column" : 9 }, - "value" : { - "value" : "Thing", + "type" : "identifier" + }, + "kind" : "field", + "tag" : null, + "names" : [ + { "position" : { + "offset" : 55, + "filename" : "fixtures/packages/methoddecl/method.go", "line" : 7, - "column" : 9, - "offset" : 57, - "filename" : "fixtures/packages/methoddecl/method.go" + "column" : 7 }, + "value" : "t", "kind" : "ident" } - } + ] }, - "params" : [], - "comments" : [], - "results" : null, - "position" : { - "line" : 7, - "column" : 1, - "offset" : 49, - "filename" : "fixtures/packages/methoddecl/method.go" - } - }, - { "name" : { - "value" : "main", + "kind" : "ident", + "value" : "Inc", "position" : { - "offset" : 94, + "offset" : 64, "filename" : "fixtures/packages/methoddecl/method.go", - "line" : 11, - "column" : 6 - }, - "kind" : "ident" + "line" : 7, + "column" : 16 + } }, + "results" : null + }, + { + "results" : null, "body" : [ { + "position" : { + "offset" : 104, + "line" : 12, + "filename" : "fixtures/packages/methoddecl/method.go", + "column" : 2 + }, + "type" : "define", "left" : [ { - "type" : "identifier", "kind" : "expression", + "type" : "identifier", "value" : { - "kind" : "ident", "value" : "t", "position" : { + "column" : 2, "offset" : 104, - "filename" : "fixtures/packages/methoddecl/method.go", "line" : 12, - "column" : 2 - } + "filename" : "fixtures/packages/methoddecl/method.go" + }, + "kind" : "ident" }, "position" : { "filename" : "fixtures/packages/methoddecl/method.go", + "line" : 12, "offset" : 104, - "column" : 2, - "line" : 12 + "column" : 2 } } ], - "position" : { - "filename" : "fixtures/packages/methoddecl/method.go", - "offset" : 104, - "column" : 2, - "line" : 12 - }, + "kind" : "statement", "right" : [ { - "declared" : { - "position" : { - "filename" : "fixtures/packages/methoddecl/method.go", - "offset" : 109, - "column" : 7, - "line" : 12 - }, - "value" : { - "position" : { - "offset" : 109, - "filename" : "fixtures/packages/methoddecl/method.go", - "line" : 12, - "column" : 7 - }, - "value" : "Thing", - "kind" : "ident" - }, - "kind" : "type", - "type" : "identifier" - }, + "kind" : "literal", "values" : [ { - "type" : "INT", - "kind" : "literal", - "value" : "1", "position" : { + "filename" : "fixtures/packages/methoddecl/method.go", "line" : 12, - "column" : 13, "offset" : 115, - "filename" : "fixtures/packages/methoddecl/method.go" - } + "column" : 13 + }, + "value" : "1", + "type" : "INT", + "kind" : "literal" } ], + "declared" : { + "value" : { + "kind" : "ident", + "value" : "Thing", + "position" : { + "column" : 7, + "offset" : 109, + "filename" : "fixtures/packages/methoddecl/method.go", + "line" : 12 + } + }, + "position" : { + "offset" : 109, + "line" : 12, + "filename" : "fixtures/packages/methoddecl/method.go", + "column" : 7 + }, + "type" : "identifier", + "kind" : "type" + }, "position" : { - "column" : 7, + "offset" : 109, "line" : 12, "filename" : "fixtures/packages/methoddecl/method.go", - "offset" : 109 + "column" : 7 }, - "type" : "composite", - "kind" : "literal" + "type" : "composite" } - ], - "type" : "define", - "kind" : "statement" + ] }, { - "type" : "expression", "kind" : "statement", "value" : { + "kind" : "expression", + "arguments" : [], "position" : { "column" : 2, + "offset" : 119, "line" : 13, - "filename" : "fixtures/packages/methoddecl/method.go", - "offset" : 119 + "filename" : "fixtures/packages/methoddecl/method.go" }, "function" : { - "type" : "identifier", - "kind" : "expression", - "value" : { - "position" : { - "line" : 13, - "column" : 4, - "offset" : 121, - "filename" : "fixtures/packages/methoddecl/method.go" - }, - "value" : "Inc", - "kind" : "ident" - }, "position" : { - "column" : 2, "line" : 13, "filename" : "fixtures/packages/methoddecl/method.go", - "offset" : 119 + "offset" : 119, + "column" : 2 }, "qualifier" : { - "kind" : "ident", "position" : { - "line" : 13, "column" : 2, "offset" : 119, + "line" : 13, "filename" : "fixtures/packages/methoddecl/method.go" }, - "value" : "t" - } + "value" : "t", + "kind" : "ident" + }, + "value" : { + "kind" : "ident", + "value" : "Inc", + "position" : { + "column" : 4, + "offset" : 121, + "filename" : "fixtures/packages/methoddecl/method.go", + "line" : 13 + } + }, + "type" : "identifier", + "kind" : "expression" }, - "ellipsis" : false, - "arguments" : [], - "kind" : "expression", - "type" : "call" - } + "type" : "call", + "ellipsis" : false + }, + "type" : "expression" }, { "type" : "expression", - "kind" : "statement", "value" : { + "ellipsis" : false, + "type" : "call", "function" : { + "kind" : "expression", + "type" : "identifier", "position" : { "offset" : 128, "filename" : "fixtures/packages/methoddecl/method.go", @@ -329,85 +327,93 @@ "column" : 2 }, "value" : { - "kind" : "ident", "value" : "println", "position" : { "offset" : 128, - "filename" : "fixtures/packages/methoddecl/method.go", "line" : 14, + "filename" : "fixtures/packages/methoddecl/method.go", "column" : 2 - } - }, - "type" : "identifier", - "kind" : "expression" + }, + "kind" : "ident" + } + }, + "position" : { + "line" : 14, + "filename" : "fixtures/packages/methoddecl/method.go", + "offset" : 128, + "column" : 2 }, - "ellipsis" : false, - "type" : "call", - "kind" : "expression", "arguments" : [ { - "type" : "identifier", "kind" : "expression", - "value" : { - "kind" : "ident", - "position" : { - "column" : 12, - "line" : 14, - "filename" : "fixtures/packages/methoddecl/method.go", - "offset" : 138 - }, - "value" : "count" - }, + "type" : "identifier", "qualifier" : { "position" : { "column" : 10, + "offset" : 136, "line" : 14, - "filename" : "fixtures/packages/methoddecl/method.go", - "offset" : 136 + "filename" : "fixtures/packages/methoddecl/method.go" }, "value" : "t", "kind" : "ident" }, "position" : { - "column" : 10, "line" : 14, "filename" : "fixtures/packages/methoddecl/method.go", - "offset" : 136 + "offset" : 136, + "column" : 10 + }, + "value" : { + "position" : { + "offset" : 138, + "filename" : "fixtures/packages/methoddecl/method.go", + "line" : 14, + "column" : 12 + }, + "value" : "count", + "kind" : "ident" } } ], - "position" : { - "line" : 14, - "column" : 2, - "offset" : 128, - "filename" : "fixtures/packages/methoddecl/method.go" - } - } + "kind" : "expression" + }, + "kind" : "statement" } ], + "name" : { + "kind" : "ident", + "value" : "main", + "position" : { + "filename" : "fixtures/packages/methoddecl/method.go", + "line" : 11, + "offset" : 94, + "column" : 6 + } + }, "kind" : "decl", - "type" : "function", - "results" : null, "position" : { - "column" : 1, "line" : 11, "filename" : "fixtures/packages/methoddecl/method.go", - "offset" : 89 + "offset" : 89, + "column" : 1 }, "comments" : [], + "type" : "function", "params" : [] } ], + "comments" : [], + "imports" : [], "name" : { - "kind" : "ident", "value" : "main", "position" : { "column" : 9, + "offset" : 8, "line" : 1, - "filename" : "fixtures/packages/methoddecl/method.go", - "offset" : 8 - } + "filename" : "fixtures/packages/methoddecl/method.go" + }, + "kind" : "ident" }, - "comments" : [], + "kind" : "file", "all-comments" : [] } diff --git a/fixtures/packages/qualifiedtype/qualified.json b/fixtures/packages/qualifiedtype/qualified.json index 5dc6814..7af16df 100644 --- a/fixtures/packages/qualifiedtype/qualified.json +++ b/fixtures/packages/qualifiedtype/qualified.json @@ -1,29 +1,39 @@ { - "kind" : "file", + "comments" : [], + "name" : { + "value" : "main", + "position" : { + "column" : 9, + "line" : 1, + "offset" : 8, + "filename" : "fixtures/packages/qualifiedtype/qualified.go" + }, + "kind" : "ident" + }, "imports" : [ { "type" : "import", - "kind" : "decl", "specs" : [ { + "path" : "go/ast", "comments" : [], + "name" : null, + "type" : "import", + "doc" : [], "position" : { - "column" : 8, "line" : 3, + "column" : 8, "filename" : "fixtures/packages/qualifiedtype/qualified.go", "offset" : 21 - }, - "name" : null, - "doc" : [], - "type" : "import", - "path" : "go/ast" + } } ], + "kind" : "decl", "position" : { - "offset" : 14, + "column" : 1, "line" : 3, - "filename" : "fixtures/packages/qualifiedtype/qualified.go", - "column" : 1 + "offset" : 14, + "filename" : "fixtures/packages/qualifiedtype/qualified.go" } } ], @@ -32,133 +42,123 @@ "position" : { "column" : 1, "line" : 3, - "filename" : "fixtures/packages/qualifiedtype/qualified.go", - "offset" : 14 + "offset" : 14, + "filename" : "fixtures/packages/qualifiedtype/qualified.go" }, + "kind" : "decl", "specs" : [ { - "type" : "import", - "path" : "go/ast", - "comments" : [], "doc" : [], - "name" : null, + "type" : "import", "position" : { - "column" : 8, - "line" : 3, + "offset" : 21, "filename" : "fixtures/packages/qualifiedtype/qualified.go", - "offset" : 21 - } + "column" : 8, + "line" : 3 + }, + "path" : "go/ast", + "comments" : [], + "name" : null } ], - "kind" : "decl", "type" : "import" }, { - "name" : { - "value" : "doit", - "position" : { - "line" : 5, - "filename" : "fixtures/packages/qualifiedtype/qualified.go", - "column" : 6, - "offset" : 36 - }, - "kind" : "ident" - }, + "comments" : [], + "results" : null, "position" : { - "offset" : 31, "column" : 1, "line" : 5, + "offset" : 31, "filename" : "fixtures/packages/qualifiedtype/qualified.go" }, - "type" : "function", - "results" : null, - "kind" : "decl", - "comments" : [], "body" : [], + "name" : { + "position" : { + "column" : 6, + "line" : 5, + "offset" : 36, + "filename" : "fixtures/packages/qualifiedtype/qualified.go" + }, + "value" : "doit", + "kind" : "ident" + }, "params" : [ { - "kind" : "field", - "names" : [ - { + "declared-type" : { + "type" : "identifier", + "value" : { + "value" : "Node", "kind" : "ident", "position" : { - "offset" : 41, - "column" : 11, + "column" : 17, "line" : 5, + "offset" : 47, "filename" : "fixtures/packages/qualifiedtype/qualified.go" - }, - "value" : "a" - } - ], - "tag" : null, - "declared-type" : { + } + }, + "kind" : "type", + "position" : { + "filename" : "fixtures/packages/qualifiedtype/qualified.go", + "offset" : 43, + "line" : 5, + "column" : 13 + }, "qualifier" : { "kind" : "ident", "value" : "ast", "position" : { "offset" : 43, - "line" : 5, "filename" : "fixtures/packages/qualifiedtype/qualified.go", - "column" : 13 + "column" : 13, + "line" : 5 } - }, - "value" : { + } + }, + "tag" : null, + "names" : [ + { "kind" : "ident", - "value" : "Node", + "value" : "a", "position" : { - "offset" : 47, - "filename" : "fixtures/packages/qualifiedtype/qualified.go", + "column" : 11, "line" : 5, - "column" : 17 + "offset" : 41, + "filename" : "fixtures/packages/qualifiedtype/qualified.go" } - }, - "position" : { - "offset" : 43, - "line" : 5, - "filename" : "fixtures/packages/qualifiedtype/qualified.go", - "column" : 13 - }, - "type" : "identifier", - "kind" : "type" - } + } + ], + "kind" : "field" } - ] + ], + "kind" : "decl", + "type" : "function" }, { - "position" : { - "column" : 1, - "filename" : "fixtures/packages/qualifiedtype/qualified.go", - "line" : 9, - "offset" : 59 - }, + "kind" : "decl", + "type" : "function", + "params" : [], "name" : { - "kind" : "ident", - "value" : "main", "position" : { - "offset" : 64, "line" : 9, + "column" : 6, "filename" : "fixtures/packages/qualifiedtype/qualified.go", - "column" : 6 - } + "offset" : 64 + }, + "value" : "main", + "kind" : "ident" + }, + "position" : { + "filename" : "fixtures/packages/qualifiedtype/qualified.go", + "offset" : 59, + "line" : 9, + "column" : 1 }, - "kind" : "decl", - "type" : "function", - "results" : null, - "comments" : [], "body" : [], - "params" : [] + "comments" : [], + "results" : null } ], - "comments" : [], - "all-comments" : [], - "name" : { - "kind" : "ident", - "position" : { - "offset" : 8, - "line" : 1, - "filename" : "fixtures/packages/qualifiedtype/qualified.go", - "column" : 9 - }, - "value" : "main" - } + "kind" : "file", + "all-comments" : [] } diff --git a/fixtures/packages/select/select.json b/fixtures/packages/select/select.json index f8c09e0..dd48728 100644 --- a/fixtures/packages/select/select.json +++ b/fixtures/packages/select/select.json @@ -1,79 +1,79 @@ { - "all-comments" : [], - "name" : { - "value" : "main", - "position" : { - "offset" : 8, - "filename" : "fixtures/packages/select/select.go", - "column" : 9, - "line" : 1 - }, - "kind" : "ident" - }, "declarations" : [ { - "results" : null, "position" : { + "filename" : "fixtures/packages/select/select.go", "column" : 1, - "line" : 3, "offset" : 14, - "filename" : "fixtures/packages/select/select.go" + "line" : 3 }, + "type" : "function", + "results" : null, + "params" : [], "name" : { - "value" : "main", "kind" : "ident", "position" : { - "line" : 3, - "column" : 6, + "filename" : "fixtures/packages/select/select.go", "offset" : 19, - "filename" : "fixtures/packages/select/select.go" - } + "column" : 6, + "line" : 3 + }, + "value" : "main" }, - "type" : "function", - "comments" : [], - "params" : [], "kind" : "decl", "body" : [ { + "type" : "select", + "position" : { + "line" : 4, + "filename" : "fixtures/packages/select/select.go", + "offset" : 29, + "column" : 2 + }, "body" : [ { + "statement" : null, "body" : [ { - "values" : [], - "type" : "return", - "kind" : "statement", "position" : { - "filename" : "fixtures/packages/select/select.go", - "offset" : 50, "line" : 6, - "column" : 3 - } + "offset" : 50, + "column" : 3, + "filename" : "fixtures/packages/select/select.go" + }, + "type" : "return", + "kind" : "statement", + "values" : [] } ], + "kind" : "statement", "type" : "select-clause", "position" : { - "line" : 5, "column" : 2, + "offset" : 39, "filename" : "fixtures/packages/select/select.go", - "offset" : 39 - }, - "statement" : null, - "kind" : "statement" + "line" : 5 + } } ], - "type" : "select", - "position" : { - "filename" : "fixtures/packages/select/select.go", - "offset" : 29, - "line" : 4, - "column" : 2 - }, "kind" : "statement" } - ] + ], + "comments" : [] } ], - "comments" : [], + "name" : { + "value" : "main", + "position" : { + "line" : 1, + "column" : 9, + "offset" : 8, + "filename" : "fixtures/packages/select/select.go" + }, + "kind" : "ident" + }, + "imports" : [], + "all-comments" : [], "kind" : "file", - "imports" : [] + "comments" : [] } diff --git a/fixtures/packages/simpletypealias/simpletypealias.json b/fixtures/packages/simpletypealias/simpletypealias.json index 8df9ca8..6aaf74f 100644 --- a/fixtures/packages/simpletypealias/simpletypealias.json +++ b/fixtures/packages/simpletypealias/simpletypealias.json @@ -1,98 +1,104 @@ { - "all-comments" : [], + "imports" : [], + "name" : { + "kind" : "ident", + "position" : { + "line" : 1, + "filename" : "fixtures/packages/simpletypealias/simpletypealias.go", + "offset" : 8, + "column" : 9 + }, + "value" : "main" + }, "kind" : "file", - "comments" : [], + "all-comments" : [], "declarations" : [ { - "kind" : "decl", - "name" : { - "kind" : "ident", - "value" : "MyArray", - "position" : { - "line" : 3, - "offset" : 19, - "column" : 6, - "filename" : "fixtures/packages/simpletypealias/simpletypealias.go" - } + "position" : { + "filename" : "fixtures/packages/simpletypealias/simpletypealias.go", + "line" : 3, + "offset" : 19, + "column" : 6 }, "comments" : [], "value" : { + "kind" : "type", + "type" : "array", + "position" : { + "line" : 3, + "filename" : "fixtures/packages/simpletypealias/simpletypealias.go", + "offset" : 27, + "column" : 14 + }, "length" : { + "type" : "INT", "kind" : "literal", "value" : "100", "position" : { - "offset" : 28, - "line" : 3, "column" : 15, - "filename" : "fixtures/packages/simpletypealias/simpletypealias.go" - }, - "type" : "INT" + "filename" : "fixtures/packages/simpletypealias/simpletypealias.go", + "line" : 3, + "offset" : 28 + } }, - "kind" : "type", - "type" : "array", "element" : { - "kind" : "type", - "type" : "identifier", "value" : { "position" : { - "filename" : "fixtures/packages/simpletypealias/simpletypealias.go", "column" : 19, - "offset" : 32, - "line" : 3 + "filename" : "fixtures/packages/simpletypealias/simpletypealias.go", + "line" : 3, + "offset" : 32 }, "value" : "int", "kind" : "ident" }, "position" : { - "line" : 3, + "column" : 19, "offset" : 32, - "filename" : "fixtures/packages/simpletypealias/simpletypealias.go", - "column" : 19 - } + "line" : 3, + "filename" : "fixtures/packages/simpletypealias/simpletypealias.go" + }, + "type" : "identifier", + "kind" : "type" } }, - "type" : "type-alias", - "position" : { - "filename" : "fixtures/packages/simpletypealias/simpletypealias.go", - "column" : 6, - "offset" : 19, - "line" : 3 - } - }, - { + "kind" : "decl", "name" : { "kind" : "ident", + "value" : "MyArray", "position" : { - "offset" : 42, - "line" : 5, + "offset" : 19, + "line" : 3, "filename" : "fixtures/packages/simpletypealias/simpletypealias.go", "column" : 6 - }, - "value" : "main" + } }, - "results" : null, - "type" : "function", - "comments" : [], + "type" : "type-alias" + }, + { "body" : [], - "kind" : "decl", - "params" : [], "position" : { - "filename" : "fixtures/packages/simpletypealias/simpletypealias.go", "column" : 1, "line" : 5, + "filename" : "fixtures/packages/simpletypealias/simpletypealias.go", "offset" : 37 - } + }, + "params" : [], + "results" : null, + "comments" : [], + "name" : { + "kind" : "ident", + "value" : "main", + "position" : { + "column" : 6, + "offset" : 42, + "filename" : "fixtures/packages/simpletypealias/simpletypealias.go", + "line" : 5 + } + }, + "type" : "function", + "kind" : "decl" } ], - "name" : { - "kind" : "ident", - "value" : "main", - "position" : { - "line" : 1, - "offset" : 8, - "filename" : "fixtures/packages/simpletypealias/simpletypealias.go", - "column" : 9 - } - }, - "imports" : [] + "comments" : [] } diff --git a/fixtures/packages/untypedvar/untyped.json b/fixtures/packages/untypedvar/untyped.json index 88ea92f..ff57828 100644 --- a/fixtures/packages/untypedvar/untyped.json +++ b/fixtures/packages/untypedvar/untyped.json @@ -1,67 +1,67 @@ { - "all-comments" : [], "imports" : [], - "kind" : "file", + "all-comments" : [], + "comments" : [], "declarations" : [ { + "kind" : "decl", "specs" : [ { - "kind" : "spec", - "position" : { - "offset" : 15, - "column" : 5, - "filename" : "fixtures/packages/untypedvar/untyped.go", - "line" : 3 - }, - "comments" : [], - "values" : [ + "type" : "var", + "names" : [ { - "type" : "INT", - "kind" : "literal", - "value" : "1", + "kind" : "ident", "position" : { "line" : 3, - "offset" : 19, - "filename" : "fixtures/packages/untypedvar/untyped.go", - "column" : 9 - } + "column" : 5, + "offset" : 15, + "filename" : "fixtures/packages/untypedvar/untyped.go" + }, + "value" : "a" } ], - "names" : [ + "kind" : "spec", + "declared-type" : null, + "values" : [ { - "value" : "a", + "type" : "INT", + "value" : "1", "position" : { "line" : 3, - "column" : 5, - "filename" : "fixtures/packages/untypedvar/untyped.go", - "offset" : 15 + "column" : 9, + "offset" : 19, + "filename" : "fixtures/packages/untypedvar/untyped.go" }, - "kind" : "ident" + "kind" : "literal" } ], - "declared-type" : null, - "type" : "var" + "position" : { + "offset" : 15, + "filename" : "fixtures/packages/untypedvar/untyped.go", + "line" : 3, + "column" : 5 + }, + "comments" : [] } ], - "type" : "var", "position" : { - "line" : 3, + "offset" : 11, "filename" : "fixtures/packages/untypedvar/untyped.go", - "column" : 1, - "offset" : 11 + "line" : 3, + "column" : 1 }, - "kind" : "decl" + "type" : "var" } ], + "kind" : "file", "name" : { "value" : "p", + "kind" : "ident", "position" : { + "column" : 9, "line" : 1, "filename" : "fixtures/packages/untypedvar/untyped.go", - "column" : 9, "offset" : 8 - }, - "kind" : "ident" - }, - "comments" : [] + } + } } diff --git a/goblin.go b/goblin.go index c0d300a..4c345c8 100644 --- a/goblin.go +++ b/goblin.go @@ -67,9 +67,9 @@ func DumpIdent(i *ast.Ident, fset *token.FileSet) map[string]interface{} { func DumpArray(a *ast.ArrayType, fset *token.FileSet) map[string]interface{} { return map[string]interface{}{ - "kind": "array", - "length": DumpExpr(a.Len, fset), - "element": DumpExprAsType(a.Elt, fset), + "kind": "array", + "length": DumpExpr(a.Len, fset), + "element": DumpExprAsType(a.Elt, fset), "position": DumpPosition(fset.Position(a.Pos())), } } @@ -109,17 +109,17 @@ func AttemptExprAsType(e ast.Expr, fset *token.FileSet) map[string]interface{} { if n, ok := e.(*ast.ArrayType); ok { if n.Len == nil { return map[string]interface{}{ - "kind": "type", - "type": "slice", - "element": DumpExprAsType(n.Elt, fset), + "kind": "type", + "type": "slice", + "element": DumpExprAsType(n.Elt, fset), "position": DumpPosition(fset.Position(e.Pos())), } } else { return map[string]interface{}{ - "kind": "type", - "type": "array", - "element": DumpExprAsType(n.Elt, fset), - "length": DumpExpr(n.Len, fset), + "kind": "type", + "type": "array", + "element": DumpExprAsType(n.Elt, fset), + "length": DumpExpr(n.Len, fset), "position": DumpPosition(fset.Position(e.Pos())), } } @@ -130,7 +130,7 @@ func AttemptExprAsType(e ast.Expr, fset *token.FileSet) map[string]interface{} { "kind": "type", "type": "pointer", "contained": DumpExprAsType(n.X, fset), - "position": DumpPosition(fset.Position(e.Pos())), + "position": DumpPosition(fset.Position(e.Pos())), } } @@ -140,16 +140,16 @@ func AttemptExprAsType(e ast.Expr, fset *token.FileSet) map[string]interface{} { "type": "interface", "incomplete": n.Incomplete, "methods": DumpFields(n.Methods, fset), - "position": DumpPosition(fset.Position(e.Pos())), + "position": DumpPosition(fset.Position(e.Pos())), } } if n, ok := e.(*ast.MapType); ok { return map[string]interface{}{ - "kind": "type", - "type": "map", - "key": DumpExprAsType(n.Key, fset), - "value": DumpExprAsType(n.Value, fset), + "kind": "type", + "type": "map", + "key": DumpExprAsType(n.Key, fset), + "value": DumpExprAsType(n.Value, fset), "position": DumpPosition(fset.Position(e.Pos())), } } @@ -160,25 +160,25 @@ func AttemptExprAsType(e ast.Expr, fset *token.FileSet) map[string]interface{} { "type": "chan", "direction": DumpChanDir(n.Dir), "value": DumpExprAsType(n.Value, fset), - "position": DumpPosition(fset.Position(e.Pos())), + "position": DumpPosition(fset.Position(e.Pos())), } } if n, ok := e.(*ast.StructType); ok { return map[string]interface{}{ - "kind": "type", - "type": "struct", - "fields": DumpFields(n.Fields, fset), + "kind": "type", + "type": "struct", + "fields": DumpFields(n.Fields, fset), "position": DumpPosition(fset.Position(e.Pos())), } } if n, ok := e.(*ast.FuncType); ok { return map[string]interface{}{ - "kind": "type", - "type": "function", - "params": DumpFields(n.Params, fset), - "results": DumpFields(n.Results, fset), + "kind": "type", + "type": "function", + "params": DumpFields(n.Params, fset), + "results": DumpFields(n.Results, fset), "position": DumpPosition(fset.Position(e.Pos())), } }