Skip to content

Commit c7fed7b

Browse files
Add location to pickle (#308)
Co-authored-by: David Goss <david@davidgoss.co>
1 parent 5b62d41 commit c7fed7b

File tree

14 files changed

+82
-0
lines changed

14 files changed

+82
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
9+
### Added
10+
- Add `location` to `Pickle` ([#308](https://github.com/cucumber/messages/pull/308))
911

1012
## [30.1.0] - 2025-10-08
1113
### Added

cpp/include/messages/cucumber/messages/pickle.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include <nlohmann/json.hpp>
88

9+
#include <cucumber/messages/location.hpp>
910
#include <cucumber/messages/pickle_step.hpp>
1011
#include <cucumber/messages/pickle_tag.hpp>
1112

@@ -34,6 +35,7 @@ struct pickle
3435
{
3536
std::string id;
3637
std::string uri;
38+
std::optional<cucumber::messages::location> location;
3739
std::string name;
3840
std::string language;
3941
std::vector<cucumber::messages::pickle_step> steps;

cpp/src/lib/messages/cucumber/messages/pickle.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ pickle::to_string() const
1212

1313
cucumber::messages::to_string(oss, "id=", id);
1414
cucumber::messages::to_string(oss, ", uri=", uri);
15+
cucumber::messages::to_string(oss, ", location=", location);
1516
cucumber::messages::to_string(oss, ", name=", name);
1617
cucumber::messages::to_string(oss, ", language=", language);
1718
cucumber::messages::to_string(oss, ", steps=", steps);
@@ -26,6 +27,7 @@ pickle::to_json(json& j) const
2627
{
2728
cucumber::messages::to_json(j, camelize("id"), id);
2829
cucumber::messages::to_json(j, camelize("uri"), uri);
30+
cucumber::messages::to_json(j, camelize("location"), location);
2931
cucumber::messages::to_json(j, camelize("name"), name);
3032
cucumber::messages::to_json(j, camelize("language"), language);
3133
cucumber::messages::to_json(j, camelize("steps"), steps);

dotnet/Cucumber.Messages/generated/Pickle.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ public sealed class Pickle
3535
* The uri of the source file
3636
*/
3737
public string Uri { get; private set; }
38+
/**
39+
* The location of this pickle in source file. A pickle constructed from `Examples` will point to the example row.
40+
*/
41+
public Location Location { get; private set; }
3842
/**
3943
* The name of the pickle
4044
*/
@@ -63,6 +67,7 @@ public sealed class Pickle
6367
public Pickle(
6468
string id,
6569
string uri,
70+
Location location,
6671
string name,
6772
string language,
6873
List<PickleStep> steps,
@@ -74,6 +79,7 @@ List<string> astNodeIds
7479
this.Id = id;
7580
RequireNonNull<string>(uri, "Uri", "Pickle.Uri cannot be null");
7681
this.Uri = uri;
82+
this.Location = location;
7783
RequireNonNull<string>(name, "Name", "Pickle.Name cannot be null");
7884
this.Name = name;
7985
RequireNonNull<string>(language, "Language", "Pickle.Language cannot be null");
@@ -94,6 +100,7 @@ public override bool Equals(Object o)
94100
return
95101
Id.Equals(that.Id) &&
96102
Uri.Equals(that.Uri) &&
103+
Object.Equals(Location, that.Location) &&
97104
Name.Equals(that.Name) &&
98105
Language.Equals(that.Language) &&
99106
Steps.Equals(that.Steps) &&
@@ -108,6 +115,8 @@ public override int GetHashCode()
108115
hash = hash * 31 + Id.GetHashCode();
109116
if (Uri != null)
110117
hash = hash * 31 + Uri.GetHashCode();
118+
if (Location != null)
119+
hash = hash * 31 + Location.GetHashCode();
111120
if (Name != null)
112121
hash = hash * 31 + Name.GetHashCode();
113122
if (Language != null)
@@ -126,6 +135,7 @@ public override string ToString()
126135
return "Pickle{" +
127136
"id=" + Id +
128137
", uri=" + Uri +
138+
", location=" + Location +
129139
", name=" + Name +
130140
", language=" + Language +
131141
", steps=" + Steps +

go/messages.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ type ParseError struct {
218218
type Pickle struct {
219219
Id string `json:"id"`
220220
Uri string `json:"uri"`
221+
Location *Location `json:"location,omitempty"`
221222
Name string `json:"name"`
222223
Language string `json:"language"`
223224
Steps []*PickleStep `json:"steps"`

java/src/generated/java/io/cucumber/messages/types/Pickle.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
public final class Pickle {
2727
private final String id;
2828
private final String uri;
29+
private final Location location;
2930
private final String name;
3031
private final String language;
3132
private final java.util.List<PickleStep> steps;
@@ -35,6 +36,7 @@ public final class Pickle {
3536
public Pickle(
3637
String id,
3738
String uri,
39+
Location location,
3840
String name,
3941
String language,
4042
java.util.List<PickleStep> steps,
@@ -43,6 +45,7 @@ public Pickle(
4345
) {
4446
this.id = requireNonNull(id, "Pickle.id cannot be null");
4547
this.uri = requireNonNull(uri, "Pickle.uri cannot be null");
48+
this.location = location;
4649
this.name = requireNonNull(name, "Pickle.name cannot be null");
4750
this.language = requireNonNull(language, "Pickle.language cannot be null");
4851
this.steps = unmodifiableList(new ArrayList<>(requireNonNull(steps, "Pickle.steps cannot be null")));
@@ -64,6 +67,13 @@ public String getUri() {
6467
return uri;
6568
}
6669

70+
/**
71+
* The location of this pickle in source file. A pickle constructed from `Examples` will point to the example row.
72+
*/
73+
public Optional<Location> getLocation() {
74+
return Optional.ofNullable(location);
75+
}
76+
6777
/**
6878
* The name of the pickle
6979
*/
@@ -110,6 +120,7 @@ public boolean equals(Object o) {
110120
return
111121
id.equals(that.id) &&
112122
uri.equals(that.uri) &&
123+
Objects.equals(location, that.location) &&
113124
name.equals(that.name) &&
114125
language.equals(that.language) &&
115126
steps.equals(that.steps) &&
@@ -122,6 +133,7 @@ public int hashCode() {
122133
return Objects.hash(
123134
id,
124135
uri,
136+
location,
125137
name,
126138
language,
127139
steps,
@@ -135,6 +147,7 @@ public String toString() {
135147
return "Pickle{" +
136148
"id=" + id +
137149
", uri=" + uri +
150+
", location=" + location +
138151
", name=" + name +
139152
", language=" + language +
140153
", steps=" + steps +

javascript/src/messages.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,9 @@ export class Pickle {
421421

422422
uri: string = ''
423423

424+
@Type(() => Location)
425+
location?: Location
426+
424427
name: string = ''
425428

426429
language: string = ''

jsonschema/messages.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,6 +1120,13 @@ A unique id for the pickle
11201120

11211121
The uri of the source file
11221122

1123+
#### Pickle.location
1124+
1125+
* Type: [Location](#location)
1126+
* Required: no
1127+
1128+
The location of this pickle in source file. A pickle constructed from `Examples` will point to the example row.
1129+
11231130
#### Pickle.name
11241131

11251132
* Type: string

jsonschema/relations.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ Meta ||..o| Ci: "has a"
9595
Ci ||..o| Git: "has a"
9696
ParameterType ||..o| SourceReference: "has a"
9797
ParseError ||..|| SourceReference: "has a"
98+
Pickle ||..o| Location: "has a"
9899
Pickle ||..|{ PickleStep: "has"
99100
Pickle ||..|{ PickleTag: "has"
100101
PickleStep ||..o| PickleStepArgument: "has a"

jsonschema/src/Pickle.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,10 @@
156156
"description": "The uri of the source file",
157157
"type": "string"
158158
},
159+
"location": {
160+
"description": "The location of this pickle in source file. A pickle constructed from `Examples` will point to the example row.",
161+
"$ref": "./Location.json"
162+
},
159163
"name": {
160164
"description": "The name of the pickle",
161165
"type": "string"

0 commit comments

Comments
 (0)