boolean () { TextRange selection = myCaret.getSelectionRange(); if (selection.isEmpty()) { return true; } PsiDocumentManager.getInstance(myFile.getProject()).commitDocument(myDocument); TextRange range = selection.grown(-1); for (PsiElement element = myFile.findElementAt(range.getStartOffset()); element != null && range.intersects(element.getTextRange()); element = element.getNextSibling()) { if (element instanceof OuterLanguageElement) { if (!isInjectedWhiteSpace(range, (OuterLanguageElement)element)) { return false; } } else { if (!isWhiteSpaceOrComment(element, range)) { return false; } } } return true; }