schalkms
12/21/2018, 8:09 PMantsiferov.ivan
12/25/2018, 11:09 AMvisitReturnExpression
and visitUnaryExpression
don’t work for unary expressions, whose result is not used. That expressions simply do not get visited by those methods (or I’m doing something wrong). So I tried to parse code like strings, but that is very fragile way to solve this case. I wonder, if there is a way to detect unary expressions with unused result, using methods from org.jetbrains.kotlin.psi
.antsiferov.ivan
12/25/2018, 11:10 AMschalkms
12/26/2018, 8:43 AMvisitUnaryExpression
is not called?
You are right. You will run into false positives with your approach.antsiferov.ivan
12/28/2018, 8:25 AM+ variableWithVeryVeryVeryVeryVeryVeryLongName
is unary expression, but visitUnaryExpression
did not get called for it.schalkms
12/30/2018, 10:42 AM+ variableWithVeryVeryVeryVeryVeryVeryLongName
is a separate PsiElement.schalkms
12/30/2018, 10:43 AMKtPrefixExpression
.schalkms
12/30/2018, 10:45 AMschalkms
12/30/2018, 10:46 AMval x = 1
+ 2
I think there is also an issue in the repo.antsiferov.ivan
01/09/2019, 9:03 AMval x = 1 +
2
It will behave as expected.