Sha256: 596901ab3e426542603afa243cef89cfd49832eaf61afc9ca9c197809fd07a52

Contents?: true

Size: 685 Bytes

Versions: 1

Compression:

Stored size: 685 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module RBS
    class ProcessedRBSSource
      attr_reader :raw_source
      attr_reader :source
      attr_reader :buffer
      attr_reader :directives
      attr_reader :decls
      attr_reader :error

      def initialize(source)
        @raw_source = source.content
        @buffer, @directives, @decls = ::RBS::Parser.parse_signature(source)
        @error = nil
        @tokens = nil
      rescue ::RBS::ParsingError => e
        @error = e
      end

      def valid_syntax?
        @error.nil?
      end

      def tokens
        @tokens ||= begin
          ::RBS::Parser.lex(buffer).value
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rubocop-on-rbs-0.6.0 lib/rubocop/rbs/processed_rbs_source.rb