com.intellij.util.xml.DomManager Java Examples
The following examples show how to use
com.intellij.util.xml.DomManager.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MuleConfigUtils.java From mule-intellij-plugins with Apache License 2.0 | 6 votes |
@NotNull private static List<DomElement> getFlowsInScope(Project project, GlobalSearchScope searchScope) { final List<DomElement> result = new ArrayList<>(); final Collection<VirtualFile> files = FileTypeIndex.getFiles(StdFileTypes.XML, searchScope); final DomManager manager = DomManager.getDomManager(project); for (VirtualFile file : files) { final PsiFile xmlFile = PsiManager.getInstance(project).findFile(file); if (isMuleFile(xmlFile)) { final DomFileElement<Mule> fileElement = manager.getFileElement((XmlFile) xmlFile, Mule.class); if (fileElement != null) { final Mule rootElement = fileElement.getRootElement(); result.addAll(rootElement.getFlows()); result.addAll(rootElement.getSubFlows()); } } } return result; }
Example #2
Source File: MuleConfigUtils.java From mule-intellij-plugins with Apache License 2.0 | 6 votes |
@Nullable private static XmlTag findGlobalElementInFile(Project project, String elementName, VirtualFile file) { final DomManager manager = DomManager.getDomManager(project); final PsiFile xmlFile = PsiManager.getInstance(project).findFile(file); if (isMuleFile(xmlFile)) { final DomFileElement<Mule> fileElement = manager.getFileElement((XmlFile) xmlFile, Mule.class); if (fileElement != null) { final Mule rootElement = fileElement.getRootElement(); final XmlTag[] subTags = rootElement.getXmlTag().getSubTags(); for (XmlTag subTag : subTags) { if (isGlobalElement(subTag)) { if (elementName.equals(subTag.getAttributeValue(MuleConfigConstants.NAME_ATTRIBUTE))) { return subTag; } } } } } return null; }
Example #3
Source File: MuleConfigUtils.java From mule-intellij-plugins with Apache License 2.0 | 6 votes |
@Nullable private static XmlTag findFlowInFile(Project project, String flowName, VirtualFile file) { final DomManager manager = DomManager.getDomManager(project); final PsiFile xmlFile = PsiManager.getInstance(project).findFile(file); if (isMuleFile(xmlFile)) { final DomFileElement<Mule> fileElement = manager.getFileElement((XmlFile) xmlFile, Mule.class); if (fileElement != null) { final Mule rootElement = fileElement.getRootElement(); final List<Flow> flows = rootElement.getFlows(); for (Flow flow : flows) { if (flowName.equals(flow.getName().getValue())) { return flow.getXmlTag(); } } final List<SubFlow> subFlows = rootElement.getSubFlows(); for (SubFlow subFlow : subFlows) { if (flowName.equals(subFlow.getName().getValue())) { return subFlow.getXmlTag(); } } } } return null; }
Example #4
Source File: MuleConfigUtils.java From mule-intellij-plugins with Apache License 2.0 | 6 votes |
@NotNull private static List<XmlTag> getGlobalElementsInScope(Project project, GlobalSearchScope searchScope) { final List<XmlTag> result = new ArrayList<>(); final Collection<VirtualFile> files = FileTypeIndex.getFiles(StdFileTypes.XML, searchScope); final DomManager manager = DomManager.getDomManager(project); for (VirtualFile file : files) { final PsiFile xmlFile = PsiManager.getInstance(project).findFile(file); if (isMuleFile(xmlFile)) { final DomFileElement<Mule> fileElement = manager.getFileElement((XmlFile) xmlFile, Mule.class); if (fileElement != null) { final Mule rootElement = fileElement.getRootElement(); final XmlTag[] subTags = rootElement.getXmlTag().getSubTags(); for (XmlTag subTag : subTags) { if (isGlobalElement(subTag)) { result.add(subTag); } } } } } return result; }
Example #5
Source File: GlobalConfigsTreeStructure.java From mule-intellij-plugins with Apache License 2.0 | 6 votes |
@Override protected SimpleNode[] buildChildren() { List<SimpleNode> myConfigNodes = new ArrayList<>(); final DomManager manager = DomManager.getDomManager(myProject); final DomFileElement<Mule> fileElement = manager.getFileElement((XmlFile) myXmlFile, Mule.class); if (fileElement != null) { final Mule rootElement = fileElement.getRootElement(); XmlTag[] subTags = rootElement.getXmlTag().getSubTags(); for (XmlTag nextTag : subTags) { MuleElementType muleElementType = MuleConfigUtils.getMuleElementTypeFromXmlElement(nextTag); if (muleElementType != null && //This is a global config (MuleElementType.CONFIG.equals(muleElementType) || (MuleElementType.TRANSPORT_CONNECTOR.equals(muleElementType)))) { GlobalConfigNode nextConfigNode = new GlobalConfigNode(this, nextTag); myConfigNodes.add(nextConfigNode); } } } return myConfigNodes.toArray(new SimpleNode[]{}); }
Example #6
Source File: WeaveEditor.java From mule-intellij-plugins with Apache License 2.0 | 6 votes |
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; }
Example #7
Source File: GlobalConfigsTreeStructure.java From mule-intellij-plugins with Apache License 2.0 | 5 votes |
@Override protected SimpleNode[] buildChildren() { List<SimpleNode> myConfigNodes = new ArrayList<>(); final DomManager manager = DomManager.getDomManager(myProject); final Collection<VirtualFile> files = FileTypeIndex.getFiles(StdFileTypes.XML, GlobalSearchScope.projectScope(myProject)); for (VirtualFile file : files) { final PsiFile xmlFile = PsiManager.getInstance(myProject).findFile(file); if (xmlFile != null) { // PsiDirectory directory = xmlFile.getParent(); // Module module = ModuleUtilCore.findModuleForPsiElement((PsiElement) (directory == null ? xmlFile : directory)); if (MuleConfigUtils.isMuleFile(xmlFile)) { final DomFileElement<Mule> fileElement = manager.getFileElement((XmlFile) xmlFile, Mule.class); if (fileElement != null) { final Mule rootElement = fileElement.getRootElement(); XmlTag[] subTags = rootElement.getXmlTag().getSubTags(); for (XmlTag nextTag : subTags) { MuleElementType muleElementType = MuleConfigUtils.getMuleElementTypeFromXmlElement(nextTag); if (muleElementType != null && //This is a global config file and it has at least one connector (MuleElementType.CONFIG.equals(muleElementType) || (MuleElementType.TRANSPORT_CONNECTOR.equals(muleElementType)))) { MuleConfigNode nextConfigNode = new MuleConfigNode(this, xmlFile); myConfigNodes.add(nextConfigNode); break; } } } } } } return myConfigNodes.toArray(new SimpleNode[]{}); }
Example #8
Source File: ManifestFixture.java From intellij with Apache License 2.0 | 5 votes |
private ManifestFixture( Project project, WorkspaceFileSystem workspace, String relativeDirPath, String packageName) { this.project = project; String relativePath = relativeDirPath + "/AndroidManifest.xml"; label = "//" + relativePath; file = (XmlFile) workspace.createPsiFile( new WorkspacePath(relativePath), String.format(EMPTY_MANIFEST, packageName)); manifest = DomManager.getDomManager(project).getFileElement(file, Manifest.class).getRootElement(); }
Example #9
Source File: SlingModuleFacet.java From aem-ide-tooling-4-intellij with Apache License 2.0 | 5 votes |
@Nullable private static <T> T getRootElement(final PsiFile file, final Class<T> domClass, final Module module) { if(!(file instanceof XmlFile)) return null; final DomManager domManager = DomManager.getDomManager(file.getProject()); final DomFileElement<DomElement> element = domManager.getFileElement((XmlFile) file, DomElement.class); if(element == null) return null; final DomElement root = element.getRootElement(); if(!ReflectionUtil.isAssignable(domClass, root.getClass())) return null; return (T) root; }
Example #10
Source File: BaseAction.java From MavenHelper with Apache License 2.0 | 5 votes |
protected DomFileElement getDomFileElement(MavenArtifactNode mavenArtifactNode) { XmlFile xmlFile = getXmlFile(mavenArtifactNode); if (xmlFile == null) { // showError(mavenArtifactNode); return null; } DomFileElement<MavenDomProjectModel> fileElement = DomManager.getDomManager(myProject).getFileElement(xmlFile, MavenDomProjectModel.class); if (fileElement == null) { showError(xmlFile); } return fileElement; }