Java 类com.intellij.psi.XmlElementVisitor 实例源码

项目:intellij-ce-playground    文件:HtmlLocalInspectionTool.java   
@Override
@NotNull
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, final boolean isOnTheFly) {
  return new XmlElementVisitor() {
    @Override public void visitXmlToken(final XmlToken token) {
      if (token.getTokenType() == XmlTokenType.XML_NAME) {
        PsiElement element = token.getPrevSibling();
        while(element instanceof PsiWhiteSpace) element = element.getPrevSibling();

        if (element instanceof XmlToken && ((XmlToken)element).getTokenType() == XmlTokenType.XML_START_TAG_START) {
          PsiElement parent = element.getParent();

          if (parent instanceof XmlTag && !(token.getNextSibling() instanceof OuterLanguageElement)) {
            XmlTag tag = (XmlTag)parent;
            checkTag(tag, holder, isOnTheFly);
          }
        }
      }
    }

    @Override public void visitXmlAttribute(final XmlAttribute attribute) {
      checkAttribute(attribute, holder, isOnTheFly);
    }
  };
}
项目:intellij-ce-playground    文件:XmlPathReferenceInspection.java   
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, final boolean isOnTheFly) {
  return new XmlElementVisitor() {
    @Override
    public void visitXmlAttributeValue(XmlAttributeValue value) {
      checkRefs(value, holder, isOnTheFly);
    }

    @Override
    public void visitXmlDoctype(XmlDoctype xmlDoctype) {
      checkRefs(xmlDoctype, holder, isOnTheFly);
    }

    @Override
    public void visitXmlTag(XmlTag tag) {
      checkRefs(tag, holder, isOnTheFly);
    }
  };
}
项目:intellij-ce-playground    文件:CheckEmptyTagInspection.java   
@Override
@NotNull
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
  return new XmlElementVisitor() {
    @Override public void visitXmlTag(final XmlTag tag) {
      if (!isTagWithEmptyEndNotAllowed(tag)) {
        return;
      }
      final ASTNode child = XmlChildRole.EMPTY_TAG_END_FINDER.findChild(tag.getNode());

      if (child == null) {
        return;
      }

      final LocalQuickFix fix = new MyLocalQuickFix();

      holder.registerProblem(tag,
                             XmlBundle.message("html.inspections.check.empty.script.message"),
                             tag.getContainingFile().getContext() != null ?
                             ProblemHighlightType.INFORMATION:
                             ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
                             fix);
    }
  };
}
项目:intellij-ce-playground    文件:CheckTagEmptyBodyInspection.java   
@Override
@NotNull
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
  return new XmlElementVisitor() {
    @Override public void visitXmlTag(final XmlTag tag) {
      if (!CheckEmptyTagInspection.isTagWithEmptyEndNotAllowed(tag)) {
        final ASTNode child = XmlChildRole.START_TAG_END_FINDER.findChild(tag.getNode());

        if (child != null) {
          final ASTNode node = child.getTreeNext();

          if (node != null &&
              node.getElementType() == XmlTokenType.XML_END_TAG_START) {
            final LocalQuickFix localQuickFix = new Fix();
            holder.registerProblem(
              tag,
              XmlBundle.message("xml.inspections.tag.empty.body"),
              isCollapsibleTag(tag) ? localQuickFix : null
            );
          }
        }
      }
    }
  };
}
项目:tools-idea    文件:HtmlLocalInspectionTool.java   
@Override
@NotNull
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, final boolean isOnTheFly) {
  return new XmlElementVisitor() {
    @Override public void visitXmlToken(final XmlToken token) {
      if (token.getTokenType() == XmlTokenType.XML_NAME) {
        PsiElement element = token.getPrevSibling();
        while(element instanceof PsiWhiteSpace) element = element.getPrevSibling();

        if (element instanceof XmlToken && ((XmlToken)element).getTokenType() == XmlTokenType.XML_START_TAG_START) {
          PsiElement parent = element.getParent();

          if (parent instanceof XmlTag && !(token.getNextSibling() instanceof OuterLanguageElement)) {
            XmlTag tag = (XmlTag)parent;
            checkTag(tag, holder, isOnTheFly);
          }
        }
      }
    }

    @Override public void visitXmlAttribute(final XmlAttribute attribute) {
      checkAttribute(attribute, holder, isOnTheFly);
    }
  };
}
项目:tools-idea    文件:XmlPathReferenceInspection.java   
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, final boolean isOnTheFly) {
  return new XmlElementVisitor() {
    @Override
    public void visitXmlAttributeValue(XmlAttributeValue value) {
      checkRefs(value, holder, isOnTheFly);
    }

    @Override
    public void visitXmlDoctype(XmlDoctype xmlDoctype) {
      checkRefs(xmlDoctype, holder, isOnTheFly);
    }

    @Override
    public void visitXmlTag(XmlTag tag) {
      checkRefs(tag, holder, isOnTheFly);
    }
  };
}
项目:tools-idea    文件:CheckEmptyTagInspection.java   
@NotNull
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
  return new XmlElementVisitor() {
    @Override public void visitXmlTag(final XmlTag tag) {
      if (!isTagWithEmptyEndNotAllowed(tag)) {
        return;
      }
      final ASTNode child = XmlChildRole.EMPTY_TAG_END_FINDER.findChild(tag.getNode());

      if (child == null) {
        return;
      }

      final LocalQuickFix fix = new MyLocalQuickFix();

      holder.registerProblem(tag,
                             XmlBundle.message("html.inspections.check.empty.script.message"),
                             tag.getContainingFile().getContext() != null ?
                             ProblemHighlightType.INFORMATION:
                             ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
                             fix);
    }
  };
}
项目:tools-idea    文件:CheckTagEmptyBodyInspection.java   
@NotNull
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
  return new XmlElementVisitor() {
    @Override public void visitXmlTag(final XmlTag tag) {
      if (!CheckEmptyTagInspection.isTagWithEmptyEndNotAllowed(tag)) {
        final ASTNode child = XmlChildRole.START_TAG_END_FINDER.findChild(tag.getNode());

        if (child != null) {
          final ASTNode node = child.getTreeNext();

          if (node != null &&
              node.getElementType() == XmlTokenType.XML_END_TAG_START) {
            final LocalQuickFix localQuickFix = new ReplaceEmptyTagBodyByEmptyEndFix();
            holder.registerProblem(
              tag,
              XmlBundle.message("xml.inspections.tag.empty.body"),
              isCollapsableTag(tag) ? localQuickFix : null
            );
          }
        }
      }
    }
  };
}
项目:consulo-xml    文件:HtmlLocalInspectionTool.java   
@Override
@NotNull
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, final boolean isOnTheFly) {
  return new XmlElementVisitor() {
    @Override public void visitXmlToken(final XmlToken token) {
      if (token.getTokenType() == XmlTokenType.XML_NAME) {
        PsiElement element = token.getPrevSibling();
        while(element instanceof PsiWhiteSpace) element = element.getPrevSibling();

        if (element instanceof XmlToken && ((XmlToken)element).getTokenType() == XmlTokenType.XML_START_TAG_START) {
          PsiElement parent = element.getParent();

          if (parent instanceof XmlTag && !(token.getNextSibling() instanceof OuterLanguageElement)) {
            XmlTag tag = (XmlTag)parent;
            checkTag(tag, holder, isOnTheFly);
          }
        }
      }
    }

    @Override public void visitXmlAttribute(final XmlAttribute attribute) {
      checkAttribute(attribute, holder, isOnTheFly);
    }
  };
}
项目:consulo-xml    文件:XmlPathReferenceInspection.java   
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, final boolean isOnTheFly) {
  return new XmlElementVisitor() {
    @Override
    public void visitXmlAttributeValue(XmlAttributeValue value) {
      checkRefs(value, holder, isOnTheFly);
    }

    @Override
    public void visitXmlDoctype(XmlDoctype xmlDoctype) {
      checkRefs(xmlDoctype, holder, isOnTheFly);
    }

    @Override
    public void visitXmlTag(XmlTag tag) {
      checkRefs(tag, holder, isOnTheFly);
    }
  };
}
项目:consulo-xml    文件:CheckEmptyTagInspection.java   
@NotNull
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
  return new XmlElementVisitor() {
    @Override public void visitXmlTag(final XmlTag tag) {
      if (!isTagWithEmptyEndNotAllowed(tag)) {
        return;
      }
      final ASTNode child = XmlChildRole.EMPTY_TAG_END_FINDER.findChild(tag.getNode());

      if (child == null) {
        return;
      }

      final LocalQuickFix fix = new MyLocalQuickFix();

      holder.registerProblem(tag,
                             XmlBundle.message("html.inspections.check.empty.script.message"),
                             tag.getContainingFile().getContext() != null ?
                             ProblemHighlightType.INFORMATION:
                             ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
                             fix);
    }
  };
}
项目:consulo-xml    文件:CheckTagEmptyBodyInspection.java   
@NotNull
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
  return new XmlElementVisitor() {
    @Override public void visitXmlTag(final XmlTag tag) {
      if (!CheckEmptyTagInspection.isTagWithEmptyEndNotAllowed(tag)) {
        final ASTNode child = XmlChildRole.START_TAG_END_FINDER.findChild(tag.getNode());

        if (child != null) {
          final ASTNode node = child.getTreeNext();

          if (node != null &&
              node.getElementType() == XmlTokenType.XML_END_TAG_START) {
            final LocalQuickFix localQuickFix = new ReplaceEmptyTagBodyByEmptyEndFix();
            holder.registerProblem(
              tag,
              XmlBundle.message("xml.inspections.tag.empty.body"),
              isCollapsableTag(tag) ? localQuickFix : null
            );
          }
        }
      }
    }
  };
}
项目:consulo-java    文件:DeprecatedClassUsageInspection.java   
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder,
                                      boolean isOnTheFly,
                                      @NotNull LocalInspectionToolSession session) {
  return new XmlElementVisitor() {
    @Override
    public void visitXmlTag(XmlTag tag) {
      if (tag.getValue().getTextElements().length > 0) {
        checkReferences(tag, holder);
      }
    }

    @Override
    public void visitXmlAttribute(XmlAttribute attribute) {
      checkReferences(attribute, holder);
    }

    @Override
    public void visitXmlAttributeValue(XmlAttributeValue value) {
      checkReferences(value, holder);
    }
  };
}
项目:intellij-ce-playground    文件:CheckDtdReferencesInspection.java   
@Override
@NotNull
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
  return new XmlElementVisitor() {
    @Override
    public void visitXmlElement(final XmlElement element) {
      if (element instanceof XmlElementContentSpec ||
          element instanceof XmlEntityRef
        ) {
        doCheckRefs(element, holder);
      }
    }
  };
}
项目:intellij-ce-playground    文件:XmlPrologImpl.java   
@Override
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof XmlElementVisitor) {
    ((XmlElementVisitor)visitor).visitXmlProlog(this);
  }
  else {
    visitor.visitElement(this);
  }
}
项目:intellij-ce-playground    文件:XmlDeclImpl.java   
@Override
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof XmlElementVisitor) {
    ((XmlElementVisitor)visitor).visitXmlDecl(this);
  }
  else {
    visitor.visitElement(this);
  }
}
项目:intellij-ce-playground    文件:XmlProcessingInstructionImpl.java   
@Override
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof XmlElementVisitor) {
    ((XmlElementVisitor)visitor).visitXmlProcessingInstruction(this);
  }
  else {
    visitor.visitElement(this);
  }
}
项目:intellij-ce-playground    文件:XmlElementContentSpecImpl.java   
@Override
public void accept(@NotNull final PsiElementVisitor visitor) {
  if (visitor instanceof XmlElementVisitor) {
    ((XmlElementVisitor)visitor).visitXmlElement(this);
  }
  else {
    visitor.visitElement(this);
  }
}
项目:intellij-ce-playground    文件:InspectionMappingConsistencyInspection.java   
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder,
                                      boolean isOnTheFly,
                                      @NotNull LocalInspectionToolSession session) {
  return new XmlElementVisitor()  {
    @Override
    public void visitXmlTag(XmlTag tag) {
      DomElement element = DomUtil.getDomElement(tag);
      if (element instanceof Extension) {
        ExtensionPoint extensionPoint = ((Extension)element).getExtensionPoint();
        if (extensionPoint != null && InheritanceUtil.isInheritor(extensionPoint.getBeanClass().getValue(), "com.intellij.codeInspection.InspectionEP")) {
          boolean key = tag.getAttribute("key") != null;
          boolean groupKey = tag.getAttribute("groupKey") != null;
          if (key) {
            if (tag.getAttribute("bundle") == null) {
              checkDefaultBundle(element, holder);
            }
          }
          else if (tag.getAttribute("displayName") == null) {
            registerProblem(element, holder, "displayName or key should be specified", "displayName", "key");
          }
          if (groupKey) {
            if (tag.getAttribute("bundle") == null && tag.getAttribute("groupBundle") == null) {
              checkDefaultBundle(element, holder);
            }
          }
          else if (tag.getAttribute("groupName") == null) {
            registerProblem(element, holder, "groupName or groupKey should be specified", "groupName", "groupKey");
          }
        }
      }
    }
  };
}
项目:wuff-intellij-plugin    文件:XmiDuplicatedIdInspection.java   
@NotNull
@Override
public PsiElementVisitor buildVisitor( @NotNull final ProblemsHolder holder, final boolean isOnTheFly )
{
    return new XmlElementVisitor()
    {
        @Override
        public void visitXmlAttributeValue( final XmlAttributeValue value )
        {
            if( value.getTextRange().isEmpty() )
            {
                return;
            }
            final PsiFile file = value.getContainingFile();
            if( !(file instanceof XmlFile) )
            {
                return;
            }
            PsiFile baseFile = PsiUtilCore.getTemplateLanguageFile( file );
            if( baseFile != file && !(baseFile instanceof XmlFile) )
            {
                return;
            }
            final XmlRefCountHolder refHolder = XmlRefCountHolder.getRefCountHolder( (XmlFile)file );
            if( refHolder == null )
                return;

            final PsiElement parent = value.getParent();
            if( !(parent instanceof XmlAttribute) )
                return;

            final XmlTag tag = (XmlTag)parent.getParent();
            if( tag == null )
                return;

            checkValue( value, (XmlFile)file, refHolder, tag, holder );
        }
    };
}
项目:tools-idea    文件:XmlPrologImpl.java   
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof XmlElementVisitor) {
    ((XmlElementVisitor)visitor).visitXmlProlog(this);
  }
  else {
    visitor.visitElement(this);
  }
}
项目:tools-idea    文件:XmlDeclImpl.java   
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof XmlElementVisitor) {
    ((XmlElementVisitor)visitor).visitXmlDecl(this);
  }
  else {
    visitor.visitElement(this);
  }
}
项目:tools-idea    文件:XmlProcessingInstructionImpl.java   
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof XmlElementVisitor) {
    ((XmlElementVisitor)visitor).visitXmlProcessingInstruction(this);
  }
  else {
    visitor.visitElement(this);
  }
}
项目:tools-idea    文件:XmlElementContentSpecImpl.java   
public void accept(@NotNull final PsiElementVisitor visitor) {
  if (visitor instanceof XmlElementVisitor) {
    ((XmlElementVisitor)visitor).visitXmlElement(this);
  }
  else {
    visitor.visitElement(this);
  }
}
项目:tools-idea    文件:InspectionMappingConsistencyInspection.java   
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder,
                                      boolean isOnTheFly,
                                      @NotNull LocalInspectionToolSession session) {
  return new XmlElementVisitor()  {
    @Override
    public void visitXmlTag(XmlTag tag) {
      DomElement element = DomUtil.getDomElement(tag);
      if (element instanceof Extension) {
        ExtensionPoint extensionPoint = ((Extension)element).getExtensionPoint();
        if (extensionPoint != null && InheritanceUtil.isInheritor(extensionPoint.getBeanClass().getValue(), "com.intellij.codeInspection.InspectionEP")) {
          boolean key = tag.getAttribute("key") != null;
          boolean groupKey = tag.getAttribute("groupKey") != null;
          if (key) {
            if (tag.getAttribute("bundle") == null) {
              checkDefaultBundle(element, holder);
            }
          }
          else if (tag.getAttribute("displayName") == null) {
            registerProblem(element, holder, "displayName or key should be specified", "displayName", "key");
          }
          if (groupKey) {
            if (tag.getAttribute("bundle") == null && tag.getAttribute("groupBundle") == null) {
              checkDefaultBundle(element, holder);
            }
          }
          else if (tag.getAttribute("groupName") == null) {
            registerProblem(element, holder, "groupName or groupKey should be specified", "groupName", "groupKey");
          }
        }
      }
    }
  };
}
项目:consulo-xml    文件:XmlPrologImpl.java   
@Override
public void accept(@NotNull PsiElementVisitor visitor)
{
    if(visitor instanceof XmlElementVisitor)
    {
        ((XmlElementVisitor) visitor).visitXmlProlog(this);
    }
    else
    {
        visitor.visitElement(this);
    }
}
项目:consulo-xml    文件:XmlDeclImpl.java   
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof XmlElementVisitor) {
    ((XmlElementVisitor)visitor).visitXmlDecl(this);
  }
  else {
    visitor.visitElement(this);
  }
}
项目:consulo-xml    文件:XmlProcessingInstructionImpl.java   
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof XmlElementVisitor) {
    ((XmlElementVisitor)visitor).visitXmlProcessingInstruction(this);
  }
  else {
    visitor.visitElement(this);
  }
}
项目:consulo-xml    文件:XmlElementContentSpecImpl.java   
public void accept(@NotNull final PsiElementVisitor visitor) {
  if (visitor instanceof XmlElementVisitor) {
    ((XmlElementVisitor)visitor).visitXmlElement(this);
  }
  else {
    visitor.visitElement(this);
  }
}
项目:consulo-xml    文件:XmlAttributeImpl.java   
@Override
public void accept(@NotNull PsiElementVisitor visitor)
{
    if(visitor instanceof XmlElementVisitor)
    {
        ((XmlElementVisitor) visitor).visitXmlAttribute(this);
    }
    else
    {
        visitor.visitElement(this);
    }
}
项目:consulo-xml    文件:XmlAttributeValueImpl.java   
@Override
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof XmlElementVisitor) {
    ((XmlElementVisitor)visitor).visitXmlAttributeValue(this);
  }
  else {
    visitor.visitElement(this);
  }
}
项目:consulo-xml    文件:XmlTextImpl.java   
@Override
public void accept(@NotNull PsiElementVisitor visitor)
{
    if(visitor instanceof XmlElementVisitor)
    {
        ((XmlElementVisitor) visitor).visitXmlText(this);
    }
    else
    {
        visitor.visitElement(this);
    }
}
项目:consulo-xml    文件:XmlEntityRefImpl.java   
@Override
public void accept(@NotNull PsiElementVisitor visitor)
{
    if(visitor instanceof XmlElementVisitor)
    {
        ((XmlElementVisitor) visitor).visitXmlElement(this);
    }
    else
    {
        visitor.visitElement(this);
    }
}
项目:consulo-xml    文件:XmlFileImpl.java   
@Override
public void accept(@NotNull PsiElementVisitor visitor)
{
    if(visitor instanceof XmlElementVisitor)
    {
        ((XmlElementVisitor) visitor).visitXmlFile(this);
    }
    else
    {
        visitor.visitFile(this);
    }
}
项目:consulo-xml    文件:XmlDocumentImpl.java   
@Override
public void accept(@NotNull PsiElementVisitor visitor)
{
    if(visitor instanceof XmlElementVisitor)
    {
        ((XmlElementVisitor) visitor).visitXmlDocument(this);
    }
    else
    {
        visitor.visitElement(this);
    }
}
项目:consulo-xml    文件:XmlDoctypeImpl.java   
@Override
public void accept(@NotNull PsiElementVisitor visitor)
{
    if(visitor instanceof XmlElementVisitor)
    {
        ((XmlElementVisitor) visitor).visitXmlDoctype(this);
    }
    else
    {
        visitor.visitElement(this);
    }
}