void (PsiElement psiElement) { PsiFile psiFile = psiElement.getContainingFile(); if (psiFile != null) { Document doc = PsiDocumentManager.getInstance(psiElement.getProject()).getDocument(psiFile); if (doc != null) { TextRange textRange = psiElement.getTextRange(); String date = DateFormatUtil.formatDateTime(new Date()); int startOffset = textRange.getStartOffset(); CharSequence chars = doc.getCharsSequence(); while (CharArrayUtil.regionMatches(chars, startOffset, AnalysisBundle.message("inspection.dead.code.comment"))) { int line = doc.getLineNumber(startOffset) + 1; if (line < doc.getLineCount()) { startOffset = doc.getLineStartOffset(line); startOffset = CharArrayUtil.shiftForward(chars, startOffset, " \t"); } } int endOffset = textRange.getEndOffset(); int line1 = doc.getLineNumber(startOffset); int line2 = doc.getLineNumber(endOffset - 1); if (line1 == line2) { doc.insertString(startOffset, AnalysisBundle.message("inspection.dead.code.date.comment", date)); } else { for (int i = line1; i <= line2; i++) { doc.insertString(doc.getLineStartOffset(i), "//"); } doc.insertString(doc.getLineStartOffset(Math.min(line2 + 1, doc.getLineCount() - 1)), AnalysisBundle.message("inspection.dead.code.stop.comment", date)); doc.insertString(doc.getLineStartOffset(line1), AnalysisBundle.message("inspection.dead.code.start.comment", date)); } } } }