Class: Yoda::Parsing::Query::CurrentCommentingNodeQuery
- Inherits:
-
Object
- Object
- Yoda::Parsing::Query::CurrentCommentingNodeQuery
- Defined in:
- lib/yoda/parsing/query/current_commenting_node_query.rb
Overview
Provides helper methods to find the node whose comment include the current position (is the current comment).
Instance Attribute Summary collapse
-
#ast ⇒ Object
readonly
Returns the value of attribute ast.
-
#comments ⇒ Object
readonly
Returns the value of attribute comments.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
Instance Method Summary collapse
- #current_commenting_node ⇒ Array<::Parser::Source::Comment>
- #current_method_definition ⇒ NodeObjects::MethodDefition?
- #current_namespace ⇒ NodeObjects::Namespace?
-
#initialize(ast, comments, location) ⇒ CurrentCommentingNodeQuery
constructor
A new instance of CurrentCommentingNodeQuery.
Constructor Details
#initialize(ast, comments, location) ⇒ CurrentCommentingNodeQuery
Returns a new instance of CurrentCommentingNodeQuery.
11 12 13 14 15 16 17 18 |
# File 'lib/yoda/parsing/query/current_commenting_node_query.rb', line 11 def initialize(ast, comments, location) fail ArgumentError, ast unless ast.is_a?(AST::Vnode) fail ArgumentError, comments unless comments.all? { |comment| comment.is_a?(::Parser::Source::Comment) } fail ArgumentError, location unless location.is_a?(Location) @ast = ast @comments = comments @location = location end |
Instance Attribute Details
#ast ⇒ Object (readonly)
Returns the value of attribute ast.
6 7 8 |
# File 'lib/yoda/parsing/query/current_commenting_node_query.rb', line 6 def ast @ast end |
#comments ⇒ Object (readonly)
Returns the value of attribute comments.
6 7 8 |
# File 'lib/yoda/parsing/query/current_commenting_node_query.rb', line 6 def comments @comments end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
6 7 8 |
# File 'lib/yoda/parsing/query/current_commenting_node_query.rb', line 6 def location @location end |
Instance Method Details
#current_commenting_node ⇒ Array<::Parser::Source::Comment>
21 22 23 |
# File 'lib/yoda/parsing/query/current_commenting_node_query.rb', line 21 def current_commenting_node @current_commenting_node ||= inverse_association[current_comment_query.current_comment_block] end |
#current_method_definition ⇒ NodeObjects::MethodDefition?
31 32 33 |
# File 'lib/yoda/parsing/query/current_commenting_node_query.rb', line 31 def current_method_definition @current_method_definition ||= namespace.calc_current_location_method(current_commenting_node_location) end |
#current_namespace ⇒ NodeObjects::Namespace?
26 27 28 |
# File 'lib/yoda/parsing/query/current_commenting_node_query.rb', line 26 def current_namespace @current_namespace ||= namespace.calc_current_location_namespace(current_commenting_node_location) end |