本文整理汇总了Java中com.intellij.util.xml.DomFileElement.getRootElement方法的典型用法代码示例。如果您正苦于以下问题:Java DomFileElement.getRootElement方法的具体用法?Java DomFileElement.getRootElement怎么用?Java DomFileElement.getRootElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.util.xml.DomFileElement
的用法示例。
在下文中一共展示了DomFileElement.getRootElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFlowsInScope
import com.intellij.util.xml.DomFileElement; //导入方法依赖的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.DomFileElement; //导入方法依赖的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.DomFileElement; //导入方法依赖的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.DomFileElement; //导入方法依赖的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.DomFileElement; //导入方法依赖的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: _getOrCreateProblemsHolder
import com.intellij.util.xml.DomFileElement; //导入方法依赖的package包/类
private DomElementsProblemsHolderImpl _getOrCreateProblemsHolder(final DomFileElement element) {
DomElementsProblemsHolderImpl holder;
final DomElement rootElement = element.getRootElement();
final XmlTag rootTag = rootElement.getXmlTag();
if (rootTag == null) return new DomElementsProblemsHolderImpl(element);
holder = rootTag.getUserData(DOM_PROBLEM_HOLDER_KEY);
if (isHolderOutdated(element.getFile()) || holder == null) {
holder = new DomElementsProblemsHolderImpl(element);
rootTag.putUserData(DOM_PROBLEM_HOLDER_KEY, holder);
final CachedValue<Boolean> cachedValue = CachedValuesManager.getManager(myProject).createCachedValue(new CachedValueProvider<Boolean>() {
@Override
public Result<Boolean> compute() {
return new Result<Boolean>(Boolean.FALSE, element, PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT, DomElementAnnotationsManagerImpl.this, ProjectRootManager.getInstance(myProject));
}
}, false);
cachedValue.getValue();
element.getFile().putUserData(CACHED_VALUE_KEY, cachedValue);
}
return holder;
}
示例7: checkIncludes
import com.intellij.util.xml.DomFileElement; //导入方法依赖的package包/类
private boolean checkIncludes(PsiFile layoutFile, PsiElement idElement) {
AndroidFacet facet = AndroidFacet.getInstance(idElement);
PsiFile containingFile = idElement.getContainingFile();
DomFileElement<AndroidDomElement> fileElement = DomManager.getDomManager(layoutFile.getProject()).getFileElement((XmlFile) layoutFile, AndroidDomElement.class);
boolean found = false;
if (fileElement != null) {
AndroidDomElement rootElement = fileElement.getRootElement();
List<Include> includes = DomUtil.getChildrenOfType(rootElement, Include.class);
for (Include include : includes) {
ResourceValue value = include.getLayout().getValue();
if (value != null) {
if (facet != null) {
if (value.getResourceType() != null && value.getResourceName() != null) {
List<PsiFile> resourceFiles = facet.getLocalResourceManager().findResourceFiles(value.getResourceType(), value.getResourceName());
if (!resourceFiles.isEmpty()) {
found = isInAllIncludes(idElement, found, resourceFiles);
}
}
}
}
}
}
return found;
}
示例8: _getOrCreateProblemsHolder
import com.intellij.util.xml.DomFileElement; //导入方法依赖的package包/类
private DomElementsProblemsHolderImpl _getOrCreateProblemsHolder(final DomFileElement element) {
DomElementsProblemsHolderImpl holder;
final DomElement rootElement = element.getRootElement();
final XmlTag rootTag = rootElement.getXmlTag();
if (rootTag == null) return new DomElementsProblemsHolderImpl(element);
holder = rootTag.getUserData(DOM_PROBLEM_HOLDER_KEY);
if (isHolderOutdated(element.getFile()) || holder == null) {
holder = new DomElementsProblemsHolderImpl(element);
rootTag.putUserData(DOM_PROBLEM_HOLDER_KEY, holder);
final CachedValue<Boolean> cachedValue = CachedValuesManager.getManager(myProject).createCachedValue(new CachedValueProvider<Boolean>() {
@Override
public Result<Boolean> compute() {
return new Result<Boolean>(Boolean.FALSE, element, PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT, myModificationTracker, ProjectRootManager.getInstance(myProject));
}
}, false);
cachedValue.getValue();
element.getFile().putUserData(CACHED_VALUE_KEY, cachedValue);
}
return holder;
}
示例9: createStructureViewBuilder
import com.intellij.util.xml.DomFileElement; //导入方法依赖的package包/类
/**
* construct view builder
*
* @param xmlFile xml file
* @return structure view builder
*/
@Nullable public StructureViewBuilder createStructureViewBuilder(@NotNull final XmlFile xmlFile) {
final DomFileElement fileElement = getFileElement(xmlFile);
if (fileElement == null) {
return null;
}
return new TreeBasedStructureViewBuilder() {
@NotNull
public StructureView createStructureView(final FileEditor fileEditor, final Project project) {
return new StructureViewComponent(fileEditor, createStructureViewModel(), project);
}
@NotNull
public StructureViewModel createStructureViewModel() {
return new SqlMapConfigStructureViewTreeModel(xmlFile, fileElement.getRootElement());
}
};
}
示例10: createStructureViewBuilder
import com.intellij.util.xml.DomFileElement; //导入方法依赖的package包/类
/**
* construct view builder
*
* @param xmlFile xml file
* @return structure view builder
*/
@Nullable public StructureViewBuilder createStructureViewBuilder(@NotNull final XmlFile xmlFile) {
final DomFileElement fileElement = getFileElement(xmlFile);
if (fileElement == null) {
return null;
}
return new TreeBasedStructureViewBuilder() {
@NotNull
public StructureView createStructureView(final FileEditor fileEditor, final Project project) {
return new StructureViewComponent(fileEditor, createStructureViewModel(), project);
}
@NotNull
public StructureViewModel createStructureViewModel() {
return new SqlMapStructureViewTreeModel(xmlFile, fileElement.getRootElement());
}
};
}
示例11: getXmlTagForSQLCompletion
import com.intellij.util.xml.DomFileElement; //导入方法依赖的package包/类
/**
* get xml tag for code completion
*
* @param psiElement psiElement
* @param psiFile current file
* @return xml tag
*/
@Nullable
public static XmlTag getXmlTagForSQLCompletion(PsiElement psiElement, PsiFile psiFile) {
if (!psiFile.isPhysical()) {
if (psiElement.getParent().getClass().getName().contains("com.intellij.sql.psi")) { // text only
if (!psiElement.isPhysical()) { //injected sql mode
//todo jacky resolve parameter code completion in sql
List<Pair<PsiElement,TextRange>> files = InjectedLanguageUtil.getInjectedPsiFiles(psiElement);
InjectedLanguageManager manager = InjectedLanguageManager.getInstance(psiElement.getProject());
PsiLanguageInjectionHost psiLanguageInjectionHost = manager.getInjectionHost(psiElement);
if (psiElement.getContainingFile() instanceof XmlFile) {
XmlFile xmlFile = (XmlFile) psiElement.getContainingFile();
final DomFileElement fileElement = DomManager.getDomManager(psiFile.getProject()).getFileElement(xmlFile, DomElement.class);
if (fileElement != null && fileElement.getRootElement() instanceof SqlMap) {
return getParentSentence(psiElement);
}
}
}
}
}
return null;
}
示例12: getAntDomProjectForceAntFile
import com.intellij.util.xml.DomFileElement; //导入方法依赖的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;
}
示例13: getRoot
import com.intellij.util.xml.DomFileElement; //导入方法依赖的package包/类
@Nullable
public <T extends DomElement> T getRoot(@Nullable JavaEEModuleExtension<?> facet, @NotNull Class<T> type)
{
if(facet != null)
{
ConfigFile item = facet.getDescriptorsContainer().getConfigFile(meta);
if(item != null)
{
XmlFile xml = item.getXmlFile();
if(xml != null)
{
DomFileElement<T> element = DomManager.getDomManager(facet.getModule().getProject()).getFileElement(xml, type);
if(element != null)
{
return element.getRootElement();
}
}
}
}
return null;
}
示例14: getRootElement
import com.intellij.util.xml.DomFileElement; //导入方法依赖的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;
}
示例15: getGrammar
import com.intellij.util.xml.DomFileElement; //导入方法依赖的package包/类
@Nullable
public static Grammar getGrammar(@NotNull XmlFile element) {
if (element instanceof RncFile) {
return ((RncFile)element).getGrammar();
}
final DomFileElement<RngGrammar> fileElement = DomManager.getDomManager(element.getProject()).getFileElement(element, RngGrammar.class);
return fileElement != null ? fileElement.getRootElement() : null;
}