Module: Tapioca::Runtime::Trackers::ConstantDefinition
- Extended by:
- T::Sig, Reflection, Tracker
- Defined in:
- lib/tapioca/runtime/trackers/constant_definition.rb
Overview
Registers a TracePoint immediately upon load to track points at which classes and modules are opened for definition. This is used to track correspondence between classes/modules and files, as this information isn’t available in the ruby runtime without extra accounting.
Defined Under Namespace
Classes: ConstantLocation
Constant Summary
Constants included from Reflection
Reflection::ANCESTORS_METHOD, Reflection::CLASS_METHOD, Reflection::CONSTANTS_METHOD, Reflection::EQUAL_METHOD, Reflection::METHOD_METHOD, Reflection::NAME_METHOD, Reflection::OBJECT_ID_METHOD, Reflection::PRIVATE_INSTANCE_METHODS_METHOD, Reflection::PROTECTED_INSTANCE_METHODS_METHOD, Reflection::PUBLIC_INSTANCE_METHODS_METHOD, Reflection::REQUIRED_FROM_LABELS, Reflection::SINGLETON_CLASS_METHOD, Reflection::SUPERCLASS_METHOD, Reflection::UNDEFINED_CONSTANT
Class Method Summary collapse
- .build_constant_location(tp, locations) ⇒ Object
- .disable! ⇒ Object
-
.files_for(klass) ⇒ Object
Returns the files in which this class or module was opened.
- .locations_for(klass) ⇒ Object
Methods included from Tracker
disable!, enabled?, extended, with_disabled_tracker
Methods included from Reflection
abstract_type_of, ancestors_of, are_equal?, class_of, 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 AttachedClassOf
Class Method Details
.build_constant_location(tp, locations) ⇒ Object
61 62 63 64 65 66 |
# File 'lib/tapioca/runtime/trackers/constant_definition.rb', line 61 def build_constant_location(tp, locations) file = resolve_loc(locations) lineno = File.identical?(file, tp.path) ? tp.lineno : 0 ConstantLocation.new(path: file, lineno: lineno) end |
.disable! ⇒ Object
55 56 57 58 59 |
# File 'lib/tapioca/runtime/trackers/constant_definition.rb', line 55 def disable! @class_tracepoint.disable @creturn_tracepoint.disable super end |
.files_for(klass) ⇒ Object
Returns the files in which this class or module was opened. Doesn’t know about situations where the class was opened prior to requireing, or where metaprogramming was used via eval
, etc.
71 72 73 |
# File 'lib/tapioca/runtime/trackers/constant_definition.rb', line 71 def files_for(klass) locations_for(klass).map(&:path).to_set end |
.locations_for(klass) ⇒ Object
75 76 77 |
# File 'lib/tapioca/runtime/trackers/constant_definition.rb', line 75 def locations_for(klass) @class_files.fetch(klass, Set.new) end |