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


Java XmlFile.getRootTag方法代码示例

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


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

示例1: getComponentDeclarations

import com.intellij.psi.xml.XmlFile; //导入方法依赖的package包/类
private static List<XmlTag> getComponentDeclarations(String componentValue, String componentType, ID<String, Void> id, Project project, ComponentMatcher componentMatcher) {
    List<XmlTag> results = new ArrayList<XmlTag>();
    Collection<VirtualFile> containingFiles = FileBasedIndex.getInstance()
        .getContainingFiles(
            id,
            componentValue,
            GlobalSearchScope.allScope(project)
        );
    PsiManager psiManager = PsiManager.getInstance(project);

    for (VirtualFile virtualFile: containingFiles) {
        XmlFile xmlFile = (XmlFile)psiManager.findFile(virtualFile);
        if (xmlFile == null) {
            continue;
        }

        XmlTag rootTag = xmlFile.getRootTag();
        if (rootTag == null) {
            continue;
        }
        collectComponentDeclarations(rootTag, results, componentValue, componentType, componentMatcher);
    }

    return results;
}
 
开发者ID:magento,项目名称:magento2-phpstorm-plugin,代码行数:26,代码来源:LayoutIndex.java

示例2: getClassConfigurations

import com.intellij.psi.xml.XmlFile; //导入方法依赖的package包/类
public static List<XmlTag> getClassConfigurations(PhpClass phpClass) {
    String classFqn = phpClass.getPresentableFQN();

    Collection<VirtualFile> containingFiles = FileBasedIndex.getInstance()
        .getContainingFiles(KEY, classFqn, GlobalSearchScope.allScope(phpClass.getProject())
    );

    PsiManager psiManager = PsiManager.getInstance(phpClass.getProject());

    List<XmlTag> tags = new ArrayList<XmlTag>();

    for (VirtualFile virtualFile: containingFiles) {
        XmlFile file = (XmlFile)psiManager.findFile(virtualFile);

        if (file == null) {
            continue;
        }

        XmlTag rootTag = file.getRootTag();
        fillRelatedTags(classFqn, rootTag, tags);
    }

    return tags;
}
 
开发者ID:magento,项目名称:magento2-phpstorm-plugin,代码行数:25,代码来源:TypeConfigurationIndex.java

示例3: getWebApiRoutes

import com.intellij.psi.xml.XmlFile; //导入方法依赖的package包/类
/**
 * Get list of Web API routes associated with the provided method.
 *
 * Parent classes are not taken into account.
 */
public static List<XmlTag> getWebApiRoutes(Method method) {
    List<XmlTag> tags = new ArrayList<>();
    if (!method.getAccess().isPublic()) {
        return tags;
    }
    PhpClass phpClass = method.getContainingClass();
    String methodFqn = method.getName();
    if (phpClass == null) {
        return tags;
    }
    String classFqn = phpClass.getPresentableFQN();
    Collection<VirtualFile> containingFiles = FileBasedIndex
        .getInstance().getContainingFiles(KEY, classFqn, GlobalSearchScope.allScope(phpClass.getProject()));

    PsiManager psiManager = PsiManager.getInstance(phpClass.getProject());
    for (VirtualFile virtualFile : containingFiles) {
        XmlFile file = (XmlFile) psiManager.findFile(virtualFile);
        if (file == null) {
            continue;
        }
        XmlTag rootTag = file.getRootTag();
        fillRelatedTags(classFqn, methodFqn, rootTag, tags);
    }
    return tags;
}
 
开发者ID:magento,项目名称:magento2-phpstorm-plugin,代码行数:31,代码来源:WebApiTypeIndex.java

示例4: insertSchemaLocationLookup

import com.intellij.psi.xml.XmlFile; //导入方法依赖的package包/类
public static void insertSchemaLocationLookup(XmlFile xmlFile, String namespace, String locationLookup) {
    final XmlTag rootTag = xmlFile.getRootTag();
    if (rootTag == null)
        return;
    final XmlAttribute attribute = rootTag.getAttribute("xsi:schemaLocation", HTTP_WWW_W3_ORG_2001_XMLSCHEMA);
    if (attribute != null) {
        final String value = attribute.getValue();
        attribute.setValue(value + "\n\t\t\t" + namespace + " " + locationLookup);
    } else {
        final XmlElementFactory elementFactory = XmlElementFactory.getInstance(xmlFile.getProject());
        final XmlAttribute schemaLocation = elementFactory.createXmlAttribute("xsi:schemaLocation", XmlUtil.XML_SCHEMA_INSTANCE_URI);
        schemaLocation.setValue(namespace + " " + locationLookup);
        rootTag.add(schemaLocation);
    }

}
 
开发者ID:machaval,项目名称:mule-intellij-plugins,代码行数:17,代码来源:MuleSchemaUtils.java

示例5: parseXmlFileInTemplate

