当前位置: 首页>>代码示例>>Java>>正文


Java XmlTag.getChildren方法代码示例

本文整理汇总了Java中com.intellij.psi.xml.XmlTag.getChildren方法的典型用法代码示例。如果您正苦于以下问题:Java XmlTag.getChildren方法的具体用法?Java XmlTag.getChildren怎么用?Java XmlTag.getChildren使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.psi.xml.XmlTag的用法示例。


在下文中一共展示了XmlTag.getChildren方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getPackageInfoText

import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
@Nullable
private static String getPackageInfoText(XmlFile xmlFile) {
  final XmlTag rootTag = xmlFile.getRootTag();
  if (rootTag == null) {
    return null;
  }
  final PsiElement[] children = rootTag.getChildren();
  for (PsiElement child : children) {
    if (!(child instanceof HtmlTag)) {
      continue;
    }
    final HtmlTag htmlTag = (HtmlTag)child;
    @NonNls final String name = htmlTag.getName();
    if ("body".equalsIgnoreCase(name)) {
      final XmlTagValue value = htmlTag.getValue();
      return value.getText();
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:PackageDotHtmlMayBePackageInfoInspection.java

示例2: findXmlTag

import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
@Nullable
private static XmlTag findXmlTag(PsiFile file, int offset){
  if (!(file instanceof XmlFile)) return null;

  PsiElement element = file.findElementAt(offset);
  if (element == null) return null;
  element = element.getParent();

  while (element != null) {
    if (element instanceof XmlTag) {
      XmlTag tag = (XmlTag)element;

      final PsiElement[] children = tag.getChildren();

      if (offset <= children[0].getTextRange().getStartOffset()) return null;

      for (PsiElement child : children) {
        final TextRange range = child.getTextRange();
        if (range.getStartOffset() <= offset && range.getEndOffset() > offset) return tag;

        if (child instanceof XmlToken) {
          XmlToken token = (XmlToken)child;
          if (token.getTokenType() == XmlTokenType.XML_TAG_END) return null;
        }
      }

      return null;
    }

    element = element.getParent();
  }

  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:35,代码来源:XmlParameterInfoHandler.java

示例3: apply

import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
@Override
public void apply(@NotNull PsiElement startElement, @NotNull PsiElement endElement, @NotNull AndroidQuickfixContexts.Context context) {
  final XmlTag tag = PsiTreeUtil.getParentOfType(startElement, XmlTag.class);
  if (tag == null) {
    return;
  }

  for (PsiElement child : tag.getChildren()) {
    if (child instanceof XmlText) {
      final XmlText xmlText = (XmlText)child;
      final String value = xmlText.getValue();

      if (value != null) {
        final List<TypographyDetector.ReplaceEdit> edits = TypographyDetector.getEdits(myIssue.getId(), myMessage, value);
        final StringBuilder builder = new StringBuilder(value);

        for (TypographyDetector.ReplaceEdit edit : edits) {
          String with = edit.replaceWith;

          if (ApplicationManager.getApplication().isUnitTestMode()) {
            with = with.replace('\u2013', '~').replace('\u2018', '{').replace('\u2019', '}');
          }

          builder.replace(edit.offset, edit.offset + edit.length, with);
        }

        final String newValue = builder.toString();
        if (!newValue.equals(value)) {
          xmlText.setValue(newValue);
        }
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:35,代码来源:TypographyQuickFix.java

示例4: appendText

import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
private static void appendText(@NonNull StringBuilder sb, @NonNull XmlTag tag) {
  PsiElement[] children = tag.getChildren();
  for (PsiElement child : children) {
    if (child instanceof XmlText) {
      XmlText text = (XmlText)child;
      sb.append(getXmlTextValue(text));
    } else if (child instanceof XmlTag) {
      XmlTag childTag = (XmlTag)child;
      // xliff support
      if (XLIFF_G_TAG.equals(childTag.getLocalName()) && childTag.getNamespace().startsWith(XLIFF_NAMESPACE_PREFIX)) {
        String example = childTag.getAttributeValue(ATTR_EXAMPLE);
        if (example != null) {
          // <xliff:g id="number" example="7">%d</xliff:g> minutes => "(7) minutes"
          sb.append('(').append(example).append(')');
          continue;
        } else {
          String id = childTag.getAttributeValue(ATTR_ID);
          if (id != null) {
            // Step <xliff:g id="step_number">%1$d</xliff:g> => Step ${step_number}
            sb.append('$').append('{').append(id).append('}');
            continue;
          }
        }
      }
      appendText(sb, childTag);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:PsiResourceItem.java

示例5: isAvailable

import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
    if (!XsltSupport.isXsltFile(file)) return false;

    final int offset = editor.getCaretModel().getOffset();
    final PsiElement element = file.findElementAt(offset);
  final XmlTag tag = PsiTreeUtil.getParentOfType(element, XmlTag.class, false);
    if (tag == null) {
        return false;
    }
    if (!XsltSupport.isXsltTag(tag)) {
        return false;
    } else if (!"attribute".equals(tag.getLocalName())) {
        return false;
    } else if (tag.getAttribute("name") == null) {
        return false;
    } else if (findParent(tag) == null) {
        // we cannot "inline" anything that isn't clearly the child of either an xsl:element or a literal result element
        return false;
    }

    final ASTNode node = tag.getNode();
    if (node == null) return false;
    final ASTNode nameNode = XmlChildRole.START_TAG_NAME_FINDER.findChild(node);

    if (nameNode == null || !nameNode.getTextRange().contains(offset)) {
        return false;
    }

    final XmlTag[] texts = tag.findSubTags("text", XsltSupport.XSLT_NS);
    final XmlTag[] exprs = tag.findSubTags("value-of", XsltSupport.XSLT_NS);
    final PsiElement[] children = tag.getChildren();
    for (PsiElement child : children) {
        if (child instanceof XmlText) {
            final XmlText text = (XmlText)child;
            if (text.getText().trim().length() == 0) {
                if (texts.length == 0 && exprs.length == 0) {
                    return false;
                }
            }
        } else if (child instanceof XmlTag) {
            final XmlTag t = (XmlTag)child;
            if (XsltSupport.isXsltTag(t)) {
                if ("text".equals(t.getLocalName())) {

                } else if ("value-of".equals(t.getLocalName())) {
                    if (t.getAttribute("select") == null) {
                        return false;
                    }
                } else {
                    return false;
                }
            } else {
                return false;
            }
        }
    }
    return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:59,代码来源:InlineXslAttribute.java


注:本文中的com.intellij.psi.xml.XmlTag.getChildren方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。