Method: PuppetLint::Data.param_tokens
- Defined in:
- lib/puppet-lint/data.rb
.param_tokens(these_tokens) ⇒ Array[PuppetLint::Lexer::Token]?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Finds all the tokens that make up the defined type or class definition parameters.
524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 |
# File 'lib/puppet-lint/data.rb', line 524 def param_tokens(these_tokens) depth = 0 lparen_idx = nil rparen_idx = nil these_tokens.each_with_index do |token, i| if token.type == :LPAREN depth += 1 lparen_idx = i if depth == 1 elsif token.type == :RPAREN depth -= 1 if depth.zero? rparen_idx = i break end elsif token.type == :LBRACE && depth.zero? # no parameters break end end if lparen_idx.nil? || rparen_idx.nil? nil else these_tokens[(lparen_idx + 1)..(rparen_idx - 1)] end end |