From d8462dcef819956cb5bcc8cae65e763851fd9749 Mon Sep 17 00:00:00 2001 From: Alfredo Beaumont Date: Fri, 6 Oct 2017 18:51:05 +0200 Subject: [PATCH] annotations: Annotate ConditionalExpression (ternary operator). Signed-off-by: Alfredo Beaumont --- driver/normalizer/annotation.go | 5 +++++ fixtures/operators.uast | 8 ++++---- fixtures/wildcard_type.uast | 8 ++++---- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/driver/normalizer/annotation.go b/driver/normalizer/annotation.go index 1975cb6..f5ddee1 100644 --- a/driver/normalizer/annotation.go +++ b/driver/normalizer/annotation.go @@ -125,6 +125,11 @@ var AnnotationRules = On(jdt.CompilationUnit).Roles(uast.File).Descendants( On(jdt.PropertyThenStatement).Roles(uast.If, uast.Then, uast.Body), On(jdt.PropertyElseStatement).Roles(uast.If, uast.Else, uast.Body), ), + On(jdt.ConditionalExpression).Roles(uast.Expression, uast.If).Children( + On(jdt.PropertyExpression).Roles(uast.If, uast.Condition), + On(jdt.PropertyThenExpression).Roles(uast.If, uast.Then), + On(jdt.PropertyElseExpression).Roles(uast.If, uast.Else), + ), On(jdt.SwitchStatement).Roles(uast.Statement, uast.Switch).Children( On(jdt.PropertyExpression).Roles(uast.Expression, uast.Switch), diff --git a/fixtures/operators.uast b/fixtures/operators.uast index 98f33cf..89373fa 100644 --- a/fixtures/operators.uast +++ b/fixtures/operators.uast @@ -1669,13 +1669,13 @@ CompilationUnit { . . . . . . . . . . . . . } . . . . . . . . . . . . } . . . . . . . . . . . . 1: ConditionalExpression { -. . . . . . . . . . . . . Roles: Assignment,Binary,Right +. . . . . . . . . . . . . Roles: Expression,If,Assignment,Binary,Right . . . . . . . . . . . . . Properties: { . . . . . . . . . . . . . . internalRole: rightHandSide . . . . . . . . . . . . . } . . . . . . . . . . . . . Children: { . . . . . . . . . . . . . . 0: ParenthesizedExpression { -. . . . . . . . . . . . . . . Roles: Expression,Incomplete +. . . . . . . . . . . . . . . Roles: If,Condition,Expression,Incomplete . . . . . . . . . . . . . . . Properties: { . . . . . . . . . . . . . . . . internalRole: expression . . . . . . . . . . . . . . . } @@ -1700,7 +1700,7 @@ CompilationUnit { . . . . . . . . . . . . . . . } . . . . . . . . . . . . . . } . . . . . . . . . . . . . . 1: NumberLiteral { -. . . . . . . . . . . . . . . Roles: Expression,Literal,Number +. . . . . . . . . . . . . . . Roles: Expression,Literal,Number,If,Then . . . . . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . . . . . Offset: 256 . . . . . . . . . . . . . . . . Line: 28 @@ -1717,7 +1717,7 @@ CompilationUnit { . . . . . . . . . . . . . . . } . . . . . . . . . . . . . . } . . . . . . . . . . . . . . 2: NumberLiteral { -. . . . . . . . . . . . . . . Roles: Expression,Literal,Number +. . . . . . . . . . . . . . . Roles: Expression,Literal,Number,If,Else . . . . . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . . . . . Offset: 260 . . . . . . . . . . . . . . . . Line: 28 diff --git a/fixtures/wildcard_type.uast b/fixtures/wildcard_type.uast index 4ad0fe0..42f2e27 100644 --- a/fixtures/wildcard_type.uast +++ b/fixtures/wildcard_type.uast @@ -951,13 +951,13 @@ CompilationUnit { . . . . . . . . . } . . . . . . . . . Children: { . . . . . . . . . . 0: ConditionalExpression { -. . . . . . . . . . . Roles: Unannotated +. . . . . . . . . . . Roles: Expression,If . . . . . . . . . . . Properties: { . . . . . . . . . . . . internalRole: expression . . . . . . . . . . . } . . . . . . . . . . . Children: { . . . . . . . . . . . . 0: InstanceofExpression { -. . . . . . . . . . . . . Roles: Unannotated +. . . . . . . . . . . . . Roles: If,Condition . . . . . . . . . . . . . Properties: { . . . . . . . . . . . . . . internalRole: expression . . . . . . . . . . . . . } @@ -1057,7 +1057,7 @@ CompilationUnit { . . . . . . . . . . . . . } . . . . . . . . . . . . } . . . . . . . . . . . . 1: MethodInvocation { -. . . . . . . . . . . . . Roles: Expression,Call +. . . . . . . . . . . . . Roles: Expression,Call,If,Then . . . . . . . . . . . . . Properties: { . . . . . . . . . . . . . . internalRole: thenExpression . . . . . . . . . . . . . } @@ -1124,7 +1124,7 @@ CompilationUnit { . . . . . . . . . . . . . } . . . . . . . . . . . . } . . . . . . . . . . . . 2: NumberLiteral { -. . . . . . . . . . . . . Roles: Expression,Literal,Number +. . . . . . . . . . . . . Roles: Expression,Literal,Number,If,Else . . . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . . . Offset: 335 . . . . . . . . . . . . . . Line: 9