Class: Yoda::AST::CommentBlock::TagPart
- Inherits:
-
BasePart
- Object
- BasePart
- Yoda::AST::CommentBlock::TagPart
show all
- Defined in:
- lib/yoda/ast/comment_block/tag_part.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
#begin_location, #end_location, #include?, #range, #text
Constructor Details
#initialize(comment_block:, token:) ⇒ TagPart
Returns a new instance of TagPart.
13
14
15
16
|
# File 'lib/yoda/ast/comment_block/tag_part.rb', line 13
def initialize(comment_block:, token:)
@comment_block =
@token = token
end
|
Instance Attribute Details
6
7
8
|
# File 'lib/yoda/ast/comment_block/tag_part.rb', line 6
def
@comment_block
end
|
9
10
11
|
# File 'lib/yoda/ast/comment_block/tag_part.rb', line 9
def token
@token
end
|
Instance Method Details
#begin_index ⇒ Integer
19
20
21
|
# File 'lib/yoda/ast/comment_block/tag_part.rb', line 19
def begin_index
token.all_tokens.first.offset
end
|
#end_index ⇒ Integer
24
25
26
27
|
# File 'lib/yoda/ast/comment_block/tag_part.rb', line 24
def end_index
last_token = token.all_tokens.last
last_token.offset + last_token.length
end
|
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/yoda/ast/comment_block/tag_part.rb', line 38
def name_part
@name_part ||= begin
if tokens_before_bracket.empty?
if tokens_after_bracket.empty?
nil
else
TagTextNamePart.new(parent: self, tokens: [tokens_after_bracket.first])
end
else
TagTextNamePart.new(parent: self, tokens: tokens_before_bracket)
end
end
end
|
#nearest_part(location) ⇒ BasePart
54
55
56
|
# File 'lib/yoda/ast/comment_block/tag_part.rb', line 54
def nearest_part(location)
[type_part, name_part, self].compact.find { |part| part.range.include?(location) }
end
|
30
31
32
33
34
35
|
# File 'lib/yoda/ast/comment_block/tag_part.rb', line 30
def type_part
return nil if tokens_in_bracket.empty?
@type_part ||= begin
TagTextTypePart.new(parent: self, tokens: tokens_in_bracket)
end
end
|