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>
This commit is contained in:
Łukasz Niemier 2019-11-08 22:38:24 +01:00 committed by Junio C Hamano
parent da72936f54
commit a807200f67
13 changed files with 78 additions and 0 deletions

View File

@ -812,6 +812,8 @@ patterns are available:
- `dts` suitable for devicetree (DTS) files.
- `elixir` suitable for source code in the Elixir language.
- `fortran` suitable for source code in the Fortran language.
- `fountain` suitable for Fountain documents.

View File

@ -32,6 +32,7 @@ diffpatterns="
csharp
css
dts
elixir
fortran
fountain
golang

View File

@ -0,0 +1,5 @@
defmodule RIGHT do
end
#
#
# ChangeMe; do not pick up 'end' line

View File

@ -0,0 +1,6 @@
defmodule Test do
test "RIGHT" do
assert true == true
assert ChangeMe
end
end

5
t/t4018/elixir-function Normal file
View File

@ -0,0 +1,5 @@
def function(RIGHT, arg) do
# comment
# comment
ChangeMe
end

5
t/t4018/elixir-macro Normal file
View File

@ -0,0 +1,5 @@
defmacro foo(RIGHT) do
# Code
# Code
ChangeMe
end

9
t/t4018/elixir-module Normal file
View File

@ -0,0 +1,9 @@
defmodule RIGHT do
@moduledoc """
Foo bar
"""
def ChangeMe(a) where is_map(a) do
a
end
end

View File

@ -0,0 +1,8 @@
defmodule Foo do
def fun(RIGHT) do
# Code
# Code
# Code
ChangeMe
end
end

View File

@ -0,0 +1,9 @@
defmodule MyApp.RIGHT do
@moduledoc """
Foo bar
"""
def ChangeMe(a) where is_map(a) do
a
end
end

View File

@ -0,0 +1,5 @@
defp function(RIGHT, arg) do
# comment
# comment
ChangeMe
end

6
t/t4018/elixir-protocol Normal file
View File

@ -0,0 +1,6 @@
defprotocol RIGHT do
@doc """
Calculates the size (and not the length!) of a data structure
"""
def size(data, ChangeMe)
end

View File

@ -0,0 +1,5 @@
defimpl RIGHT do
# Docs
# Docs
def foo(ChangeMe), do: :ok
end

View File

@ -32,6 +32,18 @@ PATTERNS("dts",
/* Property names and math operators */
"[a-zA-Z0-9,._+?#-]+"
"|[-+*/%&^|!~]|>>|<<|&&|\\|\\|"),
PATTERNS("elixir",
"^[ \t]*((def(macro|module|impl|protocol|p)?|test)[ \t].*)$",
/* Atoms, names, and module attributes */
"|[@:]?[a-zA-Z0-9@_?!]+"
/* Numbers with specific base */
"|[-+]?0[xob][0-9a-fA-F]+"
/* Numbers */
"|[-+]?[0-9][0-9_.]*([eE][-+]?[0-9_]+)?"
/* Operators and atoms that represent them */
"|:?(\\+\\+|--|\\.\\.|~~~|<>|\\^\\^\\^|<?\\|>|<<<?|>?>>|<<?~|~>?>|<~>|<=|>=|===?|!==?|=~|&&&?|\\|\\|\\|?|=>|<-|\\\\\\\\|->)"
/* Not real operators, but should be grouped */
"|:?%[A-Za-z0-9_.]\\{\\}?"),
IPATTERN("fortran",
"!^([C*]|[ \t]*!)\n"
"!^[ \t]*MODULE[ \t]+PROCEDURE[ \t]\n"