Method: Reference#process

Defined in:
lib/puppet-lint-module_reference-check/reference.rb

#process(tokens) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/puppet-lint-module_reference-check/reference.rb', line 51

def process(tokens)
  tokens = tokens.drop(get_body_start(tokens))
  feature_includes = []
  tokens.reject { |token| %i[WHITESPACE NEWLINE INDENT].include? token.type }.each do |token|
    @current_token = token
    @workflow.got_include if token.type == :NAME && token.value == 'include' && token.next_code_token&.type == :NAME
    @workflow.got_class if token.value == 'class'
    @workflow.got_features_start if token.value == 'role::include_features'
    @workflow.got_feature if token.type == :LBRACK && @workflow.current == :awaiting_feature
    @workflow.got_feature_end if token.type == :RBRACK && @workflow.current == :awaiting_feature_include
    @workflow.got_features_end(feature_includes) if token.type == :RBRACE && @workflow.current == :got_feature_start
    next unless %i[NAME SSTRING].include?(token.type)
    next if %w[include class role::include_features].include?(token.value)

    # noinspection RubyCaseWithoutElseBlockInspection
    case @workflow.current
    when :awaiting_include_name
      @workflow.got_include_name(token.value)
    when :awaiting_class_name
      @workflow.got_class_name(token.value)
    when :awaiting_feature_include
      feature_includes.append(token.value)
    end
  end
end