Class: Tapioca::Dsl::Compiler Abstract

Inherits:
Object
  • Object
show all
Extended by:
T::Sig, Runtime::Reflection
Includes:
RBIHelper, Runtime::Reflection
Defined in:
lib/tapioca/dsl/compiler.rb

Overview

This class is abstract.

: [ConstantType < Module]

Direct Known Subclasses

Tapioca::Dsl::Compilers::AASM, Tapioca::Dsl::Compilers::ActionControllerHelpers, Tapioca::Dsl::Compilers::ActionMailer, Tapioca::Dsl::Compilers::ActionText, Tapioca::Dsl::Compilers::ActiveJob, Tapioca::Dsl::Compilers::ActiveModelAttributes, Tapioca::Dsl::Compilers::ActiveModelSecurePassword, Tapioca::Dsl::Compilers::ActiveModelValidationsConfirmation, Tapioca::Dsl::Compilers::ActiveRecordAssociations, Tapioca::Dsl::Compilers::ActiveRecordColumns, Tapioca::Dsl::Compilers::ActiveRecordDelegatedTypes, Tapioca::Dsl::Compilers::ActiveRecordEnum, Tapioca::Dsl::Compilers::ActiveRecordFixtures, Tapioca::Dsl::Compilers::ActiveRecordRelations, Tapioca::Dsl::Compilers::ActiveRecordScope, Tapioca::Dsl::Compilers::ActiveRecordSecureToken, Tapioca::Dsl::Compilers::ActiveRecordStore, Tapioca::Dsl::Compilers::ActiveRecordTypedStore, Tapioca::Dsl::Compilers::ActiveResource, Tapioca::Dsl::Compilers::ActiveStorage, Tapioca::Dsl::Compilers::ActiveSupportConcern, Tapioca::Dsl::Compilers::ActiveSupportCurrentAttributes, Tapioca::Dsl::Compilers::ActiveSupportTimeExt, Tapioca::Dsl::Compilers::Config, Tapioca::Dsl::Compilers::FrozenRecord, Tapioca::Dsl::Compilers::GraphqlInputObject, Tapioca::Dsl::Compilers::GraphqlMutation, Tapioca::Dsl::Compilers::IdentityCache, Tapioca::Dsl::Compilers::JsonApiClientResource, Tapioca::Dsl::Compilers::Kredis, Tapioca::Dsl::Compilers::MixedInClassAttributes, Tapioca::Dsl::Compilers::Protobuf, Tapioca::Dsl::Compilers::RailsGenerators, Tapioca::Dsl::Compilers::SidekiqWorker, Tapioca::Dsl::Compilers::SmartProperties, Tapioca::Dsl::Compilers::StateMachines, Tapioca::Dsl::Compilers::UrlHelpers

Constant Summary collapse

@@requested_constants =

: Array # rubocop:disable Style/ClassVars

[]

Constants included from Runtime::Reflection

Runtime::Reflection::ANCESTORS_METHOD, Runtime::Reflection::CLASS_METHOD, Runtime::Reflection::CONSTANTS_METHOD, Runtime::Reflection::EQUAL_METHOD, Runtime::Reflection::METHOD_METHOD, Runtime::Reflection::NAME_METHOD, Runtime::Reflection::OBJECT_ID_METHOD, Runtime::Reflection::PRIVATE_INSTANCE_METHODS_METHOD, Runtime::Reflection::PROTECTED_INSTANCE_METHODS_METHOD, Runtime::Reflection::PUBLIC_INSTANCE_METHODS_METHOD, Runtime::Reflection::REQUIRED_FROM_LABELS, Runtime::Reflection::SINGLETON_CLASS_METHOD, Runtime::Reflection::SUPERCLASS_METHOD, Runtime::Reflection::SignatureBlockError, Runtime::Reflection::UNDEFINED_CONSTANT

Constants included from SorbetHelper

SorbetHelper::FEATURE_REQUIREMENTS, SorbetHelper::SORBET_BIN, SorbetHelper::SORBET_EXE_PATH_ENV_VAR, SorbetHelper::SORBET_GEM_SPEC, SorbetHelper::SORBET_PAYLOAD_URL, SorbetHelper::SPOOM_CONTEXT

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Runtime::Reflection

