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

The following are Jave code examples for showing how to use XML_COMMENT_CHARACTERS 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: XmlHighlightingLexer.java   Source Code and License Vote up 6 votes
@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;
}
 
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: HtmlHighlightingLexer.java   Source Code and License Vote up 6 votes
@Override
public void handleElement(Lexer lexer) {
  if (!hasSeenStyle() && !hasSeenScript() || hasNoEmbeddments) return;
  final IElementType tokenType = lexer.getTokenType();

  if (tokenType == XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN && hasSeenAttribute() ||
      tokenType == XmlTokenType.XML_DATA_CHARACTERS && hasSeenTag() ||
      tokenType == XmlTokenType.XML_COMMENT_CHARACTERS && hasSeenTag()
    ) {
    setEmbeddedLexer();

    if (embeddedLexer != null) {
      embeddedLexer.start(
        getBufferSequence(),
        HtmlHighlightingLexer.super.getTokenStart(),
        skipToTheEndOfTheEmbeddment(),
        embeddedLexer instanceof EmbedmentLexer ? ((EmbedmentLexer)embeddedLexer).getEmbeddedInitialState(tokenType) : 0
      );

      if (embeddedLexer.getTokenType() == null) {
        // no content for embeddment
        embeddedLexer = null;
      }
    }
  }
}
 
Example 4
Project: intellij-ce-playground   File: HtmlParsing.java   Source Code and License Vote up 5 votes
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);
}
 
Example 5
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 6
Project: intellij-ce-playground   File: XmlFilterLexer.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();
  }

  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();
}
 
Example 7
Project: intellij-ce-playground   File: MarkupLineWrapPositionStrategy.java   Source Code and License Vote up 4 votes
public MarkupLineWrapPositionStrategy() {
  super(true, XmlElementType.XML_TEXT, XmlTokenType.XML_COMMENT_CHARACTERS, TokenType.WHITE_SPACE);
}