Skip to content
Kward Search API index

Class: Kward::SourceOutline

Inherits:
Object
  • Object
show all
Defined in:
lib/kward/source/outline.rb

Overview

Extracts locations from the current buffer without executing it.

Constant Summary collapse

MAX_SOURCE_BYTES =
512 * 1024
MAX_OUTPUT_BYTES =
1024 * 1024
MAX_SYMBOLS =
2_000
TIME_LIMIT =
1.5

Instance Method Summary collapse

Instance Method Details

#symbols(path, content) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/kward/source/outline.rb', line 15

def symbols(path, content)
  return [] if content.bytesize > MAX_SOURCE_BYTES

  lines = content.scrub.lines
  tags = ctags_symbols(path, content, lines.length)
  return tags unless tags.nil? || tags.empty?

  SourceDeclarations.scan(lines.map { |line| line.length <= 2_000 ? line : "" }).first(MAX_SYMBOLS)
end