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 diff --git a/cpp/include/messages/cucumber/messages/pickle.hpp b/cpp/include/messages/cucumber/messages/pickle.hpp index 81776aab..28d1d07c 100644 --- a/cpp/include/messages/cucumber/messages/pickle.hpp +++ b/cpp/include/messages/cucumber/messages/pickle.hpp @@ -6,6 +6,7 @@ #include +#include #include #include @@ -34,6 +35,7 @@ struct pickle { std::string id; std::string uri; + std::optional location; std::string name; std::string language; std::vector steps; diff --git a/cpp/src/lib/messages/cucumber/messages/pickle.cpp b/cpp/src/lib/messages/cucumber/messages/pickle.cpp index e8fd1896..85f39d00 100644 --- a/cpp/src/lib/messages/cucumber/messages/pickle.cpp +++ b/cpp/src/lib/messages/cucumber/messages/pickle.cpp @@ -12,6 +12,7 @@ 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); @@ -26,6 +27,7 @@ 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); diff --git a/dotnet/Cucumber.Messages/generated/Pickle.cs b/dotnet/Cucumber.Messages/generated/Pickle.cs index 7373bbf9..9e5dcffc 100644 --- a/dotnet/Cucumber.Messages/generated/Pickle.cs +++ b/dotnet/Cucumber.Messages/generated/Pickle.cs @@ -35,6 +35,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 */ @@ -63,6 +67,7 @@ public sealed class Pickle public Pickle( string id, string uri, + Location location, string name, string language, List steps, @@ -74,6 +79,7 @@ List astNodeIds 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"); @@ -94,6 +100,7 @@ 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) && @@ -108,6 +115,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) @@ -126,6 +135,7 @@ public override string ToString() return "Pickle{" + "id=" + Id + ", uri=" + Uri + + ", location=" + Location + ", name=" + Name + ", language=" + Language + ", steps=" + Steps + diff --git a/go/messages.go b/go/messages.go index eb28b944..63423371 100644 --- a/go/messages.go +++ b/go/messages.go @@ -218,6 +218,7 @@ 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"` 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 84a20684..cf27df60 100644 --- a/java/src/generated/java/io/cucumber/messages/types/Pickle.java +++ b/java/src/generated/java/io/cucumber/messages/types/Pickle.java @@ -26,6 +26,7 @@ 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; @@ -35,6 +36,7 @@ public final class Pickle { public Pickle( String id, String uri, + Location location, String name, String language, java.util.List steps, @@ -43,6 +45,7 @@ public Pickle( ) { 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"))); @@ -64,6 +67,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 */ @@ -110,6 +120,7 @@ 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) && @@ -122,6 +133,7 @@ public int hashCode() { return Objects.hash( id, uri, + location, name, language, steps, @@ -135,6 +147,7 @@ public String toString() { return "Pickle{" + "id=" + id + ", uri=" + uri + + ", location=" + location + ", name=" + name + ", language=" + language + ", steps=" + steps + diff --git a/javascript/src/messages.ts b/javascript/src/messages.ts index 0288237e..17cb2046 100644 --- a/javascript/src/messages.ts +++ b/javascript/src/messages.ts @@ -421,6 +421,9 @@ export class Pickle { uri: string = '' + @Type(() => Location) + location?: Location + name: string = '' language: string = '' 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" diff --git a/jsonschema/src/Pickle.json b/jsonschema/src/Pickle.json index b31716b4..5824636d 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" diff --git a/perl/lib/Cucumber/Messages.pm b/perl/lib/Cucumber/Messages.pm index 1cbff56c..a9f04516 100644 --- a/perl/lib/Cucumber/Messages.pm +++ b/perl/lib/Cucumber/Messages.pm @@ -2719,6 +2719,7 @@ use Scalar::Util qw( blessed ); my %types = ( id => 'string', uri => 'string', + location => 'Cucumber::Messages::Location', name => 'string', language => 'string', steps => '[]Cucumber::Messages::PickleStep', @@ -2758,6 +2759,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 diff --git a/php/src-generated/Pickle.php b/php/src-generated/Pickle.php index 94a88571..466d0802 100644 --- a/php/src-generated/Pickle.php +++ b/php/src-generated/Pickle.php @@ -48,6 +48,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 */ @@ -87,6 +92,7 @@ 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); @@ -96,6 +102,7 @@ public static function fromArray(array $arr): self 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'])), @@ -130,6 +137,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 */ diff --git a/python/src/cucumber_messages/_messages.py b/python/src/cucumber_messages/_messages.py index be330f76..102833b0 100644 --- a/python/src/cucumber_messages/_messages.py +++ b/python/src/cucumber_messages/_messages.py @@ -398,6 +398,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 175f3b77..6d689e8d 100644 --- a/ruby/lib/cucumber/messages/pickle.rb +++ b/ruby/lib/cucumber/messages/pickle.rb @@ -29,6 +29,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 ## @@ -60,6 +65,7 @@ class Pickle < Message def initialize( id: '', uri: '', + location: nil, name: '', language: '', steps: [], @@ -68,6 +74,7 @@ def initialize( ) @id = id @uri = uri + @location = location @name = name @language = language @steps = steps @@ -89,6 +96,7 @@ 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) },