@matheusbsbs / matheus-bagliano / commits / a807200f67
Fork 0

userdiff: add Elixir to supported userdiff languages

Adds support for xfuncref in Elixir[1] language which is Ruby-like language that runs on Erlang[3] Virtual Machine (BEAM). [1]: https://elixir-lang.org [2]: https://www.erlang.org Signed-off-by: Łukasz Niemier <lukasz@niemier.pl> Acked-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Łukasz Niemier committed Nov 8, 2019 at 22:38 UTC a807200f67588f6e30a7b6ac4a3ad97ad176ccc7
13 files changed +78
Documentation/gitattributes.txt
+2
@@ -812,6 +812,8 @@ patterns are available:
812
813 - `dts` suitable for devicetree (DTS) files.
814
815 +- `elixir` suitable for source code in the Elixir language.
816 +
817 - `fortran` suitable for source code in the Fortran language.
818
819 - `fountain` suitable for Fountain documents.
t/t4018-diff-funcname.sh
+1
@@ -32,6 +32,7 @@ diffpatterns="
32 csharp
33 css
34 dts
35 + elixir
36 fortran
37 fountain
38 golang
t/t4018/elixir-do-not-pick-end new
+5
@@ -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 new
+6
@@ -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 new
+5
@@ -0,0 +1,5 @@
1 +def function(RIGHT, arg) do
2 + # comment
3 + # comment
4 + ChangeMe
5 +end
t/t4018/elixir-macro new
+5
@@ -0,0 +1,5 @@
1 +defmacro foo(RIGHT) do
2 + # Code
3 + # Code
4 + ChangeMe
5 +end
t/t4018/elixir-module new
+9
@@ -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 new
+8
@@ -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 new
+9
@@ -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 new
+5
@@ -0,0 +1,5 @@
1 +defp function(RIGHT, arg) do
2 + # comment
3 + # comment
4 + ChangeMe
5 +end
t/t4018/elixir-protocol new
+6
@@ -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
t/t4018/elixir-protocol-implementation new
+5
@@ -0,0 +1,5 @@
1 +defimpl RIGHT do
2 + # Docs
3 + # Docs
4 + def foo(ChangeMe), do: :ok
5 +end
userdiff.c
+12
@@ -32,6 +32,18 @@ PATTERNS("dts",
32 /* Property names and math operators */
33 "[a-zA-Z0-9,._+?#-]+"
34 "|[-+*/%&^|!~]|>>|<<|&&|\\|\\|"),
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_.]\\{\\}?"),
47 IPATTERN("fortran",
48 "!^([C*]|[ \t]*!)\n"
49 "!^[ \t]*MODULE[ \t]+PROCEDURE[ \t]\n"