Skip to content

Commit f24dd28

Browse files
committed
Merge pull request #47 from valich/master
adding 'more' command; raising version to beta2
2 parents a854f91 + e418dd6 commit f24dd28

File tree

4 files changed

+72
-2
lines changed

4 files changed

+72
-2
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
require 'stringio'
2+
require 'irb/ruby-lex'
3+
4+
module Debugger
5+
6+
class ExpressionInfoCommand < Command
7+
def regexp
8+
/^\s*ex(?:pression_info)?\s+/
9+
end
10+
11+
def execute
12+
string_to_parse = @match.post_match.gsub("\\n", "\n") + "\n\n\n"
13+
total_lines = string_to_parse.count("\n") + 1
14+
15+
lexer = RubyLex.new
16+
io = StringIO.new(string_to_parse)
17+
# for passing to the lexer
18+
io.instance_exec(string_to_parse.encoding) do |string_encoding|
19+
@my_encoding = string_encoding
20+
def self.encoding
21+
@my_encoding
22+
end
23+
end
24+
25+
lexer.set_input(io)
26+
27+
last_statement = ''
28+
last_prompt = ''
29+
last_indent = 0
30+
lexer.set_prompt do |ltype, indent, continue, lineno|
31+
next if (lineno >= total_lines)
32+
33+
last_prompt = ltype || ''
34+
last_indent = indent
35+
end
36+
37+
lexer.each_top_level_statement do |line, line_no|
38+
last_statement = line
39+
end
40+
41+
incomplete = true
42+
if /\A\s*\Z/m =~ last_statement[0]
43+
incomplete = false
44+
end
45+
46+
@printer.print_expression_info(incomplete, last_prompt, last_indent)
47+
end
48+
49+
class << self
50+
def help_command
51+
"expression_info"
52+
end
53+
54+
def help(cmd)
55+
%{
56+
ex[pression_info] <expression>\t
57+
returns parser-related information for the expression given\t\t
58+
'incomplete'=true|false\tindicates whether expression is a complete ruby
59+
expression and can be evaluated without getting syntax errors
60+
}
61+
end
62+
end
63+
end
64+
65+
end

lib/ruby-debug-ide/commands/inspect.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ def execute
2222
end
2323
end
2424

25-
end
25+
end

lib/ruby-debug-ide/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module Debugger
2-
IDE_VERSION='0.4.23.beta1'
2+
IDE_VERSION='0.4.23.beta2'
33
end

lib/ruby-debug-ide/xml_printer.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,11 @@ def print_expressions(exps)
220220
def print_expression(exp, value, idx)
221221
print "<dispay name=\"%s\" value=\"%s\" no=\"%d\" />", exp, value, idx
222222
end
223+
224+
def print_expression_info(incomplete, prompt, indent)
225+
print "<expressionInfo incomplete=\"%s\" prompt=\"%s\" indent=\"%s\"></expressionInfo>",
226+
incomplete, CGI.escapeHTML(prompt), indent
227+
end
223228

224229
def print_eval(exp, value)
225230
print "<eval expression=\"%s\" value=\"%s\" />", CGI.escapeHTML(exp), value

0 commit comments

Comments
 (0)