Skip to content

Commit c186ca4

Browse files
committed
Override getSourceReference() on AbstractGlueDefinition
1 parent 43a2d0c commit c186ca4

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

scala/sources/src/main/scala/io/cucumber/scala/AbstractGlueDefinition.scala

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
package io.cucumber.scala
22

33
import java.lang.reflect.InvocationTargetException
4+
import java.util.Optional
45

5-
import io.cucumber.core.backend.{CucumberInvocationTargetException, Located}
6+
import io.cucumber.core.backend.{CucumberInvocationTargetException, Located, SourceReference}
67

78
import scala.util.{Failure, Try}
89

910
trait AbstractGlueDefinition extends Located {
1011

1112
val location: StackTraceElement
1213

14+
lazy val sourceReference: SourceReference = SourceReference.fromStackTraceElement(location)
15+
1316
override def getLocation(): String = {
1417
location.toString
1518
}
@@ -18,6 +21,10 @@ trait AbstractGlueDefinition extends Located {
1821
location.getFileName != null && location.getFileName == stackTraceElement.getFileName
1922
}
2023

24+
override def getSourceReference(): Optional[SourceReference] = {
25+
Optional.of(sourceReference)
26+
}
27+
2128
/**
2229
* Executes the block of code and handle failures in the way asked by Cucumber specification: that is throwing a CucumberInvocationTargetException.
2330
*/

0 commit comments

Comments
 (0)