mirror of https://github.com/Wilfred/difftastic/
331 lines
7.8 KiB
Plaintext
331 lines
7.8 KiB
Plaintext
==================
|
|
Multiplication expression
|
|
==================
|
|
|
|
45 * 3
|
|
|
|
---
|
|
|
|
(source_file (multiplicative_expression (integer_literal) (integer_literal)))
|
|
|
|
==================
|
|
Safe Navigation
|
|
==================
|
|
|
|
a?.bar()
|
|
a? .bar()
|
|
a? . bar()
|
|
a?
|
|
.bar()
|
|
a ? . bar()
|
|
|
|
---
|
|
|
|
(source_file
|
|
(call_expression
|
|
(navigation_expression
|
|
(simple_identifier)
|
|
(navigation_suffix
|
|
(simple_identifier)))
|
|
(call_suffix
|
|
(value_arguments)))
|
|
(call_expression
|
|
(navigation_expression
|
|
(simple_identifier)
|
|
(navigation_suffix
|
|
(simple_identifier)))
|
|
(call_suffix
|
|
(value_arguments)))
|
|
(call_expression
|
|
(navigation_expression
|
|
(simple_identifier)
|
|
(navigation_suffix
|
|
(simple_identifier)))
|
|
(call_suffix
|
|
(value_arguments)))
|
|
(call_expression
|
|
(navigation_expression
|
|
(simple_identifier)
|
|
(navigation_suffix
|
|
(simple_identifier)))
|
|
(call_suffix
|
|
(value_arguments)))
|
|
(call_expression
|
|
(navigation_expression
|
|
(simple_identifier)
|
|
(navigation_suffix
|
|
(simple_identifier)))
|
|
(call_suffix
|
|
(value_arguments))))
|
|
|
|
==================
|
|
Function calls
|
|
==================
|
|
|
|
print("Hello World!")
|
|
sum(1, 2)
|
|
|
|
---
|
|
|
|
(source_file
|
|
(call_expression (simple_identifier)
|
|
(call_suffix (value_arguments
|
|
(value_argument (line_string_literal)))))
|
|
(call_expression (simple_identifier)
|
|
(call_suffix (value_arguments
|
|
(value_argument (integer_literal))
|
|
(value_argument (integer_literal))))))
|
|
|
|
==================
|
|
When expression
|
|
==================
|
|
|
|
val x = 1
|
|
val y = when(x){
|
|
1 -> true
|
|
2 -> false
|
|
}
|
|
|
|
---
|
|
|
|
(source_file
|
|
(property_declaration
|
|
(variable_declaration (simple_identifier))
|
|
(integer_literal))
|
|
(property_declaration
|
|
(variable_declaration (simple_identifier))
|
|
(when_expression
|
|
(when_subject (simple_identifier))
|
|
(when_entry (when_condition (integer_literal))
|
|
(control_structure_body (boolean_literal)))
|
|
(when_entry (when_condition (integer_literal))
|
|
(control_structure_body (boolean_literal))))))
|
|
|
|
=================
|
|
When expression with type arguments
|
|
================
|
|
|
|
when (this) {
|
|
is DispatchedCoroutine<*> -> return null
|
|
}
|
|
|
|
---
|
|
|
|
(source_file
|
|
(when_expression
|
|
(when_subject
|
|
(this_expression))
|
|
(when_entry
|
|
(when_condition
|
|
(type_test
|
|
(user_type
|
|
(type_identifier)
|
|
(type_arguments
|
|
(type_projection)))))
|
|
(control_structure_body
|
|
(jump_expression)))))
|
|
|
|
==================
|
|
Value declaration with receiver type
|
|
==================
|
|
|
|
val MyDate.s: String get() = "hello"
|
|
|
|
---
|
|
|
|
(source_file
|
|
(property_declaration
|
|
(user_type
|
|
(type_identifier))
|
|
(variable_declaration
|
|
(simple_identifier)
|
|
(user_type
|
|
(type_identifier)))
|
|
(getter
|
|
(function_body
|
|
(line_string_literal)))))
|
|
|
|
==================
|
|
Expect as an expression
|
|
==================
|
|
|
|
val x = expect(1)
|
|
|
|
---
|
|
(source_file
|
|
(property_declaration
|
|
(variable_declaration (simple_identifier))
|
|
(call_expression (simple_identifier)
|
|
(call_suffix (value_arguments (value_argument (integer_literal)))))))
|
|
|
|
==================
|
|
Expect as a top-level expression
|
|
==================
|
|
|
|
expect(1)
|
|
|
|
---
|
|
(source_file
|
|
(call_expression (simple_identifier)
|
|
(call_suffix (value_arguments (value_argument (integer_literal))))))
|
|
|
|
==================
|
|
Expect as a platform modifier
|
|
==================
|
|
|
|
expect fun randomUUID(): String
|
|
|
|
---
|
|
(source_file
|
|
(function_declaration
|
|
(modifiers (platform_modifier))
|
|
(simple_identifier)
|
|
(user_type (type_identifier))))
|
|
|
|
==================
|
|
Less than for generics
|
|
==================
|
|
|
|
foo<Int>(1,2)
|
|
foo<Int>(1)
|
|
|
|
---
|
|
(source_file
|
|
(call_expression (simple_identifier)
|
|
(call_suffix
|
|
(type_arguments (type_projection (user_type (type_identifier))))
|
|
(value_arguments (value_argument (integer_literal))
|
|
(value_argument (integer_literal)))))
|
|
(call_expression (simple_identifier)
|
|
(call_suffix
|
|
(type_arguments (type_projection (user_type (type_identifier))))
|
|
(value_arguments (value_argument (integer_literal))))))
|
|
|
|
|
|
==================
|
|
Less than for comparison
|
|
==================
|
|
|
|
val x = a<b
|
|
val y = a>b
|
|
val z = a<b>c
|
|
// this is parsed as a generic, but could also be parsed as a comparison
|
|
val w = a<b>(c)
|
|
val a = a<2>(3)
|
|
|
|
---
|
|
(source_file
|
|
(property_declaration (variable_declaration (simple_identifier))
|
|
(comparison_expression (simple_identifier) (simple_identifier)))
|
|
(property_declaration (variable_declaration (simple_identifier))
|
|
(comparison_expression (simple_identifier) (simple_identifier)))
|
|
(property_declaration (variable_declaration (simple_identifier))
|
|
(comparison_expression
|
|
(comparison_expression (simple_identifier) (simple_identifier))
|
|
(simple_identifier)))
|
|
(comment)
|
|
(property_declaration (variable_declaration (simple_identifier))
|
|
(call_expression (simple_identifier)
|
|
(call_suffix
|
|
(type_arguments (type_projection (user_type (type_identifier))))
|
|
(value_arguments (value_argument (simple_identifier))))))
|
|
(property_declaration (variable_declaration (simple_identifier))
|
|
(comparison_expression
|
|
(comparison_expression (simple_identifier) (integer_literal))
|
|
(parenthesized_expression (integer_literal)))))
|
|
|
|
==================
|
|
Lambda Expressions
|
|
==================
|
|
|
|
foo.forEach { (index, value) -> 2 }
|
|
|
|
---
|
|
|
|
(source_file
|
|
(call_expression
|
|
(navigation_expression
|
|
(simple_identifier)
|
|
(navigation_suffix
|
|
(simple_identifier)))
|
|
(call_suffix
|
|
(annotated_lambda
|
|
(lambda_literal
|
|
(lambda_parameters
|
|
(multi_variable_declaration
|
|
(variable_declaration
|
|
(simple_identifier))
|
|
(variable_declaration
|
|
(simple_identifier))))
|
|
(statements
|
|
(integer_literal)))))))
|
|
|
|
==================
|
|
Multiple Statements on a Single Line
|
|
==================
|
|
|
|
fun main() { val temp = b.y; b.y = b.z; b.z = temp }
|
|
|
|
when (dir) {
|
|
1 -> { val temp = b.y; b.y = b.z; b.z = temp }
|
|
}
|
|
---
|
|
|
|
(source_file
|
|
(function_declaration
|
|
(simple_identifier)
|
|
(function_body
|
|
(statements
|
|
(property_declaration
|
|
(variable_declaration
|
|
(simple_identifier))
|
|
(navigation_expression
|
|
(simple_identifier)
|
|
(navigation_suffix
|
|
(simple_identifier))))
|
|
(assignment
|
|
(directly_assignable_expression
|
|
(simple_identifier)
|
|
(navigation_suffix
|
|
(simple_identifier)))
|
|
(navigation_expression
|
|
(simple_identifier)
|
|
(navigation_suffix
|
|
(simple_identifier))))
|
|
(assignment
|
|
(directly_assignable_expression
|
|
(simple_identifier)
|
|
(navigation_suffix
|
|
(simple_identifier)))
|
|
(simple_identifier)))))
|
|
(when_expression
|
|
(when_subject
|
|
(simple_identifier))
|
|
(when_entry
|
|
(when_condition
|
|
(integer_literal))
|
|
(control_structure_body
|
|
(statements
|
|
(property_declaration
|
|
(variable_declaration
|
|
(simple_identifier))
|
|
(navigation_expression
|
|
(simple_identifier)
|
|
(navigation_suffix
|
|
(simple_identifier))))
|
|
(assignment
|
|
(directly_assignable_expression
|
|
(simple_identifier)
|
|
(navigation_suffix
|
|
(simple_identifier)))
|
|
(navigation_expression
|
|
(simple_identifier)
|
|
(navigation_suffix
|
|
(simple_identifier))))
|
|
(assignment
|
|
(directly_assignable_expression
|
|
(simple_identifier)
|
|
(navigation_suffix
|
|
(simple_identifier)))
|
|
(simple_identifier)))))))
|