Module: Lowkey::Query
- Included in:
- ClassVisitor, FileProxy, MethodCallVisitor, MethodDefVisitor, MethodProxy, ModuleProxy, ModuleVisitor
- Defined in:
- lib/queries/query.rb
Instance Method Summary collapse
- #namespace(node:, parent_map:, namespace: []) ⇒ Object
-
#query(node:, namespace:, name:) ⇒ Object
TODO: Make name a keypath.
Instance Method Details
#namespace(node:, parent_map:, namespace: []) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/queries/query.rb', line 14 def namespace(node:, parent_map:, namespace: []) # When inside RBX, Prism thinks we're defining a class because of "<". return nil if node.respond_to?(:constant_path) && node.constant_path.is_a?(Prism::MissingNode) if parent_map[node].nil? namespace << 'Object' if namespace.empty? return namespace.reverse.join('::') end namespace << node.constant_path.name.to_s if node.respond_to?(:constant_path) namespace(node: parent_map[node], parent_map:, namespace:) end |
#query(node:, namespace:, name:) ⇒ Object
TODO: Make name a keypath.
8 9 10 11 12 |
# File 'lib/queries/query.rb', line 8 def query(node:, namespace:, name:) # rubocop:disable Lint/UnusedMethodArgument node.breadth_first_search do |n| n.respond_to?(:name) && n.name == name.to_sym end end |