Class: Debugger::ExpressionInfoCommand
- Inherits:
-
Command
- Object
- SimpleDelegator
- Command
- Debugger::ExpressionInfoCommand
show all
- Defined in:
- lib/ruby-debug-ide/commands/expression_info.rb
Constant Summary
Constants inherited
from Command
Command::DEF_OPTIONS
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Command
commands, #find, inherited, #initialize, load_commands, #match, method_missing, options
Class Method Details
.help(cmd) ⇒ Object
54
55
56
57
58
59
60
61
|
# File 'lib/ruby-debug-ide/commands/expression_info.rb', line 54
def help(cmd)
%{
ex[pression_info] <expression>\t
returns parser-related information for the expression given\t\t
'incomplete'=true|false\tindicates whether expression is a complete ruby
expression and can be evaluated without getting syntax errors
}
end
|
.help_command ⇒ Object
50
51
52
|
# File 'lib/ruby-debug-ide/commands/expression_info.rb', line 50
def help_command
"expression_info"
end
|
Instance Method Details
#execute ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/ruby-debug-ide/commands/expression_info.rb', line 11
def execute
string_to_parse = @match.post_match.gsub("\\n", "\n") + "\n\n\n"
total_lines = string_to_parse.count("\n") + 1
lexer = RubyLex.new
io = StringIO.new(string_to_parse)
io.instance_exec(string_to_parse.encoding) do |string_encoding|
@my_encoding = string_encoding
def self.encoding
@my_encoding
end
end
lexer.set_input(io)
last_statement = ''
last_prompt = ''
last_indent = 0
lexer.set_prompt do |ltype, indent, continue, lineno|
next if (lineno >= total_lines)
last_prompt = ltype || ''
last_indent = indent
end
lexer.each_top_level_statement do |line, line_no|
last_statement = line
end
incomplete = true
if /\A\s*\Z/m =~ last_statement[0]
incomplete = false
end
@printer.print_expression_info(incomplete, last_prompt, last_indent)
end
|
#regexp ⇒ Object
7
8
9
|
# File 'lib/ruby-debug-ide/commands/expression_info.rb', line 7
def regexp
/^\s*ex(?:pression_info)?\s+/
end
|