Browse Source

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
maint
Junio C Hamano 5 years ago
parent
commit
376e7309e1
  1. 2
      Documentation/gitattributes.txt
  2. 1
      t/t4018-diff-funcname.sh
  3. 5
      t/t4018/elixir-do-not-pick-end
  4. 6
      t/t4018/elixir-ex-unit-test
  5. 5
      t/t4018/elixir-function
  6. 5
      t/t4018/elixir-macro
  7. 9
      t/t4018/elixir-module
  8. 8
      t/t4018/elixir-module-func
  9. 9
      t/t4018/elixir-nested-module
  10. 5
      t/t4018/elixir-private-function
  11. 6
      t/t4018/elixir-protocol
  12. 5
      t/t4018/elixir-protocol-implementation
  13. 12
      userdiff.c

2
Documentation/gitattributes.txt

@ -812,6 +812,8 @@ patterns are available: @@ -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.

1
t/t4018-diff-funcname.sh

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

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

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

6
t/t4018/elixir-ex-unit-test

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

5
t/t4018/elixir-function

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

5
t/t4018/elixir-macro

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

9
t/t4018/elixir-module

@ -0,0 +1,9 @@ @@ -0,0 +1,9 @@
defmodule RIGHT do
@moduledoc """
Foo bar
"""

def ChangeMe(a) where is_map(a) do
a
end
end

8
t/t4018/elixir-module-func

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

9
t/t4018/elixir-nested-module

@ -0,0 +1,9 @@ @@ -0,0 +1,9 @@
defmodule MyApp.RIGHT do
@moduledoc """
Foo bar
"""

def ChangeMe(a) where is_map(a) do
a
end
end

5
t/t4018/elixir-private-function

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

6
t/t4018/elixir-protocol

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

5
t/t4018/elixir-protocol-implementation

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

12
userdiff.c

@ -32,6 +32,18 @@ PATTERNS("dts", @@ -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"

Loading…
Cancel
Save