boolean () { PsiElement elementAtCaret = myFixture.getFile().findElementAt(myFixture.getCaretOffset()); PsiLocalVariable localVariable = PsiTreeUtil.getParentOfType(elementAtCaret, PsiLocalVariable.class); if (localVariable == null) { return false; } PsiTypeElement typeElement = localVariable.getTypeElement(); return typeElement.getText().equals("String"); }