当前位置: 首页>>代码示例>>Java>>正文


Java DomManager.getDomManager方法代码示例

本文整理汇总了Java中com.intellij.util.xml.DomManager.getDomManager方法的典型用法代码示例。如果您正苦于以下问题:Java DomManager.getDomManager方法的具体用法?Java DomManager.getDomManager怎么用?Java DomManager.getDomManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.util.xml.DomManager的用法示例。


在下文中一共展示了DomManager.getDomManager方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: expectDomAttributeValue

import com.intellij.util.xml.DomManager; //导入方法依赖的package包/类
public static <T extends DomElement, V> GenericAttributeValue<V> expectDomAttributeValue(
    @NotNull final PsiElement element,
    @NotNull final Class<? extends T> domTagClass,
    @NotNull final Function<T, GenericAttributeValue<V>> domGetter
) {
    final DomManager domManager = DomManager.getDomManager(element.getProject());

    if (!(element instanceof XmlElement)) {
        return null;
    }

    final XmlAttribute xmlAttribute = PsiTreeUtil.getParentOfType(element, XmlAttribute.class, false);
    if (xmlAttribute == null) {
        return null;
    }

    final XmlTag xmlParentTag = PsiTreeUtil.getParentOfType(element, XmlTag.class, false);
    DomElement domParentTag = domManager.getDomElement(xmlParentTag);

    return Optional.ofNullable(domParentTag)
                   .map(o -> ObjectUtils.tryCast(o, domTagClass))
                   .map(domGetter)
                   .filter(val -> val == domManager.getDomElement(xmlAttribute))
                   .orElse(null);
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:26,代码来源:BeansUtils.java

示例2: getFlowsInScope

import com.intellij.util.xml.DomManager; //导入方法依赖的package包/类
@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;
}
 
开发者ID:machaval,项目名称:mule-intellij-plugins,代码行数:19,代码来源:MuleConfigUtils.java

示例3: findGlobalElementInFile

import com.intellij.util.xml.DomManager; //导入方法依赖的package包/类
@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;
}
 
开发者ID:machaval,项目名称:mule-intellij-plugins,代码行数:21,代码来源:MuleConfigUtils.java

示例4: findFlowInFile

import com.intellij.util.xml.DomManager; //导入方法依赖的package包/类
@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;
}
 
开发者ID:machaval,项目名称:mule-intellij-plugins,代码行数:25,代码来源:MuleConfigUtils.java

示例5: getGlobalElementsInScope

import com.intellij.util.xml.DomManager; //导入方法依赖的package包/类
@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;
}
 
开发者ID:machaval,项目名称:mule-intellij-plugins,代码行数:23,代码来源:MuleConfigUtils.java

示例6: buildChildren

import com.intellij.util.xml.DomManager; //导入方法依赖的package包/类
@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[]{});
}
 
开发者ID:machaval,项目名称:mule-intellij-plugins,代码行数:25,代码来源:GlobalConfigsTreeStructure.java

示例7: getGlobalDefinitions

import com.intellij.util.xml.DomManager; //导入方法依赖的package包/类
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;
    }
 
开发者ID:machaval,项目名称:mule-intellij-plugins,代码行数:24,代码来源:WeaveEditor.java

示例8: createMockElement

