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

项目:intellij-ce-playground    文件:LightAdvHighlightingTest.java   
@Override
public void annotate(@NotNull PsiElement psiElement, @NotNull final AnnotationHolder holder) {
  psiElement.accept(new XmlElementVisitor() {
    @Override public void visitXmlTag(XmlTag tag) {
      XmlAttribute attribute = tag.getAttribute("aaa", "");
      if (attribute != null) {
        holder.createWarningAnnotation(attribute, "AAATTR");
      }
    }

    @Override public void visitXmlToken(XmlToken token) {
      if (token.getTokenType() == XmlTokenType.XML_ENTITY_REF_TOKEN) {
        holder.createWarningAnnotation(token, "ENTITY");
      }
    }
  });
}
项目: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    文件:XmlWrongClosingTagNameInspection.java   
@Nullable
static XmlToken findEndTagName(@Nullable final PsiErrorElement element) {
  if (element == null) return null;

  final ASTNode astNode = element.getNode();
  if (astNode == null) return null;

  ASTNode current = astNode.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;
}
项目:intellij-ce-playground    文件:HtmlClosingTagErrorFilter.java   
@Override
public boolean shouldHighlightErrorElement(@NotNull final PsiErrorElement element) {
  final PsiFile psiFile = element.getContainingFile();
  if (psiFile == null || psiFile.getViewProvider().getBaseLanguage() != HTMLLanguage.INSTANCE
                          && HTMLLanguage.INSTANCE != element.getLanguage()) return true;

  final PsiElement[] children = element.getChildren();
  if (children.length > 0) {
    if (children[0] instanceof XmlToken && XmlTokenType.XML_END_TAG_START == ((XmlToken)children[0]).getTokenType()) {
      if (XmlErrorMessages.message("xml.parsing.closing.tag.matches.nothing").equals(element.getErrorDescription())) {
        return false;
      }
    }
  }

  return true;
}
项目: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
            );
          }
        }
      }
    }
  };
}
项目:intellij-ce-playground    文件:XmlTagUtil.java   
private static TextRange getTag(XmlToken tagName, IElementType tagStart) {
  if (tagName != null) {
    PsiElement s = tagName.getPrevSibling();

    while (s != null && s.getNode().getElementType() != tagStart) {
      s = s.getPrevSibling();
    }

    PsiElement f = tagName.getNextSibling();

    while (f != null &&
           !(f.getNode().getElementType() == XmlTokenType.XML_TAG_END ||
             f.getNode().getElementType() == XmlTokenType.XML_EMPTY_ELEMENT_END)) {
      f = f.getNextSibling();
    }
    if (s != null && f != null) {
      return new TextRange(s.getTextRange().getStartOffset(), f.getTextRange().getEndOffset());
    }
  }
  return null;
}
项目:intellij-ce-playground    文件:XMLParserDefinition.java   
public static SpaceRequirements canStickTokensTogetherByLexerInXml(final ASTNode left,
                                                                                    final ASTNode right,
                                                                                    final Lexer lexer,
                                                                                    int state) {
  if (left.getElementType() == XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN ||
      right.getElementType() == XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN) {
    return SpaceRequirements.MUST_NOT;
  }
  if (left.getElementType() == XmlTokenType.XML_ATTRIBUTE_VALUE_END_DELIMITER && right.getElementType() == XmlTokenType.XML_NAME) {
    return SpaceRequirements.MUST;
  }
  if (left.getElementType() == XmlTokenType.XML_NAME && right.getElementType() == XmlTokenType.XML_NAME) {
    return SpaceRequirements.MUST;
  }
  return SpaceRequirements.MAY;
}
项目:intellij-ce-playground    文件:HtmlParsing.java   
private void parseHeader(String tagName) {
  boolean freeMakerTag = !tagName.isEmpty() && '#' == tagName.charAt(0);

  do {
    final IElementType tt = token();
    if (freeMakerTag) {
      if (tt == XmlTokenType.XML_EMPTY_ELEMENT_END ||
          tt == XmlTokenType.XML_TAG_END ||
          tt == XmlTokenType.XML_END_TAG_START ||
          tt == XmlTokenType.XML_START_TAG_START) break;
      advance();
    }
    else {
      if (tt == XmlTokenType.XML_NAME) {
        parseAttribute();
      }
      else if (tt == XmlTokenType.XML_CHAR_ENTITY_REF || tt == XmlTokenType.XML_ENTITY_REF_TOKEN) {
        parseReference();
      }
      else {
        break;
      }
    }
  }
  while (!eof());
}
项目:intellij-ce-playground    文件:XmlTokenImpl.java   
@Override
@NotNull
public PsiReference[] getReferences() {
  final IElementType elementType = getElementType();

  if (elementType == XmlTokenType.XML_DATA_CHARACTERS ||
      elementType == XmlTokenType.XML_CHAR_ENTITY_REF) {
    return ReferenceProvidersRegistry.getReferencesFromProviders(this);
  } else if (elementType == XmlTokenType.XML_NAME && getParent() instanceof PsiErrorElement) {
    final PsiElement element = getPrevSibling();

    if (element instanceof XmlToken && ((XmlToken)element).getTokenType() == XmlTokenType.XML_END_TAG_START) {
      return new PsiReference[] {TagNameReference.createTagNameReference(this, getNode(), false)};
    }
  }

  return super.getReferences();
}
项目:intellij-ce-playground    文件:XmlParser.java   
@Override
public ThreeState fun(ASTNode oldNode,
                      LighterASTNode newNode,
                      FlyweightCapableTreeStructure<LighterASTNode> structure) {
  if (oldNode instanceof XmlTag && newNode.getTokenType() == XmlElementType.XML_TAG) {
    String oldName = ((XmlTag)oldNode).getName();
    Ref<LighterASTNode[]> childrenRef = Ref.create(null);
    int count = structure.getChildren(newNode, childrenRef);
    if (count < 3) return ThreeState.UNSURE;
    LighterASTNode[] children = childrenRef.get();
    if (children[0].getTokenType() != XmlTokenType.XML_START_TAG_START) return ThreeState.UNSURE;
    if (children[1].getTokenType() != XmlTokenType.XML_NAME) return ThreeState.UNSURE;
    if (children[2].getTokenType() != XmlTokenType.XML_TAG_END) return ThreeState.UNSURE;
    LighterASTTokenNode name = (LighterASTTokenNode)children[1];
    CharSequence newName = name.getText();
    if (!Comparing.equal(oldName, newName)) return ThreeState.NO;
  }

  return ThreeState.UNSURE;
}
项目:intellij-ce-playground    文件:HtmlConditionalCommentInjector.java   
/**
 * Tries to parse given element as <a href="http://msdn.microsoft.com/en-us/library/ms537512(v=vs.85).aspx">conditional comment</a>.
 * 
 * @param host  target element to parse
 * @return      <code>null</code> if given element is not a conditional comment;
 *              pair like <code>(conditional comment start element; conditional comment end element)</code> otherwise
 */
