Skip to content

Commit 376e730

Browse files
committed
Merge branch 'ln/userdiff-elixir'
The patterns to detect function boundary for Elixir language has been added. * ln/userdiff-elixir: userdiff: add Elixir to supported userdiff languages
2 parents 9a5d34c + a807200 commit 376e730

13 files changed

+78
-0
lines changed

Documentation/gitattributes.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,8 @@ patterns are available:
812812

813813
- `dts` suitable for devicetree (DTS) files.
814814

815+
- `elixir` suitable for source code in the Elixir language.
816+
815817
- `fortran` suitable for source code in the Fortran language.
816818

817819
- `fountain` suitable for Fountain documents.

t/t4018-diff-funcname.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ diffpatterns="
3232
csharp
3333
css
3434
dts
35+
elixir
3536
fortran
3637
fountain
3738
golang

t/t4018/elixir-do-not-pick-end

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
defmodule RIGHT do
2+
end
3+
#
4+
#
5+
# ChangeMe; do not pick up 'end' line

t/t4018/elixir-ex-unit-test

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
defmodule Test do
2+
test "RIGHT" do
3+
assert true == true
4+
assert ChangeMe
5+
end
6+
end

t/t4018/elixir-function

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
def function(RIGHT, arg) do
2+
# comment
3+
# comment
4+
ChangeMe
5+
end

t/t4018/elixir-macro

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
defmacro foo(RIGHT) do
2+
# Code
3+
# Code
4+
ChangeMe
5+
end

t/t4018/elixir-module

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
defmodule RIGHT do
2+
@moduledoc """
3+
Foo bar
4+
"""
5+
6+
def ChangeMe(a) where is_map(a) do
7+
a
8+
end
9+
end

t/t4018/elixir-module-func

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
defmodule Foo do
2+
def fun(RIGHT) do
3+
# Code
4+
# Code
5+
# Code
6+
ChangeMe
7+
end
8+
end

t/t4018/elixir-nested-module

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
defmodule MyApp.RIGHT do
2+
@moduledoc """
3+
Foo bar
4+
"""
5+
6+
def ChangeMe(a) where is_map(a) do
7+
a
8+
end
9+
end

t/t4018/elixir-private-function

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
defp function(RIGHT, arg) do
2+
# comment
3+
# comment
4+
ChangeMe
5+
end

t/t4018/elixir-protocol

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
defprotocol RIGHT do
2+
@doc """
3+
Calculates the size (and not the length!) of a data structure
4+
"""
5+
def size(data, ChangeMe)
6+
end
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
defimpl RIGHT do
2+
# Docs
3+
# Docs
4+
def foo(ChangeMe), do: :ok
5+
end

userdiff.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,18 @@ PATTERNS("dts",
3232
/* Property names and math operators */
3333
"[a-zA-Z0-9,._+?#-]+"
3434
"|[-+*/%&^|!~]|>>|<<|&&|\\|\\|"),
35+
PATTERNS("elixir",
36+
"^[ \t]*((def(macro|module|impl|protocol|p)?|test)[ \t].*)$",
37+
/* Atoms, names, and module attributes */
38+
"|[@:]?[a-zA-Z0-9@_?!]+"
39+
/* Numbers with specific base */
40+
"|[-+]?0[xob][0-9a-fA-F]+"
41+
/* Numbers */
42+
"|[-+]?[0-9][0-9_.]*([eE][-+]?[0-9_]+)?"
43+
/* Operators and atoms that represent them */
44+
"|:?(\\+\\+|--|\\.\\.|~~~|<>|\\^\\^\\^|<?\\|>|<<<?|>?>>|<<?~|~>?>|<~>|<=|>=|===?|!==?|=~|&&&?|\\|\\|\\|?|=>|<-|\\\\\\\\|->)"
45+
/* Not real operators, but should be grouped */
46+
"|:?%[A-Za-z0-9_.]\\{\\}?"),
3547
IPATTERN("fortran",
3648
"!^([C*]|[ \t]*!)\n"
3749
"!^[ \t]*MODULE[ \t]+PROCEDURE[ \t]\n"

0 commit comments

Comments
 (0)