PsiElement (@NotNull PsiFile file, @NotNull PsiElement parent, @NotNull String type, @NotNull StringTokenizer tokenizer, @Nullable StringBuilder processingInfoStorage) { if (type.equals("tag")) { String name = tokenizer.nextToken(); if (parent instanceof XmlFile) { parent = ((XmlFile)parent).getDocument(); if (parent == null) { return null; } } try { int index = Integer.parseInt(tokenizer.nextToken()); String unescapedName = unescape(name); PsiElement result = restoreElementInternal(parent, unescapedName, index, XmlTag.class); if (result == null && file.getFileType() == StdFileTypes.JSP) { //TODO: FoldingBuilder API, psi roots, etc? if (parent instanceof XmlDocument) { // html tag, not found in jsp tree result = restoreElementInternal(HtmlUtil.getRealXmlDocument((XmlDocument)parent), unescapedName, index, XmlTag.class); } else if (name.equals("<unnamed>")) { // scriplet/declaration missed because null name result = restoreElementInternal(parent, "", index, XmlTag.class); } } return result; } catch (NumberFormatException e) { LOG.error(e); return null; } } return null; }