@Nullable
private static Pair<ASTNode, ASTNode> parseConditionalCommentBoundaries(@NotNull PsiElement host) {
  if (!(host instanceof XmlComment)) {
    return null;
  }
  final ASTNode comment = host.getNode();
  if (comment == null) {
    return null;
  }
  final ASTNode conditionalStart = comment.findChildByType(TokenSet.create(XmlTokenType.XML_CONDITIONAL_COMMENT_START_END));
  if (conditionalStart == null) {
    return null;
  }
  final ASTNode conditionalEnd = comment.findChildByType(TokenSet.create(XmlTokenType.XML_CONDITIONAL_COMMENT_END_START));
  if (conditionalEnd == null) {
    return null;
  }
  final ASTNode endOfEnd = comment.findChildByType(TokenSet.create(XmlTokenType.XML_CONDITIONAL_COMMENT_END));
  return endOfEnd == null ? null : Pair.create(conditionalStart, conditionalEnd);
}
项目:intellij-ce-playground    文件:XmlHighlightingLexer.java   
@Override
public IElementType getTokenType() {
  IElementType tokenType = getDelegate().getTokenType();

  if (tokenType == null) return tokenType;

  int state = getState() & 0xF;

  tokenType = fixWrongTokenTypes(tokenType, state);
  if (tokenType != XmlTokenType.XML_COMMENT_CHARACTERS &&
    tokenType != XmlTokenType.XML_COMMENT_END &&
    tokenType != XmlTokenType.XML_COMMENT_START &&
    tokenType != XmlTokenType.XML_ATTRIBUTE_VALUE_START_DELIMITER) {

    // TODO: do not know when this happens!
    switch (state) {
      case __XmlLexer.DOCTYPE:
        tokenType = XmlTokenType.XML_DECL_START;
        break;
    }
  }

  return tokenType;
}
项目:intellij-ce-playground    文件:ImportReferenceProvider.java   
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) {
  if (element instanceof XmlProcessingInstruction) {
    final ASTNode importNode = element.getNode().findChildByType(XmlTokenType.XML_TAG_CHARACTERS);
    if (importNode != null) {
      final PsiElement importInstr = importNode.getPsi();
      final String instructionTarget = JavaFxPsiUtil.getInstructionTarget("import", (XmlProcessingInstruction)element);
      if (instructionTarget != null && instructionTarget.equals(importInstr.getText())) {
        final PsiReference[] references =
          FxmlReferencesContributor.CLASS_REFERENCE_PROVIDER.getReferencesByString(instructionTarget, element, importInstr.getStartOffsetInParent());
        if (instructionTarget.endsWith(".*")) {
          return ArrayUtil.remove(references, references.length - 1);
        }
        else {
          return references;
        }
      }
    }
  }
  return PsiReference.EMPTY_ARRAY;
}
项目:intellij-ce-playground    文件:TagDeclarationRangeHandler.java   
@Override
@NotNull
public TextRange getDeclarationRange(@NotNull final PsiElement container) {
  XmlTag xmlTag = (XmlTag)container;
  int endOffset = xmlTag.getTextRange().getStartOffset();

  for (PsiElement child = xmlTag.getFirstChild(); child != null; child = child.getNextSibling()) {
    endOffset = child.getTextRange().getEndOffset();
    if (child instanceof XmlToken) {
      XmlToken token = (XmlToken)child;
      IElementType tokenType = token.getTokenType();
      if (tokenType == XmlTokenType.XML_EMPTY_ELEMENT_END || tokenType == XmlTokenType.XML_TAG_END) break;
    }
  }

  return new TextRange(xmlTag.getTextRange().getStartOffset(), endOffset);
}
项目:intellij-ce-playground    文件:HtmlTextCompletionConfidence.java   
@NotNull
@Override
public ThreeState shouldSkipAutopopup(@NotNull PsiElement contextElement, @NotNull PsiFile psiFile, int offset) {
  ASTNode node = contextElement.getNode();
  if (node != null && node.getElementType() == XmlTokenType.XML_DATA_CHARACTERS) {
    PsiElement parent = contextElement.getParent();
    if (parent instanceof XmlText || parent instanceof XmlDocument) {
      String contextElementText = contextElement.getText();
      int endOffset = offset - contextElement.getTextRange().getStartOffset();
      String prefix = contextElementText.substring(0, Math.min(contextElementText.length(), endOffset));
      if (!StringUtil.startsWithChar(prefix, '<') && !StringUtil.startsWithChar(prefix, '&')) {
        return ThreeState.YES;
      }
    }
  }
  return ThreeState.UNSURE;
}
项目:intellij-ce-playground    文件:HtmlCompletionData.java   
@Override
public String findPrefix(PsiElement insertedElement, int offset) {
  String prefix = super.findPrefix(insertedElement, offset);

  boolean searchForEntities =
    insertedElement instanceof XmlToken &&
    ( ((XmlToken)insertedElement).getTokenType() == XmlTokenType.XML_DATA_CHARACTERS ||
      ((XmlToken)insertedElement).getTokenType() == XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN
    );

  if (searchForEntities) {
    if (prefix.startsWith("&")) {
      prefix = prefix.substring(1);
    } else if (prefix.contains("&")) {
      prefix = prefix.substring(prefix.indexOf("&") + 1);
    }
  }

  return prefix;
}
项目:intellij-ce-playground    文件:XmlTagTreeHighlightingPass.java   
@Nullable
private static TextRange getEndTagRange(ASTNode tagNode) {
  final ASTNode endTagStart = XmlChildRole.CLOSING_TAG_START_FINDER.findChild(tagNode);
  if (endTagStart == null) {
    return null;
  }

  ASTNode endTagEnd = endTagStart;
  while (endTagEnd != null && endTagEnd.getElementType() != XmlTokenType.XML_TAG_END) {
    endTagEnd = endTagEnd.getTreeNext();
  }

  if (endTagEnd == null) {
    return null;
  }

  return new TextRange(endTagStart.getStartOffset(), endTagEnd.getTextRange().getEndOffset());
}
项目:intellij-ce-playground    文件:EnterBetweenXmlTagsHandler.java   
private static boolean isAtTheEndOfEmptyTag(Project project, Editor editor, PsiFile file, HighlighterIterator iterator) {
  if (iterator.getTokenType() != XmlTokenType.XML_TAG_END) {
    return false;
  }

  PsiDocumentManager.getInstance(project).commitDocument(editor.getDocument());
  final PsiElement element = file.findElementAt(iterator.getStart());

  if (element == null) {
    return false;
  }

  final PsiElement parent = element.getParent();
  return parent instanceof XmlTag &&
         parent.getTextRange().getEndOffset() == iterator.getEnd();
}
项目:intellij-ce-playground    文件:XmlPiTypedHandler.java   
@Override
public Result charTyped(char c, Project project, @NotNull Editor editor, @NotNull PsiFile file) {
  if (c == '?' && file.getLanguage() == XMLLanguage.INSTANCE) {
    int offset = editor.getCaretModel().getOffset();
    if (offset >= 2 && editor.getDocument().getCharsSequence().charAt(offset - 2) == '<') {
      PsiDocumentManager.getInstance(project).commitDocument(editor.getDocument());
      PsiElement at = file.findElementAt(offset - 2);
      if (at != null && at.getNode().getElementType() == XmlTokenType.XML_PI_START &&
          editor.getDocument().getText().indexOf("?>", offset) == -1) {

        editor.getDocument().insertString(offset, " ?>");
        AutoPopupController.getInstance(project).scheduleAutoPopup(editor);
      }
    }
  }
  return super.charTyped(c, project, editor, file);
}
项目:intellij-ce-playground    文件:HtmlTextContextType.java   
public static boolean isInContext(@NotNull PsiElement element) {
  if (PsiTreeUtil.getParentOfType(element, XmlComment.class) != null) {
    return false;
  }
  if (PsiTreeUtil.getParentOfType(element, XmlText.class) != null) {
    return true;
  }
  if (element.getNode().getElementType() == XmlTokenType.XML_START_TAG_START) {
    return true;
  }
  PsiElement parent = element.getParent();
  if (parent instanceof PsiErrorElement) {
    parent = parent.getParent();
  }
  return parent instanceof XmlDocument;
}
项目:intellij-ce-playground    文件:XmlBraceMatcher.java   
@Override
public int getBraceTokenGroupId(IElementType tokenType) {
  final Language l = tokenType.getLanguage();
  PairedBraceMatcher matcher = LanguageBraceMatching.INSTANCE.forLanguage(l);

  if (matcher != null) {
    BracePair[] pairs = matcher.getPairs();
    for (BracePair pair : pairs) {
      if (pair.getLeftBraceType() == tokenType || pair.getRightBraceType() == tokenType ) {
        return l.hashCode();
      }
    }
  }
  if (tokenType instanceof IXmlLeafElementType) {
    return tokenType == XmlTokenType.XML_ATTRIBUTE_VALUE_START_DELIMITER || tokenType == XmlTokenType.XML_ATTRIBUTE_VALUE_END_DELIMITER
           ? XML_VALUE_DELIMITER_GROUP
           : XML_TAG_TOKEN_GROUP;
  }
  else{
    return BraceMatchingUtil.UNDEFINED_TOKEN_GROUP;
  }
}
项目:intellij-ce-playground    文件:XmlBraceMatcher.java   
private static boolean findEndTagStart(HighlighterIterator iterator) {
  IElementType tokenType = iterator.getTokenType();
  int balance = 0;
  int count = 0;
  while(balance >= 0){
    iterator.retreat();
    count++;
    if (iterator.atEnd()) break;
    tokenType = iterator.getTokenType();
    if (tokenType == XmlTokenType.XML_TAG_END || tokenType == XmlTokenType.XML_EMPTY_ELEMENT_END){
      balance++;
    }
    else if (tokenType == XmlTokenType.XML_END_TAG_START || tokenType == XmlTokenType.XML_START_TAG_START){
      balance--;
    }
  }
  while(count-- > 0) iterator.advance();
  return tokenType == XmlTokenType.XML_END_TAG_START;
}
项目: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    文件:HtmlPolicy.java   
@Override
public boolean indentChildrenOf(final XmlTag parentTag) {
  if (parentTag == null) {
    return true;
  }
  final PsiElement firstChild = findFirstNonEmptyChild(parentTag);

  if (firstChild == null) {
    return false;
  }

  if (firstChild.getNode().getElementType() != XmlTokenType.XML_START_TAG_START) {
    return false;
  }

  if (mySettings.HTML_DO_NOT_ALIGN_CHILDREN_OF_MIN_LINES > 0 &&
      getLines(parentTag) > mySettings.HTML_DO_NOT_ALIGN_CHILDREN_OF_MIN_LINES) {
    return false;
  }
  else {
    return !checkName(parentTag, mySettings.HTML_DO_NOT_INDENT_CHILDREN_OF);
  }
}
项目:intellij-ce-playground    文件:XmlBlock.java   
private List<Block> splitAttribute(ASTNode node, XmlFormattingPolicy formattingPolicy) {
  final ArrayList<Block> result = new ArrayList<Block>(3);
  ASTNode child = node.getFirstChildNode();
  while (child != null) {
    if (child.getElementType() == XmlTokenType.XML_ATTRIBUTE_VALUE_START_DELIMITER ||
        child.getElementType() == XmlTokenType.XML_ATTRIBUTE_VALUE_END_DELIMITER) {
      result.add(new XmlBlock(child, null, null, formattingPolicy, null, null, isPreserveSpace()));
    }
    else if (!child.getPsi().getLanguage().isKindOf(XMLLanguage.INSTANCE) && containsOuterLanguageElement(child)) {
      // Fix for EA-20311:
      // In case of another embedded language create a splittable XML block which can be
      // merged with other language's code blocks.
      createLeafBlocks(child, result);
    }
    else if (child.getElementType() != TokenType.ERROR_ELEMENT || child.getFirstChildNode() != null) {
      result.add(new ReadOnlyBlock(child));
    }
    child = child.getTreeNext();
  }
  return result;
}
项目:intellij-ce-playground    文件:XmlTagUtil.java   
@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;
}
项目:intellij-ce-playground    文件:JavaFxCollapseSubTagToAttributeIntention.java   
@Override
public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement element) {
  if (element instanceof XmlToken && ((XmlToken)element).getTokenType() == XmlTokenType.XML_NAME && element.getParent() instanceof XmlTag) {
    final XmlTag tag = (XmlTag)element.getParent();
    for (XmlTag xmlTag : tag.getSubTags()) {
      if (xmlTag.getAttribute(FxmlConstants.FX_VALUE) == null) return false;
    }
    final XmlTag parentTag = tag.getParentTag();
    if (parentTag != null &&
        tag.getDescriptor() instanceof JavaFxPropertyElementDescriptor &&
        parentTag.getDescriptor() instanceof JavaFxClassBackedElementDescriptor) {

      setText("Collapse tag '" + tag.getName() + "' to attribute");
      return true;
    }
  }
  return false;
}
项目:mule-intellij-plugins    文件:MuleElementsCompletionContributor.java   
public MuleElementsCompletionContributor() {
    extend(CompletionType.BASIC,
            psiElement(XmlTokenType.XML_NAME)
                    .afterSibling(psiElement(XmlTokenType.XML_START_TAG_START)).withSuperParent(2, or(
                    xmlTag().withLocalName(MuleConfigConstants.FLOW_TAG_NAME),
                    xmlTag().withLocalName(MuleConfigConstants.WHEN_TAG_NAME),
                    xmlTag().withLocalName(MuleConfigConstants.OTHERWISE_TAG_NAME),
                    xmlTag().withLocalName(MuleConfigConstants.FOREACH_TAG_NAME),
                    xmlTag().withLocalName(MuleConfigConstants.CHAIN_TAG_NAME),
                    xmlTag().withLocalName(MuleConfigConstants.ENRICHER),
                    xmlTag().withLocalName(MuleConfigConstants.SUB_FLOW_TAG_NAME))
            ), new MuleElementCompletionProvider());
}
项目:RtplPlugin    文件:BaseHtmlLexer.java   
protected BaseHtmlLexer(Lexer _baseLexer, boolean _caseInsensitive)  {
  super(_baseLexer);
  caseInsensitive = _caseInsensitive;

  XmlNameHandler value = new XmlNameHandler();
  tokenHandlers.put(XmlTokenType.XML_NAME,value);
  tokenHandlers.put(XmlTokenType.XML_TAG_NAME,value);
  tokenHandlers.put(XmlTokenType.XML_TAG_END,new XmlTagClosedHandler());
  tokenHandlers.put(XmlTokenType.XML_END_TAG_START,new XmlTagEndHandler());
  tokenHandlers.put(XmlTokenType.XML_EMPTY_ELEMENT_END,new XmlTagEndHandler());
  tokenHandlers.put(XmlTokenType.XML_ATTRIBUTE_VALUE_END_DELIMITER,new XmlAttributeValueEndHandler());
  tokenHandlers.put(XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN,new XmlAttributeValueHandler());
}
项目:camel-idea-plugin    文件:CamelDocumentationProvider.java   
@Nullable
@Override
public PsiElement getCustomDocumentationElement(@NotNull Editor editor, @NotNull PsiFile file, @Nullable PsiElement contextElement) {
    // documentation from properties file will cause IDEA to call this method where we can tell IDEA we can provide
    // documentation for the element if we can detect its a Camel component

    if (contextElement != null) {
        ASTNode node = contextElement.getNode();
        if (node != null && node instanceof XmlToken) {
            //there is an &amp; in the route that splits the route in separated PsiElements
            if (node.getElementType() == XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN
                //the caret is at the end of the route next to the " character
                || node.getElementType() == XmlTokenType.XML_ATTRIBUTE_VALUE_END_DELIMITER
                //the caret is placed on an &amp; element
                || contextElement.getText().equals("&amp;")) {
                if (hasDocumentationForCamelComponent(contextElement.getParent())) {
                    return contextElement.getParent();
                }
            }
        }
        if (hasDocumentationForCamelComponent(contextElement)) {
            return contextElement;
        }
    }

    return null;
}
项目:intellij-ce-playground    文件:ShiftIndentInsideHelper.java   
public static boolean mayShiftIndentInside(final ASTNode leaf) {
  return (isComment(leaf) && !checkJspTexts(leaf))
         || leaf.getElementType() == TokenType.WHITE_SPACE
         || leaf.getElementType() == XmlTokenType.XML_DATA_CHARACTERS
         || leaf.getElementType() == JspTokenType.JAVA_CODE
         || leaf.getElementType() == JspElementType.JSP_SCRIPTLET
         || leaf.getElementType() == XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN;
}
项目:intellij-ce-playground    文件:SpellcheckingStrategy.java   
@NotNull
public Tokenizer getTokenizer(PsiElement element) {
  if (element instanceof PsiLanguageInjectionHost && InjectedLanguageUtil.hasInjections((PsiLanguageInjectionHost)element)) {
    return EMPTY_TOKENIZER;
  }
  if (element instanceof PsiNameIdentifierOwner) return new PsiIdentifierOwnerTokenizer();
  if (element instanceof PsiComment) {
    if (SuppressionUtil.isSuppressionComment(element)) {
      return EMPTY_TOKENIZER;
    }
    return myCommentTokenizer;
  }
  if (element instanceof XmlAttributeValue) return myXmlAttributeTokenizer;
  if (element instanceof XmlText) return myXmlTextTokenizer;
  if (element instanceof PsiPlainText) {
    PsiFile file = element.getContainingFile();
    FileType fileType = file == null ? null : file.getFileType();
    if (fileType instanceof CustomSyntaxTableFileType) {
      return new CustomFileTypeTokenizer(((CustomSyntaxTableFileType)fileType).getSyntaxTable());
    }
    return TEXT_TOKENIZER;
  }
  if (element instanceof XmlToken) {
    if (((XmlToken)element).getTokenType() == XmlTokenType.XML_DATA_CHARACTERS) {
      PsiElement injection = InjectedLanguageManager.getInstance(element.getProject()).findInjectedElementAt(element.getContainingFile(), element.getTextOffset());
      if (injection == null) {
        return TEXT_TOKENIZER;
      }
    }

  }
  return EMPTY_TOKENIZER;
}
项目:intellij-ce-playground    文件:XmlTextTokenizer.java   
private static void processChildren(PsiElement element, TokenConsumer consumer) {
  final PsiElement[] children = element.getChildren();
  for (PsiElement child : children) {
    IElementType elementType = child.getNode().getElementType();
    if (elementType == XmlTokenType.XML_DATA_CHARACTERS) {
      consumer.consumeToken(child, PlainTextSplitter.getInstance());
    }
    else if (elementType == XmlElementType.XML_CDATA) {
      processChildren(child, consumer);
    }
  }
}
项目:intellij-ce-playground    文件:RenameTagBeginOrEndIntentionAction.java   
@Override
public void invoke(@NotNull final Project project, final Editor editor, final PsiFile file) throws IncorrectOperationException {
  final int offset = editor.getCaretModel().getOffset();
  PsiElement psiElement = file.findElementAt(offset);

  if (psiElement == null || !psiElement.isValid()) return;
  if (!FileModificationService.getInstance().prepareFileForWrite(psiElement.getContainingFile())) return;

  if (psiElement instanceof PsiWhiteSpace) psiElement = PsiTreeUtil.prevLeaf(psiElement);
  if (psiElement instanceof XmlToken) {
    final IElementType tokenType = ((XmlToken)psiElement).getTokenType();
    if (tokenType != XmlTokenType.XML_NAME) {
      if (tokenType == XmlTokenType.XML_TAG_END) {
        psiElement = psiElement.getPrevSibling();
        if (psiElement == null) return;
      }
    }

    PsiElement target = null;
    final String text = psiElement.getText();
    if (!myTargetName.equals(text)) {
      target = psiElement;
    }
    else {
      // we're in the other
      target = findOtherSide(psiElement, myStart);
    }

    if (target != null) {
      final Document document = PsiDocumentManager.getInstance(project).getDocument(file);
      if (document != null) {
        final TextRange textRange = target.getTextRange();
        document.replaceString(textRange.getStartOffset(), textRange.getEndOffset(), myTargetName);
      }
    }

  }
}
项目:intellij-ce-playground    文件:XmlTemplateTreePatcher.java   
@Override
public void insert(CompositeElement parent, TreeElement anchorBefore, OuterLanguageElement toInsert) {
  if(anchorBefore != null) {
    //[mike]
    //Nasty hack. Is used not to insert OuterLanguageElements before the first token of tag.
    //See GeneralJspParsingTest.testHtml6
    if (anchorBefore.getElementType() == XmlTokenType.XML_START_TAG_START) {
      anchorBefore = anchorBefore.getTreeParent();
    }

    anchorBefore.rawInsertBeforeMe((TreeElement)toInsert);
  }
  else parent.rawAddChildren((TreeElement)toInsert);
}
项目:intellij-ce-playground    文件:HtmlParsing.java   
protected void parseComment() {
  final PsiBuilder.Marker comment = mark();
  advance();
  while (true) {
    final IElementType tt = token();
    if (tt == XmlTokenType.XML_COMMENT_CHARACTERS || tt == XmlTokenType.XML_CONDITIONAL_COMMENT_START
      || tt == XmlTokenType.XML_CONDITIONAL_COMMENT_START_END || tt == XmlTokenType.XML_CONDITIONAL_COMMENT_END_START
      || tt == XmlTokenType.XML_CONDITIONAL_COMMENT_END) {
      advance();
      continue;
    }
    if (tt == XmlTokenType.XML_ENTITY_REF_TOKEN || tt == XmlTokenType.XML_CHAR_ENTITY_REF) {
      parseReference();
      continue;
    }
    if (tt == XmlTokenType.XML_BAD_CHARACTER) {
      final PsiBuilder.Marker error = mark();
      advance();
      error.error(XmlErrorMessages.message("xml.parsing.bad.character"));
      continue;
    }
    if (tt == XmlTokenType.XML_COMMENT_END) {
      advance();
    }
    break;
  }
  comment.done(XmlElementType.XML_COMMENT);
}
项目:intellij-ce-playground    文件:HtmlParsing.java   
private void parseAttributeValue() {
  final PsiBuilder.Marker attValue = mark();
  if (token() == XmlTokenType.XML_ATTRIBUTE_VALUE_START_DELIMITER) {
    while (true) {
      final IElementType tt = token();
      if (tt == null || tt == XmlTokenType.XML_ATTRIBUTE_VALUE_END_DELIMITER || tt == XmlTokenType.XML_END_TAG_START || tt == XmlTokenType
        .XML_EMPTY_ELEMENT_END ||
          tt == XmlTokenType.XML_START_TAG_START) {
        break;
      }

      if (tt == XmlTokenType.XML_BAD_CHARACTER) {
        final PsiBuilder.Marker error = mark();
        advance();
        error.error(XmlErrorMessages.message("unescaped.ampersand.or.nonterminated.character.entity.reference"));
      }
      else if (tt == XmlTokenType.XML_ENTITY_REF_TOKEN) {
        parseReference();
      }
      else {
        advance();
      }
    }

    if (token() == XmlTokenType.XML_ATTRIBUTE_VALUE_END_DELIMITER) {
      advance();
    }
    else {
      error(XmlErrorMessages.message("xml.parsing.unclosed.attribute.value"));
    }
  }
  else {
    if (token() != XmlTokenType.XML_TAG_END && token() != XmlTokenType.XML_EMPTY_ELEMENT_END) {
      advance(); // Single token att value
    }
  }

  attValue.done(XmlElementType.XML_ATTRIBUTE_VALUE);
}
项目:intellij-ce-playground    文件:XHtmlFilterLexer.java   
@Override
public void advance() {
  final IElementType tokenType = myDelegate.getTokenType();

  if (tokenType == XmlTokenType.XML_COMMENT_CHARACTERS) {
    scanWordsInToken(UsageSearchContext.IN_COMMENTS, false, false);
    advanceTodoItemCountsInToken();
  } else if (tokenType == XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN ||
      tokenType == XmlTokenType.XML_NAME ||
      tokenType == XmlTokenType.XML_TAG_NAME
     ) {
    scanWordsInToken(UsageSearchContext.IN_PLAIN_TEXT | UsageSearchContext.IN_FOREIGN_LANGUAGES, tokenType ==
                                                                                                 XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN,
                     false);
  } else if (tokenType.getLanguage() != XMLLanguage.INSTANCE &&
    tokenType.getLanguage() != Language.ANY         
  ) {
    boolean inComments = CacheUtil.isInComments(tokenType);
    scanWordsInToken((inComments)?UsageSearchContext.IN_COMMENTS:UsageSearchContext.IN_PLAIN_TEXT | UsageSearchContext.IN_FOREIGN_LANGUAGES, true,
                     false);

    if (inComments) advanceTodoItemCountsInToken();
  }
  else if (!XmlFilterLexer.ourNoWordsTokenSet.contains(tokenType)) {
    scanWordsInToken(UsageSearchContext.IN_PLAIN_TEXT, false, false);
  }

  myDelegate.advance();
}
项目:intellij-ce-playground    文件:XmlFilterLexer.java   
@Override
public void advance() {
  final IElementType tokenType = myDelegate.getTokenType();

  if (tokenType == XmlTokenType.XML_COMMENT_CHARACTERS) {
    scanWordsInToken(UsageSearchContext.IN_COMMENTS, false, false);
    advanceTodoItemCountsInToken();
  }

  if (tokenType == XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN) {
    scanWordsInToken(UsageSearchContext.IN_PLAIN_TEXT | UsageSearchContext.IN_FOREIGN_LANGUAGES, true, false);
  }
  else if (tokenType == XmlTokenType.XML_NAME || tokenType == XmlTokenType.XML_DATA_CHARACTERS) {
    scanWordsInToken(UsageSearchContext.IN_PLAIN_TEXT | UsageSearchContext.IN_FOREIGN_LANGUAGES, false, false);
  }
  else if (tokenType == XmlTokenType.XML_ENTITY_REF_TOKEN || tokenType == XmlTokenType.XML_CHAR_ENTITY_REF) {
    scanWordsInToken(UsageSearchContext.IN_CODE, false, false);
  }
  else if (tokenType == XmlElementType.XML_TEXT) {
    scanWordsInToken(UsageSearchContext.IN_PLAIN_TEXT | UsageSearchContext.IN_FOREIGN_LANGUAGES, false, false);
  }
  else if (tokenType == XmlTokenType.XML_TAG_CHARACTERS) {
    scanWordsInToken(UsageSearchContext.IN_PLAIN_TEXT | UsageSearchContext.IN_FOREIGN_LANGUAGES, false, false);
  }
  else if (!ourNoWordsTokenSet.contains(tokenType)) {
    scanWordsInToken(UsageSearchContext.IN_PLAIN_TEXT, false, false);
  }

  myDelegate.advance();
}
项目:intellij-ce-playground    文件:XmlElementChangeUtil.java   
static void doNameReplacement(final PsiNamedElement xmlElementDecl, XmlElement nameElement, final String name) throws
                                                                                                               IncorrectOperationException {
  if (xmlElementDecl.isWritable() && isInProjectContent(xmlElementDecl.getProject(), xmlElementDecl.getContainingFile().getVirtualFile())) {

    if (nameElement!=null) {
      nameElement.replace(
        SourceTreeToPsiMap.treeElementToPsi(Factory.createSingleLeafElement(XmlTokenType.XML_NAME, name, null, xmlElementDecl.getManager()))
      );
    }
  }
}