PsiElement (PsiFile file, Editor editor) { LineRange range = getLineRangeFromSelection(editor); if (range.endLine - range.startLine != 1) return null; int offset = editor.getCaretModel().getOffset(); Document document = editor.getDocument(); int line = document.getLineNumber(offset); int lineStartOffset = document.getLineStartOffset(line); String lineText = document.getText().substring(lineStartOffset, document.getLineEndOffset(line)); if (!lineText.trim().equals("}