Java Code Examples for com.intellij.psi.xml.XmlTag#getParent()

The following examples show how to use com.intellij.psi.xml.XmlTag#getParent() . 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: ShopwareXmlCompletion.java    From idea-php-shopware-plugin with MIT License 6 votes vote down vote up
@Nullable
public static String getControllerOnScope(@NotNull XmlTag xmlTag) {
    PsiElement menuTag = xmlTag.getParent();
    if(!(menuTag instanceof XmlTag)) {
        return null;
    }

    String name = ((XmlTag) menuTag).getName();
    if(!"entry".equals(name)) {
        return null;
    }

    XmlTag controller = ((XmlTag) menuTag).findFirstSubTag("controller");
    if(controller == null) {
        return null;
    }

    String controllerName = controller.getValue().getTrimmedText();
    if(StringUtils.isBlank(controllerName)) {
        return null;
    }

    return controllerName;
}
 
Example 2
Source File: ServiceArgumentParameterHintsProvider.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
@Nullable
private Pair<String, Method> findMethodParameterHint(@NotNull XmlTag argumentTag) {
    PsiElement serviceTag = argumentTag.getParent();
    if("service".equalsIgnoreCase(((XmlTag) serviceTag).getName())) {
        String aClass = XmlHelper.getClassFromServiceDefinition((XmlTag) serviceTag);
        if(aClass != null && StringUtils.isNotBlank(aClass)) {
            return getParamater(argumentTag.getProject(), aClass, aVoid -> XmlHelper.getArgumentIndex(argumentTag));
        }
    }

    return null;
}
 
Example 3
Source File: ServiceActionUtil.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
public static boolean isValidXmlParameterInspectionService(@NotNull XmlTag xmlTag) {

        // we dont support some attributes right now
        for(String s : INVALID_ARGUMENT_ATTRIBUTES) {
            if(xmlTag.getAttribute(s) != null) {
                return false;
            }
        }

        // <service autowire="[false|true]"/>
        String autowire = xmlTag.getAttributeValue("autowire");
        if("true".equalsIgnoreCase(autowire)) {
            return false;
        } else if("false".equalsIgnoreCase(autowire)) {
            return true;
        }

        // <service><factory/></service>
        // symfony2 >= 2.6
        if(xmlTag.findSubTags("factory").length > 0) {
            return false;
        }

        // <services autowire="true"><defaults/></services>
        PsiElement servicesTag = xmlTag.getParent();
        if(servicesTag instanceof XmlTag &&  "services".equals(((XmlTag) servicesTag).getName())) {
            // <defaults autowire="true" />
            for (XmlTag defaults : ((XmlTag) servicesTag).findSubTags("defaults")) {
                if("true".equalsIgnoreCase(defaults.getAttributeValue("autowire"))) {
                    return false;
                }
            }
        }

        return true;
    }