boolean (Object what, PsiElement context) { if (!(what instanceof PsiElement)) return false; PsiElement p = (PsiElement)what; p = p.getUserData(ORG_ELT); // saved by fillCompletionVariants(). if (p == null) return false; // just in case PsiElement feeler = p; while (true) { // skip all whitespace to the left but the last PsiElement seeker = feeler.getPrevSibling(); if (!(seeker instanceof PsiWhiteSpace) || seeker.getText().indexOf('\n') < 0) break; else feeler = seeker; } int endpoint = feeler.getTextOffset()-1; PsiDocumentManager docMgr = PsiDocumentManager.getInstance(p.getProject()); Document doc = docMgr.getDocument(p.getContainingFile()); if (doc != null) { if (myText.equals(doc.getCharsSequence().subSequence(endpoint - myText.length(), endpoint).toString())) return true; } return false; }