boolean (PsiFile file, PsiElement elementAtCaret) { PsiElement prevSibling = elementAtCaret.getPrevSibling(); if (prevSibling == null) return false; int offset = prevSibling.getTextRange().getStartOffset(); PsiElement prevElement = file.findElementAt(offset); return PsiTreeUtil.getParentOfType(prevElement, PsiNewExpression.class) != null; }