Skip to content

Commit 323cb6b

Browse files
committed
Refactoring ScalaDsl with multiple traits
1 parent 1954456 commit 323cb6b

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

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

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@ import io.cucumber.scala.Aliases.{DocStringDefinitionBody, HookBody}
66

77
import scala.reflect.ClassTag
88

9-
/**
10-
* Base trait for a scala step definition implementation.
11-
*/
12-
trait ScalaDsl {
13-
self =>
9+
private[scala] trait BaseScalaDsl {
1410

1511
val NO_REPLACEMENT = Seq[String]()
1612
val EMPTY_TAG_EXPRESSION = ""
@@ -21,6 +17,17 @@ trait ScalaDsl {
2117

2218
private[scala] val registry: ScalaDslRegistry = new ScalaDslRegistry()
2319

20+
}
21+
22+
/**
23+
* Base trait for a scala step definition implementation.
24+
*/
25+
trait ScalaDsl extends BaseScalaDsl with StepDsl with HookDsl with DataTableTypeDsl with DocStringTypeDsl {
26+
27+
}
28+
29+
private[scala] trait HookDsl extends BaseScalaDsl {
30+
2431
// TODO support Before/After with no parameter
2532

2633
def Before(body: HookBody): Unit = {
@@ -87,10 +94,18 @@ trait ScalaDsl {
8794
registry.afterStepHooks += ScalaHookDetails(tagExpression, order, body)
8895
}
8996

97+
}
98+
99+
private[scala] trait DocStringTypeDsl extends BaseScalaDsl {
100+
90101
def DocStringType[T](contentType: String)(body: DocStringDefinitionBody[T])(implicit ev: ClassTag[T]): Unit = {
91102
registry.docStringTypes += ScalaDocStringTypeDetails[T](contentType, body, ev)
92103
}
93104

105+
}
106+
107+
private[scala] trait DataTableTypeDsl extends BaseScalaDsl {
108+
94109
def DataTableType: DataTableTypeBody = DataTableType(NO_REPLACEMENT)
95110

96111
def DataTableType(replaceWithEmptyString: String): DataTableTypeBody = DataTableType(Seq(replaceWithEmptyString))
@@ -117,6 +132,10 @@ trait ScalaDsl {
117132

118133
}
119134

135+
}
136+
137+
private[scala] trait StepDsl extends BaseScalaDsl {
138+
self =>
120139

121140
final class Step(name: String) {
122141
def apply(regex: String): StepBody = new StepBody(name, regex)
@@ -572,3 +591,4 @@ trait ScalaDsl {
572591
}
573592

574593
}
594+

0 commit comments

Comments
 (0)