1
1
package io .cucumber .junit .platform .engine ;
2
2
3
3
import io .cucumber .core .feature .FeatureWithLines ;
4
- import io .cucumber .core .gherkin .Feature ;
5
4
import io .cucumber .plugin .event .Node ;
6
5
import org .junit .platform .commons .util .ToStringBuilder ;
7
6
import org .junit .platform .engine .DiscoveryIssue ;
@@ -44,7 +43,7 @@ static FeatureWithLinesSelector from(FeatureWithLines featureWithLines) {
44
43
static Set <FeatureWithLinesSelector > from (UniqueId uniqueId ) {
45
44
return uniqueId .getSegments ()
46
45
.stream ()
47
- .filter (FeatureOrigin ::isFeatureSegment )
46
+ .filter (CucumberTestDescriptor ::isFeatureSegment )
48
47
.map (featureSegment -> {
49
48
URI uri = URI .create (featureSegment .getValue ());
50
49
Set <FilePosition > filePosition = getFilePosition (uniqueId .getLastSegment ());
@@ -69,7 +68,7 @@ private static URI stripQuery(URI uri) {
69
68
}
70
69
71
70
private static Set <FilePosition > getFilePosition (UniqueId .Segment segment ) {
72
- if (FeatureOrigin .isFeatureSegment (segment )) {
71
+ if (CucumberTestDescriptor .isFeatureSegment (segment )) {
73
72
return Collections .emptySet ();
74
73
}
75
74
@@ -111,28 +110,28 @@ public String toString() {
111
110
112
111
static class FeatureElementSelector implements DiscoverySelector {
113
112
114
- private final Feature feature ;
113
+ private final FeatureWithSource feature ;
115
114
private final Node element ;
116
115
117
- private FeatureElementSelector (Feature feature ) {
118
- this (feature , feature );
116
+ private FeatureElementSelector (FeatureWithSource feature ) {
117
+ this (feature , feature . getFeature () );
119
118
}
120
119
121
- private FeatureElementSelector (Feature feature , Node element ) {
120
+ private FeatureElementSelector (FeatureWithSource feature , Node element ) {
122
121
this .feature = requireNonNull (feature );
123
122
this .element = requireNonNull (element );
124
123
}
125
124
126
- static FeatureElementSelector selectFeature (Feature feature ) {
125
+ static FeatureElementSelector selectFeature (FeatureWithSource feature ) {
127
126
return new FeatureElementSelector (feature );
128
127
}
129
128
130
- static FeatureElementSelector selectElement (Feature feature , Node element ) {
129
+ static FeatureElementSelector selectElement (FeatureWithSource feature , Node element ) {
131
130
return new FeatureElementSelector (feature , element );
132
131
}
133
132
134
133
static Stream <FeatureElementSelector > selectElementsAt (
135
- Feature feature , Supplier <Optional <Set <FilePosition >>> filePositions ,
134
+ FeatureWithSource feature , Supplier <Optional <Set <FilePosition >>> filePositions ,
136
135
DiscoveryIssueReporter issueReporter
137
136
) {
138
137
return filePositions .get ()
@@ -141,23 +140,25 @@ static Stream<FeatureElementSelector> selectElementsAt(
141
140
}
142
141
143
142
private static Stream <FeatureElementSelector > selectElementsAt (
144
- Feature feature , Set <FilePosition > filePositions , DiscoveryIssueReporter issueReporter
143
+ FeatureWithSource feature , Set <FilePosition > filePositions , DiscoveryIssueReporter issueReporter
145
144
) {
146
145
return filePositions .stream ().map (filePosition -> selectElementAt (feature , filePosition , issueReporter ));
147
146
}
148
147
149
148
static FeatureElementSelector selectElementAt (
150
- Feature feature , Supplier <Optional <FilePosition >> filePosition , DiscoveryIssueReporter issueReporter
149
+ FeatureWithSource feature , Supplier <Optional <FilePosition >> filePosition ,
150
+ DiscoveryIssueReporter issueReporter
151
151
) {
152
152
return filePosition .get ()
153
153
.map (position -> selectElementAt (feature , position , issueReporter ))
154
154
.orElseGet (() -> selectFeature (feature ));
155
155
}
156
156
157
157
static FeatureElementSelector selectElementAt (
158
- Feature feature , FilePosition filePosition , DiscoveryIssueReporter issueReporter
158
+ FeatureWithSource feature , FilePosition filePosition , DiscoveryIssueReporter issueReporter
159
159
) {
160
- return feature .findPathTo (candidate -> candidate .getLocation ().getLine () == filePosition .getLine ())
160
+ return feature .getFeature ()
161
+ .findPathTo (candidate -> candidate .getLocation ().getLine () == filePosition .getLine ())
161
162
.map (nodes -> nodes .get (nodes .size () - 1 ))
162
163
.map (node -> new FeatureElementSelector (feature , node ))
163
164
.orElseGet (() -> {
@@ -167,7 +168,7 @@ static FeatureElementSelector selectElementAt(
167
168
}
168
169
169
170
private static void reportInvalidFilePosition (
170
- Feature feature , FilePosition filePosition , DiscoveryIssueReporter issueReporter
171
+ FeatureWithSource feature , FilePosition filePosition , DiscoveryIssueReporter issueReporter
171
172
) {
172
173
issueReporter .reportIssue (DiscoveryIssue .create (WARNING ,
173
174
"Feature file " + feature .getUri ()
@@ -176,7 +177,7 @@ private static void reportInvalidFilePosition(
176
177
". Selecting the whole feature instead" ));
177
178
}
178
179
179
- static Set <FeatureElementSelector > selectElementsOf (Feature feature , Node selected ) {
180
+ static Set <FeatureElementSelector > selectElementsOf (FeatureWithSource feature , Node selected ) {
180
181
if (selected instanceof Node .Container ) {
181
182
Node .Container <?> container = (Node .Container <?>) selected ;
182
183
return container .elements ().stream ()
@@ -186,7 +187,7 @@ static Set<FeatureElementSelector> selectElementsOf(Feature feature, Node select
186
187
return Collections .emptySet ();
187
188
}
188
189
189
- Feature getFeature () {
190
+ FeatureWithSource getFeature () {
190
191
return feature ;
191
192
}
192
193
0 commit comments