From 487d19f1bfd5cb92e3e92ab4c0e8af0e7fcf57f6 Mon Sep 17 00:00:00 2001 From: "M.P. Korstanje" Date: Thu, 17 Jul 2025 18:24:30 +0200 Subject: [PATCH 1/4] Add location to pickle --- .../messages/cucumber/messages/pickle.hpp | 2 ++ .../lib/messages/cucumber/messages/pickle.cpp | 2 ++ dotnet/Cucumber.Messages/generated/Pickle.cs | 14 ++++++++++++-- go/messages.go | 1 + .../io/cucumber/messages/types/Pickle.java | 19 ++++++++++++++++--- javascript/src/messages.ts | 3 +++ jsonschema/messages.md | 1 + jsonschema/src/Pickle.json | 4 ++++ perl/lib/Cucumber/Messages.pm | 11 +++++++++++ php/src-generated/Pickle.php | 17 +++++++++++++++++ python/src/cucumber_messages/_messages.py | 1 + ruby/lib/cucumber/messages/pickle.rb | 12 ++++++++++-- 12 files changed, 80 insertions(+), 7 deletions(-) diff --git a/cpp/include/messages/cucumber/messages/pickle.hpp b/cpp/include/messages/cucumber/messages/pickle.hpp index 36be3345..3eae05c5 100644 --- a/cpp/include/messages/cucumber/messages/pickle.hpp +++ b/cpp/include/messages/cucumber/messages/pickle.hpp @@ -8,6 +8,7 @@ #include #include +#include namespace cucumber::messages { @@ -41,6 +42,7 @@ struct pickle std::vector steps; std::vector tags; std::vector ast_node_ids; + std::optional location; std::string to_string() const; diff --git a/cpp/src/lib/messages/cucumber/messages/pickle.cpp b/cpp/src/lib/messages/cucumber/messages/pickle.cpp index e8fd1896..5dd05bcb 100644 --- a/cpp/src/lib/messages/cucumber/messages/pickle.cpp +++ b/cpp/src/lib/messages/cucumber/messages/pickle.cpp @@ -17,6 +17,7 @@ pickle::to_string() const cucumber::messages::to_string(oss, ", steps=", steps); cucumber::messages::to_string(oss, ", tags=", tags); cucumber::messages::to_string(oss, ", ast_node_ids=", ast_node_ids); + cucumber::messages::to_string(oss, ", location=", location); return oss.str(); } @@ -31,6 +32,7 @@ pickle::to_json(json& j) const cucumber::messages::to_json(j, camelize("steps"), steps); cucumber::messages::to_json(j, camelize("tags"), tags); cucumber::messages::to_json(j, camelize("ast_node_ids"), ast_node_ids); + cucumber::messages::to_json(j, camelize("location"), location); } std::string diff --git a/dotnet/Cucumber.Messages/generated/Pickle.cs b/dotnet/Cucumber.Messages/generated/Pickle.cs index e96855e6..352db6c8 100644 --- a/dotnet/Cucumber.Messages/generated/Pickle.cs +++ b/dotnet/Cucumber.Messages/generated/Pickle.cs @@ -60,6 +60,10 @@ public sealed class Pickle * id originating from the `Scenario` AST node, and the second from the `TableRow` AST node. */ public List AstNodeIds { get; private set; } + /** + * The location of this pickle in source file. A pickle constructed from `Examples` will point to the example row. + */ + public Location Location { get; private set; } public Pickle( @@ -69,7 +73,8 @@ public Pickle( string language, List steps, List tags, - List astNodeIds + List astNodeIds, + Location location ) { RequireNonNull(id, "Id", "Pickle.Id cannot be null"); @@ -86,6 +91,7 @@ List astNodeIds this.Tags = new List(tags); RequireNonNull>(astNodeIds, "AstNodeIds", "Pickle.AstNodeIds cannot be null"); this.AstNodeIds = new List(astNodeIds); + this.Location = location; } public override bool Equals(Object o) @@ -100,7 +106,8 @@ public override bool Equals(Object o) Language.Equals(that.Language) && Steps.Equals(that.Steps) && Tags.Equals(that.Tags) && - AstNodeIds.Equals(that.AstNodeIds); + AstNodeIds.Equals(that.AstNodeIds) && + Object.Equals(Location, that.Location); } public override int GetHashCode() @@ -120,6 +127,8 @@ public override int GetHashCode() hash = hash * 31 + Tags.GetHashCode(); if (AstNodeIds != null) hash = hash * 31 + AstNodeIds.GetHashCode(); + if (Location != null) + hash = hash * 31 + Location.GetHashCode(); return hash; } @@ -133,6 +142,7 @@ public override string ToString() ", steps=" + Steps + ", tags=" + Tags + ", astNodeIds=" + AstNodeIds + + ", location=" + Location + '}'; } diff --git a/go/messages.go b/go/messages.go index 7fb60c88..c4a0e79c 100644 --- a/go/messages.go +++ b/go/messages.go @@ -222,6 +222,7 @@ type Pickle struct { Steps []*PickleStep `json:"steps"` Tags []*PickleTag `json:"tags"` AstNodeIds []string `json:"astNodeIds"` + Location *Location `json:"location,omitempty"` } type PickleDocString struct { diff --git a/java/src/generated/java/io/cucumber/messages/types/Pickle.java b/java/src/generated/java/io/cucumber/messages/types/Pickle.java index 4ef811c3..3a8772dc 100644 --- a/java/src/generated/java/io/cucumber/messages/types/Pickle.java +++ b/java/src/generated/java/io/cucumber/messages/types/Pickle.java @@ -34,6 +34,7 @@ public final class Pickle { private final java.util.List steps; private final java.util.List tags; private final java.util.List astNodeIds; + private final Location location; public Pickle( String id, @@ -42,7 +43,8 @@ public Pickle( String language, java.util.List steps, java.util.List tags, - java.util.List astNodeIds + java.util.List astNodeIds, + Location location ) { this.id = requireNonNull(id, "Pickle.id cannot be null"); this.uri = requireNonNull(uri, "Pickle.uri cannot be null"); @@ -51,6 +53,7 @@ public Pickle( this.steps = unmodifiableList(new ArrayList<>(requireNonNull(steps, "Pickle.steps cannot be null"))); this.tags = unmodifiableList(new ArrayList<>(requireNonNull(tags, "Pickle.tags cannot be null"))); this.astNodeIds = unmodifiableList(new ArrayList<>(requireNonNull(astNodeIds, "Pickle.astNodeIds cannot be null"))); + this.location = location; } /** @@ -105,6 +108,13 @@ public java.util.List getAstNodeIds() { return astNodeIds; } + /** + * The location of this pickle in source file. A pickle constructed from `Examples` will point to the example row. + */ + public Optional getLocation() { + return Optional.ofNullable(location); + } + @Override public boolean equals(Object o) { if (this == o) return true; @@ -117,7 +127,8 @@ public boolean equals(Object o) { language.equals(that.language) && steps.equals(that.steps) && tags.equals(that.tags) && - astNodeIds.equals(that.astNodeIds); + astNodeIds.equals(that.astNodeIds) && + Objects.equals(location, that.location); } @Override @@ -129,7 +140,8 @@ public int hashCode() { language, steps, tags, - astNodeIds + astNodeIds, + location ); } @@ -143,6 +155,7 @@ public String toString() { ", steps=" + steps + ", tags=" + tags + ", astNodeIds=" + astNodeIds + + ", location=" + location + '}'; } } diff --git a/javascript/src/messages.ts b/javascript/src/messages.ts index e79c3a98..170d74e9 100644 --- a/javascript/src/messages.ts +++ b/javascript/src/messages.ts @@ -429,6 +429,9 @@ export class Pickle { tags: readonly PickleTag[] = [] astNodeIds: readonly string[] = [] + + @Type(() => Location) + location?: Location } export class PickleDocString { diff --git a/jsonschema/messages.md b/jsonschema/messages.md index 2a455533..de5844ca 100644 --- a/jsonschema/messages.md +++ b/jsonschema/messages.md @@ -282,6 +282,7 @@ will only have one of its fields set, which indicates the payload of the message | `steps` | [PickleStep](#picklestep)[] | yes | | | `tags` | [PickleTag](#pickletag)[] | yes | | | `astNodeIds` | string[] | yes | | +| `location` | [Location](#location) | no | | ## PickleDocString diff --git a/jsonschema/src/Pickle.json b/jsonschema/src/Pickle.json index 10877afe..20a0fb13 100644 --- a/jsonschema/src/Pickle.json +++ b/jsonschema/src/Pickle.json @@ -185,6 +185,10 @@ }, "type": "array", "minItems": 1 + }, + "location": { + "description": "The location of this pickle in source file. A pickle constructed from `Examples` will point to the example row.", + "$ref": "./Location.json" } }, "type": "object" diff --git a/perl/lib/Cucumber/Messages.pm b/perl/lib/Cucumber/Messages.pm index 8b6ca712..1abb0f3a 100644 --- a/perl/lib/Cucumber/Messages.pm +++ b/perl/lib/Cucumber/Messages.pm @@ -2737,6 +2737,7 @@ my %types = ( steps => '[]Cucumber::Messages::PickleStep', tags => '[]Cucumber::Messages::PickleTag', ast_node_ids => '[]string', + location => 'Cucumber::Messages::Location', ); # This is a work-around for the fact that Moo doesn't have introspection @@ -2837,6 +2838,16 @@ has ast_node_ids => ); +=head4 location + +The location of this pickle in source file. A pickle constructed from `Examples` will point to the example row. +=cut + +has location => + (is => 'ro', + ); + + } package Cucumber::Messages::PickleDocString { diff --git a/php/src-generated/Pickle.php b/php/src-generated/Pickle.php index 8f51f607..d5d9c041 100644 --- a/php/src-generated/Pickle.php +++ b/php/src-generated/Pickle.php @@ -77,6 +77,11 @@ public function __construct( * id originating from the `Scenario` AST node, and the second from the `TableRow` AST node. */ public readonly array $astNodeIds = [], + + /** + * The location of this pickle in source file. A pickle constructed from `Examples` will point to the example row. + */ + public readonly ?Location $location = null, ) { } @@ -94,6 +99,7 @@ public static function fromArray(array $arr): self self::ensureSteps($arr); self::ensureTags($arr); self::ensureAstNodeIds($arr); + self::ensureLocation($arr); return new self( (string) $arr['id'], @@ -103,6 +109,7 @@ public static function fromArray(array $arr): self array_values(array_map(fn (array $member) => PickleStep::fromArray($member), $arr['steps'])), array_values(array_map(fn (array $member) => PickleTag::fromArray($member), $arr['tags'])), array_values(array_map(fn (mixed $member) => (string) $member, $arr['astNodeIds'])), + isset($arr['location']) ? Location::fromArray($arr['location']) : null, ); } @@ -196,4 +203,14 @@ private static function ensureAstNodeIds(array $arr): void throw new SchemaViolationException('Property \'astNodeIds\' was not array'); } } + + /** + * @psalm-assert array{location?: array} $arr + */ + private static function ensureLocation(array $arr): void + { + if (array_key_exists('location', $arr) && !is_array($arr['location'])) { + throw new SchemaViolationException('Property \'location\' was not array'); + } + } } diff --git a/python/src/cucumber_messages/_messages.py b/python/src/cucumber_messages/_messages.py index 1e2ad28c..91b921c1 100644 --- a/python/src/cucumber_messages/_messages.py +++ b/python/src/cucumber_messages/_messages.py @@ -439,6 +439,7 @@ class Pickle: """ uri: str # The uri of the source file + location: Optional[Location] = None # The location of this pickle in source file. A pickle constructed from `Examples` will point to the example row. @dataclass diff --git a/ruby/lib/cucumber/messages/pickle.rb b/ruby/lib/cucumber/messages/pickle.rb index b8b54ea5..a471be94 100644 --- a/ruby/lib/cucumber/messages/pickle.rb +++ b/ruby/lib/cucumber/messages/pickle.rb @@ -63,6 +63,11 @@ class Pickle < Message ## attr_reader :ast_node_ids + ## + # The location of this pickle in source file. A pickle constructed from `Examples` will point to the example row. + ## + attr_reader :location + def initialize( id: '', uri: '', @@ -70,7 +75,8 @@ def initialize( language: '', steps: [], tags: [], - ast_node_ids: [] + ast_node_ids: [], + location: nil ) @id = id @uri = uri @@ -79,6 +85,7 @@ def initialize( @steps = steps @tags = tags @ast_node_ids = ast_node_ids + @location = location super() end @@ -99,7 +106,8 @@ def self.from_h(hash) language: hash[:language], steps: hash[:steps]&.map { |item| PickleStep.from_h(item) }, tags: hash[:tags]&.map { |item| PickleTag.from_h(item) }, - ast_node_ids: hash[:astNodeIds] + ast_node_ids: hash[:astNodeIds], + location: Location.from_h(hash[:location]) ) end end From 627b411d6474db10126a31cf52cd70deee10fbc4 Mon Sep 17 00:00:00 2001 From: "M.P. Korstanje" Date: Mon, 10 Nov 2025 16:13:46 +0100 Subject: [PATCH 2/4] Add location after uri. It is sort of the identity --- .../messages/cucumber/messages/pickle.hpp | 4 +-- .../lib/messages/cucumber/messages/pickle.cpp | 4 +-- dotnet/Cucumber.Messages/generated/Pickle.cs | 24 ++++++------- go/messages.go | 2 +- .../io/cucumber/messages/types/Pickle.java | 32 ++++++++--------- javascript/src/messages.ts | 6 ++-- jsonschema/messages.md | 2 +- jsonschema/src/Pickle.json | 8 ++--- perl/lib/Cucumber/Messages.pm | 22 ++++++------ php/src-generated/Pickle.php | 34 +++++++++---------- ruby/lib/cucumber/messages/pickle.rb | 20 +++++------ 11 files changed, 79 insertions(+), 79 deletions(-) diff --git a/cpp/include/messages/cucumber/messages/pickle.hpp b/cpp/include/messages/cucumber/messages/pickle.hpp index 3eae05c5..8543f414 100644 --- a/cpp/include/messages/cucumber/messages/pickle.hpp +++ b/cpp/include/messages/cucumber/messages/pickle.hpp @@ -6,9 +6,9 @@ #include +#include #include #include -#include namespace cucumber::messages { @@ -37,12 +37,12 @@ struct pickle { std::string id; std::string uri; + std::optional location; std::string name; std::string language; std::vector steps; std::vector tags; std::vector ast_node_ids; - std::optional location; std::string to_string() const; diff --git a/cpp/src/lib/messages/cucumber/messages/pickle.cpp b/cpp/src/lib/messages/cucumber/messages/pickle.cpp index 5dd05bcb..85f39d00 100644 --- a/cpp/src/lib/messages/cucumber/messages/pickle.cpp +++ b/cpp/src/lib/messages/cucumber/messages/pickle.cpp @@ -12,12 +12,12 @@ pickle::to_string() const cucumber::messages::to_string(oss, "id=", id); cucumber::messages::to_string(oss, ", uri=", uri); + cucumber::messages::to_string(oss, ", location=", location); cucumber::messages::to_string(oss, ", name=", name); cucumber::messages::to_string(oss, ", language=", language); cucumber::messages::to_string(oss, ", steps=", steps); cucumber::messages::to_string(oss, ", tags=", tags); cucumber::messages::to_string(oss, ", ast_node_ids=", ast_node_ids); - cucumber::messages::to_string(oss, ", location=", location); return oss.str(); } @@ -27,12 +27,12 @@ pickle::to_json(json& j) const { cucumber::messages::to_json(j, camelize("id"), id); cucumber::messages::to_json(j, camelize("uri"), uri); + cucumber::messages::to_json(j, camelize("location"), location); cucumber::messages::to_json(j, camelize("name"), name); cucumber::messages::to_json(j, camelize("language"), language); cucumber::messages::to_json(j, camelize("steps"), steps); cucumber::messages::to_json(j, camelize("tags"), tags); cucumber::messages::to_json(j, camelize("ast_node_ids"), ast_node_ids); - cucumber::messages::to_json(j, camelize("location"), location); } std::string diff --git a/dotnet/Cucumber.Messages/generated/Pickle.cs b/dotnet/Cucumber.Messages/generated/Pickle.cs index 352db6c8..473bfd13 100644 --- a/dotnet/Cucumber.Messages/generated/Pickle.cs +++ b/dotnet/Cucumber.Messages/generated/Pickle.cs @@ -37,6 +37,10 @@ public sealed class Pickle * The uri of the source file */ public string Uri { get; private set; } + /** + * The location of this pickle in source file. A pickle constructed from `Examples` will point to the example row. + */ + public Location Location { get; private set; } /** * The name of the pickle */ @@ -60,27 +64,24 @@ public sealed class Pickle * id originating from the `Scenario` AST node, and the second from the `TableRow` AST node. */ public List AstNodeIds { get; private set; } - /** - * The location of this pickle in source file. A pickle constructed from `Examples` will point to the example row. - */ - public Location Location { get; private set; } public Pickle( string id, string uri, + Location location, string name, string language, List steps, List tags, - List astNodeIds, - Location location + List astNodeIds ) { RequireNonNull(id, "Id", "Pickle.Id cannot be null"); this.Id = id; RequireNonNull(uri, "Uri", "Pickle.Uri cannot be null"); this.Uri = uri; + this.Location = location; RequireNonNull(name, "Name", "Pickle.Name cannot be null"); this.Name = name; RequireNonNull(language, "Language", "Pickle.Language cannot be null"); @@ -91,7 +92,6 @@ Location location this.Tags = new List(tags); RequireNonNull>(astNodeIds, "AstNodeIds", "Pickle.AstNodeIds cannot be null"); this.AstNodeIds = new List(astNodeIds); - this.Location = location; } public override bool Equals(Object o) @@ -102,12 +102,12 @@ public override bool Equals(Object o) return Id.Equals(that.Id) && Uri.Equals(that.Uri) && + Object.Equals(Location, that.Location) && Name.Equals(that.Name) && Language.Equals(that.Language) && Steps.Equals(that.Steps) && Tags.Equals(that.Tags) && - AstNodeIds.Equals(that.AstNodeIds) && - Object.Equals(Location, that.Location); + AstNodeIds.Equals(that.AstNodeIds); } public override int GetHashCode() @@ -117,6 +117,8 @@ public override int GetHashCode() hash = hash * 31 + Id.GetHashCode(); if (Uri != null) hash = hash * 31 + Uri.GetHashCode(); + if (Location != null) + hash = hash * 31 + Location.GetHashCode(); if (Name != null) hash = hash * 31 + Name.GetHashCode(); if (Language != null) @@ -127,8 +129,6 @@ public override int GetHashCode() hash = hash * 31 + Tags.GetHashCode(); if (AstNodeIds != null) hash = hash * 31 + AstNodeIds.GetHashCode(); - if (Location != null) - hash = hash * 31 + Location.GetHashCode(); return hash; } @@ -137,12 +137,12 @@ public override string ToString() return "Pickle{" + "id=" + Id + ", uri=" + Uri + + ", location=" + Location + ", name=" + Name + ", language=" + Language + ", steps=" + Steps + ", tags=" + Tags + ", astNodeIds=" + AstNodeIds + - ", location=" + Location + '}'; } diff --git a/go/messages.go b/go/messages.go index c4a0e79c..805985d3 100644 --- a/go/messages.go +++ b/go/messages.go @@ -217,12 +217,12 @@ type ParseError struct { type Pickle struct { Id string `json:"id"` Uri string `json:"uri"` + Location *Location `json:"location,omitempty"` Name string `json:"name"` Language string `json:"language"` Steps []*PickleStep `json:"steps"` Tags []*PickleTag `json:"tags"` AstNodeIds []string `json:"astNodeIds"` - Location *Location `json:"location,omitempty"` } type PickleDocString struct { diff --git a/java/src/generated/java/io/cucumber/messages/types/Pickle.java b/java/src/generated/java/io/cucumber/messages/types/Pickle.java index 3a8772dc..0e26e8f8 100644 --- a/java/src/generated/java/io/cucumber/messages/types/Pickle.java +++ b/java/src/generated/java/io/cucumber/messages/types/Pickle.java @@ -29,31 +29,31 @@ public final class Pickle { private final String id; private final String uri; + private final Location location; private final String name; private final String language; private final java.util.List steps; private final java.util.List tags; private final java.util.List astNodeIds; - private final Location location; public Pickle( String id, String uri, + Location location, String name, String language, java.util.List steps, java.util.List tags, - java.util.List astNodeIds, - Location location + java.util.List astNodeIds ) { this.id = requireNonNull(id, "Pickle.id cannot be null"); this.uri = requireNonNull(uri, "Pickle.uri cannot be null"); + this.location = location; this.name = requireNonNull(name, "Pickle.name cannot be null"); this.language = requireNonNull(language, "Pickle.language cannot be null"); this.steps = unmodifiableList(new ArrayList<>(requireNonNull(steps, "Pickle.steps cannot be null"))); this.tags = unmodifiableList(new ArrayList<>(requireNonNull(tags, "Pickle.tags cannot be null"))); this.astNodeIds = unmodifiableList(new ArrayList<>(requireNonNull(astNodeIds, "Pickle.astNodeIds cannot be null"))); - this.location = location; } /** @@ -70,6 +70,13 @@ public String getUri() { return uri; } + /** + * The location of this pickle in source file. A pickle constructed from `Examples` will point to the example row. + */ + public Optional getLocation() { + return Optional.ofNullable(location); + } + /** * The name of the pickle */ @@ -108,13 +115,6 @@ public java.util.List getAstNodeIds() { return astNodeIds; } - /** - * The location of this pickle in source file. A pickle constructed from `Examples` will point to the example row. - */ - public Optional getLocation() { - return Optional.ofNullable(location); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -123,12 +123,12 @@ public boolean equals(Object o) { return id.equals(that.id) && uri.equals(that.uri) && + Objects.equals(location, that.location) && name.equals(that.name) && language.equals(that.language) && steps.equals(that.steps) && tags.equals(that.tags) && - astNodeIds.equals(that.astNodeIds) && - Objects.equals(location, that.location); + astNodeIds.equals(that.astNodeIds); } @Override @@ -136,12 +136,12 @@ public int hashCode() { return Objects.hash( id, uri, + location, name, language, steps, tags, - astNodeIds, - location + astNodeIds ); } @@ -150,12 +150,12 @@ public String toString() { return "Pickle{" + "id=" + id + ", uri=" + uri + + ", location=" + location + ", name=" + name + ", language=" + language + ", steps=" + steps + ", tags=" + tags + ", astNodeIds=" + astNodeIds + - ", location=" + location + '}'; } } diff --git a/javascript/src/messages.ts b/javascript/src/messages.ts index 170d74e9..b57eba03 100644 --- a/javascript/src/messages.ts +++ b/javascript/src/messages.ts @@ -418,6 +418,9 @@ export class Pickle { uri: string = '' + @Type(() => Location) + location?: Location + name: string = '' language: string = '' @@ -429,9 +432,6 @@ export class Pickle { tags: readonly PickleTag[] = [] astNodeIds: readonly string[] = [] - - @Type(() => Location) - location?: Location } export class PickleDocString { diff --git a/jsonschema/messages.md b/jsonschema/messages.md index de5844ca..e3627c3c 100644 --- a/jsonschema/messages.md +++ b/jsonschema/messages.md @@ -277,12 +277,12 @@ will only have one of its fields set, which indicates the payload of the message | ----- | ---- | ----------- | ----------- | | `id` | string | yes | | | `uri` | string | yes | | +| `location` | [Location](#location) | no | | | `name` | string | yes | | | `language` | string | yes | | | `steps` | [PickleStep](#picklestep)[] | yes | | | `tags` | [PickleTag](#pickletag)[] | yes | | | `astNodeIds` | string[] | yes | | -| `location` | [Location](#location) | no | | ## PickleDocString diff --git a/jsonschema/src/Pickle.json b/jsonschema/src/Pickle.json index 20a0fb13..ae910eeb 100644 --- a/jsonschema/src/Pickle.json +++ b/jsonschema/src/Pickle.json @@ -156,6 +156,10 @@ "description": "The uri of the source file", "type": "string" }, + "location": { + "description": "The location of this pickle in source file. A pickle constructed from `Examples` will point to the example row.", + "$ref": "./Location.json" + }, "name": { "description": "The name of the pickle", "type": "string" @@ -185,10 +189,6 @@ }, "type": "array", "minItems": 1 - }, - "location": { - "description": "The location of this pickle in source file. A pickle constructed from `Examples` will point to the example row.", - "$ref": "./Location.json" } }, "type": "object" diff --git a/perl/lib/Cucumber/Messages.pm b/perl/lib/Cucumber/Messages.pm index 1abb0f3a..cc1403ee 100644 --- a/perl/lib/Cucumber/Messages.pm +++ b/perl/lib/Cucumber/Messages.pm @@ -2732,12 +2732,12 @@ use Scalar::Util qw( blessed ); my %types = ( id => 'string', uri => 'string', + location => 'Cucumber::Messages::Location', name => 'string', language => 'string', steps => '[]Cucumber::Messages::PickleStep', tags => '[]Cucumber::Messages::PickleTag', ast_node_ids => '[]string', - location => 'Cucumber::Messages::Location', ); # This is a work-around for the fact that Moo doesn't have introspection @@ -2773,6 +2773,16 @@ has uri => ); +=head4 location + +The location of this pickle in source file. A pickle constructed from `Examples` will point to the example row. +=cut + +has location => + (is => 'ro', + ); + + =head4 name The name of the pickle @@ -2838,16 +2848,6 @@ has ast_node_ids => ); -=head4 location - -The location of this pickle in source file. A pickle constructed from `Examples` will point to the example row. -=cut - -has location => - (is => 'ro', - ); - - } package Cucumber::Messages::PickleDocString { diff --git a/php/src-generated/Pickle.php b/php/src-generated/Pickle.php index d5d9c041..1f238684 100644 --- a/php/src-generated/Pickle.php +++ b/php/src-generated/Pickle.php @@ -50,6 +50,11 @@ public function __construct( */ public readonly string $uri = '', + /** + * The location of this pickle in source file. A pickle constructed from `Examples` will point to the example row. + */ + public readonly ?Location $location = null, + /** * The name of the pickle */ @@ -77,11 +82,6 @@ public function __construct( * id originating from the `Scenario` AST node, and the second from the `TableRow` AST node. */ public readonly array $astNodeIds = [], - - /** - * The location of this pickle in source file. A pickle constructed from `Examples` will point to the example row. - */ - public readonly ?Location $location = null, ) { } @@ -94,22 +94,22 @@ public static function fromArray(array $arr): self { self::ensureId($arr); self::ensureUri($arr); + self::ensureLocation($arr); self::ensureName($arr); self::ensureLanguage($arr); self::ensureSteps($arr); self::ensureTags($arr); self::ensureAstNodeIds($arr); - self::ensureLocation($arr); return new self( (string) $arr['id'], (string) $arr['uri'], + isset($arr['location']) ? Location::fromArray($arr['location']) : null, (string) $arr['name'], (string) $arr['language'], array_values(array_map(fn (array $member) => PickleStep::fromArray($member), $arr['steps'])), array_values(array_map(fn (array $member) => PickleTag::fromArray($member), $arr['tags'])), array_values(array_map(fn (mixed $member) => (string) $member, $arr['astNodeIds'])), - isset($arr['location']) ? Location::fromArray($arr['location']) : null, ); } @@ -139,6 +139,16 @@ private static function ensureUri(array $arr): void } } + /** + * @psalm-assert array{location?: array} $arr + */ + private static function ensureLocation(array $arr): void + { + if (array_key_exists('location', $arr) && !is_array($arr['location'])) { + throw new SchemaViolationException('Property \'location\' was not array'); + } + } + /** * @psalm-assert array{name: string|int|bool} $arr */ @@ -203,14 +213,4 @@ private static function ensureAstNodeIds(array $arr): void throw new SchemaViolationException('Property \'astNodeIds\' was not array'); } } - - /** - * @psalm-assert array{location?: array} $arr - */ - private static function ensureLocation(array $arr): void - { - if (array_key_exists('location', $arr) && !is_array($arr['location'])) { - throw new SchemaViolationException('Property \'location\' was not array'); - } - } } diff --git a/ruby/lib/cucumber/messages/pickle.rb b/ruby/lib/cucumber/messages/pickle.rb index a471be94..6aa075fb 100644 --- a/ruby/lib/cucumber/messages/pickle.rb +++ b/ruby/lib/cucumber/messages/pickle.rb @@ -33,6 +33,11 @@ class Pickle < Message ## attr_reader :uri + ## + # The location of this pickle in source file. A pickle constructed from `Examples` will point to the example row. + ## + attr_reader :location + ## # The name of the pickle ## @@ -63,29 +68,24 @@ class Pickle < Message ## attr_reader :ast_node_ids - ## - # The location of this pickle in source file. A pickle constructed from `Examples` will point to the example row. - ## - attr_reader :location - def initialize( id: '', uri: '', + location: nil, name: '', language: '', steps: [], tags: [], - ast_node_ids: [], - location: nil + ast_node_ids: [] ) @id = id @uri = uri + @location = location @name = name @language = language @steps = steps @tags = tags @ast_node_ids = ast_node_ids - @location = location super() end @@ -102,12 +102,12 @@ def self.from_h(hash) new( id: hash[:id], uri: hash[:uri], + location: Location.from_h(hash[:location]), name: hash[:name], language: hash[:language], steps: hash[:steps]&.map { |item| PickleStep.from_h(item) }, tags: hash[:tags]&.map { |item| PickleTag.from_h(item) }, - ast_node_ids: hash[:astNodeIds], - location: Location.from_h(hash[:location]) + ast_node_ids: hash[:astNodeIds] ) end end From fe2804d630624a2e389b4d30715e42a366fbc296 Mon Sep 17 00:00:00 2001 From: David Goss Date: Tue, 18 Nov 2025 16:50:25 +0000 Subject: [PATCH 3/4] regenerate code --- jsonschema/messages.md | 7 +++++++ jsonschema/relations.md | 1 + 2 files changed, 8 insertions(+) diff --git a/jsonschema/messages.md b/jsonschema/messages.md index bd278929..59f1ff6b 100644 --- a/jsonschema/messages.md +++ b/jsonschema/messages.md @@ -1120,6 +1120,13 @@ A unique id for the pickle The uri of the source file +#### Pickle.location + +* Type: [Location](#location) +* Required: no + +The location of this pickle in source file. A pickle constructed from `Examples` will point to the example row. + #### Pickle.name * Type: string diff --git a/jsonschema/relations.md b/jsonschema/relations.md index 06e51abc..28a9f18f 100644 --- a/jsonschema/relations.md +++ b/jsonschema/relations.md @@ -95,6 +95,7 @@ Meta ||..o| Ci: "has a" Ci ||..o| Git: "has a" ParameterType ||..o| SourceReference: "has a" ParseError ||..|| SourceReference: "has a" +Pickle ||..o| Location: "has a" Pickle ||..|{ PickleStep: "has" Pickle ||..|{ PickleTag: "has" PickleStep ||..o| PickleStepArgument: "has a" From 83cbcaad308e9569c02937672563d8f911b138b7 Mon Sep 17 00:00:00 2001 From: David Goss Date: Tue, 18 Nov 2025 16:54:14 +0000 Subject: [PATCH 4/4] update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 68dd344b..e95d3bb8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +### Added +- Add `location` to `Pickle` ([#308](https://github.com/cucumber/messages/pull/308)) ## [30.1.0] - 2025-10-08 ### Added