Java Code Examples for com.intellij.psi.xml.XmlTokenType.XML_TAG_NAME

The following are Jave code examples for showing how to use XML_TAG_NAME of the com.intellij.psi.xml.XmlTokenType class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: intellij-ce-playground   File: XmlWrongClosingTagNameInspection.java   Source Code and License Vote up 6 votes
@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;
}
 
Example 2
Project: intellij-ce-playground   File: XmlHighlightingLexer.java   Source Code and License Vote up 6 votes
static IElementType fixWrongTokenTypes(IElementType tokenType, final int state) {
  if (tokenType == XmlTokenType.XML_NAME) {
    if (state == __XmlLexer.TAG || state == __XmlLexer.END_TAG) {
      // translate XML names for tags into XmlTagName
      tokenType = XmlTokenType.XML_TAG_NAME;
    }
  } else if (tokenType == XmlTokenType.XML_WHITE_SPACE) {
    switch (state) {
      case __XmlLexer.ATTR_LIST:
      case __XmlLexer.ATTR:
        tokenType = XmlTokenType.TAG_WHITE_SPACE; break;
      default:
        tokenType = XmlTokenType.XML_REAL_WHITE_SPACE; break;
    }
  } else if (tokenType == XmlTokenType.XML_CHAR_ENTITY_REF ||
             tokenType == XmlTokenType.XML_ENTITY_REF_TOKEN
            ) {
    if (state == __XmlLexer.COMMENT) return XmlTokenType.XML_COMMENT_CHARACTERS;
  }
  return tokenType;
}
 
Example 3
Project: intellij-ce-playground   File: XmlTagUtil.java   Source Code and License Vote up 6 votes
@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;
}
 
Example 4
Project: intellij-ce-playground   File: XHtmlFilterLexer.java   Source Code and License Vote up 5 votes
@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();
}
 
Example 5
Project: intellij-ce-playground   File: XmlNameCompletionConfidence.java   Source Code and License Vote up 5 votes
@NotNull
@Override
public ThreeState shouldFocusLookup(@NotNull CompletionParameters parameters) {
  final ASTNode node = parameters.getPosition().getNode();
  if (node == null) return ThreeState.UNSURE;

  final IElementType elementType = node.getElementType();
  if (elementType == XmlTokenType.XML_NAME || elementType == XmlTokenType.XML_TAG_NAME) {
    return ThreeState.YES;
  }
  return ThreeState.UNSURE;
}
 
Example 6
Project: intellij-ce-playground   File: XmlTagUtil.java   Source Code and License Vote up 5 votes
@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();
}