import com.intellij.psi.xml.XmlFile; //导入方法依赖的package包/类
@NotNull
private static XmlFile parseXmlFileInTemplate(@NotNull TemplateImpl template, @NotNull CustomTemplateCallback callback,
                                              @NotNull Map<String, String> attributes) {
  XmlTag dummyRootTag = null;
  String templateString = template.getString();
  final PsiFileFactory psiFileFactory = PsiFileFactory.getInstance(callback.getProject());
  if (!containsAttrsVar(template)) {
    XmlFile dummyFile = (XmlFile)psiFileFactory.createFileFromText("dummy.html", HTMLLanguage.INSTANCE, templateString, false, true);
    dummyRootTag = dummyFile.getRootTag();
    if (dummyRootTag != null) {
      addMissingAttributes(dummyRootTag, attributes);
    }
  }

  templateString = dummyRootTag != null ? dummyRootTag.getContainingFile().getText() : templateString;
  XmlFile xmlFile =
    (XmlFile)psiFileFactory.createFileFromText("dummy.xml", StdFileTypes.XML, templateString, LocalTimeCounter.currentTime(), true);
  VirtualFile vFile = xmlFile.getVirtualFile();
  if (vFile != null) {
    vFile.putUserData(UndoConstants.DONT_RECORD_UNDO, Boolean.TRUE);
  }
  return xmlFile;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:TemplateToken.java

示例6: getPackageInfoText

import com.intellij.psi.xml.XmlFile; //导入方法依赖的package包/类
@Nullable
private static String getPackageInfoText(XmlFile xmlFile) {
  final XmlTag rootTag = xmlFile.getRootTag();
  if (rootTag == null) {
    return null;
  }
  final PsiElement[] children = rootTag.getChildren();
  for (PsiElement child : children) {
    if (!(child instanceof HtmlTag)) {
      continue;
    }
    final HtmlTag htmlTag = (HtmlTag)child;
    @NonNls final String name = htmlTag.getName();
    if ("body".equalsIgnoreCase(name)) {
      final XmlTagValue value = htmlTag.getValue();
      return value.getText();
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:PackageDotHtmlMayBePackageInfoInspection.java

示例7: getRootTagAttributeSafely

import com.intellij.psi.xml.XmlFile; //导入方法依赖的package包/类
/**
 * Get the value of an attribute in the {@link com.intellij.psi.xml.XmlFile} safely (meaning it will acquire the read lock first).
 */
@Nullable
public static String getRootTagAttributeSafely(@NotNull final XmlFile file,
                                               @NotNull final String attribute,
                                               @Nullable final String namespace) {
  Application application = ApplicationManager.getApplication();
  if (!application.isReadAccessAllowed()) {
    return application.runReadAction(new Computable<String>() {
      @Nullable
      @Override
      public String compute() {
        return getRootTagAttributeSafely(file, attribute, namespace);
      }
    });
  } else {
    XmlTag tag = file.getRootTag();
    if (tag != null) {
      XmlAttribute attr = namespace != null ? tag.getAttribute(attribute, namespace) : tag.getAttribute(attribute);
      if (attr != null) {
        return attr.getValue();
      }
    }
    return null;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:AndroidPsiUtils.java

示例8: isMuleFile

import com.intellij.psi.xml.XmlFile; //导入方法依赖的package包/类
public static boolean isMuleFile(PsiFile psiFile) {
    if (!(psiFile instanceof XmlFile)) {
        return false;
    }
    if (psiFile.getFileType() != StdFileTypes.XML) {
        return false;
    }
    final XmlFile psiFile1 = (XmlFile) psiFile;
    final XmlTag rootTag = psiFile1.getRootTag();
    return isMuleTag(rootTag);
}
 
开发者ID:machaval,项目名称:mule-intellij-plugins,代码行数:12,代码来源:MuleConfigUtils.java

示例9: isMUnitFile

import com.intellij.psi.xml.XmlFile; //导入方法依赖的package包/类
public static boolean isMUnitFile(PsiFile psiFile) {
    if (!(psiFile instanceof XmlFile)) {
        return false;
    }
    if (psiFile.getFileType() != StdFileTypes.XML) {
        return false;
    }
    final XmlFile psiFile1 = (XmlFile) psiFile;
    final XmlTag rootTag = psiFile1.getRootTag();
    if (rootTag == null || !isMuleTag(rootTag)) {
        return false;
    }
    final XmlTag[] munitTags = rootTag.findSubTags(MUNIT_TEST_LOCAL_NAME, rootTag.getNamespaceByPrefix(MUNIT_NAMESPACE));
    return munitTags.length > 0;
}
 
开发者ID:machaval,项目名称:mule-intellij-plugins,代码行数:16,代码来源:MuleConfigUtils.java

示例10: isMyFile

import com.intellij.psi.xml.XmlFile; //导入方法依赖的package包/类
@Override
public boolean isMyFile(@NotNull XmlFile file, @Nullable Module module) {
  if (!super.isMyFile(file, module)) {
    return false;
  }

  final XmlTag rootTag = file.getRootTag();
  if (rootTag == null) {
    return false;
  }

  return ANIMATION_LIST_TAG.equals(rootTag.getName());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:AnimationListDomFileDescription.java

示例11: isMyFile

import com.intellij.psi.xml.XmlFile; //导入方法依赖的package包/类
@Override
public boolean isMyFile(@NotNull XmlFile file, @Nullable Module module) {
  if (!super.isMyFile(file, module)) {
    return false;
  }

  final XmlTag rootTag = file.getRootTag();
  if (rootTag == null) {
    return false;
  }

  return TAG.equals(rootTag.getName());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:AnimatedStateListDomFileDescription.java

示例12: get

import com.intellij.psi.xml.XmlFile; //导入方法依赖的package包/类
/** Returns an {link IncludeReference} specified for the given file, or {@link #NONE} if no include should be performed from the
 * given file */
@NotNull
public static IncludeReference get(@NotNull final Module module, @NotNull final XmlFile file, @NotNull final RenderResources resolver) {
  if (!ApplicationManager.getApplication().isReadAccessAllowed()) {
    return ApplicationManager.getApplication().runReadAction(new Computable<IncludeReference>() {
      @NotNull
      @Override
      public IncludeReference compute() {
        return get(module, file, resolver);
      }
    });
  }

  ApplicationManager.getApplication().assertReadAccessAllowed();
  XmlTag rootTag = file.getRootTag();
  if (rootTag != null) {
    String layout = rootTag.getAttributeValue(ATTR_RENDER_IN, TOOLS_URI);
    if (layout != null) {
      ResourceValue resValue = resolver.findResValue(layout, false);
      if (resValue != null) {
        // TODO: Do some sort of picking based on best configuration!!
        // I should make sure I also get a configuration that is compatible with
        // my target include! I could stash it in the include reference!
        File path = ResourceHelper.resolveLayout(resolver, resValue);
        if (path != null) {
          VirtualFile source = LocalFileSystem.getInstance().findFileByIoFile(path);
          if (source != null) {
            VirtualFile target = file.getVirtualFile();
            return create(module, source, target);
          }
        }
      }
    }
  }

  return NONE;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:39,代码来源:IncludeReference.java

示例13: buildStubTree

import com.intellij.psi.xml.XmlFile; //导入方法依赖的package包/类
@Override
public Stub buildStubTree(FileContent fileContent) {
  PsiFile psiFile = fileContent.getPsiFile();
  if (!(psiFile instanceof XmlFile)) return null;

  Document document = FileDocumentManager.getInstance().getCachedDocument(fileContent.getFile());
  Project project = fileContent.getProject();
  if (project == null) {
    project = psiFile.getProject();
  }
  if (document != null) {
    PsiFile existingPsi = PsiDocumentManager.getInstance(project).getPsiFile(document);
    if (existingPsi instanceof XmlFile) {
      psiFile = existingPsi;
    }
  }

  XmlFile xmlFile = (XmlFile)psiFile;
  try {
    XmlUtil.BUILDING_DOM_STUBS.set(Boolean.TRUE);
    DomFileElement<? extends DomElement> fileElement = DomManager.getDomManager(project).getFileElement(xmlFile);
    if (fileElement == null || !fileElement.getFileDescription().hasStubs()) return null;

    XmlFileHeader header = DomService.getInstance().getXmlFileHeader(xmlFile);
    if (header.getRootTagLocalName() == null) {
      LOG.error("null root tag for " + fileElement + " for " + fileContent.getFile());
    }
    FileStub fileStub = new FileStub(header);
    XmlTag rootTag = xmlFile.getRootTag();
    if (rootTag != null) {
      new DomStubBuilderVisitor(DomManagerImpl.getDomManager(project)).visitXmlElement(rootTag, fileStub, 0);
    }
    return fileStub;
  }
  finally {
    XmlUtil.BUILDING_DOM_STUBS.set(Boolean.FALSE);
    SemService.getSemService(project).clearCache();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:40,代码来源:DomStubBuilder.java

示例14: isMyFile

import com.intellij.psi.xml.XmlFile; //导入方法依赖的package包/类
@Override
public boolean isMyFile(@NotNull XmlFile file, @Nullable Module module) {
  if (!super.isMyFile(file, module)) {
    return false;
  }

  final XmlTag rootTag = file.getRootTag();
  if (rootTag == null) {
    return false;
  }

  return ArrayUtil.find(POSSIBLE_ROOT_TAGS, rootTag.getName()) >= 0;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:LayerListDomFileDescription.java

示例15: setIncludingLayout

import com.intellij.psi.xml.XmlFile; //导入方法依赖的package包/类
public static void setIncludingLayout(@NotNull Project project, @NotNull XmlFile xmlFile, @Nullable String layout) {
  XmlTag tag = xmlFile.getRootTag();
  if (tag != null) {
    SetAttributeFix fix = new SetAttributeFix(project, tag, ATTR_RENDER_IN, TOOLS_URI, layout);
    fix.execute();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:IncludeReference.java


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