text: #include "Syntax/Unit/DelphiUnitImplementationSectionSyntax.hpp"
  
  #include <cassert>
  
  #include <argos-Core/Basic/Macros.hpp>
  #include <argos-Core/Syntax/ISyntaxToken.hpp>
  #include <argos-Core/Syntax/SyntaxKinds.hpp>
  
  #include "Syntax/DelphiUsesClauseSyntax.hpp"
  
  namespace argos::Delphi::Syntax
  {
  
  using Core::Syntax::ISyntaxToken;
  using Core::Syntax::SyntaxKind;
  using Core::Syntax::SyntaxVariant;
  
  DelphiUnitImplementationSectionSyntax::DelphiUnitImplementationSectionSyntax(const ISyntaxToken* implementationKeyword,
                                                                               const DelphiUsesClauseSyntax* uses) noexcept
      : DelphiSyntaxNode{SyntaxKind::UnitImplementationSection},
        _implementationKeyword{implementationKeyword},
        _uses{uses}
  {
      _data.position = _implementationKeyword->position();
      _implementationKeyword->setParentNode(this);
  
      if (_uses != nullptr)
          _uses->setParentNode(this);
  }
  
  const ISyntaxToken* DelphiUnitImplementationSectionSyntax::implementationKeyword() const noexcept
  {
      return _implementationKeyword;
  }
  
  const DelphiUsesClauseSyntax* DelphiUnitImplementationSectionSyntax::uses() const noexcept
  {
      return _uses;
  }
  
  argos_size DelphiUnitImplementationSectionSyntax::childCount() const noexcept
  {
      return _uses != nullptr ? 2 : 1;
  }
  
  SyntaxVariant DelphiUnitImplementationSectionSyntax::child(argos_size index) const noexcept
  {
      assert(index < childCount());
  
      switch (childCount())
      {
          case 1:
          {
              if (index == 0)
                  return SyntaxVariant{_implementationKeyword};
  
              break;
          }
          case 2:
          {
              switch (index)
              {
                  case 0: return SyntaxVariant{_implementationKeyword};
                  case 1: return SyntaxVariant{_uses};
                  default: return SyntaxVariant{};
              }
          }
          default:
              return SyntaxVariant{};
      }
  
      return SyntaxVariant{};
  }
  
  SyntaxVariant DelphiUnitImplementationSectionSyntax::first() const noexcept
  {
      return SyntaxVariant{_implementationKeyword};
  }
  
  SyntaxVariant DelphiUnitImplementationSectionSyntax::last() const noexcept
  {
      if (_uses != nullptr)
          return SyntaxVariant{_uses};
  
      return SyntaxVariant{_implementationKeyword};
  }
  
  std::string DelphiUnitImplementationSectionSyntax::typeName() const noexcept
  {
      RETURN_TYPENAME(DelphiUnitImplementationSectionSyntax)
  }
  
  } // end namespace argos::Delphi::Syntax
  