Skip to content

Commit

Permalink
Support annotations on assignments
Browse files Browse the repository at this point in the history
  • Loading branch information
knutwannheden committed Sep 11, 2023
1 parent 8a5a0d5 commit 0ba5ec8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4492,7 +4492,7 @@ class KotlinParserVisitor(
}
}

if (firElement is FirExpression && firElement.annotations.isNotEmpty()) {
if ((firElement is FirExpression || firElement is FirVariableAssignment) && (firElement as FirStatement).annotations.isNotEmpty()) {
val annotations = ArrayList<J.Annotation>(firElement.annotations.size)
for (annotation in firElement.annotations) {
annotations.add(visitElement(annotation, data) as J.Annotation)
Expand Down
15 changes: 15 additions & 0 deletions src/test/java/org/openrewrite/kotlin/tree/AssignmentTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,19 @@ void not() {
)
);
}

@Test
void annotation() {
rewriteRun(
kotlin(
"""
fun test() {
var a: Boolean
@Suppress
a = true
}
"""
)
);
}
}

0 comments on commit 0ba5ec8

Please sign in to comment.