Sha256: d6c5c3a8e6438c8219fe6b30ca033e5e7c60253b12b57ca41c5ddca124c2f465

Contents?: true

Size: 1.3 KB

Versions: 8

Compression:

Stored size: 1.3 KB

Contents

# -*- coding: utf-8 -*- #
# frozen_string_literal: true

module Rouge
  module Lexers
    module TypescriptCommon
      def keywords
        @keywords ||= super + Set.new(%w(
          is namespace static private protected public
          implements readonly
        ))
      end

      def declarations
        @declarations ||= super + Set.new(%w(
          type abstract
        ))
      end

      def reserved
        @reserved ||= super + Set.new(%w(
          string any void number namespace module
          declare default interface keyof
        ))
      end

      def builtins
        @builtins ||= super + %w(
          Capitalize ConstructorParameters Exclude Extract InstanceType
          Lowercase NonNullable Omit OmitThisParameter Parameters
          Partial Pick Readonly Record Required
          ReturnType ThisParameterType ThisType Uncapitalize Uppercase
        )
      end

      def self.extended(base)
        base.prepend :root do
          rule %r/[?][.]/, base::Punctuation
          rule %r/[?]{2}/, base::Operator
        end

        base.prepend :statement do
          rule %r/(#{Javascript.id_regex})(\??)(\s*)(:)/ do
            groups base::Name::Label, base::Punctuation, base::Text, base::Punctuation
            push :expr_start
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rouge-4.2.1 lib/rouge/lexers/typescript/common.rb
rouge-4.2.0 lib/rouge/lexers/typescript/common.rb
rouge-4.1.3 lib/rouge/lexers/typescript/common.rb
rouge-4.1.2 lib/rouge/lexers/typescript/common.rb
rouge-4.1.1 lib/rouge/lexers/typescript/common.rb
rouge-4.1.0 lib/rouge/lexers/typescript/common.rb
rouge-4.0.1 lib/rouge/lexers/typescript/common.rb
rouge-4.0.0 lib/rouge/lexers/typescript/common.rb