Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Ruby scanner can't parse complex method definitions #82

Open
Milestone
@nathany

Description

Ruby scanner has problems to recognize method names in more complex forms of singleton method definition.

I have made a test case.

# simple method definitions
def method param1, param2
 # code
end
def method(args, *rest, &block)
 # code
end
def
method(param1, param2)
 # code
end
def \
method(param1, param2)
 # code
end
def # comment
method(param1, param2)
 # code
end
def [];end
def def;end
def end?;end
def a(*) end
def !; end # Ruby 1.9
# singleton methods
def Class.method
end
def self.method
end
def object.method
end
def $~.method
end
def nil.method
end
def true.method
end
def false.method
end
def __FILE__.method
end
def __LINE__.method
end
def __ENCODING__.method
end
def __ENCODING__.method
end
def @instance_variable.method
end
def @class_variable.method
end
def (Module::Class).method
end
def (complex.expression).method
end
def (complex.expression + another(complex(expression))).method
end
# crazy
def (class Foo
 def initialize(args)
 def yet_another_method; end
 end
end).method(args, *rest, &block)
end
# wrong
def foo.bar.quux
end

The simple cases are working now. Support for def (expression).method is still missing, but possible now that the state handling has been cleaned up.

I just realized we can even have recursive expression singleton method declarations - so the parenthesis nesting depth really has to be saved in the state, not in a local variable.

I still want to get this obscure thing working, but it's not as important as other features in 1.0. So, I postpone the rest of this ticket to 1.1.

From Redmine: http://odd-eyed-code.org/issues/147

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      AltStyle によって変換されたページ (->オリジナル) /