Module: Steep::AST::Ignore
- Defined in:
- lib/steep/ast/ignore.rb
Defined Under Namespace
Classes: BufferScanner, IgnoreEnd, IgnoreLine, IgnoreStart
Class Method Summary collapse
Class Method Details
.parse(comment, buffer) ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/steep/ast/ignore.rb', line 93 def self.parse(comment, buffer) return unless comment.inline? begin_pos = buffer.loc_to_pos([comment.loc.line, comment.loc.column]) end_pos = buffer.loc_to_pos([comment.loc.last_line, comment.loc.last_column]) comment_location = RBS::Location.new(buffer, begin_pos, end_pos) scanner = BufferScanner.new(comment_location) scanner.scan(/#/) scanner.skip(/\s*/) case when loc = scanner.scan(/steep:ignore:start\b/) scanner.skip(/\s*/) return unless scanner.eos? IgnoreStart.new(comment, loc) when loc = scanner.scan(/steep:ignore:end\b/) scanner.skip(/\s*/) return unless scanner.eos? IgnoreEnd.new(comment, loc) when keyword_loc = scanner.scan(/steep:ignore\b/) # @type var diagnostics: IgnoreLine::diagnostics diagnostics = [] scanner.skip(/\s*/) while true name = scanner.scan(/[A-Z]\w*/) or break scanner.skip(/\s*/) comma = scanner.scan(/,/) scanner.skip(/\s*/) diagnostic = RBS::Location.new(buffer, name.start_pos, comma&.end_pos || name.end_pos) #: IgnoreLine::diagnostic diagnostic.add_required_child(:name, name.range) diagnostic.add_optional_child(:following_comma, comma&.range) diagnostics << diagnostic break unless comma end return unless scanner.eos? loc = RBS::Location.new( buffer, keyword_loc.start_pos, diagnostics.last&.end_pos || keyword_loc.end_pos ) IgnoreLine.new(comment, diagnostics, loc) end end |