Module: ReplTypeCompletor

Defined in:
lib/repl_type_completor.rb,
lib/repl_type_completor/scope.rb,
lib/repl_type_completor/types.rb,
lib/repl_type_completor/result.rb,
lib/repl_type_completor/methods.rb,
lib/repl_type_completor/version.rb,
lib/repl_type_completor/require_paths.rb,
lib/repl_type_completor/type_analyzer.rb

Defined Under Namespace

Modules: Methods, RequirePaths, Types Classes: Result, RootScope, Scope, TypeAnalyzer

Constant Summary collapse

VERSION =
"0.1.7"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.last_completion_errorObject (readonly)

Returns the value of attribute last_completion_error.



9
10
11
# File 'lib/repl_type_completor.rb', line 9

def last_completion_error
  @last_completion_error
end

Class Method Details

.analyze(code, binding:, filename: nil) ⇒ Object



31
32
33
34
35
36
37
38
39
40
# File 'lib/repl_type_completor.rb', line 31

def analyze(code, binding:, filename: nil)
  verbose, $VERBOSE = $VERBOSE, nil
  result = analyze_code(code, binding)
  Result.new(result, binding, filename) if result
rescue Exception => e
  handle_exception(e)
  nil
ensure
  $VERBOSE = verbose
end

.handle_exception(e) ⇒ Object



42
43
44
# File 'lib/repl_type_completor.rb', line 42

def handle_exception(e)
  @last_completion_error = e
end

.infoObject



46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/repl_type_completor.rb', line 46

def info
  require 'rbs'
  prism_info = "Prism: #{Prism::VERSION}"
  rbs_info = "RBS: #{RBS::VERSION}"
  if rbs_load_error
    rbs_info << " #{rbs_load_error.inspect}"
  elsif !rbs_load_started?
    rbs_info << ' signatures not loaded'
  elsif !rbs_loaded?
    rbs_info << ' signatures loading'
  end
  "ReplTypeCompletor: #{VERSION}, #{prism_info}, #{rbs_info}"
end

.load_rbsObject



23
24
25
# File 'lib/repl_type_completor.rb', line 23

def load_rbs
  Types.load_rbs_builder unless rbs_loaded?
end

.preload_rbsObject



27
28
29
# File 'lib/repl_type_completor.rb', line 27

def preload_rbs
  Types.preload_rbs_builder
end

.rbs_load_errorObject



11
12
13
# File 'lib/repl_type_completor.rb', line 11

def rbs_load_error
  Types.rbs_load_error
end

.rbs_load_started?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/repl_type_completor.rb', line 15

def rbs_load_started?
  Types.rbs_load_started?
end

.rbs_loaded?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/repl_type_completor.rb', line 19

def rbs_loaded?
  !!Types.rbs_builder
end