SourceRange.h 587 B

12345678910111213141516171819202122232425262728293031
  1. /*
  2. * Copyright (c) 2020, the SerenityOS developers.
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/StringView.h>
  8. #include <AK/Types.h>
  9. #include <LibJS/SourceCode.h>
  10. namespace JS {
  11. struct Position {
  12. size_t line { 0 };
  13. size_t column { 0 };
  14. size_t offset { 0 };
  15. };
  16. struct SourceRange {
  17. [[nodiscard]] bool contains(Position const& position) const { return position.offset <= end.offset && position.offset >= start.offset; }
  18. NonnullRefPtr<SourceCode> code;
  19. Position start;
  20. Position end;
  21. String const& filename() const;
  22. };
  23. }