diff --git a/grammar.js b/grammar.js index da3b3d44a..cab4d1208 100644 --- a/grammar.js +++ b/grammar.js @@ -698,6 +698,7 @@ module.exports = grammar({ data_constructors: ($) => repeat1($.data_constructor), data_constructor: ($) => seq( + optional($.attribute), field("name", $.constructor_name), optional(field("arguments", $.data_constructor_arguments)) ), diff --git a/test/corpus/attributes.txt b/test/corpus/attributes.txt index d0314cf07..211bef91f 100644 --- a/test/corpus/attributes.txt +++ b/test/corpus/attributes.txt @@ -65,3 +65,37 @@ pub fn wibble() { todo } parameters: (function_parameters) body: (block (todo)))) + +================================================================================ +Individually deprecated constructors +================================================================================ + +pub type SomeType { + NotDeprecated + @deprecated("Please use the NotDeprecated variant") + Deprecated(reason: String) +} + +-------------------------------------------------------------------------------- + +(source_file + (type_definition + (visibility_modifier) + (type_name + name: (type_identifier)) + (data_constructors + (data_constructor + name: (constructor_name)) + (data_constructor + (attribute + name: (identifier) + arguments: (arguments + (attribute_value + (string + (quoted_content))))) + name: (constructor_name) + arguments: (data_constructor_arguments + (data_constructor_argument + label: (label) + value: (type + name: (type_identifier))))))))