difftastic/vendor/tree-sitter-kotlin/test/corpus/annotations.txt

122 lines
2.2 KiB
Plaintext

==================
Annotations
==================
@Test
class Empty
---
(source_file
(class_declaration
(modifiers (annotation (user_type (type_identifier))))
(type_identifier)))
==================
Annotations with use-site-target
==================
class Empty(@field:Test val x: Boolean)
---
(source_file
(class_declaration
(type_identifier)
(primary_constructor (class_parameter
(modifiers (annotation (use_site_target) (user_type (type_identifier))))
(simple_identifier)
(user_type (type_identifier))))))
==================
Multi-annotations
==================
@set:[Inject VisibleForTesting]
var x: Int
---
(source_file
(property_declaration
(modifiers (annotation (use_site_target) (user_type (type_identifier)) (user_type (type_identifier))))
(variable_declaration (simple_identifier) (user_type (type_identifier)))))
==================
Multiple annotations on a variable
==================
class X {
@A @B
override val s: String
}
---
(source_file
(class_declaration
(type_identifier)
(class_body
(property_declaration
(modifiers
(annotation (user_type (type_identifier)))
(annotation (user_type (type_identifier)))
(member_modifier))
(variable_declaration (simple_identifier) (user_type (type_identifier)))
)
)
)
)
==================
Multiple annotations on a function
==================
class X {
@A @B
fun s(): String
}
---
(source_file
(class_declaration
(type_identifier)
(class_body
(function_declaration
(modifiers
(annotation (user_type (type_identifier)))
(annotation (user_type (type_identifier))))
(simple_identifier)
(user_type (type_identifier))
)
)
)
)
=====================
Annotated functions
======================
@Test
fun foo() = bar {}
---
(source_file
(function_declaration
(modifiers
(annotation
(user_type
(type_identifier))))
(simple_identifier)
(function_body
(call_expression
(simple_identifier)
(call_suffix
(annotated_lambda
(lambda_literal)))))))