public boolean isMuleSchema(PsiFile file) { if (!file.getName().endsWith(".xsd")) { return false; } final PsiElement[] children = file.getChildren(); if (children.length > 0 && children[0] instanceof XmlDocument) { final XmlTag rootTag = ((XmlDocument) children[0]).getRootTag(); if (rootTag != null) { final String xmlns = getNamespace(rootTag); if (xmlns != null && xmlns.startsWith("http://www.mulesoft.org/schema/mule/")) { return true; } } } return false; }
@Nullable private static String getNamespace(final XmlFile xmlFile, final Project project) { //Stupid HTTP module XSD weirdo if (xmlFile.getName().contains("mule-httpn.xsd")) return "http://www.mulesoft.org/schema/mule/http"; ///// final XmlDocument document = xmlFile.getDocument(); if (document != null) { final PsiMetaData metaData = document.getMetaData(); if (metaData instanceof XmlNSDescriptorImpl) { return ((XmlNSDescriptorImpl) metaData).getDefaultNamespace(); } } return null; }
private List<String> getGlobalDefinitions(VirtualFile file) { List<String> globalDefs = new ArrayList<>(); final DomManager manager = DomManager.getDomManager(project); final XmlFile xmlFile = (XmlFile) PsiManager.getInstance(project).findFile(file); final XmlDocument document = xmlFile.getDocument(); final XmlTag rootTag = document.getRootTag(); try { final XmlTag globalFunctions = rootTag.findFirstSubTag("configuration") .findFirstSubTag("expression-language") .findFirstSubTag("global-functions"); String nextFunction = globalFunctions.getValue().getText(); if (nextFunction != null && StringUtils.isNotEmpty(nextFunction)) { globalDefs.add(nextFunction); } } catch (Exception e) {//If the global functions config does not exist, we get NPE - but it's expected :) //Do nothing for now } return globalDefs; }
@Nullable public String getConfigFileErrorMessage(final ConfigFile configFile) { if (configFile.getVirtualFile() == null) { String path = FileUtil.toSystemDependentName(VfsUtil.urlToPath(configFile.getUrl())); return CompilerBundle.message("mesage.text.deployment.descriptor.file.not.exist", path); } PsiFile psiFile = configFile.getPsiFile(); if (psiFile == null || !psiFile.isValid()) { return CompilerBundle.message("message.text.deployment.description.invalid.file"); } if (psiFile instanceof XmlFile) { XmlDocument document = ((XmlFile)psiFile).getDocument(); if (document == null || document.getRootTag() == null) { return CompilerBundle.message("message.text.xml.file.invalid", FileUtil.toSystemDependentName(VfsUtil.urlToPath(configFile.getUrl()))); } } return null; }
@NotNull @Override public PsiElement[] createPatternTree(@NotNull String text, @NotNull PatternTreeContext context, @NotNull FileType fileType, @Nullable Language language, String contextName, @Nullable String extension, @NotNull Project project, boolean physical) { final String ext = extension != null ? extension : fileType.getDefaultExtension(); String text1 = context == PatternTreeContext.File ? text : "<QQQ>" + text + "</QQQ>"; final PsiFile fileFromText = PsiFileFactory.getInstance(project) .createFileFromText("dummy." + ext, fileType, text1, LocalTimeCounter.currentTime(), physical, true); final XmlDocument document = HtmlUtil.getRealXmlDocument(((XmlFile)fileFromText).getDocument()); if (context == PatternTreeContext.File) { return new PsiElement[]{document}; } return document.getRootTag().getValue().getChildren(); }
@Override protected XmlTag setEmptyXmlTag() { final XmlTag[] result = new XmlTag[]{null}; getManager().runChange(new Runnable() { @Override public void run() { try { final String namespace = getXmlElementNamespace(); @NonNls final String nsDecl = StringUtil.isEmpty(namespace) ? "" : " xmlns=\"" + namespace + "\""; final XmlFile xmlFile = getFile(); final XmlTag tag = XmlElementFactory.getInstance(xmlFile.getProject()).createTagFromText("<" + getXmlElementName() + nsDecl + "/>"); result[0] = ((XmlDocument)xmlFile.getDocument().replace(((XmlFile)tag.getContainingFile()).getDocument())).getRootTag(); } catch (IncorrectOperationException e) { LOG.error(e); } } }); return result[0]; }
@Override @Nullable public XmlTag getRootTag() { if (!myFile.isValid()) { return null; } final XmlDocument document = myFile.getDocument(); if (document != null) { final XmlTag tag = document.getRootTag(); if (tag != null) { if (tag.getTextLength() > 0 && getFileDescription().acceptsOtherRootTagNames()) return tag; if (myRootTagName.getXmlName().getLocalName().equals(tag.getLocalName()) && myRootTagName.isNamespaceAllowed(this, tag.getNamespace())) { return tag; } } } return null; }
/** * Consider using {@link DomService#getXmlFileHeader(com.intellij.psi.xml.XmlFile)} when implementing this. */ @SuppressWarnings({"MethodMayBeStatic"}) @NotNull public List<String> getAllowedNamespaces(@NotNull String namespaceKey, @NotNull XmlFile file) { final NotNullFunction<XmlTag, List<String>> function = myNamespacePolicies.get(namespaceKey); if (function instanceof ConstantFunction) { return function.fun(null); } if (function != null) { final XmlDocument document = file.getDocument(); if (document != null) { final XmlTag tag = document.getRootTag(); if (tag != null) { return function.fun(tag); } } } else { return Collections.singletonList(namespaceKey); } return Collections.emptyList(); }
@Nullable @Override public MyHost collectInformation(@NotNull PsiFile file) { if (!(file instanceof XmlFile)) return null; final XmlDocument document = ((XmlFile)file).getDocument(); if (document == null) return null; XmlTag rootTag = document.getRootTag(); XmlNSDescriptor nsDescriptor = rootTag == null ? null : rootTag.getNSDescriptor(rootTag.getNamespace(), false); if (nsDescriptor instanceof Validator) { //noinspection unchecked MyHost host = new MyHost(); ((Validator<XmlDocument>)nsDescriptor).validate(document, host); return host; } return null; }
@Nullable private static PsiElement[] computeInclusion(final XmlTag xincludeTag) { final XmlFile included = XmlIncludeHandler.resolveXIncludeFile(xincludeTag); final XmlDocument document = included != null ? included.getDocument() : null; final XmlTag rootTag = document != null ? document.getRootTag() : null; if (rootTag != null) { final String xpointer = xincludeTag.getAttributeValue("xpointer", XmlPsiUtil.XINCLUDE_URI); final XmlTag[] includeTag = extractXpointer(rootTag, xpointer); PsiElement[] result = new PsiElement[includeTag.length]; for (int i = 0; i < includeTag.length; i++) { result[i] = new IncludedXmlTag(includeTag[i], xincludeTag.getParentTag()); } return result; } return null; }
private static @Nullable XmlTag findSpecialTag(@NonNls String name, @NonNls String specialName, XmlTag rootTag, XmlNSDescriptorImpl descriptor, HashSet<XmlTag> visited) { XmlNSDescriptorImpl nsDescriptor = getNSDescriptorToSearchIn(rootTag, name, descriptor); if (nsDescriptor != descriptor) { final XmlDocument document = nsDescriptor.getDescriptorFile() != null ? nsDescriptor.getDescriptorFile().getDocument():null; if (document == null) return null; return findSpecialTag( XmlUtil.findLocalNameByQualifiedName(name), specialName, document.getRootTag(), nsDescriptor, visited ); } if (visited == null) visited = new HashSet<XmlTag>(1); else if (visited.contains(rootTag)) return null; visited.add(rootTag); XmlTag[] tags = rootTag.getSubTags(); return findSpecialTagIn(tags, specialName, name, rootTag, descriptor, visited); }
@Override public void init(PsiElement element){ myFile = (XmlFile) element.getContainingFile(); if (element instanceof XmlTag) { myTag = (XmlTag)element; } else { final XmlDocument document = myFile.getDocument(); if (document != null) { myTag = document.getRootTag(); } } if (myTag != null) { myTargetNamespace = myTag.getAttributeValue("targetNamespace"); } final THashSet<PsiFile> dependenciesSet = new THashSet<PsiFile>(); final Set<PsiFile> redefineProcessingSet = myRedefinedDescriptorsInProcessing.get(); if (redefineProcessingSet != null) { dependenciesSet.addAll(redefineProcessingSet); } collectDependencies(myTag, myFile, dependenciesSet); dependencies = ArrayUtil.toObjectArray(dependenciesSet); }
@NotNull @Override public Collection<Html5SectionTreeElement> provideNodes(@NotNull final TreeElement node) { if (!(node instanceof HtmlFileTreeElement)) return Collections.emptyList(); final XmlFile xmlFile = ((HtmlFileTreeElement)node).getElement(); final XmlDocument document = xmlFile == null ? null : xmlFile.getDocument(); if (document == null) return Collections.emptyList(); final List<XmlTag> rootTags = new ArrayList<XmlTag>(); document.processElements(new FilterElementProcessor(XmlTagFilter.INSTANCE, rootTags), document); final Collection<Html5SectionTreeElement> result = new ArrayList<Html5SectionTreeElement>(); for (XmlTag tag : rootTags) { result.addAll(Html5SectionsProcessor.processAndGetRootSections(tag)); } return result; }
@NotNull @Override public ThreeState shouldSkipAutopopup(@NotNull PsiElement contextElement, @NotNull PsiFile psiFile, int offset) { ASTNode node = contextElement.getNode(); if (node != null && node.getElementType() == XmlTokenType.XML_DATA_CHARACTERS) { PsiElement parent = contextElement.getParent(); if (parent instanceof XmlText || parent instanceof XmlDocument) { String contextElementText = contextElement.getText(); int endOffset = offset - contextElement.getTextRange().getStartOffset(); String prefix = contextElementText.substring(0, Math.min(contextElementText.length(), endOffset)); if (!StringUtil.startsWithChar(prefix, '<') && !StringUtil.startsWithChar(prefix, '&')) { return ThreeState.YES; } } } return ThreeState.UNSURE; }
public static boolean isInContext(@NotNull PsiElement element) { if (PsiTreeUtil.getParentOfType(element, XmlComment.class) != null) { return false; } if (PsiTreeUtil.getParentOfType(element, XmlText.class) != null) { return true; } if (element.getNode().getElementType() == XmlTokenType.XML_START_TAG_START) { return true; } PsiElement parent = element.getParent(); if (parent instanceof PsiErrorElement) { parent = parent.getParent(); } return parent instanceof XmlDocument; }
@NotNull @Override public String filterText(@NotNull String text, @NotNull TemplateToken token) { XmlDocument document = token.getFile().getDocument(); if (document != null) { XmlTag tag = document.getRootTag(); if (tag != null) { String classAttr = tag.getAttributeValue(HtmlUtil.CLASS_ATTRIBUTE_NAME); String idAttr = tag.getAttributeValue(HtmlUtil.ID_ATTRIBUTE_NAME); if (!isNullOrEmpty(classAttr) || !isNullOrEmpty(idAttr)) { String commentString = buildCommentString(classAttr, idAttr); return text + "\n<!-- /" + commentString + " -->"; } } } return text; }
@NotNull @Override public XmlElementDescriptor[] getRootElementsDescriptors(@Nullable XmlDocument document) { if (document != null) { final Project project = document.getProject(); final PsiClass paneClass = JavaPsiFacade.getInstance(project).findClass(JavaFxCommonClassNames.JAVAFX_SCENE_LAYOUT_PANE, GlobalSearchScope.allScope(project)); if (paneClass != null) { final ArrayList<XmlElementDescriptor> result = new ArrayList<XmlElementDescriptor>(); ClassInheritorsSearch.search(paneClass, paneClass.getUseScope(), true, true, false).forEach(new Processor<PsiClass>() { @Override public boolean process(PsiClass psiClass) { result.add(new JavaFxClassBackedElementDescriptor(psiClass.getName(), psiClass)); return true; } }); return result.toArray(new XmlElementDescriptor[result.size()]); } } return new XmlElementDescriptor[0]; }
PsiElement[] doCreateAndNavigate(String newName, PsiDirectory directory, String rootTagName, boolean chooseTagName, boolean navigate) throws Exception { final XmlFile file = AndroidResourceUtil .createFileResource(newName, directory, rootTagName, myResourceType.getName(), myValuesResourceFile); if (navigate) { doNavigate(file); } if (chooseTagName) { XmlDocument document = file.getDocument(); if (document != null) { XmlTag rootTag = document.getRootTag(); if (rootTag != null) { final Project project = file.getProject(); final Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor(); if (editor != null) { CaretModel caretModel = editor.getCaretModel(); caretModel.moveToOffset(rootTag.getTextOffset() + 1); XmlTagInplaceRenamer.rename(editor, rootTag); } } } } return new PsiElement[]{file}; }
@Nullable public static Navigatable createNavigatableForPom(final Project project, final VirtualFile file) { if (file == null || !file.isValid()) return null; final PsiFile result = PsiManager.getInstance(project).findFile(file); return result == null ? null : new NavigatableAdapter() { public void navigate(boolean requestFocus) { int offset = 0; if (result instanceof XmlFile) { final XmlDocument xml = ((XmlFile)result).getDocument(); if (xml != null) { final XmlTag rootTag = xml.getRootTag(); if (rootTag != null) { final XmlTag[] id = rootTag.findSubTags(ARTIFACT_ID, rootTag.getNamespace()); if (id.length > 0) { offset = id[0].getValue().getTextRange().getStartOffset(); } } } } navigate(project, file, offset, requestFocus); } }; }
public static boolean isAntFile(final XmlFile xmlFile) { final XmlDocument document = xmlFile.getDocument(); if (document != null) { final XmlTag tag = document.getRootTag(); final VirtualFile vFile = xmlFile.getOriginalFile().getVirtualFile(); if (tag != null && ROOT_TAG_NAME.equals(tag.getName()) && tag.getContext() instanceof XmlDocument) { if (tag.getAttributeValue("name") != null && tag.getAttributeValue("default") != null && vFile != null && ForcedAntFileAttribute.mayBeAntFile(vFile)) { return true; } } if (vFile != null && ForcedAntFileAttribute.isAntFile(vFile)) { return true; } } return false; }
public void registerPageLanguage(final Project project, final XmlFile containingFile, final String languageName) { new WriteCommandAction.Simple(project, getFamilyName()) { @Override protected void run() { final PsiFileFactory factory = PsiFileFactory.getInstance(project); final XmlFile dummyFile = (XmlFile)factory.createFileFromText("_Dummy_.fxml", StdFileTypes.XML, "<?language " + languageName + "?>"); final XmlDocument document = dummyFile.getDocument(); if (document != null) { final XmlProlog prolog = document.getProlog(); final Collection<XmlProcessingInstruction> instructions = PsiTreeUtil.findChildrenOfType(prolog, XmlProcessingInstruction.class); LOG.assertTrue(instructions.size() == 1); final XmlDocument xmlDocument = containingFile.getDocument(); if (xmlDocument != null) { final XmlProlog xmlProlog = xmlDocument.getProlog(); if (xmlProlog != null) { final PsiElement element = xmlProlog.addBefore(instructions.iterator().next(), xmlProlog.getFirstChild()); xmlProlog.addAfter(PsiParserFacade.SERVICE.getInstance(project).createWhiteSpaceFromText("\n\n"), element); } } } } }.execute(); }
@NotNull @Override public DataIndexer<String, String, FileContent> getIndexer() { return inputData -> { Map<String, String> map = new THashMap<>(); PsiFile psiFile = inputData.getPsiFile(); if (!Settings.isEnabled(psiFile.getProject())) { return map; } if (psiFile instanceof XmlFile) { XmlDocument xmlDocument = ((XmlFile) psiFile).getDocument(); if (xmlDocument != null) { XmlTag xmlRootTag = xmlDocument.getRootTag(); if (xmlRootTag != null) { for (XmlTag virtualTypeTag : xmlRootTag.findSubTags("virtualType")) { String name = virtualTypeTag.getAttributeValue("name"); String type = virtualTypeTag.getAttributeValue("type"); if (name != null && type != null && !name.isEmpty() && !type.isEmpty()) { map.put(name, type); } } } } } return map; }; }
@NotNull @Override public DataIndexer<String, Void, FileContent> getIndexer() { return inputData -> { Map<String, Void> map = new HashMap<>(); PsiFile psiFile = inputData.getPsiFile(); if (!Settings.isEnabled(psiFile.getProject())) { return map; } if (!(psiFile instanceof XmlFile)) { return map; } XmlDocument document = ((XmlFile) psiFile).getDocument(); if (document == null) { return map; } XmlTag xmlTags[] = PsiTreeUtil.getChildrenOfType(psiFile.getFirstChild(), XmlTag.class); if (xmlTags == null) { return map; } for (XmlTag xmlTag : xmlTags) { if (xmlTag.getName().equals("routes")) { for (XmlTag routeNode : xmlTag.findSubTags("route")) { for (XmlTag serviceNode : routeNode.findSubTags("service")) { String typeName = serviceNode.getAttributeValue("class"); if (typeName != null) { map.put(PhpLangUtil.toPresentableFQN(typeName), null); } } } } } return map; }; }
private void grabEventNamesFromXmlFile(XmlFile file, Map<String, Void> map) { XmlDocument xmlDocument = file.getDocument(); if (xmlDocument != null) { XmlTag xmlRootTag = xmlDocument.getRootTag(); if (xmlRootTag != null) { for (XmlTag eventTag : xmlRootTag.findSubTags("event")) { String name = eventTag.getAttributeValue("name"); if (name != null && !name.isEmpty()) { map.put(name, null); } } } } }
@Override @NotNull public Set<String> getAvailableNamespaces(@NotNull XmlFile file, @Nullable String tagName) { final Module module = ModuleUtil.findModuleForPsiElement(file); Map<String, XmlFile> schemas = getSchemas(module); Set<String> namespaces = new HashSet<>(); try { for (XmlFile xsd : schemas.values()) { final XmlDocument document = xsd.getDocument(); if (document != null) { final PsiMetaData metaData = document.getMetaData(); if (metaData instanceof XmlNSDescriptorImpl) { XmlNSDescriptorImpl descriptor = (XmlNSDescriptorImpl) metaData; String defaultNamespace = descriptor.getDefaultNamespace(); //Stupid HTTP module XSD weirdo if (xsd.getName().contains("mule-httpn")) defaultNamespace = "http://www.mulesoft.org/schema/mule/http"; ///// if (StringUtils.isNotEmpty(defaultNamespace)) { if (StringUtils.isNotEmpty(tagName)) { XmlElementDescriptor elementDescriptor = descriptor.getElementDescriptor(tagName, defaultNamespace); if (elementDescriptor != null) { namespaces.add(defaultNamespace); } } else { namespaces.add(defaultNamespace); } } } } } } catch (Exception e) { //e.printStackTrace(); } return namespaces; }
private static boolean isXSD(final XmlFile xmlFile) { final XmlDocument document = xmlFile.getDocument(); if (document != null) { final PsiMetaData metaData = document.getMetaData(); if (metaData instanceof XmlNSDescriptorImpl) { return true; } } return false; }
@Override public boolean isValid() { final PsiFile psiFile = getPsiFile(); if (psiFile == null || !psiFile.isValid()) { return false; } if (psiFile instanceof XmlFile) { final XmlDocument document = ((XmlFile)psiFile).getDocument(); return document != null && document.getRootTag() != null; } return true; }
public static PomModelEvent createXmlDocumentChanged(PomModel source, XmlDocument document) { final PomModelEvent event = new PomModelEvent(source); XmlFile xmlFile = PsiTreeUtil.getParentOfType(document, XmlFile.class); final XmlAspectChangeSetImpl xmlAspectChangeSet = new XmlAspectChangeSetImpl(source, xmlFile); xmlAspectChangeSet.add(new XmlDocumentChangedImpl(document)); event.registerChangeSet(source.getModelAspect(XmlAspect.class), xmlAspectChangeSet); return event; }
@Override @NotNull public XmlElementDescriptor[] getRootElementsDescriptors(@Nullable final XmlDocument document) { final List<XmlElementDescriptor> descriptors = new ArrayList<XmlElementDescriptor>(); for (XmlNSDescriptor descriptor : sequence) { ContainerUtil.addAll(descriptors, descriptor.getRootElementsDescriptors(document)); } return descriptors.toArray(new XmlElementDescriptor[descriptors.size()]); }
@Nullable public static XmlDocument getRealXmlDocument(@Nullable XmlDocument doc) { if (doc == null) return null; final PsiFile containingFile = doc.getContainingFile(); final PsiFile templateFile = TemplateLanguageUtil.getTemplateFile(containingFile); if (templateFile instanceof XmlFile) { return ((XmlFile)templateFile).getDocument(); } return doc; }
public static XmlNSDescriptorImpl getRedefinedElementDescriptor(final XmlTag parentTag) { XmlFile file = getRedefinedElementDescriptorFile(parentTag); if (file != null) { final XmlDocument document = file.getDocument(); final PsiMetaData metaData = document != null ? document.getMetaData():null; if (metaData instanceof XmlNSDescriptorImpl) return (XmlNSDescriptorImpl)metaData; } return null; }
private XmlNSDescriptorImpl findNSDescriptor(final XmlTag tag, final XmlDocument document) { final XmlNSDescriptorImpl nsDescriptor; if(IMPORT_TAG_NAME.equals(tag.getLocalName())) { final XmlNSDescriptor importedDescriptor = (XmlNSDescriptor)document.getMetaData(); nsDescriptor = (importedDescriptor instanceof XmlNSDescriptorImpl) ? (XmlNSDescriptorImpl)importedDescriptor: this; } else { nsDescriptor = this; } return nsDescriptor; }
@Override public XmlNSDescriptor getNSDescriptor() { XmlNSDescriptor nsDescriptor = NSDescriptor; if (nsDescriptor ==null) { final XmlFile file = XmlUtil.getContainingFile(getType(null).getDeclaration()); if(file == null) return null; final XmlDocument document = file.getDocument(); if(document == null) return null; NSDescriptor = nsDescriptor = (XmlNSDescriptor)document.getMetaData(); } return nsDescriptor; }
@Nullable @Override public String[][] getNamespacesFromDocument(XmlDocument parent, boolean declarationsExist) { String[][] namespaces = super.getNamespacesFromDocument(parent, false); if (namespaces == null || !HtmlUtil.isHtml5Document(parent)) return namespaces; for (String[] namespace : namespaces) { if ("xlink".equals(namespace[0])) return namespaces; } String[][] newNamespaces = new String[namespaces.length + 1][2]; System.arraycopy(namespaces, 0, newNamespaces, 0, namespaces.length); newNamespaces[namespaces.length] = new String[] {"xlink", "http://www.w3.org/1999/xlink"}; return newNamespaces; }
@Override public XmlDocument getDocument() { PsiElement child = getFirstChild(); while (child != null) { if (child instanceof XmlDocument) return (XmlDocument)child; child = child.getNextSibling(); } return null; }
@Override public XmlDocument getDocument() { CompositeElement treeElement = calcTreeElement(); ASTNode node = treeElement.findChildByType(XmlElementType.HTML_DOCUMENT); return node != null ? (XmlDocument)node.getPsi() : null; }
@Override public boolean isAcceptable(Object element, PsiElement context){ if(element instanceof XmlTag){ final String attributeValue = ((XmlTag)element).getAttributeValue("targetNamespace"); if(attributeValue != null){ for (String aMyValue : myValue) { if (aMyValue.equals(attributeValue)) return true; } } } else if(element instanceof XmlDocument){ return isAcceptable(((XmlDocument) element).getRootTag(), context); } return false; }
@Override public boolean isAcceptable(Object element, PsiElement scope){ if (!(element instanceof XmlDocument)) return false; final XmlTag rootTag = ((XmlDocument)element).getRootTag(); if(rootTag == null) return false; return getFilter().isAcceptable(rootTag, (PsiElement)element); }
@Override @NotNull public Collection<StructureViewTreeElement> getChildrenBase() { if (isHtml5SectionsMode()) { return Collections.emptyList(); // Html5SectionsNodeProvider will return its structure } final XmlFile xmlFile = getElement(); final XmlDocument document = xmlFile == null ? null : xmlFile.getDocument(); if (document == null) { return Collections.emptyList(); } final List<XmlTag> rootTags = new SmartList<XmlTag>(); document.processElements(new FilterElementProcessor(XmlTagFilter.INSTANCE, rootTags), document); if (rootTags.isEmpty()) { return Collections.emptyList(); } else if (rootTags.size() == 1) { final XmlTag rootTag = rootTags.get(0); if ("html".equalsIgnoreCase(rootTag.getLocalName())) { final XmlTag[] subTags = rootTag.getSubTags(); if (subTags.length == 1 && ("head".equalsIgnoreCase(subTags[0].getLocalName()) || "body".equalsIgnoreCase(subTags[0].getLocalName()))) { return new HtmlTagTreeElement(subTags[0]).getChildrenBase(); } return new HtmlTagTreeElement(rootTag).getChildrenBase(); } return Collections.<StructureViewTreeElement>singletonList(new HtmlTagTreeElement(rootTag)); } else { final Collection<StructureViewTreeElement> result = new ArrayList<StructureViewTreeElement>(rootTags.size()); for (XmlTag tag : rootTags) { result.add(new HtmlTagTreeElement(tag)); } return result; } }
public static boolean isWithinTag(Lookup lookup) { if (isInXmlContext(lookup)) { PsiElement psiElement = lookup.getPsiElement(); final PsiElement parentElement = psiElement != null ? psiElement.getParent() : null; if (parentElement instanceof XmlTag) return true; if (parentElement instanceof PsiErrorElement && parentElement.getParent() instanceof XmlDocument) return true; return (parentElement instanceof XmlDocument || parentElement instanceof XmlText) && (psiElement.textMatches("<") || psiElement.textMatches("\"")); } return false; }