Module: XcodeResultBundleProcessor::SLF0::ClassNameResolver

Defined in:
lib/xcoderesultbundleprocessor/slf0/class_name_resolver.rb

Defined Under Namespace

Classes: ResolvedClassName

Class Method Summary collapse

Class Method Details

.resolve_class_names(tokens) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/xcoderesultbundleprocessor/slf0/class_name_resolver.rb', line 7

def self.resolve_class_names(tokens)
  class_names = []

  Enumerator.new do |enumerator|
    tokens.each do |token|
      if token.is_a?(Tokenizer::ClassName)
        class_names << token.class_name
      elsif token.is_a?(Tokenizer::ClassNameRef)
        raise "Invalid ClassNameRef to class index #{token.class_name_id}" if token.class_name_id > class_names.length
        class_name = class_names[token.class_name_id - 1]
        enumerator.yield(ResolvedClassName.new(class_name))
      else
        enumerator.yield(token)
      end
    end
  end
end