Java 类com.intellij.psi.xml.XmlTagChild 实例源码

项目:intellij-ce-playground    文件:XmlSurroundDescriptor.java   
@Override
@NotNull public PsiElement[] getElementsToSurround(PsiFile file, int startOffset, int endOffset) {
  final Pair<XmlTagChild, XmlTagChild> childrenInRange = XmlUtil.findTagChildrenInRange(file, startOffset, endOffset);
  if (childrenInRange == null) {
    final PsiElement elementAt = file.findElementAt(startOffset);
    if (elementAt instanceof XmlToken &&
        ((XmlToken)elementAt).getTokenType() == XmlTokenType.XML_DATA_CHARACTERS) {
      return new PsiElement[] {elementAt};
    }
    return PsiElement.EMPTY_ARRAY;
  }
  List<PsiElement> result = new ArrayList<PsiElement>();
  PsiElement first = childrenInRange.getFirst();
  PsiElement last = childrenInRange.getSecond();
  while(true) {
    result.add(first);
    if (first == last) break;
    first = first.getNextSibling();
  }

  return PsiUtilCore.toPsiElementArray(result);
}
项目:intellij-ce-playground    文件:MavenPropertyPsiReference.java   
@Nullable
public PsiElement resolve() {
  PsiElement result = doResolve();
  if (result == null) {
    if (MavenDomUtil.isMavenFile(getElement())) {
      result = tryResolveToActivationSection();
      if (result == null) return null;
    }
  }

  if (result instanceof XmlTag) {
    XmlTagChild[] children = ((XmlTag)result).getValue().getChildren();
    if (children.length != 1 || !(children[0] instanceof Navigatable)) return result;
    return new MavenPsiElementWrapper(result, (Navigatable)children[0]);
  }

  return result;
}
项目:intellij-ce-playground    文件:UnwrapTagFix.java   
@Override
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
  final PsiElement element = descriptor.getPsiElement();
  if (element != null) {
    final PsiFile containingFile = element.getContainingFile();
    LOG.assertTrue(containingFile != null && JavaFxFileTypeFactory.isFxml(containingFile), containingFile == null ? "no containing file found" : "containing file: " + containingFile.getName());
    final XmlTag xmlTag = PsiTreeUtil.getParentOfType(element, XmlTag.class);
    if (xmlTag != null) {
      final XmlTag parentTag = xmlTag.getParentTag();
      final PsiElement[] children = PsiTreeUtil.getChildrenOfType(xmlTag, XmlTagChild.class);
      if (children != null) {
        if (!FileModificationService.getInstance().preparePsiElementsForWrite(element)) return;
        if (children.length > 0) {
          parentTag.addRange(children[0], children[children.length - 1]);
        }
        xmlTag.delete();
        CodeStyleManager.getInstance(project).reformat(parentTag);
      }
    }
  }
}
项目:tools-idea    文件:XmlSurroundDescriptor.java   
@NotNull public PsiElement[] getElementsToSurround(PsiFile file, int startOffset, int endOffset) {
  final Pair<XmlTagChild, XmlTagChild> childrenInRange = XmlUtil.findTagChildrenInRange(file, startOffset, endOffset);
  if (childrenInRange == null) {
    final PsiElement elementAt = file.findElementAt(startOffset);
    if (elementAt instanceof XmlToken &&
        ((XmlToken)elementAt).getTokenType() == XmlTokenType.XML_DATA_CHARACTERS) {
      return new PsiElement[] {elementAt};
    }
    return PsiElement.EMPTY_ARRAY;
  }
  List<PsiElement> result = new ArrayList<PsiElement>();
  PsiElement first = childrenInRange.getFirst();
  PsiElement last = childrenInRange.getSecond();
  while(true) {
    result.add(first);
    if (first == last) break;
    first = first.getNextSibling();
  }

  return PsiUtilCore.toPsiElementArray(result);
}
项目:tools-idea    文件:MavenPropertyPsiReference.java   
@Nullable
public PsiElement resolve() {
  PsiElement result = doResolve();
  if (result == null) {
    if (MavenDomUtil.isMavenFile(getElement())) {
      result = tryResolveToActivationSection();
      if (result == null) return null;
    }
  }

  if (result instanceof XmlTag) {
    XmlTagChild[] children = ((XmlTag)result).getValue().getChildren();
    if (children.length != 1 || !(children[0] instanceof Navigatable)) return result;
    return new MavenPsiElementWrapper(result, (Navigatable)children[0]);
  }

  return result;
}
项目:tools-idea    文件:UnwrapTagFix.java   
@Override
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
  final PsiElement element = descriptor.getPsiElement();
  if (element != null) {
    final PsiFile containingFile = element.getContainingFile();
    LOG.assertTrue(containingFile != null && JavaFxFileTypeFactory.isFxml(containingFile), containingFile == null ? "no containing file found" : "containing file: " + containingFile.getName());
    final XmlTag xmlTag = PsiTreeUtil.getParentOfType(element, XmlTag.class);
    if (xmlTag != null) {
      final XmlTag parentTag = xmlTag.getParentTag();
      final PsiElement[] children = PsiTreeUtil.getChildrenOfType(xmlTag, XmlTagChild.class);
      if (children != null) {
        if (!FileModificationService.getInstance().preparePsiElementsForWrite(element)) return;
        if (children.length > 0) {
          parentTag.addRange(children[0], children[children.length - 1]);
        }
        xmlTag.delete();
        CodeStyleManager.getInstance(project).reformat(parentTag);
      }
    }
  }
}
项目:consulo-javafx    文件:UnwrapTagFix.java   
@Override
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
  final PsiElement element = descriptor.getPsiElement();
  if (element != null) {
    final PsiFile containingFile = element.getContainingFile();
    LOG.assertTrue(containingFile != null && JavaFxFileTypeFactory.isFxml(containingFile), containingFile == null ? "no containing file found" : "containing file: " + containingFile.getName());
    final XmlTag xmlTag = PsiTreeUtil.getParentOfType(element, XmlTag.class);
    if (xmlTag != null) {
      final XmlTag parentTag = xmlTag.getParentTag();
      final PsiElement[] children = PsiTreeUtil.getChildrenOfType(xmlTag, XmlTagChild.class);
      if (children != null) {
        if (!FileModificationService.getInstance().preparePsiElementsForWrite(element)) return;
        if (children.length > 0) {
          parentTag.addRange(children[0], children[children.length - 1]);
        }
        xmlTag.delete();
        CodeStyleManager.getInstance(project).reformat(parentTag);
      }
    }
  }
}
项目:consulo-xml    文件:XmlTagValueImpl.java   
@Override
@NotNull
public XmlText[] getTextElements()
{
    XmlText[] textElements = myTextElements;
    if(textElements != null)
    {
        return textElements;
    }
    final List<XmlText> textElementsList = new ArrayList<XmlText>();
    for(final XmlTagChild element : myElements)
    {
        if(element instanceof XmlText)
        {
            textElementsList.add((XmlText) element);
        }
    }
    return myTextElements = textElementsList.isEmpty() ? XmlText.EMPTY_ARRAY : ContainerUtil.toArray(textElementsList, new XmlText[textElementsList.size()]);
}
项目:consulo-xml    文件:XmlTagValueImpl.java   
@Override
@NotNull
public String getText()
{
    String text = myText;
    if(text != null)
    {
        return text;
    }
    final StringBuilder consolidatedText = new StringBuilder();
    for(final XmlTagChild element : myElements)
    {
        consolidatedText.append(element.getText());
    }
    return myText = consolidatedText.toString();
}
项目:consulo-xml    文件:XmlSurroundDescriptor.java   
@NotNull public PsiElement[] getElementsToSurround(PsiFile file, int startOffset, int endOffset) {
  final Pair<XmlTagChild, XmlTagChild> childrenInRange = XmlUtil.findTagChildrenInRange(file, startOffset, endOffset);
  if (childrenInRange == null) {
    final PsiElement elementAt = file.findElementAt(startOffset);
    if (elementAt instanceof XmlToken &&
        ((XmlToken)elementAt).getTokenType() == XmlTokenType.XML_DATA_CHARACTERS) {
      return new PsiElement[] {elementAt};
    }
    return PsiElement.EMPTY_ARRAY;
  }
  List<PsiElement> result = new ArrayList<PsiElement>();
  PsiElement first = childrenInRange.getFirst();
  PsiElement last = childrenInRange.getSecond();
  while(true) {
    result.add(first);
    if (first == last) break;
    first = first.getNextSibling();
  }

  return PsiUtilBase.toPsiElementArray(result);
}
项目:consulo-javascript    文件:JSAnnotatingVisitor.java   
private void checkClassReferenceInStaticContext(final JSExpression node, @PropertyKey(resourceBundle = JavaScriptBundle.BUNDLE) String key)
{
    PsiElement element = PsiTreeUtil.getParentOfType(node, JSFunction.class, JSFile.class, JSClass.class, JSObjectLiteralExpression.class,
            XmlTagChild.class);

    if(element instanceof JSFunction)
    {
        final JSFunction function = (JSFunction) element;

        final JSAttributeList attributeList = function.getAttributeList();
        if(attributeList != null && attributeList.hasModifier(JSAttributeList.ModifierType.STATIC))
        {
            myHolder.createErrorAnnotation(node, JavaScriptBundle.message(key));
            return;
        }
    }

    PsiElement elementParent;
    if(node instanceof JSSuperExpression && (element == null || (!((elementParent = element.getParent()) instanceof JSClass) && (!(elementParent
            instanceof JSFile) || elementParent.getContext() == null))))
    {
        myHolder.createErrorAnnotation(node, JavaScriptBundle.message("javascript.validation.message.super.referenced.without.class.instance.context"));
    }
}
项目:consulo-javascript    文件:JSAnnotatingVisitor.java   
@Override
public void visitJSReturnStatement(final JSReturnStatement node)
{
    final PsiElement element = PsiTreeUtil.getParentOfType(node, JSFunction.class, XmlTagChild.class, XmlAttributeValue.class, JSFile.class);
    if((element instanceof JSFile && !(element.getContext() instanceof PsiLanguageInjectionHost)) || (element instanceof XmlTagChild && !(element
            .getParent() instanceof XmlAttributeValue)))
    {
        myHolder.createErrorAnnotation(node, JavaScriptBundle.message("javascript.validation.message.return.outside.function.definition"));
    }

    if(element instanceof JSFunction)
    {
        final @NonNls String typeString = ((JSFunction) element).getReturnTypeString();
        if(typeString != null && !"void".equals(typeString) && node.getExpression() == null)
        {
            myHolder.createErrorAnnotation(node, JavaScriptBundle.message("javascript.validation.message.return.value.of.type.is.required", typeString));
        }
    }
}
项目:consulo-javascript    文件:UnterminatedStatementJSInspection.java   
private static boolean isTerminated(JSStatement statement)
{
    final PsiElement parent = statement.getParent();
    if(parent instanceof JSForInStatement || parent instanceof JSForStatement)
    {
        return true;
    }
    final String text = statement.getText();
    if(text == null)
    {
        return true;
    }

    boolean terminated = text.endsWith(";");
    if(!terminated)
    {
        PsiElement container = PsiTreeUtil.getNonStrictParentOfType(parent, JSFile.class, XmlAttributeValue.class, XmlTagChild.class);
        if(container instanceof JSFile)
        {
            container = container.getContext();
        }
        terminated = container instanceof XmlAttributeValue; // some inline javascript
    }
    return terminated;
}
项目:intellij-ce-playground    文件:XmlTagChildChangedImpl.java   
public static PomModelEvent createXmlTagChildChanged(PomModel source, XmlTag context, XmlTagChild treeElement) {
  final PomModelEvent event = new PomModelEvent(source);
  final XmlAspectChangeSetImpl xmlAspectChangeSet = new XmlAspectChangeSetImpl(source, PsiTreeUtil.getParentOfType(context, XmlFile.class));
  xmlAspectChangeSet.add(new XmlTagChildChangedImpl(context, treeElement));
  event.registerChangeSet(source.getModelAspect(XmlAspect.class), xmlAspectChangeSet);
  return event;
}
项目:tools-idea    文件:XmlTagChildChangedImpl.java   
public static PomModelEvent createXmlTagChildChanged(PomModel source, XmlTag context, XmlTagChild treeElement) {
  final PomModelEvent event = new PomModelEvent(source);
  final XmlAspectChangeSetImpl xmlAspectChangeSet = new XmlAspectChangeSetImpl(source, PsiTreeUtil.getParentOfType(context, XmlFile.class));
  xmlAspectChangeSet.add(new XmlTagChildChangedImpl(context, treeElement));
  event.registerChangeSet(source.getModelAspect(XmlAspect.class), xmlAspectChangeSet);
  return event;
}
项目:consulo-xml    文件:XmlTagChildChangedImpl.java   
public static PomModelEvent createXmlTagChildChanged(PomModel source, XmlTag context, XmlTagChild treeElement) {
  final PomModelEvent event = new PomModelEvent(source);
  final XmlAspectChangeSetImpl xmlAspectChangeSet = new XmlAspectChangeSetImpl(source, PsiTreeUtil.getParentOfType(context, XmlFile.class));
  xmlAspectChangeSet.add(new XmlTagChildChangedImpl(context, treeElement));
  event.registerChangeSet(source.getModelAspect(XmlAspect.class), xmlAspectChangeSet);
  return event;
}
项目:consulo-xml    文件:XmlTagValueImpl.java   
public static XmlTagValue createXmlTagValue(XmlTag tag)
{
    final List<XmlTagChild> bodyElements = new ArrayList<XmlTagChild>();

    tag.processElements(new PsiElementProcessor()
    {
        boolean insideBody = false;

        @Override
        public boolean execute(@NotNull PsiElement element)
        {
            final ASTNode treeElement = element.getNode();
            if(insideBody)
            {
                if(treeElement != null && treeElement.getElementType() == XmlTokenType.XML_END_TAG_START)
                {
                    return false;
                }
                if(!(element instanceof XmlTagChild))
                {
                    return true;
                }
                bodyElements.add((XmlTagChild) element);
            }
            else if(treeElement != null && treeElement.getElementType() == XmlTokenType.XML_TAG_END)
            {
                insideBody = true;
            }
            return true;
        }
    }, tag);

    XmlTagChild[] tagChildren = ContainerUtil.toArray(bodyElements, new XmlTagChild[bodyElements.size()]);
    return new XmlTagValueImpl(tagChildren, tag);
}
项目:consulo-xml    文件:XmlTextImpl.java   
@Override
public XmlTagChild getNextSiblingInTag()
{
    PsiElement nextSibling = getNextSibling();
    if(nextSibling instanceof XmlTagChild)
    {
        return (XmlTagChild) nextSibling;
    }
    return null;
}
项目:consulo-xml    文件:XmlTextImpl.java   
@Override
public XmlTagChild getPrevSiblingInTag()
{
    PsiElement prevSibling = getPrevSibling();
    if(prevSibling instanceof XmlTagChild)
    {
        return (XmlTagChild) prevSibling;
    }
    return null;
}
项目:consulo-javascript    文件:JSLanguageInjector.java   
private boolean doInjectTo(final XmlTag tag)
{
    final XmlTagValue value = tag.getValue();
    final XmlTagChild[] tagChildren = value.getChildren();

    return tagChildren.length == 1 && (tagChildren[0].getNode().getElementType() == XmlElementType.XML_CDATA || !tagChildren[0].textContains('<'));
}
项目:consulo-javascript    文件:JSResolveUtil.java   
public static void processInjectedFileForTag(final @NotNull XmlTag tag, @NotNull JSInjectedFilesVisitor visitor)
{

    for(XmlTagChild child : tag.getValue().getChildren())
    {
        if(child instanceof XmlText)
        {
            InjectedLanguageUtil.enumerate(child, visitor);
        }
    }
}
项目:consulo-javascript    文件:JSEmbeddedContentImpl.java   
@Override
public XmlTagChild getNextSiblingInTag()
{
    PsiElement nextSibling = getNextSibling();
    if(nextSibling instanceof XmlTagChild)
    {
        return (XmlTagChild) nextSibling;
    }
    return null;
}
项目:consulo-javascript    文件:JSEmbeddedContentImpl.java   
@Override
public XmlTagChild getPrevSiblingInTag()
{
    final PsiElement prevSibling = getPrevSibling();
    if(prevSibling instanceof XmlTagChild)
    {
        return (XmlTagChild) prevSibling;
    }
    return null;
}
项目:consulo-javascript    文件:JSReferenceSet.java   
private PsiElement findNearestClass()
{
    PsiElement elt = element;
    PsiElement parent;
    while(!((parent = elt.getParent()) instanceof JSFile) && !(parent instanceof JSPackageStatement))
    {
        if(parent instanceof XmlTagChild)
        {
            break;
        }
        elt = parent;
        if(elt == null || elt instanceof JSClass)
        {
            break;
        }
    }

    if(parent instanceof XmlTag && XmlBackedJSClassImpl.isInlineComponentTag((XmlTag) parent))
    {
        elt = XmlBackedJSClassImpl.getXmlBackedClass((XmlTag) parent);
    }

    if(elt != null && !(elt instanceof JSClass))
    {
        elt = elt.getNextSibling();
        if(elt instanceof PsiWhiteSpace)
        {
            elt = elt.getNextSibling();
        }
    }
    return elt;
}
项目:magento2-phpstorm-plugin    文件:LineMarkerXmlTagDecorator.java   
@Override
@Nullable
public XmlTagChild getNextSiblingInTag() {
    return xmlTag.getNextSiblingInTag();
}
项目:magento2-phpstorm-plugin    文件:LineMarkerXmlTagDecorator.java   
@Override
@Nullable
public XmlTagChild getPrevSiblingInTag() {
    return xmlTag.getPrevSiblingInTag();
}
项目:intellij-ce-playground    文件:XmlTagChildChangedImpl.java   
public XmlTagChildChangedImpl(XmlTag context, XmlTagChild treeElement) {
  myTag = context;
  myChild = treeElement;
}
项目:intellij-ce-playground    文件:XmlTagChildChangedImpl.java   
@Override
public XmlTagChild getChild() {
  return myChild;
}
项目:intellij-ce-playground    文件:XmlTagChildAddImpl.java   
public XmlTagChildAddImpl(XmlTag context, XmlTagChild treeElement) {
  myTag = context;
  myChild = treeElement;
}
项目:intellij-ce-playground    文件:XmlTagChildAddImpl.java   
@Override
public XmlTagChild getChild() {
  return myChild;
}
项目:intellij-ce-playground    文件:XmlTagChildRemovedImpl.java   
public XmlTagChildRemovedImpl(XmlTag context, XmlTagChild treeElement) {
  myTag = context;
  myChild = treeElement;
}
项目:intellij-ce-playground    文件:XmlTagChildRemovedImpl.java   
@Override
public XmlTagChild getChild() {
  return myChild;
}
项目:intellij-ce-playground    文件:IncludedXmlText.java   
@Override
public XmlTagChild getNextSiblingInTag() {
  return null;
}
项目:intellij-ce-playground    文件:IncludedXmlText.java   
@Override
public XmlTagChild getPrevSiblingInTag() {
  return null;
}
项目:intellij-ce-playground    文件:IncludedXmlTag.java   
@Override
public XmlTagChild getNextSiblingInTag() {
  return null;
}
项目:intellij-ce-playground    文件:IncludedXmlTag.java   
@Override
public XmlTagChild getPrevSiblingInTag() {
  return null;
}
项目:intellij-ce-playground    文件:HtmlEmbeddedContentImpl.java   
@Override
public XmlTagChild getNextSiblingInTag() {
  PsiElement nextSibling = getNextSibling();
  if (nextSibling instanceof XmlTagChild) return (XmlTagChild)nextSibling;
  return null;
}
项目:intellij-ce-playground    文件:HtmlEmbeddedContentImpl.java   
@Override
public XmlTagChild getPrevSiblingInTag() {
  final PsiElement prevSibling = getPrevSibling();
  if (prevSibling instanceof XmlTagChild) return (XmlTagChild)prevSibling;
  return null;
}
项目:intellij-ce-playground    文件:XPathEmbeddedContentImpl.java   
public XmlTagChild getNextSiblingInTag() {
    PsiElement nextSibling = getNextSibling();
    if(nextSibling instanceof XmlTagChild) return (XmlTagChild)nextSibling;
    return null;
}
项目:intellij-ce-playground    文件:XPathEmbeddedContentImpl.java   
public XmlTagChild getPrevSiblingInTag() {
    final PsiElement prevSibling = getPrevSibling();
    if(prevSibling instanceof XmlTagChild) return (XmlTagChild)prevSibling;
    return null;
}