com.intellij.psi.impl.source.xml.XmlFileImpl Java Examples

The following examples show how to use com.intellij.psi.impl.source.xml.XmlFileImpl. 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: PushAction.java    From ADB-Duang with MIT License 6 votes vote down vote up
@Override
protected boolean runEnable(AnActionEvent anActionEvent) {
    Object o = anActionEvent.getDataContext().getData(DataConstants.PSI_FILE);
    if (o instanceof XmlFileImpl) {
        parentFileName = ((XmlFileImpl) o).getVirtualFile().getParent().getName();
        if (isPreference(parentFileName)) {
            return true;
        }

    } else if (o instanceof PsiFile) {
        parentFileName = ((PsiFile) o).getVirtualFile().getParent().getName();
        if (isDataBase(parentFileName)) {
            return true;
        }
    }
    return false;
}
 
Example #2
Source File: SqlsXmlUtil.java    From NutzCodeInsight with Apache License 2.0 5 votes vote down vote up
public static List<PsiElement> findXmlPsiElement(Project project, Collection<VirtualFile> virtualFiles, String key) {
    List<PsiElement> result = new ArrayList<>();
    for (VirtualFile virtualFile : virtualFiles) {
        PsiFile psiFile = PsiManager.getInstance(project).findFile(virtualFile);
        if (psiFile instanceof XmlFileImpl) {
            XmlFileImpl xmlFile = (XmlFileImpl) psiFile;
            PsiElement navigationElement = xmlFile.getNavigationElement();
            if (Objects.nonNull(navigationElement)) {
                if (Objects.nonNull(navigationElement.getChildren())) {
                    PsiElement child = navigationElement.getChildren()[0];
                    if (Objects.nonNull(child)) {
                        if (Objects.nonNull(child.getChildren()) && child.getChildren().length > 0) {
                            PsiElement child1 = child.getChildren()[1];
                            if (Objects.nonNull(child1)) {
                                PsiElement[] psiElements = child1.getChildren();
                                if (Objects.nonNull(psiElements) && psiElements.length > 0) {
                                    List<XmlTag> xmlTags = PsiTreeUtil.getChildrenOfAnyType(child1, XmlTag.class);
                                    for (XmlTag xmlTag : xmlTags) {
                                        if ("sql".equals(xmlTag.getName())) {
                                            XmlAttribute xmlAttribute = xmlTag.getAttribute("id");
                                            String id = xmlAttribute.getValue();
                                            if (key.equals(id)) {
                                                result.add(xmlAttribute.getValueElement());
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    return result;
}
 
Example #3
Source File: PushAction.java    From ADB-Duang with MIT License 5 votes vote down vote up
@Override
protected String getAndroidFacetName(AnActionEvent anActionEvent) {
    Object o = anActionEvent.getDataContext().getData(DataConstants.PSI_FILE);
    if (o instanceof XmlFileImpl) {

        return ((XmlFileImpl) o).getVirtualFile().getParent().getParent().getName();

    } else if (o instanceof PsiFile) {
        return parentFileName = ((PsiFile) o).getVirtualFile().getParent().getParent().getName();
    }
    return super.getAndroidFacetName(anActionEvent);
}
 
Example #4
Source File: RequirejsProjectComponent.java    From WebStormRequireJsPlugin with MIT License 5 votes vote down vote up
public boolean parseRequirejsConfig() {
    VirtualFile mainJsVirtualFile = findPathInWebDir(settings.configFilePath);
    if (null == mainJsVirtualFile) {
        this.showErrorConfigNotification("Config file not found. File " + settings.publicPath + '/' + settings.configFilePath + " not found in project");
        LOG.debug("Config not found");
        return false;
    } else {
        PsiFile mainJs = PsiManager.getInstance(project).findFile(mainJsVirtualFile);
        if (mainJs instanceof JSFileImpl || mainJs instanceof XmlFileImpl) {
            Map<String, VirtualFile> allConfigPaths;
            packageConfig.clear();
            requireMap.clear();
            requirePaths.clear();
            if (((PsiFileImpl) mainJs).getTreeElement() == null) {
                parseMainJsFile(((PsiFileImpl) mainJs).calcTreeElement());
            } else {
                parseMainJsFile(((PsiFileImpl) mainJs).getTreeElement());
            }
        } else {
            this.showErrorConfigNotification("Config file wrong format");
            LOG.debug("Config file wrong format");
            return false;
        }
    }

    return true;
}