abstract_type_of, ancestors_of, are_equal?, class_of, const_source_location, constant_defined?, constantize, constants_of, descendants_of, file_candidates_for, final_module?, inherited_ancestors_of, method_of, name_of, name_of_type, object_id_of, private_instance_methods_of, protected_instance_methods_of, public_instance_methods_of, qualified_name_of, resolve_loc, sealed_module?, signature_of, signature_of!, singleton_class_of, superclass_of

Methods included from Runtime::AttachedClassOf

#attached_class_of

Methods included from RBIHelper

#as_nilable_type, #as_non_nilable_type, #create_block_param, #create_kw_opt_param, #create_kw_param, #create_kw_rest_param, #create_opt_param, #create_param, #create_rest_param, #create_typed_param, #sanitize_signature_types, serialize_type_variable, #valid_method_name?, #valid_parameter_name?

Methods included from SorbetHelper

#sorbet, #sorbet_path, #sorbet_supports?

Constructor Details

#initialize(pipeline, root, constant, options = {}) ⇒ Compiler

: (Tapioca::Dsl::Pipeline pipeline, RBI::Tree root, ConstantType constant, ?Hash[String, untyped] options) -> void



87
88
89
90
91
92
93
# File 'lib/tapioca/dsl/compiler.rb', line 87

def initialize(pipeline, root, constant, options = {})
  @pipeline = pipeline
  @root = root
  @constant = constant
  @options = options
  @errors = [] #: Array[String]
end

Instance Attribute Details

#constantObject (readonly)

: ConstantType



16
17
18
# File 'lib/tapioca/dsl/compiler.rb', line 16

def constant
  @constant
end

#optionsObject (readonly)

: Hash[String, untyped]



22
23
24
# File 'lib/tapioca/dsl/compiler.rb', line 22

def options
  @options
end

#rootObject (readonly)

: RBI::Tree



19
20
21
# File 'lib/tapioca/dsl/compiler.rb', line 19

def root
  @root
end

Class Method Details

.gather_constantsObject

This method is abstract.

: -> T::Enumerable

Raises:

  • (NotImplementedError)


36
# File 'lib/tapioca/dsl/compiler.rb', line 36

def gather_constants = raise NotImplementedError, "Abstract method called"

.handles?(constant) ⇒ Boolean

: (Module constant) -> bool

Returns:

  • (Boolean)


30
31
32
# File 'lib/tapioca/dsl/compiler.rb', line 30

def handles?(constant)
  processable_constants.include?(constant)
end

.processable_constantsObject

: -> Set



39
40
41
# File 'lib/tapioca/dsl/compiler.rb', line 39

def processable_constants
  @processable_constants ||= T::Set[Module].new.compare_by_identity.merge(gather_constants) #: Set[Module]?
end

.requested_constants=(constants) ⇒ Object

: (Array constants) -> void



44
45
46
# File 'lib/tapioca/dsl/compiler.rb', line 44

def requested_constants=(constants)
  @@requested_constants = constants # rubocop:disable Style/ClassVars
end

.reset_stateObject

: -> void



49
50
51
52
53
# File 'lib/tapioca/dsl/compiler.rb', line 49

def reset_state
  @processable_constants = nil
  @all_classes = nil
  @all_modules = nil
end

Instance Method Details

#add_error(error) ⇒ Object

NOTE: This should eventually accept an ‘Error` object or `Exception` rather than simply a `String`. : (String error) -> void



106
107
108
# File 'lib/tapioca/dsl/compiler.rb', line 106

def add_error(error)
  @pipeline.add_error(error)
end

#compiler_enabled?(compiler_name) ⇒ Boolean

: (String compiler_name) -> bool

Returns:

  • (Boolean)


96
97
98
# File 'lib/tapioca/dsl/compiler.rb', line 96

def compiler_enabled?(compiler_name)
  @pipeline.compiler_enabled?(compiler_name)
end

#decorateObject

This method is abstract.

: -> void

Raises:

  • (NotImplementedError)


102
# File 'lib/tapioca/dsl/compiler.rb', line 102

def decorate = raise NotImplementedError, "Abstract method called"