Module: Tapioca::Runtime::Trackers::ConstantDefinition
- Extended by:
- 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.
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::SignatureBlockError, Reflection::UNDEFINED_CONSTANT
Class Method Summary
collapse
Methods included from Tracker
disable!, enabled?, extended, with_disabled_tracker
Methods included from Reflection
abstract_type_of, ancestors_of, are_equal?, attached_class_of, 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
Class Method Details
.build_source_location(tp, locations) ⇒ Object
58
59
60
61
62
63
64
65
|
# File 'lib/tapioca/runtime/trackers/constant_definition.rb', line 58
def build_source_location(tp, locations)
loc = resolve_loc(locations)
file = loc&.file
line = loc&.line
lineno = file && File.identical?(file, tp.path) ? tp.lineno : (line || 0)
SourceLocation.from_loc([file || "", lineno])
end
|
.disable! ⇒ Object
52
53
54
55
56
|
# File 'lib/tapioca/runtime/trackers/constant_definition.rb', line 52
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. : (T::Module klass) -> Set
87
88
89
|
# File 'lib/tapioca/runtime/trackers/constant_definition.rb', line 87
def files_for(klass)
locations_for(klass).map(&:file).to_set
end
|
.locations_for(klass) ⇒ Object
92
93
94
|
# File 'lib/tapioca/runtime/trackers/constant_definition.rb', line 92
def locations_for(klass)
@class_files.fetch(klass, Set.new)
end
|
.register(constant, loc) ⇒ Object
67
68
69
70
71
|
# File 'lib/tapioca/runtime/trackers/constant_definition.rb', line 67
def register(constant, loc)
return unless loc
(@class_files[constant] ||= Set.new) << loc
end
|
.register_cname(cname, namespace, locations) ⇒ Object