From ba8638cc1e65c3a94f61c6c2c749608a54c68e44 Mon Sep 17 00:00:00 2001 From: Denys Smirnov Date: Wed, 5 Dec 2018 22:26:36 +0200 Subject: [PATCH] uast: define Bool node (boolean literal) Signed-off-by: Denys Smirnov --- uast/types_test.go | 21 +++++++++++++++++++++ uast/uast.go | 7 +++++++ 2 files changed, 28 insertions(+) diff --git a/uast/types_test.go b/uast/types_test.go index ad1c1d29..c7cf3052 100644 --- a/uast/types_test.go +++ b/uast/types_test.go @@ -71,6 +71,27 @@ var casesToNode = []struct { KeyEnd: expPos(4, 2, 2), }, }, + { + name: "Bool", + obj: Bool{ + GenNode: GenNode{ + Positions: Positions{ + KeyStart: {Offset: 3, Line: 2, Col: 1}, + KeyEnd: {Offset: 8, Line: 2, Col: 6}, + }, + }, + Value: true, + }, + exp: nodes.Object{ + KeyType: nodes.String("uast:Bool"), + KeyPos: nodes.Object{ + KeyType: nodes.String(TypePositions), + KeyStart: expPos(3, 2, 1), + KeyEnd: expPos(8, 2, 6), + }, + "Value": nodes.Bool(true), + }, + }, { name: "Alias", obj: Alias{ diff --git a/uast/uast.go b/uast/uast.go index 04e4ee60..8a0837e9 100644 --- a/uast/uast.go +++ b/uast/uast.go @@ -31,6 +31,7 @@ func init() { GenNode{}, Identifier{}, String{}, + Bool{}, QualifiedIdentifier{}, Comment{}, Group{}, @@ -346,3 +347,9 @@ type Function struct { Type FunctionType `json:"Type"` Body *Block `json:"Body"` } + +// Bool is a boolean literal. +type Bool struct { + GenNode + Value bool `json:"Value"` +}