mirror of
				https://github.com/neovim/neovim.git
				synced 2025-10-26 12:27:24 +00:00 
			
		
		
		
	fix(treesitter): mark supertype nodes as named
**Problem:** Tree-sitter 0.24.0 introduced a new symbol type to denote supertype nodes (`TSSymbolTypeSupertype`). Now, `language.inspect()` (and the query `omnifunc`) return supertype symbols, but with double quotes around them. **Solution:** Mark a symbol as "named" based on it *not* being an anonymous node, rather than checking that it is a regular node (which a supertype also is not).
This commit is contained in:
		 Riley Bruins
					Riley Bruins
				
			
				
					committed by
					
						 Christian Clason
						Christian Clason
					
				
			
			
				
	
			
			
			 Christian Clason
						Christian Clason
					
				
			
						parent
						
							45f8f957c0
						
					
				
				
					commit
					4b90952851
				
			| @@ -272,7 +272,7 @@ int tslua_inspect_lang(lua_State *L) | |||||||
|       continue; |       continue; | ||||||
|     } |     } | ||||||
|     const char *name = ts_language_symbol_name(lang, (TSSymbol)i); |     const char *name = ts_language_symbol_name(lang, (TSSymbol)i); | ||||||
|     bool named = t == TSSymbolTypeRegular; |     bool named = t != TSSymbolTypeAnonymous; | ||||||
|     lua_pushboolean(L, named);  // [retval, symbols, is_named] |     lua_pushboolean(L, named);  // [retval, symbols, is_named] | ||||||
|     if (!named) { |     if (!named) { | ||||||
|       char buf[256]; |       char buf[256]; | ||||||
|   | |||||||
| @@ -73,7 +73,7 @@ describe('treesitter language API', function() | |||||||
|     eq(true, fset['directive']) |     eq(true, fset['directive']) | ||||||
|     eq(true, fset['initializer']) |     eq(true, fset['initializer']) | ||||||
|  |  | ||||||
|     local has_named, has_anonymous |     local has_named, has_anonymous, has_supertype | ||||||
|     for symbol, named in pairs(symbols) do |     for symbol, named in pairs(symbols) do | ||||||
|       eq('string', type(symbol)) |       eq('string', type(symbol)) | ||||||
|       eq('boolean', type(named)) |       eq('boolean', type(named)) | ||||||
| @@ -81,11 +81,13 @@ describe('treesitter language API', function() | |||||||
|         has_named = true |         has_named = true | ||||||
|       elseif symbol == '"|="' and named == false then |       elseif symbol == '"|="' and named == false then | ||||||
|         has_anonymous = true |         has_anonymous = true | ||||||
|  |       elseif symbol == 'statement' and named == true then | ||||||
|  |         has_supertype = true | ||||||
|       end |       end | ||||||
|     end |     end | ||||||
|     eq( |     eq( | ||||||
|       { has_named = true, has_anonymous = true }, |       { has_named = true, has_anonymous = true, has_supertype = true }, | ||||||
|       { has_named = has_named, has_anonymous = has_anonymous } |       { has_named = has_named, has_anonymous = has_anonymous, has_supertype = has_supertype } | ||||||
|     ) |     ) | ||||||
|   end) |   end) | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user