本文整理汇总了Java中com.intellij.util.xml.DomManager.getFileElement方法的典型用法代码示例。如果您正苦于以下问题:Java DomManager.getFileElement方法的具体用法?Java DomManager.getFileElement怎么用?Java DomManager.getFileElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.util.xml.DomManager
的用法示例。
在下文中一共展示了DomManager.getFileElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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;
}
示例4: 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;
}
示例5: 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[]{});
}
示例6: 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);
}
示例7: 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;
}
示例8: getRootElement
import com.intellij.util.xml.DomManager; //导入方法依赖的package包/类
@Nullable
public 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;
}
示例9: doVisitRncOrRngFile
import com.intellij.util.xml.DomManager; //导入方法依赖的package包/类
private static void doVisitRncOrRngFile(PsiFile file, CommonElement.Visitor visitor) {
if (file instanceof RncFile) {
final Grammar grammar = ((RncFile)file).getGrammar();
if (grammar != null) {
grammar.acceptChildren(visitor);
}
} else if (file instanceof XmlFile) {
final DomManager mgr = DomManager.getDomManager(file.getProject());
final DomFileElement<RngGrammar> element = mgr.getFileElement((XmlFile)file, RngGrammar.class);
if (element != null) {
element.getRootElement().acceptChildren(visitor);
}
}
}
示例10: loadDomElementWithReadPermission
import com.intellij.util.xml.DomManager; //导入方法依赖的package包/类
/** This method should be called under a read action. */
@Nullable
public static <T extends DomElement> T loadDomElementWithReadPermission(@NotNull Project project,
@NotNull XmlFile xmlFile,
@NotNull Class<T> aClass) {
ApplicationManager.getApplication().assertReadAccessAllowed();
DomManager domManager = DomManager.getDomManager(project);
DomFileElement<T> element = domManager.getFileElement(xmlFile, aClass);
if (element == null) return null;
return element.getRootElement();
}
示例11: getRootElement
import com.intellij.util.xml.DomManager; //导入方法依赖的package包/类
@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;
}
示例12: getAntDomProject
import com.intellij.util.xml.DomManager; //导入方法依赖的package包/类
@Nullable
public static AntDomProject getAntDomProject(PsiFile psiFile) {
if (psiFile instanceof XmlFile) {
final DomManager domManager = DomManager.getDomManager(psiFile.getProject());
final DomFileElement<AntDomProject> fileElement = domManager.getFileElement((XmlFile)psiFile, AntDomProject.class);
return fileElement != null? fileElement.getRootElement() : null;
}
return null;
}
示例13: 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;
}
示例14: getAntLib
import com.intellij.util.xml.DomManager; //导入方法依赖的package包/类
@Nullable
public static AntDomAntlib getAntLib(PsiFile psiFile) {
if (psiFile instanceof XmlFile) {
final DomManager domManager = DomManager.getDomManager(psiFile.getProject());
final DomFileElement<AntDomAntlib> fileElement = domManager.getFileElement((XmlFile)psiFile, AntDomAntlib.class);
return fileElement != null? fileElement.getRootElement() : null;
}
return null;
}
示例15: getRootElement
import com.intellij.util.xml.DomManager; //导入方法依赖的package包/类
@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;
}