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); if (element instanceof PsiAssignmentExpression assignment) { PsiExpression rhs = assignment.getRExpression(); if (rhs == null) return null; final PsiType rhsType = rhs.getType(); if (rhsType == null) return null; return new PsiTypeResult(rhsType, project); } else if (element instanceof PsiVariable var) { PsiExpression initializer = var.getInitializer(); if (initializer == null) return null; PsiType type = CommonJavaRefactoringUtil.getTypeByExpression(initializer); if (type == null) return null; return new PsiTypeResult(type, project); } return null; }