import com.intellij.util.xml.DomManager; //导入方法依赖的package包/类
private <T extends DomElement> T createMockElement(final Class<T> aClass, final Module module) {
  final Project project = module.getProject();
  ApplicationManager.getApplication().invokeLater(new Runnable() {
    @Override
    public void run() {
      if (myFileEditor.isInitialised()) {
        myContents.reset();
      }
    }
  });
  final DomManager domManager = DomManager.getDomManager(project);
  final T mockElement = domManager.createMockElement(aClass, module, true);
  if (myFileEditor != null) {
    myFileEditor.addWatchedElement(mockElement);
  }
  return mockElement;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:MockDomElementsEditor.java

示例9: getDomElementAndBaseClassQName

import com.intellij.util.xml.DomManager; //导入方法依赖的package包/类
@Nullable
public static Pair<AndroidDomElement, String> getDomElementAndBaseClassQName(@NotNull XmlTag tag) {
  final PsiFile file = tag.getContainingFile();
  if (!(file instanceof XmlFile)) return null;
  Project project = file.getProject();
  if (project.isDefault()) return null;

  final DomManager domManager = DomManager.getDomManager(project);
  if (domManager.getFileElement((XmlFile)file, AndroidDomElement.class) == null) return null;
  
  final DomElement domElement = domManager.getDomElement(tag);
  if (!(domElement instanceof AndroidDomElement)) {
    return null;
  }

  String className = null;
  if (domElement instanceof LayoutViewElement) {
    className = AndroidUtils.VIEW_CLASS_NAME;
  }
  else if (domElement instanceof XmlResourceElement) {
    className = AndroidXmlResourcesUtil.PREFERENCE_CLASS_NAME;
  }
  return Pair.create((AndroidDomElement)domElement, className);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:AndroidDomElementDescriptorProvider.java

示例10: isEnabledForPsiRange

import com.intellij.util.xml.DomManager; //导入方法依赖的package包/类
@Override
protected boolean isEnabledForPsiRange(@NotNull PsiElement from, @Nullable PsiElement to) {
  final DomManager domManager = DomManager.getDomManager(from.getProject());
  PsiElement e = from;
  boolean containsViewElement = false;

  while (e != null) {
    if (e instanceof XmlTag) {
      final DomElement domElement = domManager.getDomElement((XmlTag)e);

      if (!isSuitableDomElement(domElement)) {
        return false;
      }
      if (domElement instanceof LayoutViewElement) {
        containsViewElement = true;
      }
    }
    if (e == to) {
      break;
    }
    e = e.getNextSibling();
  }
  return containsViewElement;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:AndroidExtractAsIncludeAction.java

示例11: processAllClassAttrValues

import com.intellij.util.xml.DomManager; //导入方法依赖的package包/类
private static void processAllClassAttrValues(@NotNull XmlFile file,
                                              @NotNull final Processor<Pair<GenericAttributeValue, PsiClass>> processor) {
  final DomManager domManager = DomManager.getDomManager(file.getProject());

  file.accept(new XmlRecursiveElementVisitor() {
    @Override
    public void visitXmlAttribute(XmlAttribute attribute) {
      final GenericAttributeValue domAttrValue = domManager.getDomElement(attribute);

      if (domAttrValue != null) {
        final Object value = domAttrValue.getValue();

        if (value instanceof PsiClass) {
          processor.process(Pair.create(domAttrValue, (PsiClass)value));
        }
      }
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:AndroidApplicationPackageRenameProcessor.java

示例12: processDynamicElements

import com.intellij.util.xml.DomManager; //导入方法依赖的package包/类
@Override
public void processDynamicElements(@NotNull PsiType qualifierType,
                                   PsiClass aClass,
                                   @NotNull PsiScopeProcessor processor,
                                   @NotNull PsiElement place,
                                   @NotNull ResolveState state) {
  PsiElement pomElement = aClass.getContainingFile().getContext();
  if (pomElement == null) return;

  PsiFile pomFile = pomElement.getContainingFile();
  if (!(pomFile instanceof XmlFile)) return;

  DomManager domManager = DomManager.getDomManager(pomElement.getProject());
  if (!(domManager.getDomFileDescription((XmlFile)pomFile) instanceof MavenDomProjectModelDescription)) {
    return;
  }

  DynamicMemberUtils.process(processor, false, place, CLASS_SOURCE);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:MavenGroovyPomScriptMemberContributor.java

示例13: createMockElement

import com.intellij.util.xml.DomManager; //导入方法依赖的package包/类
private <T extends DomElement> T createMockElement(final Class<T> aClass, final Module module) {
  final Project project = module.getProject();
  ApplicationManager.getApplication().invokeLater(new Runnable() {
    public void run() {
      if (myFileEditor.isInitialised()) {
        myContents.reset();
      }
    }
  });
  final DomManager domManager = DomManager.getDomManager(project);
  final T mockElement = domManager.createMockElement(aClass, module, true);
  if (myFileEditor != null) {
    myFileEditor.addWatchedElement(mockElement);
  }
  return mockElement;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:17,代码来源:MockDomElementsEditor.java

示例14: processDynamicElements

import com.intellij.util.xml.DomManager; //导入方法依赖的package包/类
@Override
public void processDynamicElements(@NotNull PsiType qualifierType,
                                   PsiClass aClass,
                                   PsiScopeProcessor processor,
                                   PsiElement place,
                                   ResolveState state) {
  PsiElement pomElement = aClass.getContainingFile().getContext();
  if (pomElement == null) return;

  PsiFile pomFile = pomElement.getContainingFile();
  if (!(pomFile instanceof XmlFile)) return;

  DomManager domManager = DomManager.getDomManager(pomElement.getProject());
  if (!(domManager.getDomFileDescription((XmlFile)pomFile) instanceof MavenDomProjectModelDescription)) {
    return;
  }

  DynamicMemberUtils.process(processor, false, place, CLASS_SOURCE);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:20,代码来源:MavenGroovyPomScriptMemberContributor.java

示例15: getAntDomProjectForceAntFile

import com.intellij.util.xml.DomManager; //导入方法依赖的package包/类
@Nullable
public static AntDomProject getAntDomProjectForceAntFile(PsiFile psiFile)
{
	if(psiFile instanceof XmlFile)
	{
		final DomManager domManager = DomManager.getDomManager(psiFile.getProject());
		DomFileElement<AntDomProject> fileElement = domManager.getFileElement((XmlFile) psiFile, AntDomProject.class);
		if(fileElement == null)
		{
			ForcedAntFileAttribute.forceAntFile(psiFile.getVirtualFile(), true);
			fileElement = domManager.getFileElement((XmlFile) psiFile, AntDomProject.class);
		}
		return fileElement != null ? fileElement.getRootElement() : null;
	}
	return null;
}
 
开发者ID:consulo,项目名称:consulo-apache-ant,代码行数:17,代码来源:AntSupport.java


注:本文中的com.intellij.util.xml.DomManager.getDomManager方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。