Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ruby: extend mixin field #2481

Merged
merged 2 commits into from
Apr 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Units/parser-ruby.r/ruby-mixin-field.d/expected.tags
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,11 @@ A input.rb /^class A$/;" c mixin:include:X,include:Y
hi input.rb /^ def hi$/;" f class:A
B input.rb /^class B$/;" c mixin:include:X
prep input.rb /^ def self.prep$/;" S class:B
C input.rb /^class C$/;" c mixin:prepend:X,prepend:Y
hi input.rb /^ def hi$/;" f class:C
D input.rb /^class D$/;" c mixin:prepend:X
prep input.rb /^ def self.prep$/;" S class:D
E input.rb /^class E$/;" c mixin:extend:X,extend:Y
hi input.rb /^ def hi$/;" f class:E
F input.rb /^class F$/;" c mixin:extend:X
prep input.rb /^ def self.prep$/;" S class:F
28 changes: 28 additions & 0 deletions Units/parser-ruby.r/ruby-mixin-field.d/input.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,31 @@ def self.prep
include X
end
end

class C
prepend X
def hi
p "Calling 'hi' in C."
end
prepend Y
end

class D
def self.prep
prepend X
end
end

class E
extend X
def hi
p "Calling 'hi' in E."
end
extend Y
end

class F
def self.prep
extend X
end
end
8 changes: 8 additions & 0 deletions parsers/ruby.c
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,14 @@ static void findRubyTags (void)
{
readAndStoreMixinSpec (&cp, "include");
}
else if (canMatchKeywordWithAssign (&cp, "prepend"))
{
readAndStoreMixinSpec (&cp, "prepend");
}
else if (canMatchKeywordWithAssign (&cp, "extend"))
{
readAndStoreMixinSpec (&cp, "extend");
}
else if (canMatchKeywordWithAssign (&cp, "def"))
{
rubyKind kind = K_METHOD;
Expand Down