Result (Expression @NotNull [] params, ExpressionContext context) { int offset = context.getStartOffset(); Project project = context.getProject(); PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(context.getEditor().getDocument()); PsiElement element = file.findElementAt(offset); element = PsiTreeUtil.getParentOfType(element, PsiAssignmentExpression.class, PsiVariable.class); PsiType leftType = null; PsiExpression rightSide = null; if (element instanceof PsiAssignmentExpression assignment) { leftType = assignment.getLExpression().getType(); rightSide = assignment.getRExpression(); } else if (element instanceof PsiVariable var) { leftType = var.getType(); rightSide = var.getInitializer(); } while (rightSide instanceof PsiTypeCastExpression) rightSide = ((PsiTypeCastExpression) rightSide).getOperand(); if (leftType != null && rightSide != null && rightSide.getType() != null && !leftType.isAssignableFrom(rightSide.getType())) { return new TextResult("("+ leftType.getCanonicalText() + ")"); } return new TextResult(""); }