Package com.intellij.psi.xml

Examples of com.intellij.psi.xml.XmlTag


                               @NotNull final Collection<LineMarkerInfo> lineMarkerInfos) {
    if (!(element instanceof XmlTag)) {
      return;
    }

    final XmlTag xmlTag = (XmlTag) element;

    // any of our tags?
    final String tagName = xmlTag.getLocalName();
    if (Arrays.binarySearch(TAGS_WITH_ACTION_ATTRIBUTE, tagName) < 0) {
      return;
    }

    if (!Comparing.equal(xmlTag.getNamespace(), StrutsConstants.TAGLIB_STRUTS_UI_URI)) {
      return;
    }

    // short exit when Struts 2 facet not present
    final Module module = ModuleUtilCore.findModuleForPsiElement(element);
    if (module == null) {
      return;
    }

    if (StrutsFacet.getInstance(module) == null) {
      return;
    }

    // special case for <action>
    final String actionPath = Comparing.equal(tagName, ACTION_ATTRIBUTE_NAME) ?
        xmlTag.getAttributeValue("name") :
        xmlTag.getAttributeValue(ACTION_ATTRIBUTE_NAME);
    if (actionPath == null) {
      return;
    }

    final StrutsModel strutsModel = StrutsManager.getInstance(element.getProject()).getCombinedModel(module);
    if (strutsModel == null) {
      return;
    }

    final String namespace = xmlTag.getAttributeValue("namespace");
    final List<Action> actions = strutsModel.findActionsByName(actionPath, namespace);
    if (actions.isEmpty()) {
      return;
    }
View Full Code Here


    final PsiElement parent = methodAttribute.getParent().getParent();
    if (!(parent instanceof XmlTag)) {
      return PsiReference.EMPTY_ARRAY;
    }

    final XmlTag tag = (XmlTag) parent;
    final XmlAttribute action = tag.getAttribute("action");
    if (action == null) {
      return PsiReference.EMPTY_ARRAY;
    }

    final XmlAttributeValue valueElement = action.getValueElement();
View Full Code Here

                                               @NotNull final ProcessingContext processingContext) {
    if (TaglibUtil.isDynamicExpression(((XmlAttributeValue) psiElement).getValue())) {
      return PsiReference.EMPTY_ARRAY;
    }

    final XmlTag tag = PsiTreeUtil.getParentOfType(psiElement, XmlTag.class);
    assert tag != null;

    final XmlTag actionTag = findEnclosingTag(tag, tag.getNamespacePrefix());
    if (actionTag == null) {
      return PsiReference.EMPTY_ARRAY;
    }

    final String actionName = Comparing.equal(actionTag.getLocalName(), "action") ?
        actionTag.getAttributeValue("name") : actionTag.getAttributeValue("action");
    if (actionName == null || TaglibUtil.isDynamicExpression(actionName)) {
      return PsiReference.EMPTY_ARRAY;
    }

    final StrutsManager strutsManager = StrutsManager.getInstance(psiElement.getProject());
    final StrutsModel strutsModel = strutsManager.getCombinedModel(psiElement);
    if (strutsModel == null) {
      return PsiReference.EMPTY_ARRAY;
    }

    final List<Action> actions = strutsModel.findActionsByName(actionName, actionTag.getAttributeValue("namespace"));
    if (actions.size() != 1) {
      return PsiReference.EMPTY_ARRAY;
    }

    final Action action = actions.get(0);
View Full Code Here

  private static final String[] TAGS_WITH_ACTION_ATTRIBUTE = new String[]{"a", "action", "form", "reset", "submit", "url"};

  @Nullable
  private static XmlTag findEnclosingTag(@NotNull final XmlTag xmlTag,
                                         @NotNull final String namespacePrefix) {
    final XmlTag tag = PsiTreeUtil.getParentOfType(xmlTag, XmlTag.class);
    if (tag == null) {
      return null;
    }

    if (tag.getNamespacePrefix().equals(namespacePrefix) &&
        Arrays.binarySearch(TAGS_WITH_ACTION_ATTRIBUTE, tag.getLocalName()) > -1) {
      return tag;
    }

    return findEnclosingTag(tag, namespacePrefix);
  }
View Full Code Here

    final String constantName = constant.getName().getStringValue();
    if (StringUtil.isEmpty(constantName)) {
      return null;
    }

    final XmlTag xmlTag = domElement.getXmlTag();
    final StrutsConstantManager constantManager = StrutsConstantManager.getInstance(xmlTag.getProject());

    //noinspection ConstantConditions
    return constantManager.findConverter(xmlTag, StrutsConstantKey.<Object>create(constantName));
  }
