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


Java XmlTag.getNode方法代码示例

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


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

示例1: getEndTagNameElement

import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
@Nullable
public static XmlToken getEndTagNameElement(@NotNull XmlTag tag) {
  final ASTNode node = tag.getNode();
  if (node == null) return null;

  ASTNode current = node.getLastChildNode();
  ASTNode prev = current;

  while (current != null) {
    final IElementType elementType = prev.getElementType();
    if ((elementType == XmlTokenType.XML_NAME || elementType == XmlTokenType.XML_TAG_NAME) &&
        current.getElementType() == XmlTokenType.XML_END_TAG_START) {
      return (XmlToken)prev.getPsi();
    }

    prev = current;
    current = current.getTreePrev();

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

示例2: 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);
    if (element == null) return false;
    final XmlTag tag = PsiTreeUtil.getParentOfType(element, XmlTag.class);
    if (tag == null || tag.getParentTag() == null) return false;
    if (!tag.getLocalName().equals("if") || !XsltSupport.isXsltTag(tag)) return false;
    if (tag.getAttributeValue("test") == null) return false;

    final ASTNode node = tag.getNode();
    if (node == null) return false;

    final ASTNode child = XmlChildRole.START_TAG_NAME_FINDER.findChild(node);
    return child != null && child.getTextRange().contains(offset);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:ConvertIfToChooseIntention.java

示例3: isAvailableAt

import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
protected static boolean isAvailableAt(PsiElement element, XmlTag tag, int offset) {
        final ASTNode node = tag.getNode();
        if (node != null) {
            final ASTNode child = XmlChildRole.START_TAG_NAME_FINDER.findChild(node);
            if (child != null && child.getTextRange().contains(offset)) {
                return true;
            }
        }

//        final XmlAttribute att = PsiTreeUtil.getParentOfType(element, XmlAttribute.class);
//        if (att != null && "name".equals(att.getName()) && att.getValueElement() != null) {
//            return att.getValueElement().getTextRange().contains(offset);
//        }

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

示例4: getStartTagNameElement

import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
@Nullable
public static XmlToken getStartTagNameElement(@NotNull XmlTag tag) {
  final ASTNode node = tag.getNode();
  if (node == null) return null;

  ASTNode current = node.getFirstChildNode();
  IElementType elementType;
  while (current != null
         && (elementType = current.getElementType()) != XmlTokenType.XML_NAME
         && elementType != XmlTokenType.XML_TAG_NAME) {
    current = current.getTreeNext();
  }
  return current == null ? null : (XmlToken)current.getPsi();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:XmlTagUtil.java

示例5: replaceByTagContent

import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
private static void replaceByTagContent(Project project, XmlTag tagToReplace, XmlTag tagToInline)
  throws AndroidRefactoringErrorException {
  final ASTNode node = tagToInline.getNode();

  if (node == null) {
    throw new AndroidRefactoringErrorException();
  }
  final ASTNode startTagEnd = XmlChildRole.START_TAG_END_FINDER.findChild(node);
  final ASTNode closingTagStart = XmlChildRole.CLOSING_TAG_START_FINDER.findChild(node);

  if (startTagEnd == null || closingTagStart == null) {
    throw new AndroidRefactoringErrorException();
  }
  final int contentStart = startTagEnd.getTextRange().getEndOffset();
  final int contentEnd = closingTagStart.getTextRange().getStartOffset();

  if (contentStart < 0 || contentEnd < 0 || contentStart >= contentEnd) {
    throw new AndroidRefactoringErrorException();
  }
  final PsiFile file = tagToInline.getContainingFile();

  if(file == null) {
    throw new AndroidRefactoringErrorException();
  }
  final String textToInline = file.getText().
    substring(contentStart, contentEnd).trim();
  final PsiDocumentManager documentManager = PsiDocumentManager.getInstance(project);
  final Document document = documentManager.getDocument(tagToReplace.getContainingFile());

  if (document == null) {
    throw new AndroidRefactoringErrorException();
  }
  final TextRange range = tagToReplace.getTextRange();
  document.replaceString(range.getStartOffset(), range.getEndOffset(), textToInline);
  documentManager.commitDocument(document);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:37,代码来源:LayoutUsageData.java

示例6: getTagRanges

import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
@NotNull
private static Pair<TextRange, TextRange> getTagRanges(XmlTag tag) {
  final ASTNode tagNode = tag.getNode();
  return Pair.create(getStartTagRange(tagNode), getEndTagRange(tagNode));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:6,代码来源:XmlTagTreeHighlightingPass.java

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