TextRange (Object occurrence) { if (occurrence instanceof PsiElement) { return ((PsiElement)occurrence).getTextRange(); } else if (occurrence instanceof StringPartInfo) { return ((StringPartInfo)occurrence).getRange(); } else { return null; } }