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

Fix arguments in method defifinition. #136

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
202 changes: 89 additions & 113 deletions Syntaxes/Ruby.plist
Original file line number Diff line number Diff line change
Expand Up @@ -520,102 +520,19 @@
</dict>
</dict>
<key>match</key>
<string>\G([&amp;*]?)(?:([_a-zA-Z]\w*(:))|([_a-zA-Z]\w*))</string>
</dict>
<dict>
<key>include</key>
<string>#parens</string>
</dict>
<dict>
<key>include</key>
<string>#braces</string>
</dict>
<dict>
<key>include</key>
<string>$self</string>
</dict>
</array>
</dict>
</array>
<key>repository</key>
<dict>
<key>braces</key>
<dict>
<key>begin</key>
<string>\{</string>
<key>beginCaptures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>punctuation.section.function.begin.ruby</string>
</dict>
</dict>
<key>end</key>
<string>\}</string>
<key>endCaptures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>punctuation.section.function.end.ruby</string>
</dict>
</dict>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#parens</string>
</dict>
<dict>
<key>include</key>
<string>#braces</string>
<string>\G(&amp;|\*\*?)?(?:([_a-zA-Z]\w*(:))|([_a-zA-Z]\w*))</string>
</dict>
<dict>
<key>include</key>
<string>$self</string>
</dict>
</array>
</dict>
<key>parens</key>
<dict>
<key>begin</key>
<string>\(</string>
<key>beginCaptures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>punctuation.section.function.begin.ruby</string>
</dict>
</dict>
<key>end</key>
<string>\)</string>
<key>endCaptures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>punctuation.section.function.end.ruby</string>
</dict>
</dict>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#parens</string>
</dict>
<dict>
<key>include</key>
<string>#braces</string>
</dict>
<dict>
<key>include</key>
<string>$self</string>
</dict>
</array>
<key>include</key>
<string>$self</string>
</dict>
</dict>
</array>
</dict>
<dict>
<key>begin</key>
Expand Down Expand Up @@ -644,16 +561,16 @@
<key>comment</key>
<string>same as the previous rule, but without parentheses around the arguments</string>
<key>end</key>
<string>$</string>
<string>(?=;)|(?&lt;=[\w\])}`'"!?])(?=\s*#|\s*$)</string>
<key>name</key>
<string>meta.function.method.with-arguments.ruby</string>
<key>patterns</key>
<array>
<dict>
<key>begin</key>
<string>(?![\s,])</string>
<string>(?=[&amp;*_a-zA-Z])</string>
<key>end</key>
<string>(?=,|$)</string>
<string>(?=,|;|\s*#|\s*$)</string>
<key>patterns</key>
<array>
<dict>
Expand Down Expand Up @@ -681,16 +598,18 @@
</dict>
</dict>
<key>match</key>
<string>\G([&amp;*]?)(?:([_a-zA-Z]\w*(:))|([_a-zA-Z]\w*))</string>
<key>name</key>
<string>variable.parameter.function.ruby</string>
<string>\G(&amp;|\*\*?)?(?:([_a-zA-Z]\w*(:))|([_a-zA-Z]\w*))</string>
</dict>
<dict>
<key>include</key>
<string>$self</string>
</dict>
</array>
</dict>
<dict>
<key>include</key>
<string>$self</string>
</dict>
</array>
</dict>
<dict>
Expand Down Expand Up @@ -1956,34 +1875,91 @@
<string>punctuation.separator.other.ruby</string>
</dict>
<dict>
<key>match</key>
<key>begin</key>
<string>\{</string>
<key>name</key>
<string>punctuation.section.scope.begin.ruby</string>
</dict>
<dict>
<key>match</key>
<key>beginCaptures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>punctuation.section.scope.begin.ruby</string>
</dict>
</dict>
<key>end</key>
<string>\}</string>
<key>name</key>
<string>punctuation.section.scope.end.ruby</string>
<key>endCaptures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>punctuation.section.scope.end.ruby</string>
</dict>
</dict>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>$self</string>
</dict>
</array>
</dict>
<dict>
<key>match</key>
<key>begin</key>
<string>\[</string>
<key>name</key>
<string>punctuation.section.array.begin.ruby</string>
</dict>
<dict>
<key>match</key>
<key>beginCaptures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>punctuation.section.array.begin.ruby</string>
</dict>
</dict>
<key>end</key>
<string>\]</string>
<key>name</key>
<string>punctuation.section.array.end.ruby</string>
<key>endCaptures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>punctuation.section.array.end.ruby</string>
</dict>
</dict>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>$self</string>
</dict>
</array>
</dict>
<dict>
<key>match</key>
<string>\(|\)</string>
<key>name</key>
<string>punctuation.section.function.ruby</string>
<key>begin</key>
<string>\(</string>
<key>beginCaptures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>punctuation.section.function.ruby</string>
</dict>
</dict>
<key>end</key>
<string>\)</string>
<key>endCaptures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>punctuation.section.function.ruby</string>
</dict>
</dict>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>$self</string>
</dict>
</array>
</dict>
</array>
<key>repository</key>
Expand Down
72 changes: 72 additions & 0 deletions Tests/method_arguments.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
def method; hello, world = [1,2] end # test comment

def method_with_parentheses(a, b, c = [foo,bar,baz]); hello, world = [1,2] end # test comment

def method_without_parentheses a, b, c = [foo,bar,baz]; hello, world = [1,2] end # test comment

def method # test comment
hello, world = [1,2]
end

def method_with_parentheses(a, b, c = [foo,bar,baz]) # test comment
hello, world = [1,2]
end

def method_without_parentheses a, b, c = [foo,bar,baz] # test comment
hello, world = [1,2]
end

def method_with_parentheses(a, b = "hello", c = ["foo", "bar"], d = (2 + 2) * 2, e = {}) # test comment
hello, world = [1,2]
do_something1
do_something2
end

def method_without_parentheses a, b = "hello", c = ["foo", "bar"], d = (2 + 2) * 2, e = "" # test comment
hello, world = [1,2]
do_something1
do_something2
end

def method_with_parentheses(a,
b = hello, # test comment
c = ["foo", bar, :baz],
d = (2 + 2) * 2,
e = {})
hello, world = [1,2]
do_something1
do_something2
end

def method_without_parentheses a,
b = "hello" , # test comment
c = ["foo", bar, :baz],
d = (2 + 2) * 2,
e = proc { |e| e + e }
hello, world = [1,2]
do_something1
do_something2
end

def method_without_parentheses a,
b: hello , # test comment
c: ["foo", bar, :baz],
d: (2 + 2) * 2,
e: proc { |e| e + e }
hello, world = [1,2]
do_something1
do_something2
end

# double splat, splat, and & opearator
def method_with_parentheses(*a, **b, &c); hello, world = [1,2] end # test comment

def method_without_parentheses *a, **b, &c; hello, world = [1,2] end # test comment

def method_with_parentheses(*a, **b, &c) # test comment
hello, world = [1,2]
end

def method_without_parentheses *a, **b, &c # test comment
hello, world = [1,2]
end