File tree Expand file tree Collapse file tree 1 file changed +62
-1
lines changed Expand file tree Collapse file tree 1 file changed +62
-1
lines changed Original file line number Diff line number Diff line change @@ -1976,26 +1976,87 @@ nodes:
1976
1976
fields :
1977
1977
- name : if_keyword_loc
1978
1978
type : location?
1979
+ comment : |
1980
+ The location of the `if` keyword if present.
1981
+
1982
+ bar if foo
1983
+ ^^
1984
+
1985
+ The `if_keyword_loc` field will be `nil` when the `IfNode` represents a ternary expression.
1979
1986
- name : predicate
1980
1987
type : node
1988
+ comment : |
1989
+ The node for the condition the `IfNode` is testing.
1990
+
1991
+ if foo
1992
+ ^^^
1993
+ bar
1994
+ end
1995
+
1996
+ bar if foo
1997
+ ^^^
1998
+
1999
+ foo ? bar : baz
2000
+ ^^^
1981
2001
- name : then_keyword_loc
1982
2002
type : location?
2003
+ comment : |
2004
+ The location of the `then` keyword (if present) or the `?` in a ternary expression, `nil` otherwise.
2005
+
2006
+ if foo then bar end
2007
+ ^^^^
2008
+
2009
+ a ? b : c
2010
+ ^
1983
2011
- name : statements
1984
2012
type : node?
1985
2013
kind : StatementsNode
2014
+ comment : |
2015
+ Represents the body of statements that will be executed when the predicate is evaluated as truthy. Will be `nil` when no body is provided.
2016
+
2017
+ if foo
2018
+ bar
2019
+ ^^^
2020
+ baz
2021
+ ^^^
2022
+ end
1986
2023
- name : consequent
1987
2024
type : node?
2025
+ comment : |
2026
+ Represents an `ElseNode` or an `IfNode` when there is an `else` or an `elsif` in the `if` statement.
2027
+
2028
+ if foo
2029
+ bar
2030
+ elsif baz
2031
+ ^^^^^^^^^
2032
+ qux
2033
+ ^^^
2034
+ end
2035
+ ^^^
2036
+
2037
+ if foo then bar else baz end
2038
+ ^^^^^^^^^^^^
1988
2039
- name : end_keyword_loc
1989
2040
type : location?
2041
+ comment : |
2042
+ The location of the `end` keyword if present, `nil` otherwise.
2043
+
2044
+ if foo
2045
+ bar
2046
+ end
2047
+ ^^^
1990
2048
newline : predicate
1991
2049
comment : |
1992
- Represents the use of the `if` keyword, either in the block form or the modifier form.
2050
+ Represents the use of the `if` keyword, either in the block form or the modifier form, or a ternary expression .
1993
2051
1994
2052
bar if foo
1995
2053
^^^^^^^^^^
1996
2054
1997
2055
if foo then bar end
1998
2056
^^^^^^^^^^^^^^^^^^^
2057
+
2058
+ foo ? bar : baz
2059
+ ^^^^^^^^^^^^^^^
1999
2060
- name : ImaginaryNode
2000
2061
fields :
2001
2062
- name : numeric
You can’t perform that action at this time.
0 commit comments