Class: Dependabot::Bazel::FileParser::StarlarkParser

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/dependabot/bazel/file_parser/starlark_parser.rb

Defined Under Namespace

Classes: FunctionCall

Instance Method Summary collapse

Constructor Details

#initialize(content) ⇒ StarlarkParser

Returns a new instance of StarlarkParser.



21
22
23
24
25
26
# File 'lib/dependabot/bazel/file_parser/starlark_parser.rb', line 21

def initialize(content)
  @content = content
  @position = T.let(0, Integer)
  @line = T.let(1, Integer)
  @length = T.let(content.length, Integer)
end

Instance Method Details

#parse_function_callsObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/dependabot/bazel/file_parser/starlark_parser.rb', line 29

def parse_function_calls
  function_calls = T.let([], T::Array[FunctionCall])

  while @position < @length
    skip_whitespace_and_comments

    next unless @position < @length

    start_position = @position
    function_call = try_parse_function_call
    function_calls << function_call if function_call

    move_to_next_char if @position == start_position
  end

  function_calls
end