11package io .cucumber .junit .platform .engine ;
22
33import io .cucumber .core .feature .FeatureWithLines ;
4- import io .cucumber .core .gherkin .Feature ;
54import io .cucumber .plugin .event .Node ;
65import org .junit .platform .commons .util .ToStringBuilder ;
76import org .junit .platform .engine .DiscoveryIssue ;
@@ -44,7 +43,7 @@ static FeatureWithLinesSelector from(FeatureWithLines featureWithLines) {
4443 static Set <FeatureWithLinesSelector > from (UniqueId uniqueId ) {
4544 return uniqueId .getSegments ()
4645 .stream ()
47- .filter (FeatureOrigin ::isFeatureSegment )
46+ .filter (CucumberTestDescriptor ::isFeatureSegment )
4847 .map (featureSegment -> {
4948 URI uri = URI .create (featureSegment .getValue ());
5049 Set <FilePosition > filePosition = getFilePosition (uniqueId .getLastSegment ());
@@ -69,7 +68,7 @@ private static URI stripQuery(URI uri) {
6968 }
7069
7170 private static Set <FilePosition > getFilePosition (UniqueId .Segment segment ) {
72- if (FeatureOrigin .isFeatureSegment (segment )) {
71+ if (CucumberTestDescriptor .isFeatureSegment (segment )) {
7372 return Collections .emptySet ();
7473 }
7574
@@ -111,28 +110,28 @@ public String toString() {
111110
112111 static class FeatureElementSelector implements DiscoverySelector {
113112
114- private final Feature feature ;
113+ private final FeatureWithSource feature ;
115114 private final Node element ;
116115
117- private FeatureElementSelector (Feature feature ) {
118- this (feature , feature );
116+ private FeatureElementSelector (FeatureWithSource feature ) {
117+ this (feature , feature . getFeature () );
119118 }
120119
121- private FeatureElementSelector (Feature feature , Node element ) {
120+ private FeatureElementSelector (FeatureWithSource feature , Node element ) {
122121 this .feature = requireNonNull (feature );
123122 this .element = requireNonNull (element );
124123 }
125124
126- static FeatureElementSelector selectFeature (Feature feature ) {
125+ static FeatureElementSelector selectFeature (FeatureWithSource feature ) {
127126 return new FeatureElementSelector (feature );
128127 }
129128
130- static FeatureElementSelector selectElement (Feature feature , Node element ) {
129+ static FeatureElementSelector selectElement (FeatureWithSource feature , Node element ) {
131130 return new FeatureElementSelector (feature , element );
132131 }
133132
134133 static Stream <FeatureElementSelector > selectElementsAt (
135- Feature feature , Supplier <Optional <Set <FilePosition >>> filePositions ,
134+ FeatureWithSource feature , Supplier <Optional <Set <FilePosition >>> filePositions ,
136135 DiscoveryIssueReporter issueReporter
137136 ) {
138137 return filePositions .get ()
@@ -141,23 +140,25 @@ static Stream<FeatureElementSelector> selectElementsAt(
141140 }
142141
143142 private static Stream <FeatureElementSelector > selectElementsAt (
144- Feature feature , Set <FilePosition > filePositions , DiscoveryIssueReporter issueReporter
143+ FeatureWithSource feature , Set <FilePosition > filePositions , DiscoveryIssueReporter issueReporter
145144 ) {
146145 return filePositions .stream ().map (filePosition -> selectElementAt (feature , filePosition , issueReporter ));
147146 }
148147
149148 static FeatureElementSelector selectElementAt (
150- Feature feature , Supplier <Optional <FilePosition >> filePosition , DiscoveryIssueReporter issueReporter
149+ FeatureWithSource feature , Supplier <Optional <FilePosition >> filePosition ,
150+ DiscoveryIssueReporter issueReporter
151151 ) {
152152 return filePosition .get ()
153153 .map (position -> selectElementAt (feature , position , issueReporter ))
154154 .orElseGet (() -> selectFeature (feature ));
155155 }
156156
157157 static FeatureElementSelector selectElementAt (
158- Feature feature , FilePosition filePosition , DiscoveryIssueReporter issueReporter
158+ FeatureWithSource feature , FilePosition filePosition , DiscoveryIssueReporter issueReporter
159159 ) {
160- return feature .findPathTo (candidate -> candidate .getLocation ().getLine () == filePosition .getLine ())
160+ return feature .getFeature ()
161+ .findPathTo (candidate -> candidate .getLocation ().getLine () == filePosition .getLine ())
161162 .map (nodes -> nodes .get (nodes .size () - 1 ))
162163 .map (node -> new FeatureElementSelector (feature , node ))
163164 .orElseGet (() -> {
@@ -167,7 +168,7 @@ static FeatureElementSelector selectElementAt(
167168 }
168169
169170 private static void reportInvalidFilePosition (
170- Feature feature , FilePosition filePosition , DiscoveryIssueReporter issueReporter
171+ FeatureWithSource feature , FilePosition filePosition , DiscoveryIssueReporter issueReporter
171172 ) {
172173 issueReporter .reportIssue (DiscoveryIssue .create (WARNING ,
173174 "Feature file " + feature .getUri ()
@@ -176,7 +177,7 @@ private static void reportInvalidFilePosition(
176177 ". Selecting the whole feature instead" ));
177178 }
178179
179- static Set <FeatureElementSelector > selectElementsOf (Feature feature , Node selected ) {
180+ static Set <FeatureElementSelector > selectElementsOf (FeatureWithSource feature , Node selected ) {
180181 if (selected instanceof Node .Container ) {
181182 Node .Container <?> container = (Node .Container <?>) selected ;
182183 return container .elements ().stream ()
@@ -186,7 +187,7 @@ static Set<FeatureElementSelector> selectElementsOf(Feature feature, Node select
186187 return Collections .emptySet ();
187188 }
188189
189- Feature getFeature () {
190+ FeatureWithSource getFeature () {
190191 return feature ;
191192 }
192193
0 commit comments