diff --git a/Syntaxes/Ruby.plist b/Syntaxes/Ruby.plist index d8e3756..e2227cd 100644 --- a/Syntaxes/Ruby.plist +++ b/Syntaxes/Ruby.plist @@ -520,56 +520,7 @@ match - \G([&*]?)(?:([_a-zA-Z]\w*(:))|([_a-zA-Z]\w*)) - - - include - #parens - - - include - #braces - - - include - $self - - - - - repository - - braces - - begin - \{ - beginCaptures - - 0 - - name - punctuation.section.function.begin.ruby - - - end - \} - endCaptures - - 0 - - name - punctuation.section.function.end.ruby - - - patterns - - - include - #parens - - - include - #braces + \G(&|\*\*?)?(?:([_a-zA-Z]\w*(:))|([_a-zA-Z]\w*)) include @@ -577,45 +528,11 @@ - parens - begin - \( - beginCaptures - - 0 - - name - punctuation.section.function.begin.ruby - - - end - \) - endCaptures - - 0 - - name - punctuation.section.function.end.ruby - - - patterns - - - include - #parens - - - include - #braces - - - include - $self - - + include + $self - + begin @@ -644,16 +561,16 @@ comment same as the previous rule, but without parentheses around the arguments end - $ + (?=;)|(?<=[\w\])}`'"!?])(?=\s*#|\s*$) name meta.function.method.with-arguments.ruby patterns begin - (?![\s,]) + (?=[&*_a-zA-Z]) end - (?=,|$) + (?=,|;|\s*#|\s*$) patterns @@ -681,9 +598,7 @@ match - \G([&*]?)(?:([_a-zA-Z]\w*(:))|([_a-zA-Z]\w*)) - name - variable.parameter.function.ruby + \G(&|\*\*?)?(?:([_a-zA-Z]\w*(:))|([_a-zA-Z]\w*)) include @@ -691,6 +606,10 @@ + + include + $self + @@ -1956,34 +1875,91 @@ punctuation.separator.other.ruby - match + begin \{ - name - punctuation.section.scope.begin.ruby - - - match + beginCaptures + + 0 + + name + punctuation.section.scope.begin.ruby + + + end \} - name - punctuation.section.scope.end.ruby + endCaptures + + 0 + + name + punctuation.section.scope.end.ruby + + + patterns + + + include + $self + + - match + begin \[ - name - punctuation.section.array.begin.ruby - - - match + beginCaptures + + 0 + + name + punctuation.section.array.begin.ruby + + + end \] - name - punctuation.section.array.end.ruby + endCaptures + + 0 + + name + punctuation.section.array.end.ruby + + + patterns + + + include + $self + + - match - \(|\) - name - punctuation.section.function.ruby + begin + \( + beginCaptures + + 0 + + name + punctuation.section.function.ruby + + + end + \) + endCaptures + + 0 + + name + punctuation.section.function.ruby + + + patterns + + + include + $self + + repository diff --git a/Tests/method_arguments.rb b/Tests/method_arguments.rb new file mode 100644 index 0000000..9134b28 --- /dev/null +++ b/Tests/method_arguments.rb @@ -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