TextRange (RadComponent component, PsiFile file) { CharSequence contents = file.getViewProvider().getContents(); int componentId = StringUtil.indexOf(contents, "id=\"" + component.getId() + "\""); if (componentId == -1) return null; PsiFileFactory fileFactory = PsiFileFactory.getInstance(file.getProject()); XmlFile xmlFile = (XmlFile)fileFactory.createFileFromText("form.xml", XmlFileType.INSTANCE, contents); XmlTag componentTag = PsiTreeUtil.getParentOfType(xmlFile.findElementAt(componentId), XmlTag.class); return componentTag != null ? componentTag.getTextRange() : null; }