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

The following examples show how to use com.intellij.psi.tree.TokenSet#andNot() . 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: ClosingBraceSanityAnnotator.java    From bamboo-soy with Apache License 2.0 5 votes vote down vote up
@Override
public void annotate(@NotNull PsiElement psiElement, @NotNull AnnotationHolder annotationHolder) {
  if (psiElement instanceof TagElement) {
    TagElement tagElement = (TagElement) psiElement;

    TokenSet allowedRBraces = SoyTokenTypes.RIGHT_BRACES;
    if (mustCloseRBraceTags.contains(tagElement.getClass())) {
      allowedRBraces = TokenSet.andNot(allowedRBraces, SoyTokenTypes.SLASH_R_BRACES);
    } else if (mustCloseSlashRBraceTags.contains(tagElement.getClass())) {
      allowedRBraces = TokenSet.andSet(allowedRBraces, SoyTokenTypes.SLASH_R_BRACES);
    }

    if (tagElement.isDoubleBraced()) {
      allowedRBraces = TokenSet.andSet(allowedRBraces, SoyTokenTypes.DOUBLE_BRACES);
    } else {
      allowedRBraces = TokenSet.andNot(allowedRBraces, SoyTokenTypes.DOUBLE_BRACES);
    }

    if (!allowedRBraces.contains(tagElement.getClosingBraceType())) {
      annotationHolder.createErrorAnnotation(tagElement, "Must close by " +
          Stream.of(allowedRBraces.getTypes())
              .map(SoyTokenTypes.BRACE_TYPE_TO_STRING::get)
              .sorted()
              .collect(Collectors.joining(" or ")));
    }
  }
}
 
Example 2
Source File: CSharpBuilderWrapper.java    From consulo-csharp with Apache License 2.0 4 votes vote down vote up
public void disableSoftKeywords(@Nonnull TokenSet tokenSet)
{
	mySoftSet = TokenSet.andNot(mySoftSet, tokenSet);
}
 
Example 3
Source File: CSharpBuilderWrapper.java    From consulo-csharp with Apache License 2.0 4 votes vote down vote up
public void disableSoftKeyword(@Nonnull IElementType elementType)
{
	mySoftSet = TokenSet.andNot(mySoftSet, TokenSet.create(elementType));
}