Search in sources :

Example 46 with XmlElement

use of com.intellij.psi.xml.XmlElement in project intellij-community by JetBrains.

the class XsltContextProviderExtensionBase method accepts.

public boolean accepts(XPathFile file) {
    final PsiElement context = file.getContext();
    if (!(context instanceof XmlElement))
        return false;
    final XmlAttribute att = PsiTreeUtil.getParentOfType(context, XmlAttribute.class);
    if (att == null)
        return false;
    return XsltSupport.isXPathAttribute(att) ? acceptsLanguage(file.getLanguage()) : false;
}
Also used : XmlAttribute(com.intellij.psi.xml.XmlAttribute) XmlElement(com.intellij.psi.xml.XmlElement) PsiElement(com.intellij.psi.PsiElement)

Example 47 with XmlElement

use of com.intellij.psi.xml.XmlElement in project intellij-community by JetBrains.

the class MavenPluginConfigurationDomExtender method isInPluginManagement.

private static boolean isInPluginManagement(MavenDomConfiguration pluginNode) {
    XmlElement xmlElement = pluginNode.getXmlElement();
    if (xmlElement == null)
        return false;
    PsiElement pluginTag = xmlElement.getParent();
    if (pluginTag == null)
        return false;
    PsiElement pluginsTag = pluginTag.getParent();
    if (pluginsTag == null)
        return false;
    PsiElement pluginManagementTag = pluginsTag.getParent();
    return pluginManagementTag instanceof XmlTag && "pluginManagement".equals(((XmlTag) pluginManagementTag).getName());
}
Also used : XmlElement(com.intellij.psi.xml.XmlElement) PsiElement(com.intellij.psi.PsiElement) XmlTag(com.intellij.psi.xml.XmlTag)

Example 48 with XmlElement

use of com.intellij.psi.xml.XmlElement in project intellij-community by JetBrains.

the class MavenPropertyResolver method resolve.

public static String resolve(String text, MavenDomProjectModel projectDom) {
    XmlElement element = projectDom.getXmlElement();
    if (element == null)
        return text;
    VirtualFile file = MavenDomUtil.getVirtualFile(element);
    if (file == null)
        return text;
    MavenProjectsManager manager = MavenProjectsManager.getInstance(projectDom.getManager().getProject());
    MavenProject mavenProject = manager.findProject(file);
    if (mavenProject == null)
        return text;
    StringBuilder res = new StringBuilder();
    try {
        doFilterText(PATTERN, manager, mavenProject, text, collectPropertiesFromDOM(mavenProject, projectDom), null, false, null, res);
    } catch (IOException e) {
        // never thrown
        throw new RuntimeException(e);
    }
    return res.toString();
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) MavenProjectsManager(org.jetbrains.idea.maven.project.MavenProjectsManager) MavenProject(org.jetbrains.idea.maven.project.MavenProject) XmlElement(com.intellij.psi.xml.XmlElement) IOException(java.io.IOException)

Example 49 with XmlElement

use of com.intellij.psi.xml.XmlElement in project intellij-community by JetBrains.

the class MavenDomUtil method getCollectionIndex.

public static int getCollectionIndex(@NotNull final MavenDomDependencies dependencies, @Nullable final Editor editor) {
    if (editor != null) {
        int offset = editor.getCaretModel().getOffset();
        List<MavenDomDependency> dependencyList = dependencies.getDependencies();
        for (int i = 0; i < dependencyList.size(); i++) {
            MavenDomDependency dependency = dependencyList.get(i);
            XmlElement xmlElement = dependency.getXmlElement();
            if (xmlElement != null && xmlElement.getTextRange().getStartOffset() >= offset) {
                return i;
            }
        }
    }
    return -1;
}
Also used : XmlElement(com.intellij.psi.xml.XmlElement)

Example 50 with XmlElement

use of com.intellij.psi.xml.XmlElement in project intellij-community by JetBrains.

the class MavenDomUtil method findProject.

@Nullable
public static MavenProject findProject(@NotNull MavenDomProjectModel projectDom) {
    XmlElement element = projectDom.getXmlElement();
    if (element == null)
        return null;
    VirtualFile file = getVirtualFile(element);
    if (file == null)
        return null;
    MavenProjectsManager manager = MavenProjectsManager.getInstance(element.getProject());
    return manager.findProject(file);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LightVirtualFile(com.intellij.testFramework.LightVirtualFile) MavenProjectsManager(org.jetbrains.idea.maven.project.MavenProjectsManager) XmlElement(com.intellij.psi.xml.XmlElement) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

XmlElement (com.intellij.psi.xml.XmlElement)69 PsiElement (com.intellij.psi.PsiElement)16 NotNull (org.jetbrains.annotations.NotNull)16 Nullable (org.jetbrains.annotations.Nullable)11 XmlTag (com.intellij.psi.xml.XmlTag)10 PsiFile (com.intellij.psi.PsiFile)7 PsiReference (com.intellij.psi.PsiReference)6 XmlAttribute (com.intellij.psi.xml.XmlAttribute)6 XmlFile (com.intellij.psi.xml.XmlFile)6 Manifest (org.jetbrains.android.dom.manifest.Manifest)5 Module (com.intellij.openapi.module.Module)4 Project (com.intellij.openapi.project.Project)4 DomElement (com.intellij.util.xml.DomElement)4 ArrayList (java.util.ArrayList)4 WriteCommandAction (com.intellij.openapi.command.WriteCommandAction)3 CompositePsiElement (com.intellij.psi.impl.source.tree.CompositePsiElement)3 SmartList (com.intellij.util.SmartList)3 AndroidFacet (org.jetbrains.android.facet.AndroidFacet)3 ResourceType (com.android.resources.ResourceType)2 Result (com.intellij.openapi.application.Result)2