Java Code Examples for com.intellij.psi.tree.TokenSet.getTypes()

The following are Jave code examples for showing how to use getTypes() of the com.intellij.psi.tree.TokenSet 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: SyntaxHighlighterBase.java   Source Code and License Vote up 5 votes
/**
 * Tries to update the map by associating given keys with a given value.
 * Throws error if the map already contains different mapping for one of given keys.
 */
protected static void safeMap(@NotNull final Map<IElementType, TextAttributesKey> map,
                              @NotNull final TokenSet keys,
                              @NotNull final TextAttributesKey value) {
  for (final IElementType type : keys.getTypes()) {
    safeMap(map, type, value);
  }
}
 
Example 2
Project: intellij-ce-playground   File: XPathParser.java   Source Code and License Vote up 5 votes
private static void consumeBadTokens(PsiBuilder builder, TokenSet nextAccepted) {
  if (nextAccepted.getTypes().length == 0 && builder.eof()) {
    return;
  }
  if (!nextAccepted.contains(builder.getTokenType())) {
    builder.error("Unexpected token");
    do {
      if (builder.eof()) {
        builder.error("Unexpected end of file");
        break;
      }
      builder.advanceLexer();
    } while (!nextAccepted.contains(builder.getTokenType()));
  }
}