View Full Code Here

          return Indent.getNormalIndent();
        }

        // otherwise, only indent if our foreign parent isn't indenting us
        if (foreignBlockParent.getNode() instanceof XmlTag) {
          XmlTag xmlTag = (XmlTag) foreignBlockParent.getNode();
          if (!myHtmlPolicy.indentChildrenOf(xmlTag)) {
            // no indent from xml parent, add our own
            return Indent.getNormalIndent();
          }
        }
View Full Code Here

    return xmlDocument.getRootTagNSDescriptor().getRootElementsDescriptors(xmlDocument);
  }

  @Override
  public XmlElementDescriptor getElementDescriptor(XmlTag childTag, XmlTag contextTag) {
    XmlTag parent = contextTag.getParentTag();
    if (parent == null) return null;
    final XmlNSDescriptor descriptor = parent.getNSDescriptor(childTag.getNamespace(), true);
    return descriptor == null ? null : descriptor.getElementDescriptor(childTag);
  }
View Full Code Here

        if(!XmlHelper.getArgumentServiceIdPattern().accepts(psiElement)) {
            return;
        }

        // search for parent service definition
        XmlTag currentXmlTag = PsiTreeUtil.getParentOfType(psiElement, XmlTag.class);
        XmlTag parentXmlTag = PsiTreeUtil.getParentOfType(currentXmlTag, XmlTag.class);
        if(parentXmlTag == null) {
            return;
        }

        String name = parentXmlTag.getName();


        if(name.equals("service")) {

            // service/argument[id]

            XmlAttribute classAttribute = parentXmlTag.getAttribute("class");
            if(classAttribute != null) {

                String serviceDefName = classAttribute.getValue();
                PhpClass phpClass = ServiceUtil.getResolvedClassDefinition(psiElement.getProject(), serviceDefName);

                // check type hint on constructor
                if(phpClass != null) {
                    Method constructor = phpClass.getConstructor();
                    if(constructor != null) {
                        String serviceName = ((XmlAttributeValue) psiElement).getValue();
                        attachMethodInstances(psiElement, serviceName, constructor, getArgumentIndex(currentXmlTag), holder);
                    }
                }

            }
        } else if (name.equals("call")) {

            // service/call/argument[id]

            XmlAttribute methodAttribute = parentXmlTag.getAttribute("method");
            if(methodAttribute != null) {
                String methodName = methodAttribute.getValue();
                XmlTag serviceTag = parentXmlTag.getParentTag();

                // get service class
                if(serviceTag != null && "service".equals(serviceTag.getName())) {
                    XmlAttribute classAttribute = serviceTag.getAttribute("class");
                    if(classAttribute != null) {

                        String serviceDefName = classAttribute.getValue();
                        PhpClass phpClass = ServiceUtil.getResolvedClassDefinition(psiElement.getProject(), serviceDefName);
View Full Code Here

    private static class FormAliasParametersCompletionProvider extends CompletionProvider<CompletionParameters> {
        @Override
        protected void addCompletions(@NotNull CompletionParameters completionParameters, ProcessingContext processingContext, final @NotNull CompletionResultSet completionResultSet) {
            PsiElement psiElement = completionParameters.getOriginalPosition();

            XmlTag xmlTag = PsiTreeUtil.getParentOfType(psiElement, XmlTag.class);
            if(xmlTag == null) {
                return;
            }

            XmlTag xmlTagService = PsiTreeUtil.getParentOfType(xmlTag, XmlTag.class);
            if(xmlTagService != null) {
                XmlAttribute xmlAttribute = xmlTagService.getAttribute("class");
                if(xmlAttribute != null) {
                    String value = xmlAttribute.getValue();
                    if(value != null && StringUtils.isNotBlank(value)) {
                        PhpClass phpClass = ServiceUtil.getResolvedClassDefinition(psiElement.getProject(), value);
                        if(phpClass != null) {
View Full Code Here

         *     <tag name="form.type" alias="foo_type_alias" />
         *   </service>
         * </services>
         */

        XmlTag xmlTags[] = PsiTreeUtil.getChildrenOfType(psiFile.getFirstChild(), XmlTag.class);
        if(xmlTags == null) {
            return map;
        }

        for(XmlTag xmlTag: xmlTags) {
View Full Code Here

TOP

Related Classes of com.intellij.psi.xml.XmlTag

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.