Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
社会瑞弟呀
brakeman
提交
4d603423
B
brakeman
项目概览
社会瑞弟呀
/
brakeman
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
B
brakeman
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4d603423
编写于
9月 21, 2012
作者:
J
Justin
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #150 from presidentbeef/more_method_missing_sexp
Fix uses of `method_missing` for Sexp
上级
6b3991dd
327ea4d3
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
46 addition
and
3 deletion
+46
-3
lib/ruby_parser/bm_sexp.rb
lib/ruby_parser/bm_sexp.rb
+20
-3
test/tests/test_sexp.rb
test/tests/test_sexp.rb
+26
-0
未找到文件。
lib/ruby_parser/bm_sexp.rb
浏览文件 @
4d603423
...
...
@@ -35,12 +35,26 @@ class Sexp
self
[
0
]
=
type
end
#Don't use this, please.
#:nodoc:
def
resbody
delete
=
false
#RubyParser
relies on method_missing for this, but since we don't want to us
e
#method_missing, here's a real method.
#RubyParser
and Ruby2Ruby rely on method_missing for this, but since w
e
#
don't want to use
method_missing, here's a real method.
find_node
:resbody
,
delete
end
#Don't use this, please.
#:nodoc:
def
lasgn
delete
=
false
find_node
:lasgn
,
delete
end
#Don't use this, please.
#:nodoc:
def
iasgn
delete
=
false
find_node
:iasgn
,
delete
end
alias
:node_type
:sexp_type
alias
:values
:sexp_body
# TODO: retire
...
...
@@ -304,13 +318,16 @@ class Sexp
# s(:block, s(:lvar, :y), s(:call, nil, :z, s(:arglist))))
# ^-------------------- block --------------------------^
def
block
expect
:iter
,
:call_with_block
,
:scope
expect
:iter
,
:call_with_block
,
:scope
,
:resbody
case
self
.
node_type
when
:iter
,
:call_with_block
self
[
3
]
when
:scope
self
[
1
]
when
:resbody
#This is for Ruby2Ruby ONLY
find_node
:block
end
end
...
...
test/tests/test_sexp.rb
浏览文件 @
4d603423
...
...
@@ -243,4 +243,30 @@ class SexpTests < Test::Unit::TestCase
assert_equal
s
(
:arglist
,
s
(
:lit
,
1
)),
exp
.
arglist
assert_equal
s
(
s
(
:lit
,
1
)),
exp
.
args
end
def
test_resbody_block
#Ruby2Ruby has calls like this which need to be supported
#for Brakeman::OutputProcessor
exp
=
parse
"begin; rescue; end"
assert_nil
exp
.
resbody
.
block
end
def
test_lasgn
#Ruby2Ruby has calls like this which need to be supported
#for Brakeman::OutputProcessor
exp
=
parse
"blah; x = 1"
assert_equal
s
(
:lasgn
,
:x
,
s
(
:lit
,
1
)),
exp
.
lasgn
(
true
)
assert_equal
nil
,
exp
.
lasgn
#Was deleted
end
def
test_iasgn
#Ruby2Ruby has calls like this which need to be supported
#for Brakeman::OutputProcessor
exp
=
parse
"blah; @x = 1"
assert_equal
s
(
:iasgn
,
:@x
,
s
(
:lit
,
1
)),
exp
.
iasgn
(
true
)
assert_equal
nil
,
exp
.
iasgn
#Was deleted
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录