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