From 4e877de54d4ad79cf5dafca6642f63ee1a8d5ae4 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Mon, 18 Apr 2022 10:14:48 -0500 Subject: Fix Golang textobject queries (#2153) * log textobject query construction errors The current behavior is that invalid queries are discarded silently which makes it difficult to debug invalid textobjects (either invalid syntax or an update may have come through that changed the valid set of nodes). * fix golang textobject query `method_spec_list` used to be a named node but was removed (I think for Helix, it was when updated to pull in the support for generics). Instead of a named node for the list of method specs we have a bunch of `method_spec` children nodes now. We can match on the set of them with a `+` wildcard. Example go for this query: type Shape interface { area() float64 perimeter() float64 } Which is parsed as: (source_file (type_declaration (type_spec name: (type_identifier) type: (interface_type (method_spec name: (field_identifier) parameters: (parameter_list) result: (type_identifier)) (method_spec name: (field_identifier) parameters: (parameter_list) result: (type_identifier))))))--- runtime/queries/go/textobjects.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/queries/go/textobjects.scm b/runtime/queries/go/textobjects.scm index d77e14b7..3cdf6203 100644 --- a/runtime/queries/go/textobjects.scm +++ b/runtime/queries/go/textobjects.scm @@ -12,7 +12,7 @@ (type_spec (type_identifier) (struct_type (field_declaration_list (_)?) @class.inside))) @class.around (type_declaration - (type_spec (type_identifier) (interface_type (method_spec_list (_)?) @class.inside))) @class.around + (type_spec (type_identifier) (interface_type (method_spec)+ @class.inside))) @class.around (parameter_list (_) @parameter.inside) -- cgit v1.2.3-70-g09d2