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

The following examples show how to use com.intellij.psi.tree.TokenSet#getTypes() . 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: CSharpAccessorCompletionContributor.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
private static void buildAccessorKeywordsCompletion(CompletionResultSet resultSet, final CSharpXAccessorOwner accessorOwner, @Nullable InsertHandler<LookupElement> insertHandler)
{
	TokenSet tokenSet = accessorOwner instanceof CSharpEventDeclaration ? TokenSet.create(CSharpSoftTokens.ADD_KEYWORD, CSharpSoftTokens.REMOVE_KEYWORD) : TokenSet.create(CSharpSoftTokens
			.GET_KEYWORD, CSharpSoftTokens.SET_KEYWORD);

	for(IElementType elementType : tokenSet.getTypes())
	{
		if(!isCanShowAccessorKeyword(elementType, accessorOwner))
		{
			continue;
		}
		LookupElementBuilder builder = LookupElementBuilder.create(CSharpCompletionUtil.textOfKeyword(elementType));
		builder = builder.bold();

		if(insertHandler != null)
		{
			builder = builder.withInsertHandler(insertHandler);
		}

		builder.putUserData(CSharpCompletionUtil.KEYWORD_ELEMENT_TYPE, elementType);

		resultSet.addElement(builder);
	}
}
 
Example 2
Source File: NASMPairedBraceMatcher.java    From JetBrains-NASM-Language with MIT License 5 votes vote down vote up
@Override
public boolean isPairedBracesAllowedBeforeType(@NotNull IElementType lbraceType, @Nullable IElementType contextType) {
    for (TokenSet tokens : InsertPairBraceBefore) {
        for (IElementType type : tokens.getTypes()) {
            if (type == contextType)
                return true;
        }
    }
    return false;
}
 
Example 3
Source File: LatteTemplateDataElementType.java    From intellij-latte with MIT License 5 votes vote down vote up
public LatteTemplateDataElementType(@NonNls String debugName,
							   Language language,
							   @NotNull TokenSet htmlTemplateElementType,
							   @NotNull IElementType outerElementType) {
	super(debugName, language, htmlTemplateElementType.getTypes()[0], outerElementType);
	elementTypesSet = htmlTemplateElementType;
}
 
Example 4
Source File: CSharpCompletionUtil.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
public static void tokenSetToLookup(@Nonnull CompletionResultSet resultSet,
		@Nonnull TokenSet tokenSet,
		@Nullable NotNullPairFunction<LookupElementBuilder, IElementType, LookupElement> decorator,
		@Nullable Condition<IElementType> condition)
{
	for(IElementType elementType : tokenSet.getTypes())
	{
		elementToLookup(resultSet, elementType, decorator, condition);
	}
}
 
Example 5
Source File: SyntaxHighlighterBase.java    From consulo with Apache License 2.0 5 votes vote down vote up
/**
 * 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(
  @Nonnull final Map<IElementType, TextAttributesKey> map,
  @Nonnull final TokenSet keys,
  @Nonnull final TextAttributesKey value)
{
  for (final IElementType type : keys.getTypes()) {
    safeMap(map, type, value);
  }
}
 
Example 6
Source File: SyntaxHighlighterBase.java    From consulo with Apache License 2.0 4 votes vote down vote up
/**
 * @deprecated use safeMap() instead
 */
@Deprecated
protected static void fillMap(Map<IElementType, TextAttributesKey> map, TokenSet keys, TextAttributesKey value) {
  IElementType[] types = keys.getTypes();
  fillMap(map, value, types);
}