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

The following examples show how to use com.intellij.psi.tree.TokenSet#orSet() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WordParsing.java    From BashSupport with Apache License 2.0 6 votes vote down vote up
/**
 * Looks ahead if the current token is the start of a static double-quoted string value.
 *
 * @param builder         the current bulder
 * @param allowWhitespace if whitespace content is allowed
 * @return true if this is a quoted string which only consists of quotes and static string content
 */
public boolean isSimpleComposedString(BashPsiBuilder builder, boolean allowWhitespace) {
    if (builder.getTokenType() != STRING_BEGIN) {
        return false;
    }

    TokenSet accepted = TokenSet.create(STRING_CONTENT);
    if (allowWhitespace) {
        accepted = TokenSet.orSet(accepted, TokenSet.create(WHITESPACE));
    }

    int lookahead = 1;
    while (accepted.contains(builder.rawLookup(lookahead))) {
        lookahead++;
    }

    if (builder.rawLookup(lookahead) != STRING_END) {
        return false;
    }

    IElementType end = builder.rawLookup(lookahead + 1);
    return end == null || end == WHITESPACE || end == LINE_FEED;
}
 
Example 2
Source File: GLSLTokenTypes.java    From glsl4idea with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static TokenSet merge(TokenSet... sets) {
    TokenSet tokenSet = TokenSet.create();
    for (TokenSet set : sets) {
        tokenSet = TokenSet.orSet(tokenSet, set);
    }
    return tokenSet;
}
 
Example 3
Source File: CSharpBuilderWrapper.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
public boolean enableSoftKeyword(@Nonnull IElementType elementType)
{
	if(mySoftSet.contains(elementType))
	{
		return false;
	}
	mySoftSet = TokenSet.orSet(mySoftSet, TokenSet.create(elementType));
	return true;
}
 
Example 4
Source File: FindManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static TokenSet addTokenTypesForLanguage(FindModel model, Language lang, TokenSet tokensOfInterest) {
  ParserDefinition definition = LanguageParserDefinitions.INSTANCE.forLanguage(lang);
  if (definition != null) {
    for (LanguageVersion languageVersion : lang.getVersions()) {
      tokensOfInterest = TokenSet.orSet(tokensOfInterest, model.isInCommentsOnly() ? definition.getCommentTokens(languageVersion) : TokenSet.EMPTY);
      tokensOfInterest =
              TokenSet.orSet(tokensOfInterest, model.isInStringLiteralsOnly() ? definition.getStringLiteralElements(languageVersion) : TokenSet.EMPTY);
    }
  }
  return tokensOfInterest;
}
 
Example 5
Source File: CSharpBuilderWrapper.java    From consulo-csharp with Apache License 2.0 4 votes vote down vote up
public void enableSoftKeywords(@Nonnull TokenSet tokenSet)
{
	mySoftSet = TokenSet.orSet(mySoftSet, tokenSet);
}