Search in sources :

Example 1 with KtCallExpression

use of org.jetbrains.kotlin.psi.KtCallExpression in project kotlin by JetBrains.

the class KotlinExpressionSurrounder method isApplicable.

@Override
public boolean isApplicable(@NotNull PsiElement[] elements) {
    if (elements.length != 1 || !(elements[0] instanceof KtExpression)) {
        return false;
    }
    KtExpression expression = (KtExpression) elements[0];
    if (expression instanceof KtCallExpression && expression.getParent() instanceof KtQualifiedExpression) {
        return false;
    }
    KotlinType type = ResolutionUtils.analyze(expression, BodyResolveMode.PARTIAL).getType(expression);
    if (type == null || isUnit(type)) {
        return false;
    }
    return isApplicable(expression);
}
Also used : KotlinType(org.jetbrains.kotlin.types.KotlinType) KtExpression(org.jetbrains.kotlin.psi.KtExpression) KtCallExpression(org.jetbrains.kotlin.psi.KtCallExpression) KtQualifiedExpression(org.jetbrains.kotlin.psi.KtQualifiedExpression)

Aggregations

KtCallExpression (org.jetbrains.kotlin.psi.KtCallExpression)1 KtExpression (org.jetbrains.kotlin.psi.KtExpression)1 KtQualifiedExpression (org.jetbrains.kotlin.psi.KtQualifiedExpression)1 KotlinType (org.jetbrains.kotlin.types.KotlinType)1