String (final M method) { if (method == null) return ""; final PsiFile file = method.getContainingFile(); Document document = file != null ? PsiDocumentManager.getInstance(myProject).getDocument(file) : null; if (document != null) { TextRange textRange = method.getTextRange(); if (textRange != null) { final int start = document.getLineStartOffset(document.getLineNumber(textRange.getStartOffset())); final int end = document.getLineEndOffset(document.getLineNumber(textRange.getEndOffset())); return document.getText().substring(start, end); } } return ""; }