| @@ 21-41 (lines=21) @@ | ||
| 18 | /** |
|
| 19 | * Class ScalarBuilder |
|
| 20 | */ |
|
| 21 | class ScalarBuilder extends Builder |
|
| 22 | { |
|
| 23 | /** |
|
| 24 | * @param RuleInterface|ScalarDefinitionNode $rule |
|
| 25 | * @param Definition $parent |
|
| 26 | * @return Definition |
|
| 27 | * @throws \Railt\Io\Exception\ExternalFileException |
|
| 28 | */ |
|
| 29 | public function build(RuleInterface $rule, Definition $parent): Definition |
|
| 30 | { |
|
| 31 | $scalar = new ScalarDefinition($parent->getDocument(), $rule->getTypeName()); |
|
| 32 | $scalar->withOffset($rule->getOffset()); |
|
| 33 | $scalar->withDescription($rule->getDescription()); |
|
| 34 | ||
| 35 | foreach ($rule->getDirectives() as $ast) { |
|
| 36 | $scalar->withDirective($this->dependent($ast, $scalar)); |
|
| 37 | } |
|
| 38 | ||
| 39 | return $scalar; |
|
| 40 | } |
|
| 41 | } |
|
| 42 | ||
| @@ 26-50 (lines=25) @@ | ||
| 23 | /** |
|
| 24 | * Class EnumValueBuilder |
|
| 25 | */ |
|
| 26 | class EnumValueBuilder extends Builder |
|
| 27 | { |
|
| 28 | /** |
|
| 29 | * @param RuleInterface|EnumValueDefinitionNode $rule |
|
| 30 | * @param Definition|EnumDefinition $parent |
|
| 31 | * @return Definition |
|
| 32 | * @throws \Railt\Io\Exception\ExternalFileException |
|
| 33 | */ |
|
| 34 | public function build(RuleInterface $rule, Definition $parent): Definition |
|
| 35 | { |
|
| 36 | $value = new EnumValueDefinition($parent, $rule->getName()); |
|
| 37 | $value->withOffset($rule->getOffset()); |
|
| 38 | $value->withDescription($rule->getDescription()); |
|
| 39 | ||
| 40 | if ($hint = $rule->getTypeHint()) { |
|
| 41 | // TODO With Value |
|
| 42 | } |
|
| 43 | ||
| 44 | foreach ($rule->getDirectives() as $ast) { |
|
| 45 | $value->withDirective($this->dependent($ast, $value)); |
|
| 46 | } |
|
| 47 | ||
| 48 | return $value; |
|
| 49 | } |
|
| 50 | } |
|
| 51 | ||