Skip to content

Commit

Permalink
Merge pull request #2481 from AmaiKinono/ruby-mixin
Browse files Browse the repository at this point in the history
Ruby: extend mixin field (prepend and extend)
  • Loading branch information
masatake committed Apr 2, 2020
2 parents 6c50aae + db63ee3 commit 7d81c52
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
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

0 comments on commit 7d81c52

Please sign in to comment.