userdiff: Add diff driver for Kotlin lang and tests
PATCH 1/1 userdiff: Add diff driver for Kotlin lang and tests
This patch adds diff driver for kotlin lang and some test cases for it. Also, modifies Documentation/.gitattributes.txt to state the same
PATCH 1/1 userdiff: Add diff driver for Kotlin lang and tests
The xfuncname pattern finds func/class declarations in diffs to display as a hunk header.
This patch adds xfuncname regex and some respective tests for Kotlin language.
Also modifies Documentation./gitattributes.txt to state the same.
--- Documentation/gitattributes.txt | 2 ++ t/t4018/kotlin-class | 5 +++++ t/t4018/kotlin-enum-class | 5 +++++ t/t4018/kotlin-fun | 5 +++++ t/t4018/kotlin-inheritace-class | 5 +++++ t/t4018/kotlin-inline-class | 5 +++++ t/t4018/kotlin-interface | 5 +++++ t/t4018/kotlin-nested-fun | 9 +++++++++ t/t4018/kotlin-public-class | 5 +++++ t/t4018/kotlin-sealed-class | 5 +++++ userdiff.c | 8 ++++++++ 11 files changed, 59 insertions(+) create mode 100644 t/t4018/kotlin-class create mode 100644 t/t4018/kotlin-enum-class create mode 100644 t/t4018/kotlin-fun create mode 100644 t/t4018/kotlin-inheritace-class create mode 100644 t/t4018/kotlin-inline-class create mode 100644 t/t4018/kotlin-interface create mode 100644 t/t4018/kotlin-nested-fun create mode 100644 t/t4018/kotlin-public-class create mode 100644 t/t4018/kotlin-sealed-class
Documentation/gitattributes.txt +2 -0
@@ -829,6 +829,8 @@ patterns are available: - `java` suitable for source code in the Java language. +- `kotlin` suitable for source code in the Kotlin language + - `markdown` suitable for Markdown documents. - `matlab` suitable for source code in the MATLAB and Octave languages.
t/t4018/kotlin-class new file +5 -0
@@ -0,0 +1,5 @@ +class RIGHT { + //comment + //comment + return ChangeMe +}
t/t4018/kotlin-enum-class new file +5 -0
@@ -0,0 +1,5 @@ +enum class RIGHT{ + // Left + // a comment + ChangeMe +}
t/t4018/kotlin-fun new file +5 -0
@@ -0,0 +1,5 @@ +fun RIGHT(){ + //a comment + //b comment + return ChangeMe() +}
t/t4018/kotlin-inheritace-class new file +5 -0
@@ -0,0 +1,5 @@ +open class RIGHT{ + // a comment + // b comment + // ChangeMe +}
t/t4018/kotlin-inline-class new file +5 -0
@@ -0,0 +1,5 @@ +value class RIGHT(Args){ + // a comment + // b comment + ChangeMe +}
t/t4018/kotlin-interface new file +5 -0
@@ -0,0 +1,5 @@ +interface RIGHT{ + //another comment + //another comment + //ChangeMe +}
t/t4018/kotlin-nested-fun new file +9 -0
@@ -0,0 +1,9 @@ +class LEFT{ + class CENTER{ + fun RIGHT( a:Int){ + //comment + //comment + ChangeMe + } + } +}
t/t4018/kotlin-public-class new file +5 -0
@@ -0,0 +1,5 @@ +public class RIGHT{ + //comment1 + //comment2 + ChangeMe +}
t/t4018/kotlin-sealed-class new file +5 -0
@@ -0,0 +1,5 @@ +sealed class RIGHT { + // a comment + // b comment + ChangeMe +}
userdiff.c +8 -0
@@ -168,6 +168,14 @@ PATTERNS("java","|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?" "|[-+*/<>%&^|=!]=" "|--|\\+\\+|<<=?|>>>?=?|&&|\\|\\|"), +PATTERNS ("kotlin" , +/* fun, class, interface, declarations */ +"^[ \t]*(([a-z]+[ \t]+)*(fun|class|interface)[ \t]+.*[ \t]*)$" , +/* -- */ +"[a-zA-Z_][a-zA-Z0-9_]*" +"|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?" +"|[-+*/<>%&^|=!]=" +"|--|\\+\\+|<<=?|>>>?=?|&&|\\|\\|" ), PATTERNS("markdown", "^ {0,3}#{1,6}[ \t].*",/* -- */
Signature · 1 line
2.35.1
Quoted 1 line · Jaydeep P Das
Subject: Re: [PATCH] userdiff: Add diff driver for Kotlin lang and tests
"Add" -> "add". "lang and tests" -> "language".
Quoted 2 lines
The xfuncname pattern finds func/class declarations in diffs to display as a hunk header.
Yes, but an entry for a language in userdiff.c consists of the funcname pattern AND the word_regex. And I think the patch is adding both, not just funcname pattern.
Quoted 5 lines
This patch adds xfuncname regex and some respective tests for Kotlin language.
Also modifies
Documentation./gitattributes.txtto state the same.
See Documenation/SubmittingPatches::[[imperative-mood]].
But it probably is better to leave these unsaid. The patterns, tests and documentation updates go hand in hand.
Quoted 16 lines
11 files changed, 59 insertions(+) create mode 100644 t/t4018/kotlin-class create mode 100644 t/t4018/kotlin-enum-class create mode 100644 t/t4018/kotlin-fun create mode 100644 t/t4018/kotlin-inheritace-class create mode 100644 t/t4018/kotlin-inline-class create mode 100644 t/t4018/kotlin-interface create mode 100644 t/t4018/kotlin-nested-fun create mode 100644 t/t4018/kotlin-public-class create mode 100644 t/t4018/kotlin-sealed-classDocumentation/gitattributes.txt +0
-0
Documentation/gitattributes.txt patterns are available: · line 834
Quoted 6 lines
Documentation/gitattributes.txt +2
-0@@ -829,6 +829,8 @@ patterns are available: - `java` suitable for source code in the Java language. +- `kotlin` suitable for source code in the Kotlin language + - `markdown` suitable for Markdown documents.
The entries before and after this new one both end with a full stop, and this new entry should do the same.
userdiff.c PATTERNS("java", · line 173
Quoted 11 lines
userdiff.c +3
-0@@ -168,6 +168,14 @@ PATTERNS("java","|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?" "|[-+*/<>%&^|=!]=" "|--|\\+\\+|<<=?|>>>?=?|&&|\\|\\|"), +PATTERNS("kotlin", + /* fun, class, interface, declarations */ + "^[ \t]*(([a-z]+[ \t]+)*(fun|class|interface)[ \t]+.*[ \t]*)$",
With the three keywords clearly visible in the pattern, the comment looks somewhat redundant. I dunno.
userdiff.c PATTERNS("java", · line 178
Quoted 5 lines
userdiff.c +5
-0+/* -- */ +"[a-zA-Z_][a-zA-Z0-9_]*" +"|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?" +"|[-+*/<>%&^|=!]=" + "|--|\\+\\+|<<=?|>>>?=?|&&|\\|\\|"),
The latter half is word regex, which is tested in t4034 to at least ensure that it is well formed. We can also add t/t4034/$language/ to see the patterns hit the word boundary as expected.
Quoted 3 lines
userdiff.c +0
-0PATTERNS("markdown", "^ {0,3}#{1,6}[ \t].*",/* -- */
Quoted 10 lines · Jaydeep P Das
The xfuncname pattern finds func/class declarations in diffs to display as a hunk header.
This patch adds xfuncname regex and some respective tests for Kotlin language.
Also modifies
Documentation./gitattributes.txtto state the same.Signed-off-by Jaydeep P Das <[email protected]>
Quoted 12 lines
--- Documentation/gitattributes.txt | 2 ++ t/t4018/kotlin-class | 5 +++++ t/t4018/kotlin-enum-class | 5 +++++ t/t4018/kotlin-fun | 5 +++++ t/t4018/kotlin-inheritace-class | 5 +++++ t/t4018/kotlin-inline-class | 5 +++++ t/t4018/kotlin-interface | 5 +++++ t/t4018/kotlin-nested-fun | 9 +++++++++ t/t4018/kotlin-public-class | 5 +++++ t/t4018/kotlin-sealed-class | 5 +++++ userdiff.c | 8 ++++++++
I didn't look at the regexes etc. at a glance, but this is missing the corresponding tests for the word-diff part of the regexes. It would be nice to have those tests too.
See the t/t4034/ directory for that (and no, this whole setup isn't very discoverable, sorry!).
Thanks for the review. I will be submitting another patch with the requested changes shortly.
Thanks,
Jaydeep.
PATCH 1/1 userdiff: add builtin diff driver for Kotlin language.
In reply to Jaydeep P DasThe xfuncname pattern finds func/class declarations in diffs to display as a hunk header. The word_regex pattern finds individual tokens in Kotlin code to generate appropriate diffs.
This patch adds xfuncname regex and word_regex for Kotlin language.
--- Documentation/gitattributes.txt | 2 ++ t/t4018/kotlin-class | 5 +++++ t/t4018/kotlin-enum-class | 5 +++++ t/t4018/kotlin-fun | 5 +++++ t/t4018/kotlin-inheritace-class | 5 +++++ t/t4018/kotlin-inline-class | 5 +++++ t/t4018/kotlin-interface | 5 +++++ t/t4018/kotlin-nested-fun | 9 +++++++++ t/t4018/kotlin-public-class | 5 +++++ t/t4018/kotlin-sealed-class | 5 +++++ t/t4034-diff-words.sh | 1 + t/t4034/kotlin/expect | 33 +++++++++++++++++++++++++++++++++ t/t4034/kotlin/post | 16 ++++++++++++++++ t/t4034/kotlin/pre | 16 ++++++++++++++++ userdiff.c | 7 +++++++ 15 files changed, 124 insertions(+) create mode 100644 t/t4018/kotlin-class create mode 100644 t/t4018/kotlin-enum-class create mode 100644 t/t4018/kotlin-fun create mode 100644 t/t4018/kotlin-inheritace-class create mode 100644 t/t4018/kotlin-inline-class create mode 100644 t/t4018/kotlin-interface create mode 100644 t/t4018/kotlin-nested-fun create mode 100644 t/t4018/kotlin-public-class create mode 100644 t/t4018/kotlin-sealed-class create mode 100644 t/t4034/kotlin/expect create mode 100644 t/t4034/kotlin/post create mode 100644 t/t4034/kotlin/pre
Documentation/gitattributes.txt +2 -0
@@ -829,6 +829,8 @@ patterns are available: - `java` suitable for source code in the Java language. +- `kotlin` suitable for source code in the Kotlin language. + - `markdown` suitable for Markdown documents. - `matlab` suitable for source code in the MATLAB and Octave languages.
t/t4018/kotlin-class new file +5 -0
@@ -0,0 +1,5 @@ +class RIGHT { + //comment + //comment + return ChangeMe +}
t/t4018/kotlin-enum-class new file +5 -0
@@ -0,0 +1,5 @@ +enum class RIGHT{ + // Left + // a comment + ChangeMe +}
t/t4018/kotlin-fun new file +5 -0
@@ -0,0 +1,5 @@ +fun RIGHT(){ + //a comment + //b comment + return ChangeMe() +}
t/t4018/kotlin-inheritace-class new file +5 -0
@@ -0,0 +1,5 @@ +open class RIGHT{ + // a comment + // b comment + // ChangeMe +}
t/t4018/kotlin-inline-class new file +5 -0
@@ -0,0 +1,5 @@ +value class RIGHT(Args){ + // a comment + // b comment + ChangeMe +}
t/t4018/kotlin-interface new file +5 -0
@@ -0,0 +1,5 @@ +interface RIGHT{ + //another comment + //another comment + //ChangeMe +}
t/t4018/kotlin-nested-fun new file +9 -0
@@ -0,0 +1,9 @@ +class LEFT{ + class CENTER{ + fun RIGHT( a:Int){ + //comment + //comment + ChangeMe + } + } +}
t/t4018/kotlin-public-class new file +5 -0
@@ -0,0 +1,5 @@ +public class RIGHT{ + //comment1 + //comment2 + ChangeMe +}
t/t4018/kotlin-sealed-class new file +5 -0
@@ -0,0 +1,5 @@ +sealed class RIGHT { + // a comment + // b comment + ChangeMe +}
t/t4034-diff-words.sh +1 -0
@@ -324,6 +324,7 @@ test_language_driver dts test_language_driver fortran test_language_driver html test_language_driver java +test_language_driver kotlin test_language_driver matlab test_language_driver objc test_language_driver pascal
t/t4034/kotlin/expect new file +33 -0
@@ -0,0 +1,33 @@ +<BOLD>diff --git a/pre b/post<RESET> +<BOLD>index e8a199a..e6ebebb 100644<RESET> +<BOLD>--- a/pre<RESET> +<BOLD>+++ b/post<RESET> +<CYAN>@@ -1,16 +1,16 @@<RESET> +println("Hello World<RED>!\n<RESET><GREEN>?<RESET>") +<GREEN>(<RESET>1<GREEN>) (<RESET>-1e10<RED>0xabcdef<RESET><GREEN>) (0xaybcdef)<RESET> '<RED>x<RESET><GREEN>y<RESET>' +[<RED>a<RESET><GREEN>x<RESET>] <RED>a<RESET><GREEN>x<RESET>-><RED>b a<RESET><GREEN>y x<RESET>.<RED>b<RESET><GREEN>y<RESET> +!<RED>a a<RESET><GREEN>x x<RESET>.inv() <RED>a<RESET><GREEN>x<RESET>*<RED>b a<RESET><GREEN>y x<RESET>&<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET>*<RED>b a<RESET><GREEN>y x<RESET>/<RED>b a<RESET><GREEN>y x<RESET>%<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET>+<RED>b a<RESET><GREEN>y x<RESET>-<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET> shl <RED>b a<RESET><GREEN>y x<RESET> shr <RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET><<RED>b a<RESET><GREEN>y x<RESET><=<RED>b a<RESET><GREEN>y x<RESET>><RED>b a<RESET><GREEN>y x<RESET>>=<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET>==<RED>b a<RESET><GREEN>y x<RESET>!=<RED>b a<RESET><GREEN>y x<RESET>===<RED>b<RESET> +<RED>a and b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x xnd y<RESET> +<GREEN>x<RESET>^<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET> or <RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET>&&<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET>||<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET>=<RED>b a<RESET><GREEN>y x<RESET>+=<RED>b a<RESET><GREEN>y x<RESET>-=<RED>b a<RESET><GREEN>y x<RESET>*=<RED>b a<RESET><GREEN>y x<RESET>/=<RED>b a<RESET><GREEN>y x<RESET>%=<RED>b a<RESET><GREEN>y x<RESET><<=<RED>b a<RESET><GREEN>y x<RESET>>>=<RED>b a<RESET><GREEN>y x<RESET>&=<RED>b a<RESET><GREEN>y x<RESET>^=<RED>b a<RESET><GREEN>y x<RESET>|=<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET>,y
t/t4034/kotlin/post new file +16 -0
@@ -0,0 +1,16 @@ +println("Hello World?") +(1) (-1e10) (0xaybcdef) 'y' +[x] x->y x.y +!x x.inv() x*y x&y +x*y x/y x%y +x+y x-y +x shl y x shr y +x<y x<=y x>y x>=y +x==y x!=y x===y +x xnd y +x^y +x or y +x&&y +x||y +x=y x+=y x-=y x*=y x/=y x%=y x<<=y x>>=y x&=y x^=y x|=y +x,y
t/t4034/kotlin/pre new file +16 -0
@@ -0,0 +1,16 @@ +println("Hello World!\n") +1 -1e10 0xabcdef 'x' +[a] a->b a.b +!a a.inv() a*b a&b +a*b a/b a%b +a+b a-b +a shl b a shr b +a<b a<=b a>b a>=b +a==b a!=b a===b +a and b +a^b +a or b +a&&b +a||b +a=b a+=b a-=b a*=b a/=b a%=b a<<=b a>>=b a&=b a^=b a|=b +a,y
userdiff.c +7 -0
@@ -168,6 +168,13 @@ PATTERNS("java","|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?" "|[-+*/<>%&^|=!]=" "|--|\\+\\+|<<=?|>>>?=?|&&|\\|\\|"), +PATTERNS ("kotlin" , +"^[ \t]*(([a-z]+[ \t]+)*(fun|class|interface)[ \t]+.*[ \t]*)$" , +/* -- */ +"[a-zA-Z_][a-zA-Z0-9_]*" +"|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?" +"|[-+*/<>%&^|=!]=" +"|--|\\+\\+|<<=?|>>>?=?|&&|\\|\\|" ), PATTERNS("markdown", "^ {0,3}#{1,6}[ \t].*",/* -- */
Signature · 1 line
2.35.1
Re: [PATCH] userdiff: add builtin diff driver for Kotlin language.
Documentation/gitattributes.txt patterns are available: · line 836
Quoted 13 lines · Jaydeep P Das
Documentation/gitattributes.txt +2
-0@@ -829,6 +829,8 @@ patterns are available: - `java` suitable for source code in the Java language. +- `kotlin` suitable for source code in the Kotlin language. + - `markdown` suitable for Markdown documents. - `matlab` suitable for source code in the MATLAB and Octave languages.
I do not speak the language, but hopefully those who do will find issues and help us correct them if there still are any. The patch organization looks good. Will queue.
Thanks.
Quoted 18 lines
userdiff.c +7
-0@@ -168,6 +168,13 @@ PATTERNS("java","|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?" "|[-+*/<>%&^|=!]=" "|--|\\+\\+|<<=?|>>>?=?|&&|\\|\\|"), +PATTERNS ("kotlin" , +"^[ \t]*(([a-z]+[ \t]+)*(fun|class|interface)[ \t]+.*[ \t]*)$" , +/* -- */ +"[a-zA-Z_][a-zA-Z0-9_]*" +"|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?" +"|[-+*/<>%&^|=!]=" +"|--|\\+\\+|<<=?|>>>?=?|&&|\\|\\|" ), PATTERNS("markdown", "^ {0,3}#{1,6}[ \t].*",/* -- */
Re: [PATCH] userdiff: add builtin diff driver for Kotlin language.
Thanks for the review.
I have some criticism regarding t/t4018-diff-funcname.sh.
When any test fails, its verbose output is not "verbose" enough. For example, If due to wrong xfuncname regex or wrong test, all of the following hunk headers
@@...@@
@@...@@fun right(){
@@...@@fun
produce the same verbose output:
not ok:....hunk header:[testfilename]
Initially, I had a difficult time to debug what was going wrong so as a temporary fix, I made t/t4018-diff-funcname.sh to cat out the hunk stored in actual.
``` # check each individual file for i in $(git ls-files) do test_expect_success "hunk header of file: $i" " git diff -U1 $i >actual && echo 'hunk:' && cat actual && echo && grep '@@ .* @@.*RIGHT' actual " done ```
Is there another proper way to make the test script produce the hunk for each test?
Thanks,
Jaydeep.
Re: [PATCH] userdiff: add builtin diff driver for Kotlin language.
Am 01.03.22 um 19:09 schrieb [email protected]:
Quoted 11 lines
When any test fails, its verbose output is not "verbose" enough. For example, If due to wrong xfuncname regex or wrong test, all of the following hunk headers
@@...@@
@@...@@fun right(){
@@...@@funproduce the same verbose output:
not ok:....hunk header:[testfilename]
You run
./t4018-diff-funcname.sh -v -i
which stops at the first failing test case. You get
expecting success of 4018.160 'hunk header: kotlin-interface':
git diff -U1 kotlin-interface >actual &&
grep '@@ .* @@.*RIGHT' actualnot ok 160 - hunk header: kotlin-interface
#
# git diff -U1 kotlin-interface >actual &&
# grep '@@ .* @@.*RIGHT' actual
#
from which you see that you have to inspect the file actual:
less trash\ directory.t4018-diff-funcname/actual
-- Hannes
Re: [PATCH] userdiff: add builtin diff driver for Kotlin language.
In reply to Jaydeep P DasAm 01.03.22 um 16:54 schrieb Jaydeep P Das:
Quoted 6 lines
t/t4018/kotlin-nested-fun new file +0
-0
t/t4018/kotlin-nested-fun line 9
Quoted 9 lines
t/t4018/kotlin-nested-fun new file +9
-0@@ -0,0 +1,9 @@ +class LEFT{ + class CENTER{ + fun RIGHT( a:Int){ + //comment + //comment + ChangeMe + } + } +}
Nice move to include a test with an indented key phrase. The t4018 test cases all look fine. I don't speek Kotlin, though, so...
Quoted 73 lines
t/t4034/kotlin/expect new file +33
-0@@ -0,0 +1,33 @@ +<BOLD>diff --git a/pre b/post<RESET> +<BOLD>index e8a199a..e6ebebb 100644<RESET> +<BOLD>--- a/pre<RESET> +<BOLD>+++ b/post<RESET> +<CYAN>@@ -1,16 +1,16 @@<RESET> +println("Hello World<RED>!\n<RESET><GREEN>?<RESET>") +<GREEN>(<RESET>1<GREEN>) (<RESET>-1e10<RED>0xabcdef<RESET><GREEN>) (0xaybcdef)<RESET> '<RED>x<RESET><GREEN>y<RESET>' +[<RED>a<RESET><GREEN>x<RESET>] <RED>a<RESET><GREEN>x<RESET>-><RED>b a<RESET><GREEN>y x<RESET>.<RED>b<RESET><GREEN>y<RESET> +!<RED>a a<RESET><GREEN>x x<RESET>.inv() <RED>a<RESET><GREEN>x<RESET>*<RED>b a<RESET><GREEN>y x<RESET>&<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET>*<RED>b a<RESET><GREEN>y x<RESET>/<RED>b a<RESET><GREEN>y x<RESET>%<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET>+<RED>b a<RESET><GREEN>y x<RESET>-<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET> shl <RED>b a<RESET><GREEN>y x<RESET> shr <RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET><<RED>b a<RESET><GREEN>y x<RESET><=<RED>b a<RESET><GREEN>y x<RESET>><RED>b a<RESET><GREEN>y x<RESET>>=<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET>==<RED>b a<RESET><GREEN>y x<RESET>!=<RED>b a<RESET><GREEN>y x<RESET>===<RED>b<RESET> +<RED>a and b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x xnd y<RESET> +<GREEN>x<RESET>^<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET> or <RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET>&&<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET>||<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET>=<RED>b a<RESET><GREEN>y x<RESET>+=<RED>b a<RESET><GREEN>y x<RESET>-=<RED>b a<RESET><GREEN>y x<RESET>*=<RED>b a<RESET><GREEN>y x<RESET>/=<RED>b a<RESET><GREEN>y x<RESET>%=<RED>b a<RESET><GREEN>y x<RESET><<=<RED>b a<RESET><GREEN>y x<RESET>>>=<RED>b a<RESET><GREEN>y x<RESET>&=<RED>b a<RESET><GREEN>y x<RESET>^=<RED>b a<RESET><GREEN>y x<RESET>|=<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET>,yt/t4034/kotlin/post new file +16
-0@@ -0,0 +1,16 @@ +println("Hello World?") +(1) (-1e10) (0xaybcdef) 'y' +[x] x->y x.y +!x x.inv() x*y x&y +x*y x/y x%y +x+y x-y +x shl y x shr y +x<y x<=y x>y x>=y +x==y x!=y x===y +x xnd y +x^y +x or y +x&&y +x||y +x=y x+=y x-=y x*=y x/=y x%=y x<<=y x>>=y x&=y x^=y x|=y +x,yt/t4034/kotlin/pre new file +6
-0@@ -0,0 +1,16 @@ +println("Hello World!\n") +1 -1e10 0xabcdef 'x' +[a] a->b a.b +!a a.inv() a*b a&b +a*b a/b a%b +a+b a-b
t/t4034/kotlin/pre line 16
Quoted 10 lines
t/t4034/kotlin/pre new file +10
-0+a shl b a shr b +a<b a<=b a>b a>=b +a==b a!=b a===b +a and b +a^b +a or b +a&&b +a||b +a=b a+=b a-=b a*=b a/=b a%=b a<<=b a>>=b a&=b a^=b a|=b +a,y
I know you just copied an existing test case. But actually, it misses the important parts of the word regex patterns. In particular, it only tests that a change of a to x is found, but does not test that the operators are not split into individual characters. Please have a look at my series 1cf93847c1ed~..386076ec92c7 and in particular 1cf93847c1ed to see what you actually want to test. For example, you could test a change from a+=b to a-=b, i.e., that operators += and -= are not split into +, -, and =.
userdiff.c PATTERNS("java", · line 172
Quoted 10 lines
userdiff.c +2
-0@@ -168,6 +168,13 @@ PATTERNS("java","|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?" "|[-+*/<>%&^|=!]=" "|--|\\+\\+|<<=?|>>>?=?|&&|\\|\\|"), +PATTERNS("kotlin", + "^[ \t]*(([a-z]+[ \t]+)*(fun|class|interface)[ \t]+.*[ \t]*)$",
I would guess that the trailing [ \t]* is pointless and always empty, because it is covered by the preceding .*, so you can remove it.
userdiff.c PATTERNS("java", · line 175
Quoted 3 lines
userdiff.c +3
-0+/* -- */ +"[a-zA-Z_][a-zA-Z0-9_]*" +"|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?"
The first part intends to match integers and floatingpoint numbers. Word regex can be loose. This one, however, is too loose. For example, it treats -e+2 as a single token, but that is actually a whole expression consisting of several tokens and is not unlikely to occur in real code. See also 350b87cd6585.
I am pretty sure that, e.g., -1 and +2.5 are both two tokens each, i.e., the sign is not part of the number token.
Also, it looks like 3.0e5 is a floating point number; is 3.0E5 not?
userdiff.c PATTERNS("java", · line 180
Quoted 5 lines
userdiff.c +2
-0+"|[-+*/<>%&^|=!]=" + "|--|\\+\\+|<<=?|>>>?=?|&&|\\|\\|"), PATTERNS("markdown", "^ {0,3}#{1,6}[ \t].*",/* -- */
-- Hannes
PATCH v2 1/1 userdiff: add builtin driver for kotlin language
In reply to Jaydeep P DasThanks for the review.
Yes. As Johannes pointed out, the word_regex was very loose and did not properly tokenise the code.
I have fixed(and added tests) for the following things in this patch:
+= or -= is not split into + = or - =
-a or +a is split into 2 tokens(for each)
Since kotlin supports _ in between digits to improve readability, therefore numbers like 100_000 are single tokens and not broken up by the regex in this patch.
Kotlin also does not support octal literals, and so the regex does not attempt to find it.
PATCH 1/1 userdiff: add builtin driver for kotlin language
The xfuncname pattern finds func/class declarations in diffs to display as a hunk header. The word_regex pattern finds individual tokens in Kotlin code to generate appropriate diffs.
This patch adds xfuncname regex and word_regex for Kotlin language.
--- Documentation/gitattributes.txt | 2 ++ t/t4018/kotlin-class | 5 +++++ t/t4018/kotlin-enum-class | 5 +++++ t/t4018/kotlin-fun | 5 +++++ t/t4018/kotlin-inheritace-class | 5 +++++ t/t4018/kotlin-inline-class | 5 +++++ t/t4018/kotlin-interface | 5 +++++ t/t4018/kotlin-nested-fun | 9 +++++++++ t/t4018/kotlin-public-class | 5 +++++ t/t4018/kotlin-sealed-class | 5 +++++ t/t4034-diff-words.sh | 1 + t/t4034/kotlin/expect | 35 +++++++++++++++++++++++++++++++++ t/t4034/kotlin/post | 19 ++++++++++++++++++ t/t4034/kotlin/pre | 19 ++++++++++++++++++ userdiff.c | 8 ++++++++ 15 files changed, 133 insertions(+) create mode 100644 t/t4018/kotlin-class create mode 100644 t/t4018/kotlin-enum-class create mode 100644 t/t4018/kotlin-fun create mode 100644 t/t4018/kotlin-inheritace-class create mode 100644 t/t4018/kotlin-inline-class create mode 100644 t/t4018/kotlin-interface create mode 100644 t/t4018/kotlin-nested-fun create mode 100644 t/t4018/kotlin-public-class create mode 100644 t/t4018/kotlin-sealed-class create mode 100644 t/t4034/kotlin/expect create mode 100644 t/t4034/kotlin/post create mode 100644 t/t4034/kotlin/pre
Documentation/gitattributes.txt +2 -0
@@ -829,6 +829,8 @@ patterns are available: - `java` suitable for source code in the Java language. +- `kotlin` suitable for source code in the Kotlin language. + - `markdown` suitable for Markdown documents. - `matlab` suitable for source code in the MATLAB and Octave languages.
t/t4018/kotlin-class new file +5 -0
@@ -0,0 +1,5 @@ +class RIGHT { + //comment + //comment + return ChangeMe +}
t/t4018/kotlin-enum-class new file +5 -0
@@ -0,0 +1,5 @@ +enum class RIGHT{ + // Left + // a comment + ChangeMe +}
t/t4018/kotlin-fun new file +5 -0
@@ -0,0 +1,5 @@ +fun RIGHT(){ + //a comment + //b comment + return ChangeMe() +}
t/t4018/kotlin-inheritace-class new file +5 -0
@@ -0,0 +1,5 @@ +open class RIGHT{ + // a comment + // b comment + // ChangeMe +}
t/t4018/kotlin-inline-class new file +5 -0
@@ -0,0 +1,5 @@ +value class RIGHT(Args){ + // a comment + // b comment + ChangeMe +}
t/t4018/kotlin-interface new file +5 -0
@@ -0,0 +1,5 @@ +interface RIGHT{ + //another comment + //another comment + //ChangeMe +}
t/t4018/kotlin-nested-fun new file +9 -0
@@ -0,0 +1,9 @@ +class LEFT{ + class CENTER{ + fun RIGHT( a:Int){ + //comment + //comment + ChangeMe + } + } +}
t/t4018/kotlin-public-class new file +5 -0
@@ -0,0 +1,5 @@ +public class RIGHT{ + //comment1 + //comment2 + ChangeMe +}
t/t4018/kotlin-sealed-class new file +5 -0
@@ -0,0 +1,5 @@ +sealed class RIGHT { + // a comment + // b comment + ChangeMe +}
t/t4034-diff-words.sh +1 -0
@@ -324,6 +324,7 @@ test_language_driver dts test_language_driver fortran test_language_driver html test_language_driver java +test_language_driver kotlin test_language_driver matlab test_language_driver objc test_language_driver pascal
t/t4034/kotlin/expect new file +35 -0
@@ -0,0 +1,35 @@ +<BOLD>diff --git a/pre b/post<RESET> +<BOLD>index 884560d..7e136e2 100644<RESET> +<BOLD>--- a/pre<RESET> +<BOLD>+++ b/post<RESET> +<CYAN>@@ -1,19 +1,19 @@<RESET> +println("Hello World<RED>!\n<RESET><GREEN>?<RESET>") +<GREEN>(<RESET>1<GREEN>) (<RESET>-1e10<GREEN>) (<RESET>0xabcdef<GREEN>)<RESET> '<RED>x<RESET><GREEN>y<RESET>' +<RED>100000<RESET><GREEN>100_000<RESET> +[<RED>a<RESET><GREEN>x<RESET>] <RED>a<RESET><GREEN>x<RESET>-><RED>b a<RESET><GREEN>y x<RESET>.<RED>b<RESET><GREEN>y<RESET> +!<RED>a a<RESET><GREEN>x x<RESET>.inv() <RED>a<RESET><GREEN>x<RESET>*<RED>b a<RESET><GREEN>y x<RESET>&<RED>b<RESET><GREEN>y<RESET> +a<RED>+=<RESET><GREEN>-=<RESET>b +<RED>a<RESET><GREEN>x<RESET>*<RED>b a<RESET><GREEN>y x<RESET>/<RED>b a<RESET><GREEN>y x<RESET>%<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET>+<RED>b a<RESET><GREEN>y x<RESET>-<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET> shl <RED>b a<RESET><GREEN>y x<RESET> shr <RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET><<RED>b a<RESET><GREEN>y x<RESET><=<RED>b a<RESET><GREEN>y x<RESET>><RED>b a<RESET><GREEN>y x<RESET>>=<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET>==<RED>b a<RESET><GREEN>y x<RESET>!=<RED>b a<RESET><GREEN>y x<RESET>===<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET> and <RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET>^<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET> or <RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET>&&<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET>||<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET>=<RED>b a<RESET><GREEN>y x<RESET>+=<RED>b a<RESET><GREEN>y x<RESET>-=<RED>b a<RESET><GREEN>y x<RESET>*=<RED>b a<RESET><GREEN>y x<RESET>/=<RED>b a<RESET><GREEN>y x<RESET>%=<RED>b a<RESET><GREEN>y x<RESET><<=<RED>b a<RESET><GREEN>y x<RESET>>>=<RED>b a<RESET><GREEN>y x<RESET>&=<RED>b a<RESET><GREEN>y x<RESET>^=<RED>b a<RESET><GREEN>y x<RESET>|=<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET>,y +-<RED>a<RESET><GREEN>x<RESET>+2
t/t4034/kotlin/post new file +19 -0
@@ -0,0 +1,19 @@ +println("Hello World?") +(1) (-1e10) (0xabcdef) 'y' +100_000 +[x] x->y x.y +!x x.inv() x*y x&y +a-=b +x*y x/y x%y +x+y x-y +x shl y x shr y +x<y x<=y x>y x>=y +x==y x!=y x===y +x and y +x^y +x or y +x&&y +x||y +x=y x+=y x-=y x*=y x/=y x%=y x<<=y x>>=y x&=y x^=y x|=y +x,y +-x+2
t/t4034/kotlin/pre new file +19 -0
@@ -0,0 +1,19 @@ +println("Hello World!\n") +1 -1e10 0xabcdef 'x' +100000 +[a] a->b a.b +!a a.inv() a*b a&b +a+=b +a*b a/b a%b +a+b a-b +a shl b a shr b +a<b a<=b a>b a>=b +a==b a!=b a===b +a and b +a^b +a or b +a&&b +a||b +a=b a+=b a-=b a*=b a/=b a%=b a<<=b a>>=b a&=b a^=b a|=b +a,y +-a+2
userdiff.c +8 -0
@@ -168,6 +168,14 @@ PATTERNS("java","|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?" "|[-+*/<>%&^|=!]=" "|--|\\+\\+|<<=?|>>>?=?|&&|\\|\\|"), +PATTERNS ("kotlin" , +"^[ \t]*(([a-z]+[ \t]+)*(fun|class|interface)[ \t]+.*)$" , +/* -- */ +"[_]?[a-zA-Z][a-zA-Z0-9_]*" +/*hexadecimal, integers and binary numbers*/ +"|(0x0F|0b)?[0-9._]+([Ee][-+]?[0-9]+)?[fFlLuU]*" +/*match unary and binary operators*/ +"|[-+*/<>%&^|=!]*" ), PATTERNS("markdown", "^ {0,3}#{1,6}[ \t].*",/* -- */
Signature · 1 line
2.35.1
Re: [PATCH] userdiff: add builtin driver for kotlin language
Added jc to Cc:.
Am 02.03.22 um 07:45 schrieb Jaydeep P Das:
Quoted 6 lines
t/t4034/kotlin/expect new file +0
-0
t/t4034/kotlin/expect line 8
Quoted 8 lines
t/t4034/kotlin/expect new file +8
-0@@ -0,0 +1,35 @@ +<BOLD>diff --git a/pre b/post<RESET> +<BOLD>index 884560d..7e136e2 100644<RESET> +<BOLD>--- a/pre<RESET> +<BOLD>+++ b/post<RESET> +<CYAN>@@ -1,19 +1,19 @@<RESET> +println("Hello World<RED>!\n<RESET><GREEN>?<RESET>") +<GREEN>(<RESET>1<GREEN>) (<RESET>-1e10<GREEN>) (<RESET>0xabcdef<GREEN>)<RESET> '<RED>x<RESET><GREEN>y<RESET>' +<RED>100000<RESET><GREEN>100_000<RESET>
This test does not demonstrates that numbers do not end at an '_', because if it did end there, the change would be from the single token 100000 to two tokens 100 and _000, and the mark-up would look exactly the same as we see here, and would remain undiagnosed.
Instead, write the pre-image as 100_000 and the post image as 200_000. Then the correct mark-up would be
<RED>100_000<RESET><GREEN>200_000<RESET>
and a bogus markup (that the test wants to diagnose) would look like
<RED>100<RESET><GREEN>200<RESET>_000
t/t4034/kotlin/expect line 11
Quoted 3 lines
t/t4034/kotlin/expect new file +3
-0+[<RED>a<RESET><GREEN>x<RESET>] <RED>a<RESET><GREEN>x<RESET>-><RED>b a<RESET><GREEN>y x<RESET>.<RED>b<RESET><GREEN>y<RESET> +!<RED>a a<RESET><GREEN>x x<RESET>.inv() <RED>a<RESET><GREEN>x<RESET>*<RED>b a<RESET><GREEN>y x<RESET>&<RED>b<RESET><GREEN>y<RESET> +a<RED>+=<RESET><GREEN>-=<RESET>b
OK, so you decided to check operator += and -=. But what about all the other multi-character operators?
Quoted 11 lines
t/t4034/kotlin/expect new file +11
-0+<RED>a<RESET><GREEN>x<RESET>*<RED>b a<RESET><GREEN>y x<RESET>/<RED>b a<RESET><GREEN>y x<RESET>%<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET>+<RED>b a<RESET><GREEN>y x<RESET>-<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET> shl <RED>b a<RESET><GREEN>y x<RESET> shr <RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET><<RED>b a<RESET><GREEN>y x<RESET><=<RED>b a<RESET><GREEN>y x<RESET>><RED>b a<RESET><GREEN>y x<RESET>>=<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET>==<RED>b a<RESET><GREEN>y x<RESET>!=<RED>b a<RESET><GREEN>y x<RESET>===<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET> and <RED>b<RESET>
t/t4034/kotlin/expect line 32
Quoted 10 lines
t/t4034/kotlin/expect new file +10
-0+<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET>^<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET> or <RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET>&&<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET>||<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET>=<RED>b a<RESET><GREEN>y x<RESET>+=<RED>b a<RESET><GREEN>y x<RESET>-=<RED>b a<RESET><GREEN>y x<RESET>*=<RED>b a<RESET><GREEN>y x<RESET>/=<RED>b a<RESET><GREEN>y x<RESET>%=<RED>b a<RESET><GREEN>y x<RESET><<=<RED>b a<RESET><GREEN>y x<RESET>>>=<RED>b a<RESET><GREEN>y x<RESET>&=<RED>b a<RESET><GREEN>y x<RESET>^=<RED>b a<RESET><GREEN>y x<RESET>|=<RED>b<RESET>
This line is the best candidate to check many multi-character operators. For example, the pre-image could read
a=b c+=d e-=f g*=h i/=j k%=l m<<=n o>>=p q&=r s^=t u|=v
and the post-image
a+=b c=d e<=f g>=h i/j k%l m<<n o>>p q&r s^t u|v
but there are more operators to check.
Please either make these changes or drop this t4034 test case, because in its current form it gives a false sense of security, IMHO.
t/t4034/kotlin/expect line 35
Quoted 3 lines
t/t4034/kotlin/expect new file +3
-0+<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET>,y +-<RED>a<RESET><GREEN>x<RESET>+2
What do you want to demonstrate with this new test case? If you want to show that the + in +2 is not part of the number, then you must change, for example, "a+2" to "a+1". If you change only the a to x, then we do not know whether the +2 was regarded as one token or two.
userdiff.c PATTERNS("java", · line 174
Quoted 12 lines
userdiff.c +4
-0@@ -168,6 +168,14 @@ PATTERNS("java","|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?" "|[-+*/<>%&^|=!]=" "|--|\\+\\+|<<=?|>>>?=?|&&|\\|\\|"), +PATTERNS ("kotlin" , +"^[ \t]*(([a-z]+[ \t]+)*(fun|class|interface)[ \t]+.*)$" , +/* -- */ + "[_]?[a-zA-Z][a-zA-Z0-9_]*"
An underscore followed by a digit is not an identifier, but a number, right? Then this expression correctly does not match and the following expression dedicated to numbers takes care of it. Good.
userdiff.c PATTERNS("java", · line 176
Quoted 2 lines
userdiff.c +2
-0+/*hexadecimal, integers and binary numbers*/ +"|(0x0F|0b)?[0-9._]+([Ee][-+]?[0-9]+)?[fFlLuU]*"
What is this "0x0F"? Did you mean just "0x"? And what about prefixes 0X and 0B? Are they not used as prefixes for hex and binary numbers? Moreover, I do not see how a hex number 0xff would be matched as a single token.
userdiff.c PATTERNS("java", · line 178
Quoted 2 lines
userdiff.c +2
-0+/*match unary and binary operators*/ + "|[-+*/<>%&^|=!]*"),
Do not do this. There is an implicit single-character match that need not be written down in the regex. List all multi-character operators (but not the single-character operators) like you did in earlier rounds. As written, the "++!=" in an expression such as "a++!=b++" (which is not unlikely to be seen in real code) would be regarded as a single token.
The verb "match" in the comment does not match the style of the other comments (drop the word), and please insert blanks between the comment delimiters and the text.
userdiff.c PATTERNS("java", · line 181
Quoted 3 lines
userdiff.c +0
-0PATTERNS("markdown", "^ {0,3}#{1,6}[ \t].*",/* -- */
-- Hannes
Re: [PATCH] userdiff: add builtin driver for kotlin language
Quoted 4 lines
This test does not demonstrates that numbers do not end at an '_', because if it did end there, the change would be from the single token 100000 to two tokens 100 and _000, and the mark-up would look exactly the same as we see here, and would remain undiagnosed.
Yes but numbers ending in _ would be illegal syntax in Kotlin so the regex assumes that user is writing correct code.
Quoted 8 lines
Instead, write the pre-image as 100_000 and the post image as 200_000. Then the correct mark-up would be
<RED>100_000<RESET><GREEN>200_000<RESET>
and a bogus markup (that the test wants to diagnose) would look like
<RED>100<RESET><GREEN>200<RESET>_000
Right. I will add that test too.
Quoted 1 line
What is this "
0x0F"? Did you mean just "0x"?
0x0F indicates that its a hexadecimal literal in Kotlin.
Quoted 7 lines
And what about prefixes 0X
and 0B? Are they not used as prefixes for hex and binary numbers? Moreover, I do not see how a hex number0xffwould be matched as a single token.userdiff.c PATTERNS("java", · line 178
Quoted 2 lines
userdiff.c +2
-0+/*match unary and binary operators*/ + "|[-+*/<>%&^|=!]*"),
Yes. I would make the changes.
Quoted 6 lines
Do not do this. There is an implicit single-character match that need not be written down in the regex. List all multi-character operators (but not the single-character operators) like you did in earlier rounds. As written, the "++!=" in an expression such as "a++!=b++" (which is not unlikely to be seen in real code) would be regarded as a single token.
Quoted 7 lines
The verb "match" in the comment does not match the style of the other comments (drop the word), and please insert blanks between the comment delimiters and the text.
Quoted 3 lines
PATTERNS("markdown",
"^ {0,3}#{1,6}[ \t].*",
/* -- */
Noted.
Thanks,
Jaydeep.
Re: [PATCH] userdiff: add builtin driver for kotlin language
Quoted 1 line · On 3/2/22 2:39 PM, [email protected] wrote:
0x0Findicates that its a hexadecimal literal in Kotlin.
My bad. It was wrong. Hexadecimals are prefixed with 0xFF. I will fix it.
PATCH v3 1/1 userdiff: add builtin driver for kotlin language
In reply to Jaydeep P DasThanks Johannes for the review.
This patch hopefully fixes the problems you mentioned:
- Hexadecimals, binary and numbers with _ are considered a single token
Pre Post
0xFF_EC_DE_5E 0xFF_E1_DE_5E
0b100_000 0b100_100
100_000 200_000Even though a single character is changed in each of the above numbers, the diffs would be produced as if they were single tokens
- More tests added for "proper" multicharacter operators.
Earlier regex would consider a++!=++b as 3 different tokens(a, ++!=++, b) This patch matches the tokens properly into (a, ++, !=, ++, b)
PATCH 1/1 userdiff: add builtin driver for kotlin language
The xfuncname pattern finds func/class declarations in diffs to display as a hunk header. The word_regex pattern finds individual tokens in Kotlin code to generate appropriate diffs.
This patch adds xfuncname regex and word_regex for Kotlin language.
--- Documentation/gitattributes.txt | 2 ++ t/t4018/kotlin-class | 5 +++++ t/t4018/kotlin-enum-class | 5 +++++ t/t4018/kotlin-fun | 5 +++++ t/t4018/kotlin-inheritace-class | 5 +++++ t/t4018/kotlin-inline-class | 5 +++++ t/t4018/kotlin-interface | 5 +++++ t/t4018/kotlin-nested-fun | 9 +++++++++ t/t4018/kotlin-public-class | 5 +++++ t/t4018/kotlin-sealed-class | 5 +++++ t/t4034-diff-words.sh | 1 + t/t4034/kotlin/expect | 34 +++++++++++++++++++++++++++++++++ t/t4034/kotlin/post | 21 ++++++++++++++++++++ t/t4034/kotlin/pre | 21 ++++++++++++++++++++ userdiff.c | 10 ++++++++++ 15 files changed, 138 insertions(+) create mode 100644 t/t4018/kotlin-class create mode 100644 t/t4018/kotlin-enum-class create mode 100644 t/t4018/kotlin-fun create mode 100644 t/t4018/kotlin-inheritace-class create mode 100644 t/t4018/kotlin-inline-class create mode 100644 t/t4018/kotlin-interface create mode 100644 t/t4018/kotlin-nested-fun create mode 100644 t/t4018/kotlin-public-class create mode 100644 t/t4018/kotlin-sealed-class create mode 100644 t/t4034/kotlin/expect create mode 100644 t/t4034/kotlin/post create mode 100644 t/t4034/kotlin/pre
Documentation/gitattributes.txt +2 -0
@@ -829,6 +829,8 @@ patterns are available: - `java` suitable for source code in the Java language. +- `kotlin` suitable for source code in the Kotlin language. + - `markdown` suitable for Markdown documents. - `matlab` suitable for source code in the MATLAB and Octave languages.
t/t4018/kotlin-class new file +5 -0
@@ -0,0 +1,5 @@ +class RIGHT { + //comment + //comment + return ChangeMe +}
t/t4018/kotlin-enum-class new file +5 -0
@@ -0,0 +1,5 @@ +enum class RIGHT{ + // Left + // a comment + ChangeMe +}
t/t4018/kotlin-fun new file +5 -0
@@ -0,0 +1,5 @@ +fun RIGHT(){ + //a comment + //b comment + return ChangeMe() +}
t/t4018/kotlin-inheritace-class new file +5 -0
@@ -0,0 +1,5 @@ +open class RIGHT{ + // a comment + // b comment + // ChangeMe +}
t/t4018/kotlin-inline-class new file +5 -0
@@ -0,0 +1,5 @@ +value class RIGHT(Args){ + // a comment + // b comment + ChangeMe +}
t/t4018/kotlin-interface new file +5 -0
@@ -0,0 +1,5 @@ +interface RIGHT{ + //another comment + //another comment + //ChangeMe +}
t/t4018/kotlin-nested-fun new file +9 -0
@@ -0,0 +1,9 @@ +class LEFT{ + class CENTER{ + fun RIGHT( a:Int){ + //comment + //comment + ChangeMe + } + } +}
t/t4018/kotlin-public-class new file +5 -0
@@ -0,0 +1,5 @@ +public class RIGHT{ + //comment1 + //comment2 + ChangeMe +}
t/t4018/kotlin-sealed-class new file +5 -0
@@ -0,0 +1,5 @@ +sealed class RIGHT { + // a comment + // b comment + ChangeMe +}
t/t4034-diff-words.sh +1 -0
@@ -324,6 +324,7 @@ test_language_driver dts test_language_driver fortran test_language_driver html test_language_driver java +test_language_driver kotlin test_language_driver matlab test_language_driver objc test_language_driver pascal
t/t4034/kotlin/expect new file +34 -0
@@ -0,0 +1,34 @@ +<BOLD>diff --git a/pre b/post<RESET> +<BOLD>index 3cfa271..20d26cc 100644<RESET> +<BOLD>--- a/pre<RESET> +<BOLD>+++ b/post<RESET> +<CYAN>@@ -1,21 +1,21 @@<RESET> +println("Hello World<RED>!\n<RESET><GREEN>?<RESET>") +<GREEN>(<RESET>1<GREEN>) (<RESET>-1e10<GREEN>) (<RESET>0xabcdef<GREEN>)<RESET> '<RED>x<RESET><GREEN>y<RESET>' +[<RED>a<RESET><GREEN>x<RESET>] <RED>a<RESET><GREEN>x<RESET>-><RED>b a<RESET><GREEN>y x<RESET>.<RED>b<RESET><GREEN>y<RESET> +!<RED>a a<RESET><GREEN>x x<RESET>.inv() <RED>a<RESET><GREEN>x<RESET>*<RED>b a<RESET><GREEN>y x<RESET>&<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET>*<RED>b a<RESET><GREEN>y x<RESET>/<RED>b a<RESET><GREEN>y x<RESET>%<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET>+<RED>b a<RESET><GREEN>y x<RESET>-<RED>b<RESET><GREEN>y<RESET> +a <RED>shr<RESET><GREEN>shl<RESET> b +<RED>a<RESET><GREEN>x<RESET><<RED>b a<RESET><GREEN>y x<RESET><=<RED>b a<RESET><GREEN>y x<RESET>><RED>b a<RESET><GREEN>y x<RESET>>=<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET>==<RED>b a<RESET><GREEN>y x<RESET>!=<RED>b a<RESET><GREEN>y x<RESET>===<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET> and <RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET>^<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET> or <RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET>&&<RED>b a<RESET><GREEN>y x<RESET>||<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET>=<RED>b a<RESET><GREEN>y x<RESET>+=<RED>b a<RESET><GREEN>y x<RESET>-=<RED>b a<RESET><GREEN>y x<RESET>*=<RED>b a<RESET><GREEN>y x<RESET>/=<RED>b a<RESET><GREEN>y x<RESET>%=<RED>b a<RESET><GREEN>y x<RESET><<=<RED>b a<RESET><GREEN>y x<RESET>>>=<RED>b a<RESET><GREEN>y x<RESET>&=<RED>b a<RESET><GREEN>y x<RESET>^=<RED>b a<RESET><GREEN>y x<RESET>|=<RED>b<RESET><GREEN>y<RESET> +a<RED>=<RESET><GREEN>+=<RESET>b c<RED>+=<RESET><GREEN>=<RESET>d e<RED>-=<RESET><GREEN><=<RESET>f g<RED>*=<RESET><GREEN>>=<RESET>h i<RED>/=<RESET><GREEN>/<RESET>j k<RED>%=<RESET><GREEN>%<RESET>l m<RED><<=<RESET><GREEN><<<RESET>n o<RED>>>=<RESET><GREEN>>><RESET>p q<RED>&=<RESET><GREEN>&<RESET>r s<RED>^=<RESET><GREEN>^<RESET>t u<RED>|=<RESET><GREEN>|<RESET>v +a<RED><<=<RESET><GREEN><=<RESET>b +a<RED>||<RESET><GREEN>|<RESET>b a<RED>&&<RESET><GREEN>&<RESET>b +<RED>a<RESET><GREEN>x<RESET>,y +--a<RED>==<RESET><GREEN>!=<RESET>--b +a++<RED>==<RESET><GREEN>!=<RESET>++b +<RED>0xFF_EC_DE_5E 0b100_000 100_000<RESET><GREEN>0xFF_E1_DE_5E 0b100_100 200_000<RESET>
t/t4034/kotlin/post new file +21 -0
@@ -0,0 +1,21 @@ +println("Hello World?") +(1) (-1e10) (0xabcdef) 'y' +[x] x->y x.y +!x x.inv() x*y x&y +x*y x/y x%y +x+y x-y +a shl b +x<y x<=y x>y x>=y +x==y x!=y x===y +x and y +x^y +x or y +x&&y x||y +x=y x+=y x-=y x*=y x/=y x%=y x<<=y x>>=y x&=y x^=y x|=y +a+=b c=d e<=f g>=h i/j k%l m<<n o>>p q&r s^t u|v +a<=b +a|b a&b +x,y +--a!=--b +a++!=++b +0xFF_E1_DE_5E 0b100_100 200_000
t/t4034/kotlin/pre new file +21 -0
@@ -0,0 +1,21 @@ +println("Hello World!\n") +1 -1e10 0xabcdef 'x' +[a] a->b a.b +!a a.inv() a*b a&b +a*b a/b a%b +a+b a-b +a shr b +a<b a<=b a>b a>=b +a==b a!=b a===b +a and b +a^b +a or b +a&&b a||b +a=b a+=b a-=b a*=b a/=b a%=b a<<=b a>>=b a&=b a^=b a|=b +a=b c+=d e-=f g*=h i/=j k%=l m<<=n o>>=p q&=r s^=t u|=v +a<<=b +a||b a&&b +a,y +--a==--b +a++==++b +0xFF_EC_DE_5E 0b100_000 100_000
userdiff.c +10 -0
@@ -168,6 +168,16 @@ PATTERNS("java","|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?" "|[-+*/<>%&^|=!]=" "|--|\\+\\+|<<=?|>>>?=?|&&|\\|\\|"), +PATTERNS ("kotlin" , +"^[ \t]*(([a-z]+[ \t]+)*(fun|class|interface)[ \t]+.*)$" , +/* -- */ +"[_]?[a-zA-Z][a-zA-Z0-9_]*" +/* hexadecimal and binary numbers */ +"|0[xXbB][0-9a-fA-F_]+[lLuU]*" +/* integers and floats */ +"|[0-9._]+([Ee][-+]?[0-9]+)?[fFlLuU]*" +/* unary and binary operators */ +"|[-+*/<>%&^|=!]?=(=)?|--|\\+\\+|<<?=?|>>?=?|&&?|[|]?\\||\\|->\\*?|\\.\\*" ), PATTERNS("markdown", "^ {0,3}#{1,6}[ \t].*",/* -- */
Signature · 1 line
2.35.1
Re: [PATCH] userdiff: add builtin driver for kotlin language
Am 02.03.22 um 15:26 schrieb Jaydeep P Das:
Quoted 30 lines
t/t4034/kotlin/expect new file +24
-0@@ -0,0 +1,34 @@ +<BOLD>diff --git a/pre b/post<RESET> +<BOLD>index 3cfa271..20d26cc 100644<RESET> +<BOLD>--- a/pre<RESET> +<BOLD>+++ b/post<RESET> +<CYAN>@@ -1,21 +1,21 @@<RESET> +println("Hello World<RED>!\n<RESET><GREEN>?<RESET>") +<GREEN>(<RESET>1<GREEN>) (<RESET>-1e10<GREEN>) (<RESET>0xabcdef<GREEN>)<RESET> '<RED>x<RESET><GREEN>y<RESET>' +[<RED>a<RESET><GREEN>x<RESET>] <RED>a<RESET><GREEN>x<RESET>-><RED>b a<RESET><GREEN>y x<RESET>.<RED>b<RESET><GREEN>y<RESET> +!<RED>a a<RESET><GREEN>x x<RESET>.inv() <RED>a<RESET><GREEN>x<RESET>*<RED>b a<RESET><GREEN>y x<RESET>&<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET>*<RED>b a<RESET><GREEN>y x<RESET>/<RED>b a<RESET><GREEN>y x<RESET>%<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET>+<RED>b a<RESET><GREEN>y x<RESET>-<RED>b<RESET><GREEN>y<RESET> +a <RED>shr<RESET><GREEN>shl<RESET> b +<RED>a<RESET><GREEN>x<RESET><<RED>b a<RESET><GREEN>y x<RESET><=<RED>b a<RESET><GREEN>y x<RESET>><RED>b a<RESET><GREEN>y x<RESET>>=<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET>==<RED>b a<RESET><GREEN>y x<RESET>!=<RED>b a<RESET><GREEN>y x<RESET>===<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET> and <RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET>^<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET> or <RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET>
t/t4034/kotlin/expect line 34
Quoted 10 lines
t/t4034/kotlin/expect new file +10
-0+<GREEN>x<RESET>&&<RED>b a<RESET><GREEN>y x<RESET>||<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET>=<RED>b a<RESET><GREEN>y x<RESET>+=<RED>b a<RESET><GREEN>y x<RESET>-=<RED>b a<RESET><GREEN>y x<RESET>*=<RED>b a<RESET><GREEN>y x<RESET>/=<RED>b a<RESET><GREEN>y x<RESET>%=<RED>b a<RESET><GREEN>y x<RESET><<=<RED>b a<RESET><GREEN>y x<RESET>>>=<RED>b a<RESET><GREEN>y x<RESET>&=<RED>b a<RESET><GREEN>y x<RESET>^=<RED>b a<RESET><GREEN>y x<RESET>|=<RED>b<RESET><GREEN>y<RESET> +a<RED>=<RESET><GREEN>+=<RESET>b c<RED>+=<RESET><GREEN>=<RESET>d e<RED>-=<RESET><GREEN><=<RESET>f g<RED>*=<RESET><GREEN>>=<RESET>h i<RED>/=<RESET><GREEN>/<RESET>j k<RED>%=<RESET><GREEN>%<RESET>l m<RED><<=<RESET><GREEN><<<RESET>n o<RED>>>=<RESET><GREEN>>><RESET>p q<RED>&=<RESET><GREEN>&<RESET>r s<RED>^=<RESET><GREEN>^<RESET>t u<RED>|=<RESET><GREEN>|<RESET>v +a<RED><<=<RESET><GREEN><=<RESET>b +a<RED>||<RESET><GREEN>|<RESET>b a<RED>&&<RESET><GREEN>&<RESET>b +<RED>a<RESET><GREEN>x<RESET>,y +--a<RED>==<RESET><GREEN>!=<RESET>--b +a++<RED>==<RESET><GREEN>!=<RESET>++b +<RED>0xFF_EC_DE_5E 0b100_000 100_000<RESET><GREEN>0xFF_E1_DE_5E 0b100_100 200_000<RESET>
Many of the a->x, b->y changes are redundant IMHO, but they do not hurt. This looks good.
Quoted 8 lines
userdiff.c +0
-0@@ -168,6 +168,16 @@ PATTERNS("java","|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?" "|[-+*/<>%&^|=!]=" "|--|\\+\\+|<<=?|>>>?=?|&&|\\|\\|"),
userdiff.c PATTERNS("java", · line 180
Quoted 10 lines
userdiff.c +10
-0+PATTERNS ("kotlin" , +"^[ \t]*(([a-z]+[ \t]+)*(fun|class|interface)[ \t]+.*)$" , +/* -- */ +"[_]?[a-zA-Z][a-zA-Z0-9_]*" +/* hexadecimal and binary numbers */ +"|0[xXbB][0-9a-fA-F_]+[lLuU]*" +/* integers and floats */ +"|[0-9._]+([Ee][-+]?[0-9]+)?[fFlLuU]*" +/* unary and binary operators */ + "|[-+*/<>%&^|=!]?=(=)?|--|\\+\\+|<<?=?|>>?=?|&&?|[|]?\\||\\|->\\*?|\\.\\*"),
Some of these sub-expressions match single-character operators, but that does not hurt.
How many tokens will the word-regex find in the expression X.e+200UL? .e+200UL is a single token. Also, X.Find consists of the three tokens X .F ind.
It's most easily fixed by requiring a digit before the fullstop. But if floatingpoint numbers can begin with a fullstop, then we need a second expression that requires a digit after a leading fullstop.
userdiff.c PATTERNS("java", · line 183
Quoted 3 lines
userdiff.c +0
-0PATTERNS("markdown", "^ {0,3}#{1,6}[ \t].*",/* -- */
-- Hannes
Re: [PATCH] userdiff: add builtin driver for kotlin language
How about modifying the number match regex to:
[0-9._]+([Ee][-+]?[0-9]+)?[fFlLuU]*[^a-zA-Z] ?
The [^a-zA-Z] in the end would make sure to not match the .F in X.Find.
Additionally, we can add another regex for matching just the method calls:
[.][a-zA-Z()0-9]+
Both of these changes would make word_regex match 2 tokens in X.Find() : X and .Find() (Here X can be any valid identifier name)
Quoted 4 lines
How many tokens will the word-regex find in the expression X.e+200UL?
.e+200UL is a single token. > It's most easily fixed by requiring a digit before the fullstop. But if floatingpoint numbers can begin with a fullstop, then we need a second
expression that requires a digit after a leading fullstop.
But that syntax would be wrong. I tried making a condition like you said,
but it always ended up breaking something else(like breaking 2.e+200UL into 2, .e, + and 200UL)
Also, I realized I did a bit of mistake in the identifier regex.
Both _abc and __abc are valid identifiers. _3432, __3232 are valid identifiers too.(not numbers)
The previous regex matched only one _, so in the next patch, I plan to implement the following regex:
Identifier: ([_]*[a-zA-Z]|[_]+[0-9]+)[a-zA-Z0-9_]*
Numbers: [0-9_.]+([Ee][-+]?[0-9]+)?[fFlLuU]*[^a-zA-Z] (It makes sure that in X.Find, .F is not matched )
Additionally, An extra regex for method calls:
[.][a-zA-Z()0-9]+
What do you think?
Thanks,
Jaydeep.
Re: [PATCH] userdiff: add builtin driver for kotlin language
Quoted 32 lines · Jaydeep Das
How about modifying the number match regex to:
[0-9._]+([Ee][-+]?[0-9]+)?[fFlLuU]*[^a-zA-Z]?The
[^a-zA-Z]in the end would make sure to not match the.FinX.Find.Additionally, we can add another regex for matching just the method calls:
[.][a-zA-Z()0-9]+Both of these changes would make
word_regexmatch 2 tokens inX.Find(): X and .Find() (Here X can be any valid identifier name)Quoted 4 lines
How many tokens will the word-regex find in the expression X.e+200UL?
.e+200UL is a single token. > It's most easily fixed by requiring a digit before the fullstop. But if floatingpoint numbers can begin with a fullstop, then we need a second
expression that requires a digit after a leading fullstop.But that syntax would be wrong. I tried making a condition like you said,
but it always ended up breaking somethingelse(like breaking 2.e+200UL into 2, .e, + and 200UL)Also, I realized I did a bit of mistake in the identifier regex.
Both_abcand__abcare valid identifiers. _3432, __3232 are valid identifiers too.(not numbers)The previous regex matched only one
_, so in the next patch, I plan to implement the following regex:Identifier:
([_]*[a-zA-Z]|[_]+[0-9]+)[a-zA-Z0-9_]*
Quoted 8 lines
Numbers:
[0-9_.]+([Ee][-+]?[0-9]+)?[fFlLuU]*[^a-zA-Z](It makes sure that in X.Find, .F is not matched )Additionally, An extra regex for method calls:
[.][a-zA-Z()0-9]+What do you think?
Just a small note on rx syntax> [.] can be handy to escape "." (but you can also use "\\.", but that's arguably not as easy to read.
But there's no reason to use [_]* over just _*..
(Also, I have an in-flight change to userdiff.c that would conflict, but I wonder if it wouldn't be handy to make the word_regex a "struct userdiff_funcname". Then we could specify icase flags, which in this case would make it a lot easier to read).
Re: [PATCH] userdiff: add builtin driver for kotlin language
In reply to Jaydeep DasQuoted 6 lines · Jaydeep Das
How about modifying the number match regex to:
[0-9._]+([Ee][-+]?[0-9]+)?[fFlLuU]*[^a-zA-Z]?The
[^a-zA-Z]in the end would make sure to not match the.FinX.Find.
Do we want to match "foo.F<EOL>"? If requiring at least one non-alpha after [fFlLuU]* is OK, then please ignore this message ;-)
Thanks.
Re: [PATCH] userdiff: add builtin driver for kotlin language
In reply to Jaydeep DasAm 03.03.22 um 12:41 schrieb Jaydeep Das:
Quoted 6 lines
How about modifying the number match regex to:
[0-9._]+([Ee][-+]?[0-9]+)?[fFlLuU]*[^a-zA-Z]?The
[^a-zA-Z]in the end would make sure to not match the.FinX.Find.
No, you cannot do that, because then in X.u+1 you have three tokens X .u+ 1, which you do not want, either.
Quoted 7 lines
Additionally, we can add another regex for matching just the method calls:
[.][a-zA-Z()0-9]+Both of these changes would make
word_regexmatch 2 tokens inX.Find(): X and .Find() (Here X can be any valid identifier name)
Well, you can do that. But I would not do that if it is allowed to have a blank between the fullstop and a method name.
Quoted 10 lines
Quoted 5 lines
How many tokens will the word-regex find in the expression X.e+200UL? .e+200UL is a single token. > It's most easily fixed by requiring a digit before the fullstop. But if
floatingpoint numbers can begin with a fullstop, then we need a second expression that requires a digit after a leading fullstop.But that syntax would be wrong. I tried making a condition like you said, but it always ended up breaking something
else(like breaking 2.e+200UL into 2, .e, + and 200UL)
Quoted 8 lines
Also, I realized I did a bit of mistake in the identifier regex. Both
_abcand__abcare valid identifiers. _3432, __3232 are valid identifiers too.(not numbers)The previous regex matched only one
_, so in the next patch, I plan to implement the following regex:Identifier:
([_]*[a-zA-Z]|[_]+[0-9]+)[a-zA-Z0-9_]*
But then you can use the regex you had in the first round:
[a-zA-Z_][a-zA-Z0-9_]*
Quoted 9 lines
Numbers:
[0-9_.]+([Ee][-+]?[0-9]+)?[fFlLuU]*[^a-zA-Z](It makes sure that in X.Find, .F is not matched )Additionally, An extra regex for method calls:
[.][a-zA-Z()0-9]+What do you think?
Have a look at the regex in the cpp driver. I think we need something like this:
/* integers floatingpoint numbers */ "|[0-9][0-9_.]*([Ee][*-]?[0-9]+)?[FfLl]*"
/* floatingpoint numbers that begin with a decimal point */ "|[.][0-9][0-9_]*([Ee][*-]?[0-9]+)?[FfLl]*"
Drop the second option if numbers such as .5 are invalid syntax in Kotlin.
-- Hannes
Re: [PATCH] userdiff: add builtin driver for kotlin language
Quoted 10 lines · Johannes Sixt
Am 03.03.22 um 12:41 schrieb Jaydeep Das:
Quoted 6 lines
How about modifying the number match regex to:
[0-9._]+([Ee][-+]?[0-9]+)?[fFlLuU]*[^a-zA-Z]?The
[^a-zA-Z]in the end would make sure to not match the.FinX.Find.No, you cannot do that, because then in X.u+1 you have three tokens X .u+ 1, which you do not want, either.
If X is an integer here, then
In C/C++ 2.f is equivalent to 2.000000
However in Kotlin 2.f is invalid syntax. 2.0f is valid.
So is implementing a proper regex for invalid syntax really necessary?
Quoted 3 lines
But then you can use the regex you had in the first round:
[a-zA-Z_][a-zA-Z0-9_]*
Right. I will change that.
Quoted 12 lines
Quoted 8 lines
Numbers:
[0-9_.]+([Ee][-+]?[0-9]+)?[fFlLuU]*[^a-zA-Z](It makes sure that in X.Find, .F is not matched )Additionally, An extra regex for method calls:
[.][a-zA-Z()0-9]+What do you think?
Have a look at the regex in the cpp driver. I think we need something like this:
Quoted 7 lines
/* integers floatingpoint numbers */ "|[0-9][0-9_.]*([Ee][*-]?[0-9]+)?[FfLl]*" /* floatingpoint numbers that begin with a decimal point */ "|[.][0-9][0-9_]*([Ee][*-]?[0-9]+)?[FfLl]*"Drop the second option if numbers such as .5 are invalid syntax in Kotlin.
.5 is valid syntax in Kotlin.
--
Thanks,
Jaydeep.
Re: [PATCH] userdiff: add builtin driver for kotlin language
Am 04.03.22 um 13:28 schrieb Jaydeep Das:
Quoted 6 lines · Johannes Sixt
Quoted 5 lines
Am 03.03.22 um 12:41 schrieb Jaydeep Das:
Quoted 4 lines
How about modifying the number match regex to:
[0-9._]+([Ee][-+]?[0-9]+)?[fFlLuU]*[^a-zA-Z]?
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines
The
[^a-zA-Z]in the end would make sure to not match the.FinX.Find.Quoted 2 lines
No, you cannot do that, because then in X.u+1 you have three tokens X .u+ 1, which you do not want, either.
If X is an integer here, then
No, I mean X literally, i.e., an identifier.
Quoted 6 lines
In C/C++ 2.f is equivalent to 2.000000
However in Kotlin 2.f is invalid syntax. 2.0f is valid.So is implementing a proper regex for invalid syntax really necessary?
No, that's not necessary. It can be assumed that invalid syntax does not occur. For this reason...
Quoted 5 lines
Quoted 5 lines
Have a look at the regex in the cpp driver. I think we need something like this:
/* integers floatingpoint numbers */
"|[0-9][0-9_.]*([Ee][*-]?[0-9]+)?[FfLl]*"
... I propose this loose [0-9_.]* after the first digit, even though it would match "9.8_7._65"; we can assume that this invalid token will not occur.
BTW, make that [FfLlUl] near the end.
Quoted 7 lines
Quoted 6 lines
/* floatingpoint numbers that begin with a decimal point */ "|[.][0-9][0-9_]*([Ee][*-]?[0-9]+)?[FfLl]*"
Drop the second option if numbers such as .5 are invalid syntax in Kotlin.
.5 is valid syntax in Kotlin.
OK, then we need this second branch, which ensures that there is a digit after the fullstop.
-- Hannes
PATCH 1/1 userdiff: add builtin diff driver for Kotlin language.
In reply to Jaydeep P DasThe xfuncname pattern finds func/class declarations in diffs to display as a hunk header. The word_regex pattern finds individual tokens in Kotlin code to generate appropriate diffs.
This patch adds xfuncname regex and word_regex for Kotlin language.
--- Documentation/gitattributes.txt | 2 ++ t/t4018/kotlin-class | 5 +++++ t/t4018/kotlin-enum-class | 5 +++++ t/t4018/kotlin-fun | 5 +++++ t/t4018/kotlin-inheritace-class | 5 +++++ t/t4018/kotlin-inline-class | 5 +++++ t/t4018/kotlin-interface | 5 +++++ t/t4018/kotlin-nested-fun | 9 ++++++++ t/t4018/kotlin-public-class | 5 +++++ t/t4018/kotlin-sealed-class | 5 +++++ t/t4034-diff-words.sh | 1 + t/t4034/kotlin/expect | 37 +++++++++++++++++++++++++++++++++ t/t4034/kotlin/post | 24 +++++++++++++++++++++ t/t4034/kotlin/pre | 24 +++++++++++++++++++++ userdiff.c | 12 +++++++++++ 15 files changed, 149 insertions(+) create mode 100644 t/t4018/kotlin-class create mode 100644 t/t4018/kotlin-enum-class create mode 100644 t/t4018/kotlin-fun create mode 100644 t/t4018/kotlin-inheritace-class create mode 100644 t/t4018/kotlin-inline-class create mode 100644 t/t4018/kotlin-interface create mode 100644 t/t4018/kotlin-nested-fun create mode 100644 t/t4018/kotlin-public-class create mode 100644 t/t4018/kotlin-sealed-class create mode 100644 t/t4034/kotlin/expect create mode 100644 t/t4034/kotlin/post create mode 100644 t/t4034/kotlin/pre
Documentation/gitattributes.txt +2 -0
@@ -829,6 +829,8 @@ patterns are available: - `java` suitable for source code in the Java language. +- `kotlin` suitable for source code in the Kotlin language. + - `markdown` suitable for Markdown documents. - `matlab` suitable for source code in the MATLAB and Octave languages.
t/t4018/kotlin-class new file +5 -0
@@ -0,0 +1,5 @@ +class RIGHT { + //comment + //comment + return ChangeMe +}
t/t4018/kotlin-enum-class new file +5 -0
@@ -0,0 +1,5 @@ +enum class RIGHT{ + // Left + // a comment + ChangeMe +}
t/t4018/kotlin-fun new file +5 -0
@@ -0,0 +1,5 @@ +fun RIGHT(){ + //a comment + //b comment + return ChangeMe() +}
t/t4018/kotlin-inheritace-class new file +5 -0
@@ -0,0 +1,5 @@ +open class RIGHT{ + // a comment + // b comment + // ChangeMe +}
t/t4018/kotlin-inline-class new file +5 -0
@@ -0,0 +1,5 @@ +value class RIGHT(Args){ + // a comment + // b comment + ChangeMe +}
t/t4018/kotlin-interface new file +5 -0
@@ -0,0 +1,5 @@ +interface RIGHT{ + //another comment + //another comment + //ChangeMe +}
t/t4018/kotlin-nested-fun new file +9 -0
@@ -0,0 +1,9 @@ +class LEFT{ + class CENTER{ + fun RIGHT( a:Int){ + //comment + //comment + ChangeMe + } + } +}
t/t4018/kotlin-public-class new file +5 -0
@@ -0,0 +1,5 @@ +public class RIGHT{ + //comment1 + //comment2 + ChangeMe +}
t/t4018/kotlin-sealed-class new file +5 -0
@@ -0,0 +1,5 @@ +sealed class RIGHT { + // a comment + // b comment + ChangeMe +}
t/t4034-diff-words.sh +1 -0
@@ -324,6 +324,7 @@ test_language_driver dts test_language_driver fortran test_language_driver html test_language_driver java +test_language_driver kotlin test_language_driver matlab test_language_driver objc test_language_driver pascal
t/t4034/kotlin/expect new file +37 -0
@@ -0,0 +1,37 @@ +<BOLD>diff --git a/pre b/post<RESET> +<BOLD>index a569cfc..c4b213b 100644<RESET> +<BOLD>--- a/pre<RESET> +<BOLD>+++ b/post<RESET> +<CYAN>@@ -1,24 +1,24 @@<RESET> +println("Hello World<RED>!\n<RESET><GREEN>?<RESET>") +<RED>1 -1e10 <RESET><GREEN>(1) (-1e10) (<RESET>0xabcdef<GREEN>)<RESET> '<RED>x<RESET><GREEN>y<RESET>' +[<RED>a<RESET><GREEN>x<RESET>] <RED>a<RESET><GREEN>x<RESET>-><RED>b a.b<RESET><GREEN>y x.y<RESET> +!<RED>a a<RESET><GREEN>x x<RESET>.inv() <RED>a<RESET><GREEN>x<RESET>*<RED>b a<RESET><GREEN>y x<RESET>&<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET>*<RED>b a<RESET><GREEN>y x<RESET>/<RED>b a<RESET><GREEN>y x<RESET>%<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET>+<RED>b a<RESET><GREEN>y x<RESET>-<RED>b<RESET><GREEN>y<RESET> +a <RED>shr<RESET><GREEN>shl<RESET> b +<RED>a<RESET><GREEN>x<RESET><<RED>b a<RESET><GREEN>y x<RESET><=<RED>b a<RESET><GREEN>y x<RESET>><RED>b a<RESET><GREEN>y x<RESET>>=<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET>==<RED>b a<RESET><GREEN>y x<RESET>!=<RED>b a<RESET><GREEN>y x<RESET>===<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET> and <RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET>^<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET> or <RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET>&&<RED>b a<RESET><GREEN>y x<RESET>||<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET>=<RED>b a<RESET><GREEN>y x<RESET>+=<RED>b a<RESET><GREEN>y x<RESET>-=<RED>b a<RESET><GREEN>y x<RESET>*=<RED>b a<RESET><GREEN>y x<RESET>/=<RED>b a<RESET><GREEN>y x<RESET>%=<RED>b a<RESET><GREEN>y x<RESET><<=<RED>b a<RESET><GREEN>y x<RESET>>>=<RED>b a<RESET><GREEN>y x<RESET>&=<RED>b a<RESET><GREEN>y x<RESET>^=<RED>b a<RESET><GREEN>y x<RESET>|=<RED>b<RESET><GREEN>y<RESET> +a<RED>=<RESET><GREEN>+=<RESET>b c<RED>+=<RESET><GREEN>=<RESET>d e<RED>-=<RESET><GREEN><=<RESET>f g<RED>*=<RESET><GREEN>>=<RESET>h i<RED>/=<RESET><GREEN>/<RESET>j k<RED>%=<RESET><GREEN>%<RESET>l m<RED><<=<RESET><GREEN><<<RESET>n o<RED>>>=<RESET><GREEN>>><RESET>p q<RED>&=<RESET><GREEN>&<RESET>r s<RED>^=<RESET><GREEN>^<RESET>t u<RED>|=<RESET><GREEN>|<RESET>v +a<RED><<=<RESET><GREEN><=<RESET>b +a<RED>||<RESET><GREEN>|<RESET>b a<RED>&&<RESET><GREEN>&<RESET>b +<RED>a<RESET><GREEN>x<RESET>,y +--a<RED>==<RESET><GREEN>!=<RESET>--b +a++<RED>==<RESET><GREEN>!=<RESET>++b +<RED>0xFF_EC_DE_5E 0b100_000 100_000<RESET><GREEN>0xFF_E1_DE_5E 0b100_100 200_000<RESET> +a<RED>==<RESET><GREEN>===<RESET>b +<RED>_32<RESET><GREEN>_33<RESET>.find(arr) +X<RED>.fill()<RESET><GREEN>.find()<RESET>
t/t4034/kotlin/post new file +24 -0
@@ -0,0 +1,24 @@ +println("Hello World?") +(1) (-1e10) (0xabcdef) 'y' +[x] x->y x.y +!x x.inv() x*y x&y +x*y x/y x%y +x+y x-y +a shl b +x<y x<=y x>y x>=y +x==y x!=y x===y +x and y +x^y +x or y +x&&y x||y +x=y x+=y x-=y x*=y x/=y x%=y x<<=y x>>=y x&=y x^=y x|=y +a+=b c=d e<=f g>=h i/j k%l m<<n o>>p q&r s^t u|v +a<=b +a|b a&b +x,y +--a!=--b +a++!=++b +0xFF_E1_DE_5E 0b100_100 200_000 +a===b +_33.find(arr) +X.find()
t/t4034/kotlin/pre new file +24 -0
@@ -0,0 +1,24 @@ +println("Hello World!\n") +1 -1e10 0xabcdef 'x' +[a] a->b a.b +!a a.inv() a*b a&b +a*b a/b a%b +a+b a-b +a shr b +a<b a<=b a>b a>=b +a==b a!=b a===b +a and b +a^b +a or b +a&&b a||b +a=b a+=b a-=b a*=b a/=b a%=b a<<=b a>>=b a&=b a^=b a|=b +a=b c+=d e-=f g*=h i/=j k%=l m<<=n o>>=p q&=r s^=t u|=v +a<<=b +a||b a&&b +a,y +--a==--b +a++==++b +0xFF_EC_DE_5E 0b100_000 100_000 +a==b +_32.find(arr) +X.fill()
userdiff.c +12 -0
@@ -168,6 +168,18 @@ PATTERNS("java","|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?" "|[-+*/<>%&^|=!]=" "|--|\\+\\+|<<=?|>>>?=?|&&|\\|\\|"), +PATTERNS ("kotlin" , +"^[ \t]*(([a-z]+[ \t]+)*(fun|class|interface)[ \t]+.*)$" , +/* -- */ +"(_*[a-zA-Z]|_+[0-9])[a-zA-Z0-9_]*" +/* hexadecimal and binary numbers */ +"|0[xXbB][0-9a-fA-F_]+[lLuU]*" +/* integers and floats */ +"|[^_\n][0-9_.]+([Ee][-+]?[0-9]+)?[fFlLuU]*[^a-zA-Z]" +/* method calls */ +"|[.][a-zA-Z()0-9]+" +/* unary and binary operators */ +"|[-+*/<>%&^|=!]?=(=)?|--|\\+\\+|<<?=?|>>?=?|&&?|[|]?\\||\\|->\\*?|\\.\\*" ), PATTERNS("markdown", "^ {0,3}#{1,6}[ \t].*",/* -- */
Signature · 1 line
2.35.1
Re: [PATCH] userdiff: add builtin diff driver for Kotlin language.
Quoted 1 line · Jaydeep P Das
Subject: Re: [PATCH] userdiff: add builtin diff driver for Kotlin language.
"git format-patch --help" and look for "-v <n>", perhaps. This is the fourth iteration, so [PATCH v4], I guess?
Re: [PATCH] userdiff: add builtin diff driver for Kotlin language.
Quoted 7 lines · Junio C Hamano
Quoted 1 line · Jaydeep P Das
Subject: Re: [PATCH] userdiff: add builtin diff driver for Kotlin language.
"git format-patch --help" and look for "-v <n>", perhaps. This is the fourth iteration, so [PATCH v4], I guess?
Yes. I think I forgot to fill in the subject so it was sent with the default. I didn't know format-patch allows to specify version numbers. I will check it out. Also, In the next patch, should I do it as v4 or v5?
Thanks,
Jaydeep
Re: [PATCH] userdiff: add builtin diff driver for Kotlin language.
In reply to Junio C HamanoAm 04.03.22 um 03:44 schrieb Junio C Hamano:
Quoted 6 lines
Quoted 1 line · Jaydeep P Das
Subject: Re: [PATCH] userdiff: add builtin diff driver for Kotlin language.
"git format-patch --help" and look for "-v <n>", perhaps. This is the fourth iteration, so [PATCH v4], I guess?
Note though, that this iteration is a step in the wrong direction. Let's forget that it has been submitted. (I saw this submission only long after I responded in the thread on the earlier round
https://lore.kernel.org/git/[email protected]/)
-- Hannes
PATCH v4 1/1 userdiff: add builtin diff driver for Kotlin language.
In reply to Jaydeep P DasThe xfuncname pattern finds func/class declarations in diffs to display as a hunk header. The word_regex pattern finds individual tokens in Kotlin code to generate appropriate diffs.
This patch adds xfuncname regex and word_regex for Kotlin language.
--- Documentation/gitattributes.txt | 2 ++ t/t4018/kotlin-class | 5 +++++ t/t4018/kotlin-enum-class | 5 +++++ t/t4018/kotlin-fun | 5 +++++ t/t4018/kotlin-inheritace-class | 5 +++++ t/t4018/kotlin-inline-class | 5 +++++ t/t4018/kotlin-interface | 5 +++++ t/t4018/kotlin-nested-fun | 9 ++++++++ t/t4018/kotlin-public-class | 5 +++++ t/t4018/kotlin-sealed-class | 5 +++++ t/t4034-diff-words.sh | 1 + t/t4034/kotlin/expect | 39 +++++++++++++++++++++++++++++++++ t/t4034/kotlin/post | 26 ++++++++++++++++++++++ t/t4034/kotlin/pre | 26 ++++++++++++++++++++++ userdiff.c | 12 ++++++++++ 15 files changed, 155 insertions(+) create mode 100644 t/t4018/kotlin-class create mode 100644 t/t4018/kotlin-enum-class create mode 100644 t/t4018/kotlin-fun create mode 100644 t/t4018/kotlin-inheritace-class create mode 100644 t/t4018/kotlin-inline-class create mode 100644 t/t4018/kotlin-interface create mode 100644 t/t4018/kotlin-nested-fun create mode 100644 t/t4018/kotlin-public-class create mode 100644 t/t4018/kotlin-sealed-class create mode 100644 t/t4034/kotlin/expect create mode 100644 t/t4034/kotlin/post create mode 100644 t/t4034/kotlin/pre
Documentation/gitattributes.txt +2 -0
@@ -829,6 +829,8 @@ patterns are available: - `java` suitable for source code in the Java language. +- `kotlin` suitable for source code in the Kotlin language. + - `markdown` suitable for Markdown documents. - `matlab` suitable for source code in the MATLAB and Octave languages.
t/t4018/kotlin-class new file +5 -0
@@ -0,0 +1,5 @@ +class RIGHT { + //comment + //comment + return ChangeMe +}
t/t4018/kotlin-enum-class new file +5 -0
@@ -0,0 +1,5 @@ +enum class RIGHT{ + // Left + // a comment + ChangeMe +}
t/t4018/kotlin-fun new file +5 -0
@@ -0,0 +1,5 @@ +fun RIGHT(){ + //a comment + //b comment + return ChangeMe() +}
t/t4018/kotlin-inheritace-class new file +5 -0
@@ -0,0 +1,5 @@ +open class RIGHT{ + // a comment + // b comment + // ChangeMe +}
t/t4018/kotlin-inline-class new file +5 -0
@@ -0,0 +1,5 @@ +value class RIGHT(Args){ + // a comment + // b comment + ChangeMe +}
t/t4018/kotlin-interface new file +5 -0
@@ -0,0 +1,5 @@ +interface RIGHT{ + //another comment + //another comment + //ChangeMe +}
t/t4018/kotlin-nested-fun new file +9 -0
@@ -0,0 +1,9 @@ +class LEFT{ + class CENTER{ + fun RIGHT( a:Int){ + //comment + //comment + ChangeMe + } + } +}
t/t4018/kotlin-public-class new file +5 -0
@@ -0,0 +1,5 @@ +public class RIGHT{ + //comment1 + //comment2 + ChangeMe +}
t/t4018/kotlin-sealed-class new file +5 -0
@@ -0,0 +1,5 @@ +sealed class RIGHT { + // a comment + // b comment + ChangeMe +}
t/t4034-diff-words.sh +1 -0
@@ -324,6 +324,7 @@ test_language_driver dts test_language_driver fortran test_language_driver html test_language_driver java +test_language_driver kotlin test_language_driver matlab test_language_driver objc test_language_driver pascal
t/t4034/kotlin/expect new file +39 -0
@@ -0,0 +1,39 @@ +<BOLD>diff --git a/pre b/post<RESET> +<BOLD>index 0c2a5a8..a9e7b41 100644<RESET> +<BOLD>--- a/pre<RESET> +<BOLD>+++ b/post<RESET> +<CYAN>@@ -1,26 +1,26 @@<RESET> +println("Hello World<RED>!\n<RESET><GREEN>?<RESET>") +<GREEN>(<RESET>1<GREEN>) (<RESET>-1e10<GREEN>) (<RESET>0xabcdef<GREEN>)<RESET> '<RED>x<RESET><GREEN>y<RESET>' +[<RED>a<RESET><GREEN>x<RESET>] <RED>a<RESET><GREEN>x<RESET>-><RED>b a.b<RESET><GREEN>y x.y<RESET> +!<RED>a a<RESET><GREEN>x x<RESET>.inv() <RED>a<RESET><GREEN>x<RESET>*<RED>b a<RESET><GREEN>y x<RESET>&<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET>*<RED>b a<RESET><GREEN>y x<RESET>/<RED>b a<RESET><GREEN>y x<RESET>%<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET>+<RED>b a<RESET><GREEN>y x<RESET>-<RED>b<RESET><GREEN>y<RESET> +a <RED>shr<RESET><GREEN>shl<RESET> b +<RED>a<RESET><GREEN>x<RESET><<RED>b a<RESET><GREEN>y x<RESET><=<RED>b a<RESET><GREEN>y x<RESET>><RED>b a<RESET><GREEN>y x<RESET>>=<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET>==<RED>b a<RESET><GREEN>y x<RESET>!=<RED>b a<RESET><GREEN>y x<RESET>===<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET> and <RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET>^<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET> or <RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET>&&<RED>b a<RESET><GREEN>y x<RESET>||<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET>=<RED>b a<RESET><GREEN>y x<RESET>+=<RED>b a<RESET><GREEN>y x<RESET>-=<RED>b a<RESET><GREEN>y x<RESET>*=<RED>b a<RESET><GREEN>y x<RESET>/=<RED>b a<RESET><GREEN>y x<RESET>%=<RED>b a<RESET><GREEN>y x<RESET><<=<RED>b a<RESET><GREEN>y x<RESET>>>=<RED>b a<RESET><GREEN>y x<RESET>&=<RED>b a<RESET><GREEN>y x<RESET>^=<RED>b a<RESET><GREEN>y x<RESET>|=<RED>b<RESET><GREEN>y<RESET> +a<RED>=<RESET><GREEN>+=<RESET>b c<RED>+=<RESET><GREEN>=<RESET>d e<RED>-=<RESET><GREEN><=<RESET>f g<RED>*=<RESET><GREEN>>=<RESET>h i<RED>/=<RESET><GREEN>/<RESET>j k<RED>%=<RESET><GREEN>%<RESET>l m<RED><<=<RESET><GREEN><<<RESET>n o<RED>>>=<RESET><GREEN>>><RESET>p q<RED>&=<RESET><GREEN>&<RESET>r s<RED>^=<RESET><GREEN>^<RESET>t u<RED>|=<RESET><GREEN>|<RESET>v +a<RED><<=<RESET><GREEN><=<RESET>b +a<RED>||<RESET><GREEN>|<RESET>b a<RED>&&<RESET><GREEN>&<RESET>b +<RED>a<RESET><GREEN>x<RESET>,y +--a<RED>==<RESET><GREEN>!=<RESET>--b +a++<RED>==<RESET><GREEN>!=<RESET>++b +<RED>0xFF_EC_DE_5E 0b100_000 100_000<RESET><GREEN>0xFF_E1_DE_5E 0b100_100 200_000<RESET> +a<RED>==<RESET><GREEN>===<RESET>b +<RED>_32<RESET><GREEN>_33<RESET>.find(arr) +X<RED>.fill()<RESET><GREEN>.find()<RESET> +X<RED>.u<RESET><GREEN>.f<RESET>+1 +X.u<RED>-<RESET><GREEN>+<RESET>2
t/t4034/kotlin/post new file +26 -0
@@ -0,0 +1,26 @@ +println("Hello World?") +(1) (-1e10) (0xabcdef) 'y' +[x] x->y x.y +!x x.inv() x*y x&y +x*y x/y x%y +x+y x-y +a shl b +x<y x<=y x>y x>=y +x==y x!=y x===y +x and y +x^y +x or y +x&&y x||y +x=y x+=y x-=y x*=y x/=y x%=y x<<=y x>>=y x&=y x^=y x|=y +a+=b c=d e<=f g>=h i/j k%l m<<n o>>p q&r s^t u|v +a<=b +a|b a&b +x,y +--a!=--b +a++!=++b +0xFF_E1_DE_5E 0b100_100 200_000 +a===b +_33.find(arr) +X.find() +X.f+1 +X.u+2
t/t4034/kotlin/pre new file +26 -0
@@ -0,0 +1,26 @@ +println("Hello World!\n") +1 -1e10 0xabcdef 'x' +[a] a->b a.b +!a a.inv() a*b a&b +a*b a/b a%b +a+b a-b +a shr b +a<b a<=b a>b a>=b +a==b a!=b a===b +a and b +a^b +a or b +a&&b a||b +a=b a+=b a-=b a*=b a/=b a%=b a<<=b a>>=b a&=b a^=b a|=b +a=b c+=d e-=f g*=h i/=j k%=l m<<=n o>>=p q&=r s^=t u|=v +a<<=b +a||b a&&b +a,y +--a==--b +a++==++b +0xFF_EC_DE_5E 0b100_000 100_000 +a==b +_32.find(arr) +X.fill() +X.u+1 +X.u-2
userdiff.c +12 -0
@@ -168,6 +168,18 @@ PATTERNS("java","|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?" "|[-+*/<>%&^|=!]=" "|--|\\+\\+|<<=?|>>>?=?|&&|\\|\\|"), +PATTERNS ("kotlin" , +"^[ \t]*(([a-z]+[ \t]+)*(fun|class|interface)[ \t]+.*)$" , +/* -- */ +"[a-zA-Z_][a-zA-Z0-9_]*" +/* hexadecimal and binary numbers */ +"|0[xXbB][0-9a-fA-F_]+[lLuU]*" +/* integers and floats */ +"|[0-9][0-9_.]*([Ee][-+]?[0-9]+)?[fFlL]*" +/* method calls */ +"|[.][a-zA-Z()0-9]+" +/* unary and binary operators */ +"|[-+*/<>%&^|=!]?=(=)?|--|\\+\\+|<<?=?|>>?=?|&&?|[|]?\\||\\|->\\*?|\\.\\*" ), PATTERNS("markdown", "^ {0,3}#{1,6}[ \t].*",/* -- */
Signature · 1 line
2.35.1
Re: [PATCH v4] userdiff: add builtin diff driver for Kotlin language.
Am 05.03.22 um 10:40 schrieb Jaydeep P Das:
t/t4034/kotlin/expect line 39
Quoted 4 lines
+<RED>_32<RESET><GREEN>_33<RESET>.find(arr)
t/t4034/kotlin/expect new file +3
-0+X<RED>.fill()<RESET><GREEN>.find()<RESET> +X<RED>.u<RESET><GREEN>.f<RESET>+1 +X.u<RED>-<RESET><GREEN>+<RESET>2
Nice move to include these new tests!
Quoted 6 lines
userdiff.c +0
-0@@ -168,6 +168,18 @@ PATTERNS("java","|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?"
userdiff.c PATTERNS("java", · line 178
Quoted 10 lines
userdiff.c +8
-0"|[-+*/<>%&^|=!]=" "|--|\\+\\+|<<=?|>>>?=?|&&|\\|\\|"), +PATTERNS ("kotlin" , +"^[ \t]*(([a-z]+[ \t]+)*(fun|class|interface)[ \t]+.*)$" , +/* -- */ +"[a-zA-Z_][a-zA-Z0-9_]*" +/* hexadecimal and binary numbers */ +"|0[xXbB][0-9a-fA-F_]+[lLuU]*" +/* integers and floats */ + "|[0-9][0-9_.]*([Ee][-+]?[0-9]+)?[fFlL]*"
Good!
userdiff.c PATTERNS("java", · line 180
Quoted 2 lines
userdiff.c +2
-0+/* method calls */ +"|[.][a-zA-Z()0-9]+"
This matches both .empty() as well as .125, but only the .5e part of .5e-3 and only the .find(x part of .find(x/2). Is that intended?
I find the desire to have method calls as an entire token a bit strange. In other languages, the last expression part is actually split into many
tokens: . find ( x / 2 ).
BTW, I'm in no way saying that this must be changed (personally I do not care at all as I'm not writing Kotlin), so if you say that is how people want Kotlin code to be split with --word-diff, I will believe you.
userdiff.c PATTERNS("java", · line 182
Quoted 2 lines
userdiff.c +2
-0+/* unary and binary operators */ + "|[-+*/<>%&^|=!]?=(=)?|--|\\+\\+|<<?=?|>>?=?|&&?|[|]?\\||\\|->\\*?|\\.\\*"),
Is the part
"|\\|->\\*?|"
actually meant to be something else? Does Kotlin have the tokens "|->" and "|->*"?
A final minor nit: There is "|&&?|[|]?\\||" that could just be "|&&|\\|\\||" (remember: single character operators are matched implicitly).
userdiff.c PATTERNS("java", · line 185
Quoted 3 lines
userdiff.c +0
-0PATTERNS("markdown", "^ {0,3}#{1,6}[ \t].*",/* -- */
-- Hannes
Re: [PATCH v4] userdiff: add builtin diff driver for Kotlin language.
Quoted 6 lines
userdiff.c PATTERNS("java", · line 180
Quoted 3 lines
userdiff.c +2
-0+/* method calls */ +"|[.][a-zA-Z()0-9]+" This matches both .empty() as well as .125, but only the .5e part of .5e-3 and only the .find(x part of .find(x/2). Is that intended?
Oh. It completely missed my mind. Anyways, that method call regex is better gone. For matching these,
Maybe we could just use cpp's regex for floating numbers starting with decimal point:
"|\\.[0-9][0-9]*([Ee][-+]?[0-9]+)?[fFlL]?"
Or maybe, we can make the current regex for floats and integers a bit more loose:
"|[0-9.][0-9_.]*([Ee][*-]?[0-9]+)?[FfLl]*"
What do you think would be better?
Quoted 7 lines
I find the desire to have method calls as an entire token a bit strange. In other languages, the last expression part is actually split into many
tokens: . find ( x / 2 ).BTW, I'm in no way saying that this must be changed (personally I do not care at all as I'm not writing Kotlin), so if you say that is how people want Kotlin code to be split with --word-diff, I will believe you.
Yes. The tokenisation does not make sense if its something like X.find(2). I think I should remove it.
Quoted 9 lines
userdiff.c PATTERNS("java", · line 182
Quoted 2 lines
userdiff.c +2
-0+/* unary and binary operators */ + "|[-+*/<>%&^|=!]?=(=)?|--|\\+\\+|<<?=?|>>?=?|&&?|[|]?\\||\\|->\\*?|\\.\\*"),Is the part
"|\\|->\\*?|"actually meant to be something else? Does Kotlin have the tokens "|->" and "|->*"?
Ah. yes. Kotlin does have "->" operator but not "|->". Also there are a few
more compound operators like ".." , "!!" etc which I forgot to add. I will add these in the next patch.
Quoted 3 lines
A final minor nit: There is "|&&?|[|]?\\||" that could just be "|&&|\\|\\||" (remember: single character operators are matched implicitly).
Yes. Right.
--
Thanks :]
Jaydeep
Re: [PATCH v4] userdiff: add builtin diff driver for Kotlin language.
Am 05.03.22 um 20:18 schrieb [email protected]:
Quoted 4 lines
Maybe we could just use cpp's regex for floating numbers starting with decimal point:
"|\\.[0-9][0-9]*([Ee][-+]?[0-9]+)?[fFlL]?"
Yes, but with '_' permitted after the first digit:
"|\\.[0-9][0-9_]*([Ee][-+]?[0-9]+)?[fFlL]?"
Quoted 6 lines
Or maybe, we can make the current regex for floats and integers a bit more loose:
"|[0-9.][0-9_.]*([Ee][*-]?[0-9]+)?[FfLl]*"
What do you think would be better?
No, that does not work, either, because it splits X.Find into X .F ind. I fixed that very problem with the cpp driver recently. We do need a separate alternative for the floatingpoint numbers that start with a decimal point.
-- Hannes
PATCH v5 1/1 userdiff: add builtin diff driver for kotlin language.
In reply to Jaydeep P DasThe xfuncname pattern finds func/class declarations in diffs to display as a hunk header. The word_regex pattern finds individual tokens in Kotlin code to generate appropriate diffs.
This patch adds xfuncname regex and word_regex for Kotlin language.
--- Documentation/gitattributes.txt | 2 ++ t/t4018/kotlin-class | 5 ++++ t/t4018/kotlin-enum-class | 5 ++++ t/t4018/kotlin-fun | 5 ++++ t/t4018/kotlin-inheritace-class | 5 ++++ t/t4018/kotlin-inline-class | 5 ++++ t/t4018/kotlin-interface | 5 ++++ t/t4018/kotlin-nested-fun | 9 +++++++ t/t4018/kotlin-public-class | 5 ++++ t/t4018/kotlin-sealed-class | 5 ++++ t/t4034-diff-words.sh | 1 + t/t4034/kotlin/expect | 42 +++++++++++++++++++++++++++++++++ t/t4034/kotlin/post | 29 +++++++++++++++++++++++ t/t4034/kotlin/pre | 29 +++++++++++++++++++++++ userdiff.c | 12 ++++++++++ 15 files changed, 164 insertions(+) create mode 100644 t/t4018/kotlin-class create mode 100644 t/t4018/kotlin-enum-class create mode 100644 t/t4018/kotlin-fun create mode 100644 t/t4018/kotlin-inheritace-class create mode 100644 t/t4018/kotlin-inline-class create mode 100644 t/t4018/kotlin-interface create mode 100644 t/t4018/kotlin-nested-fun create mode 100644 t/t4018/kotlin-public-class create mode 100644 t/t4018/kotlin-sealed-class create mode 100644 t/t4034/kotlin/expect create mode 100644 t/t4034/kotlin/post create mode 100644 t/t4034/kotlin/pre
Documentation/gitattributes.txt +2 -0
@@ -829,6 +829,8 @@ patterns are available: - `java` suitable for source code in the Java language. +- `kotlin` suitable for source code in the Kotlin language. + - `markdown` suitable for Markdown documents. - `matlab` suitable for source code in the MATLAB and Octave languages.
t/t4018/kotlin-class new file +5 -0
@@ -0,0 +1,5 @@ +class RIGHT { + //comment + //comment + return ChangeMe +}
t/t4018/kotlin-enum-class new file +5 -0
@@ -0,0 +1,5 @@ +enum class RIGHT{ + // Left + // a comment + ChangeMe +}
t/t4018/kotlin-fun new file +5 -0
@@ -0,0 +1,5 @@ +fun RIGHT(){ + //a comment + //b comment + return ChangeMe() +}
t/t4018/kotlin-inheritace-class new file +5 -0
@@ -0,0 +1,5 @@ +open class RIGHT{ + // a comment + // b comment + // ChangeMe +}
t/t4018/kotlin-inline-class new file +5 -0
@@ -0,0 +1,5 @@ +value class RIGHT(Args){ + // a comment + // b comment + ChangeMe +}
t/t4018/kotlin-interface new file +5 -0
@@ -0,0 +1,5 @@ +interface RIGHT{ + //another comment + //another comment + //ChangeMe +}
t/t4018/kotlin-nested-fun new file +9 -0
@@ -0,0 +1,9 @@ +class LEFT{ + class CENTER{ + fun RIGHT( a:Int){ + //comment + //comment + ChangeMe + } + } +}
t/t4018/kotlin-public-class new file +5 -0
@@ -0,0 +1,5 @@ +public class RIGHT{ + //comment1 + //comment2 + ChangeMe +}
t/t4018/kotlin-sealed-class new file +5 -0
@@ -0,0 +1,5 @@ +sealed class RIGHT { + // a comment + // b comment + ChangeMe +}
t/t4034-diff-words.sh +1 -0
@@ -324,6 +324,7 @@ test_language_driver dts test_language_driver fortran test_language_driver html test_language_driver java +test_language_driver kotlin test_language_driver matlab test_language_driver objc test_language_driver pascal
t/t4034/kotlin/expect new file +42 -0
42 lines not on this page · raw message
t/t4034/kotlin/post new file +29 -0
@@ -0,0 +1,29 @@ +println("Hello World?") +(1) (-1e10) (0xabcdef) 'y' +[x] x->y x.y +!x x.inv() x*y x&y +x*y x/y x%y +x+y x-y +a shl b +x<y x<=y x>y x>=y +x==y x!=y x===y +x and y +x^y +x or y +x&&y x||y +x=y x+=y x-=y x*=y x/=y x%=y x<<=y x>>=y x&=y x^=y x|=y +a+=b c=d e<=f g>=h i/j k%l m<<n o>>p q&r s^t u|v +a<=b +a|b a&b +x,y +--a!=--b +a++!=++b +0xFF_E1_DE_5E 0b100_100 200_000 +a===b +a!=b +_33.find(arr) +X.find() +X.f+1 +X.u+2 +a..b +a?:b
t/t4034/kotlin/pre new file +29 -0
@@ -0,0 +1,29 @@ +println("Hello World!\n") +1 -1e10 0xabcdef 'x' +[a] a->b a.b +!a a.inv() a*b a&b +a*b a/b a%b +a+b a-b +a shr b +a<b a<=b a>b a>=b +a==b a!=b a===b +a and b +a^b +a or b +a&&b a||b +a=b a+=b a-=b a*=b a/=b a%=b a<<=b a>>=b a&=b a^=b a|=b +a=b c+=d e-=f g*=h i/=j k%=l m<<=n o>>=p q&=r s^=t u|=v +a<<=b +a||b a&&b +a,y +--a==--b +a++==++b +0xFF_EC_DE_5E 0b100_000 100_000 +a==b +a!!b +_32.find(arr) +X.fill() +X.u+1 +X.u-2 +a.b +a?.b
userdiff.c +12 -0
@@ -168,6 +168,18 @@ PATTERNS("java","|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?" "|[-+*/<>%&^|=!]=" "|--|\\+\\+|<<=?|>>>?=?|&&|\\|\\|"), +PATTERNS ("kotlin" , +"^[ \t]*(([a-z]+[ \t]+)*(fun|class|interface)[ \t]+.*)$" , +/* -- */ +"[a-zA-Z_][a-zA-Z0-9_]*" +/* hexadecimal and binary numbers */ +"|0[xXbB][0-9a-fA-F_]+[lLuU]*" +/* integers and floats */ +"|[0-9][.]?[0-9_]+([Ee][-+]?[0-9]+)?[fFlL]*" +/* floating point numbers beginning with decimal point */ +"|[.][0-9][0-9]*([Ee][-+]?[0-9]+)?[fFlLuU]?" +/* unary and binary operators */ +"|[-+*/<>%&^|=!]?==?|--|\\+\\+|<<?=?|>>?=?|&&|\\|[|]?|->|\\.\\*|!!|::|[?:.][.:]" ), PATTERNS("markdown", "^ {0,3}#{1,6}[ \t].*",/* -- */
Signature · 1 line
2.35.1
Re: [PATCH v5] userdiff: add builtin diff driver for kotlin language.
Am 06.03.22 um 12:15 schrieb Jaydeep P Das:
Quoted 8 lines
userdiff.c +0
-0@@ -168,6 +168,18 @@ PATTERNS("java","|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?" "|[-+*/<>%&^|=!]=" "|--|\\+\\+|<<=?|>>>?=?|&&|\\|\\|"),
userdiff.c PATTERNS("java", · line 180
Quoted 10 lines
userdiff.c +10
-0+PATTERNS ("kotlin" , +"^[ \t]*(([a-z]+[ \t]+)*(fun|class|interface)[ \t]+.*)$" , +/* -- */ +"[a-zA-Z_][a-zA-Z0-9_]*" +/* hexadecimal and binary numbers */ +"|0[xXbB][0-9a-fA-F_]+[lLuU]*" +/* integers and floats */ +"|[0-9][.]?[0-9_]+([Ee][-+]?[0-9]+)?[fFlL]*" +/* floating point numbers beginning with decimal point */ + "|[.][0-9][0-9]*([Ee][-+]?[0-9]+)?[fFlLuU]?"
I guess that the suffix u is intended to mark unsigned integers. So, I would say that the alternatives [fFlL] and [fFlLuU] should be swapped.
Furthermore, is it intentional that you do not recognize the '_' digit separator in floating point numbers that begin with a decimal point?
userdiff.c PATTERNS("java", · line 182
Quoted 2 lines
userdiff.c +2
-0+/* unary and binary operators */ + "|[-+*/<>%&^|=!]?==?|--|\\+\\+|<<?=?|>>?=?|&&|\\|[|]?|->|\\.\\*|!!|::|[?:.][.:]"),
What is the justification that there is still "|&&|\\|[|]?|" instead of "|&&|\\|\\||" that I suggested (and I think I stressed that the point is that single-character operators are matched elsewhere) and to which you said "yes, right"?
Also, the part "|<<?=?|>>?=?|" can match <, >, <=, and >=, all of which are matched by other expressions, so you could reduce it to "|<<=|>>=|", because that are the only tokens that they must match.
-- Hannes
Re: [PATCH v5] userdiff: add builtin diff driver for kotlin language.
Quoted 3 lines
I guess that the suffix u is intended to mark unsigned integers. So, I would say that the alternatives [fFlL] and [fFlLuU] should be swapped.
Okay.
Quoted 2 lines
Furthermore, is it intentional that you do not recognize the '_' digit separator in floating point numbers that begin with a decimal point?
No. I will fix it.
Quoted 7 lines
userdiff.c PATTERNS("java", · line 182
Quoted 2 lines
userdiff.c +2
-0+/* unary and binary operators */ + "|[-+*/<>%&^|=!]?==?|--|\\+\\+|<<?=?|>>?=?|&&|\\|[|]?|->|\\.\\*|!!|::|[?:.][.:]"),What is the justification that there is still "|&&|\\|[|]?|" instead of "|&&|\\|\\||" that I suggested (and I think I stressed that the point is that single-character operators are matched elsewhere) and to which you said "yes, right"?
Yes. Must have slipped my mind. Sorry.
Quoted 3 lines
Also, the part "|<<?=?|>>?=?|" can match <, >, <=, and >=, all of which are matched by other expressions, so you could reduce it to "|<<=|>>=|", because that are the only tokens that they must match.
Alright.
So, the final regexes are these, right?:
"[a-zA-Z_][a-zA-Z0-9_]*" /* hexadecimal and binary numbers */ "|0[xXbB][0-9a-fA-F_]+[lLuU]*" /* integers and floats */ "|[0-9][.]?[0-9_]+([Ee][-+]?[0-9]+)?[fFlLuU]*" /* floating point numbers beginning with decimal point */ "|[.][0-9][0-9_]*([Ee][-+]?[0-9]+)?[fFlL]?" /* unary and binary operators */ "|[-+*/<>%&^|=!]?==?|--|\\+\\+|<<=|>>=|&&|[||]|->|\\.\\*|!!|::|[?:.][.:]"),
Thanks,
Jaydeep.
Re: [PATCH v5] userdiff: add builtin diff driver for kotlin language.
Am 08.03.22 um 17:54 schrieb [email protected]:
Quoted 1 line
So, the final regexes are these, right?:
Not quite.
Quoted 6 lines
"[a-zA-Z_][a-zA-Z0-9_]*"
/* hexadecimal and binary numbers */ "|0[xXbB][0-9a-fA-F_]+[lLuU]*"
/* integers and floats */ "|[0-9][.]?[0-9_]+([Ee][-+]?[0-9]+)?[fFlLuU]*"
This would not match 12.5 because you allow only a single digit before the decimal point. Perhaps
"|[0-9][.0-9_]*([Ee][-+]?[0-9]+)?[fFlLuU]*"
Quoted 5 lines
/* floating point numbers beginning with decimal point */ "|[.][0-9][0-9_]*([Ee][-+]?[0-9]+)?[fFlL]?"
/* unary and binary operators */
"|[-+*/<>%&^|=!]?==?|--|\\+\\+|<<=|>>=|&&|[||]|->|\\.\\*|!!|::|[?:.][.:]"),
[||] does not work as you intend. A new suggestion: do not start with an initial optional character in order to reduce the number of backtrackings that the regular expression evaluation has to do. I would write this line as
"|[-+*/<>%&^|=!]==?|--|\\+\\+|<<=|>>=|&&|\\|\\||->|\\.\\*|!!|::|[?:.][.:]"),
BTW which operators are handled by "[?:.][.:]"? I'm asking because you list :: separatly that would also be matched by this sub-expression.
-- Hannes
Re: [PATCH v5] userdiff: add builtin diff driver for kotlin language.
Sorry for the late reply.
Quoted 12 lines · Johannes Sixt
Am 08.03.22 um 17:54 schrieb [email protected]:
Quoted 1 line
So, the final regexes are these, right?:
Not quite.
Quoted 6 lines
"[a-zA-Z_][a-zA-Z0-9_]*"
/* hexadecimal and binary numbers */ "|0[xXbB][0-9a-fA-F_]+[lLuU]*"
/* integers and floats */ "|[0-9][.]?[0-9_]+([Ee][-+]?[0-9]+)?[fFlLuU]*"
Quoted 4 lines
This would not match 12.5 because you allow only a single digit before the decimal point. Perhaps
"|[0-9][.0-9_]*([Ee][-+]?[0-9]+)?[fFlLuU]*"
Okay.
Quoted 11 lines
Quoted 5 lines
/* floating point numbers beginning with decimal point */ "|[.][0-9][0-9_]*([Ee][-+]?[0-9]+)?[fFlL]?"
/* unary and binary operators */"|[-+*/<>%&^|=!]?==?|--|\\+\\+|<<=|>>=|&&|[||]|->|\\.\\*|!!|::|[?:.][.:]"),
[||] does not work as you intend. A new suggestion: do not start with an initial optional character in order to reduce the number of backtrackings that the regular expression evaluation has to do. I would write this line as
Quoted 4 lines
"|[-+*/<>%&^|=!]==?|--|\\+\\+|<<=|>>=|&&|\\|\\||->|\\.\\*|!!|::|[?:.][.:]"),BTW which operators are handled by "[?:.][.:]"? I'm asking because you list :: separatly that would also be matched by this sub-expression.
It matches the following operators: ?:, ?., .. ::. Although matching :: is unnecessary since its matched before.
https://kotlinlang.org/docs/keyword-reference.html#operators-and-special-symbols
Re: [PATCH v5] userdiff: add builtin diff driver for kotlin language.
In reply to Johannes SixtQuoted 12 lines · Johannes Sixt
Am 08.03.22 um 17:54 schrieb [email protected]:
Quoted 1 line
So, the final regexes are these, right?:
Not quite.
Quoted 6 lines
"[a-zA-Z_][a-zA-Z0-9_]*"
/* hexadecimal and binary numbers */ "|0[xXbB][0-9a-fA-F_]+[lLuU]*"
/* integers and floats */ "|[0-9][.]?[0-9_]+([Ee][-+]?[0-9]+)?[fFlLuU]*"
Quoted 5 lines
This would not match 12.5 because you allow only a single digit before the decimal point. Perhaps
"|[0-9][.0-9_]*([Ee][-+]?[0-9]+)?[fFlLuU]*"
The problem with this approach is that it matches 2..5 as a single token. However in Kotlin, .. is used to specify a range so 2..5 should be broken into 2 .. and 5.
Re: [PATCH v5] userdiff: add builtin diff driver for kotlin language.
Am 10.03.22 um 17:29 schrieb Jaydeep Das:
Quoted 7 lines
Quoted 2 lines
"|[0-9][.0-9_]*([Ee][-+]?[0-9]+)?[fFlLuU]*"
The problem with this approach is that it matches
2..5as a single token. However in Kotlin,..is used to specify a range so 2..5 should be broken into
2 .. and 5.
Good catch. Then we have to be more restrictive with the fractional part:
"|[0-9][0-9_]*([.][0-9_]*)([Ee][-+]?[0-9]+)?[fFlLuU]*"
-- Hannes
PATCH v6 1/1 userdiff: add builtin diff driver for kotlin language.
In reply to Jaydeep P DasThe xfuncname pattern finds func/class declarations in diffs to display as a hunk header. The word_regex pattern finds individual tokens in Kotlin code to generate appropriate diffs.
This patch adds xfuncname regex and word_regex for Kotlin language.
--- Documentation/gitattributes.txt | 2 ++ t/t4018/kotlin-class | 5 ++++ t/t4018/kotlin-enum-class | 5 ++++ t/t4018/kotlin-fun | 5 ++++ t/t4018/kotlin-inheritace-class | 5 ++++ t/t4018/kotlin-inline-class | 5 ++++ t/t4018/kotlin-interface | 5 ++++ t/t4018/kotlin-nested-fun | 9 +++++++ t/t4018/kotlin-public-class | 5 ++++ t/t4018/kotlin-sealed-class | 5 ++++ t/t4034-diff-words.sh | 1 + t/t4034/kotlin/expect | 43 +++++++++++++++++++++++++++++++++ t/t4034/kotlin/post | 30 +++++++++++++++++++++++ t/t4034/kotlin/pre | 30 +++++++++++++++++++++++ userdiff.c | 12 +++++++++ 15 files changed, 167 insertions(+) create mode 100644 t/t4018/kotlin-class create mode 100644 t/t4018/kotlin-enum-class create mode 100644 t/t4018/kotlin-fun create mode 100644 t/t4018/kotlin-inheritace-class create mode 100644 t/t4018/kotlin-inline-class create mode 100644 t/t4018/kotlin-interface create mode 100644 t/t4018/kotlin-nested-fun create mode 100644 t/t4018/kotlin-public-class create mode 100644 t/t4018/kotlin-sealed-class create mode 100644 t/t4034/kotlin/expect create mode 100644 t/t4034/kotlin/post create mode 100644 t/t4034/kotlin/pre
Documentation/gitattributes.txt +2 -0
@@ -829,6 +829,8 @@ patterns are available: - `java` suitable for source code in the Java language. +- `kotlin` suitable for source code in the Kotlin language. + - `markdown` suitable for Markdown documents. - `matlab` suitable for source code in the MATLAB and Octave languages.
t/t4018/kotlin-class new file +5 -0
@@ -0,0 +1,5 @@ +class RIGHT { + //comment + //comment + return ChangeMe +}
t/t4018/kotlin-enum-class new file +5 -0
@@ -0,0 +1,5 @@ +enum class RIGHT{ + // Left + // a comment + ChangeMe +}
t/t4018/kotlin-fun new file +5 -0
@@ -0,0 +1,5 @@ +fun RIGHT(){ + //a comment + //b comment + return ChangeMe() +}
t/t4018/kotlin-inheritace-class new file +5 -0
@@ -0,0 +1,5 @@ +open class RIGHT{ + // a comment + // b comment + // ChangeMe +}
t/t4018/kotlin-inline-class new file +5 -0
@@ -0,0 +1,5 @@ +value class RIGHT(Args){ + // a comment + // b comment + ChangeMe +}
t/t4018/kotlin-interface new file +5 -0
@@ -0,0 +1,5 @@ +interface RIGHT{ + //another comment + //another comment + //ChangeMe +}
t/t4018/kotlin-nested-fun new file +9 -0
@@ -0,0 +1,9 @@ +class LEFT{ + class CENTER{ + fun RIGHT( a:Int){ + //comment + //comment + ChangeMe + } + } +}
t/t4018/kotlin-public-class new file +5 -0
@@ -0,0 +1,5 @@ +public class RIGHT{ + //comment1 + //comment2 + ChangeMe +}
t/t4018/kotlin-sealed-class new file +5 -0
@@ -0,0 +1,5 @@ +sealed class RIGHT { + // a comment + // b comment + ChangeMe +}
t/t4034-diff-words.sh +1 -0
@@ -324,6 +324,7 @@ test_language_driver dts test_language_driver fortran test_language_driver html test_language_driver java +test_language_driver kotlin test_language_driver matlab test_language_driver objc test_language_driver pascal
t/t4034/kotlin/expect new file +43 -0
43 lines not on this page · raw message
t/t4034/kotlin/post new file +30 -0
@@ -0,0 +1,30 @@ +println("Hello World?") +(1) (-1e10) (0xabcdef) 'y' +[x] x->y x.y +!x x.inv() x*y x&y +x*y x/y x%y +x+y x-y +a shl b +x<y x<=y x>y x>=y +x==y x!=y x===y +x and y +x^y +x or y +x&&y x||y +x=y x+=y x-=y x*=y x/=y x%=y x<<=y x>>=y x&=y x^=y x|=y +a+=b c=d e<=f g>=h i/j k%l m<<n o>>p q&r s^t u|v +a<=b +a|b a&b +x,y +--a!=--b +a++!=++b +0xFF_E1_DE_5E 0b100_100 200_000 +a===b +a!=b +_33.find(arr) +X.find() +X.f+1 +X.u+2 +a..b +a?:b +.32_00_446
t/t4034/kotlin/pre new file +30 -0
@@ -0,0 +1,30 @@ +println("Hello World!\n") +1 -1e10 0xabcdef 'x' +[a] a->b a.b +!a a.inv() a*b a&b +a*b a/b a%b +a+b a-b +a shr b +a<b a<=b a>b a>=b +a==b a!=b a===b +a and b +a^b +a or b +a&&b a||b +a=b a+=b a-=b a*=b a/=b a%=b a<<=b a>>=b a&=b a^=b a|=b +a=b c+=d e-=f g*=h i/=j k%=l m<<=n o>>=p q&=r s^=t u|=v +a<<=b +a||b a&&b +a,y +--a==--b +a++==++b +0xFF_EC_DE_5E 0b100_000 100_000 +a==b +a!!b +_32.find(arr) +X.fill() +X.u+1 +X.u-2 +a.b +a?.b +.32_00_456
userdiff.c +12 -0
@@ -168,6 +168,18 @@ PATTERNS("java","|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?" "|[-+*/<>%&^|=!]=" "|--|\\+\\+|<<=?|>>>?=?|&&|\\|\\|"), +PATTERNS ("kotlin" , +"^[ \t]*(([a-z]+[ \t]+)*(fun|class|interface)[ \t]+.*)$" , +/* -- */ +"[a-zA-Z_][a-zA-Z0-9_]*" +/* hexadecimal and binary numbers */ +"|0[xXbB][0-9a-fA-F_]+[lLuU]*" +/* integers and floats */ +"|[0-9][0-9_]*([.][0-9_]*)([Ee][-+]?[0-9]+)?[fFlLuU]*" +/* floating point numbers beginning with decimal point */ +"|[.][0-9][0-9_]*([Ee][-+]?[0-9]+)?[fFlLuU]?" +/* unary and binary operators */ +"|[-+*/<>%&^|=!]==?|--|\\+\\+|<<=|>>=|&&|\\|\\||->|\\.\\*|!!|[?:.][.:]" ), PATTERNS("markdown", "^ {0,3}#{1,6}[ \t].*",/* -- */
Signature · 1 line
2.35.1
Re: [PATCH v6] userdiff: add builtin diff driver for kotlin language.
Am 11.03.22 um 08:27 schrieb Jaydeep P Das:
Quoted 10 lines
The xfuncname pattern finds func/class declarations in diffs to display as a hunk header. The
word_regexpattern finds individual tokens in Kotlin code to generate appropriate diffs.This patch adds xfuncname regex and
word_regexfor Kotlin language.Signed-off-by Jaydeep P Das <[email protected]>---
Thank you. At first, I thought this round is it, but then I noticed this line:
Quoted 1 line
+<RED>0xFF_EC_DE_5E 0b100_000 1<RESET><GREEN>0xFF_E1_DE_5E 0b100_100 2<RESET>00_000
Notice how the change from 100_000 to 200_000 breaks out the first digit into its own token.
Quoted 6 lines
userdiff.c +0
-0@@ -168,6 +168,18 @@ PATTERNS("java","|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?"
userdiff.c PATTERNS("java", · line 178
Quoted 10 lines
userdiff.c +8
-0"|[-+*/<>%&^|=!]=" "|--|\\+\\+|<<=?|>>>?=?|&&|\\|\\|"), +PATTERNS ("kotlin" , +"^[ \t]*(([a-z]+[ \t]+)*(fun|class|interface)[ \t]+.*)$" , +/* -- */ +"[a-zA-Z_][a-zA-Z0-9_]*" +/* hexadecimal and binary numbers */ +"|0[xXbB][0-9a-fA-F_]+[lLuU]*" +/* integers and floats */ + "|[0-9][0-9_]*([.][0-9_]*)([Ee][-+]?[0-9]+)?[fFlLuU]*"
This line matches a non-empty digit sequence of any length, and I thought the longest match would win. Why is that not the case here? Frankly, I'm scratching my head over it. Any ideas?
userdiff.c PATTERNS("java", · line 185
Quoted 7 lines
userdiff.c +4
-0+/* floating point numbers beginning with decimal point */ +"|[.][0-9][0-9_]*([Ee][-+]?[0-9]+)?[fFlLuU]?" +/* unary and binary operators */ + "|[-+*/<>%&^|=!]==?|--|\\+\\+|<<=|>>=|&&|\\|\\||->|\\.\\*|!!|[?:.][.:]"), PATTERNS("markdown", "^ {0,3}#{1,6}[ \t].*",/* -- */
-- Hannes
Re: [PATCH v6] userdiff: add builtin diff driver for kotlin language.
Quoted 12 lines · Johannes Sixt
Am 11.03.22 um 08:27 schrieb Jaydeep P Das:
Quoted 10 lines
The xfuncname pattern finds func/class declarations in diffs to display as a hunk header. The
word_regexpattern finds individual tokens in Kotlin code to generate appropriate diffs.This patch adds xfuncname regex and
word_regexfor Kotlin language.Signed-off-by Jaydeep P Das <[email protected]>---
Quoted 7 lines
Thank you. At first, I thought this round is it, but then I noticed this line:
Quoted 1 line
+<RED>0xFF_EC_DE_5E 0b100_000 1<RESET><GREEN>0xFF_E1_DE_5E 0b100_100 2<RESET>00_000
Notice how the change from 100_000 to 200_000 breaks out the first digit into its own token.
Wow. I completely missed it.
Quoted 12 lines
Quoted 12 lines
userdiff.c +4
-0@@ -168,6 +168,18 @@ PATTERNS("java","|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?" "|[-+*/<>%&^|=!]=" "|--|\\+\\+|<<=?|>>>?=?|&&|\\|\\|"), +PATTERNS ("kotlin" , +"^[ \t]*(([a-z]+[ \t]+)*(fun|class|interface)[ \t]+.*)$" , +/* -- */ + "[a-zA-Z_][a-zA-Z0-9_]*"
Quoted 8 lines
userdiff.c PATTERNS("java", · line 178
Quoted 4 lines
userdiff.c +4
-0+/* hexadecimal and binary numbers */ +"|0[xXbB][0-9a-fA-F_]+[lLuU]*" +/* integers and floats */ +"|[0-9][0-9_]*([.][0-9_]*)([Ee][-+]?[0-9]+)?[fFlLuU]*" This line matches a non-empty digit sequence of any length, and I thought the longest match would win. Why is that not the case here? Frankly, I'm scratching my head over it. Any ideas?
Yes. The capture group ([.][0-9_]*) should occur once or zero times. So this ([.][0-9_]*)? will fix it.
Re: [PATCH v6] userdiff: add builtin diff driver for kotlin language.
Am 12.03.22 um 05:36 schrieb [email protected]:
Quoted 23 lines · Johannes Sixt
Quoted 13 lines
Am 11.03.22 um 08:27 schrieb Jaydeep P Das:
Quoted 12 lines
userdiff.c +0
-0@@ -168,6 +168,18 @@ PATTERNS("java","|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?" "|[-+*/<>%&^|=!]=" "|--|\\+\\+|<<=?|>>>?=?|&&|\\|\\|"),+PATTERNS("kotlin",
+ "^[ \t]*(([a-z]+[ \t]+)*(fun|class|interface)[ \t]+.*)$", + /* -- */
+ "[a-zA-Z_][a-zA-Z0-9_]*"Quoted 8 lines
Quoted 4 lines
+ /* hexadecimal and binary numbers */
+ "|0[xXbB][0-9a-fA-F_]+[lLuU]*"
+ /* integers and floats */
+ "|[0-9][0-9_]*([.][0-9_]*)([Ee][-+]?[0-9]+)?[fFlLuU]*"This line matches a non-empty digit sequence of any length, and I thought the longest match would win. Why is that not the case here? Frankly, I'm scratching my head over it. Any ideas?
Quoted 2 lines
Yes. The capture group ([.][0-9_]*) should occur once or zero times. So this
([.][0-9_]*)?will fix it.
Oh, good catch! That's the missing piece.
-- Hannes
PATCH v7 1/1 userdiff: add builtin diff driver for kotlin language.
In reply to Jaydeep P DasThe xfuncname pattern finds func/class declarations in diffs to display as a hunk header. The word_regex pattern finds individual tokens in Kotlin code to generate appropriate diffs.
This patch adds xfuncname regex and word_regex for Kotlin language.
--- Documentation/gitattributes.txt | 2 ++ t/t4018/kotlin-class | 5 ++++ t/t4018/kotlin-enum-class | 5 ++++ t/t4018/kotlin-fun | 5 ++++ t/t4018/kotlin-inheritace-class | 5 ++++ t/t4018/kotlin-inline-class | 5 ++++ t/t4018/kotlin-interface | 5 ++++ t/t4018/kotlin-nested-fun | 9 +++++++ t/t4018/kotlin-public-class | 5 ++++ t/t4018/kotlin-sealed-class | 5 ++++ t/t4034-diff-words.sh | 1 + t/t4034/kotlin/expect | 43 +++++++++++++++++++++++++++++++++ t/t4034/kotlin/post | 30 +++++++++++++++++++++++ t/t4034/kotlin/pre | 30 +++++++++++++++++++++++ userdiff.c | 12 +++++++++ 15 files changed, 167 insertions(+) create mode 100644 t/t4018/kotlin-class create mode 100644 t/t4018/kotlin-enum-class create mode 100644 t/t4018/kotlin-fun create mode 100644 t/t4018/kotlin-inheritace-class create mode 100644 t/t4018/kotlin-inline-class create mode 100644 t/t4018/kotlin-interface create mode 100644 t/t4018/kotlin-nested-fun create mode 100644 t/t4018/kotlin-public-class create mode 100644 t/t4018/kotlin-sealed-class create mode 100644 t/t4034/kotlin/expect create mode 100644 t/t4034/kotlin/post create mode 100644 t/t4034/kotlin/pre
Documentation/gitattributes.txt +2 -0
@@ -829,6 +829,8 @@ patterns are available: - `java` suitable for source code in the Java language. +- `kotlin` suitable for source code in the Kotlin language. + - `markdown` suitable for Markdown documents. - `matlab` suitable for source code in the MATLAB and Octave languages.
t/t4018/kotlin-class new file +5 -0
@@ -0,0 +1,5 @@ +class RIGHT { + //comment + //comment + return ChangeMe +}
t/t4018/kotlin-enum-class new file +5 -0
@@ -0,0 +1,5 @@ +enum class RIGHT{ + // Left + // a comment + ChangeMe +}
t/t4018/kotlin-fun new file +5 -0
@@ -0,0 +1,5 @@ +fun RIGHT(){ + //a comment + //b comment + return ChangeMe() +}
t/t4018/kotlin-inheritace-class new file +5 -0
@@ -0,0 +1,5 @@ +open class RIGHT{ + // a comment + // b comment + // ChangeMe +}
t/t4018/kotlin-inline-class new file +5 -0
@@ -0,0 +1,5 @@ +value class RIGHT(Args){ + // a comment + // b comment + ChangeMe +}
t/t4018/kotlin-interface new file +5 -0
@@ -0,0 +1,5 @@ +interface RIGHT{ + //another comment + //another comment + //ChangeMe +}
t/t4018/kotlin-nested-fun new file +9 -0
@@ -0,0 +1,9 @@ +class LEFT{ + class CENTER{ + fun RIGHT( a:Int){ + //comment + //comment + ChangeMe + } + } +}
t/t4018/kotlin-public-class new file +5 -0
@@ -0,0 +1,5 @@ +public class RIGHT{ + //comment1 + //comment2 + ChangeMe +}
t/t4018/kotlin-sealed-class new file +5 -0
@@ -0,0 +1,5 @@ +sealed class RIGHT { + // a comment + // b comment + ChangeMe +}
t/t4034-diff-words.sh +1 -0
@@ -324,6 +324,7 @@ test_language_driver dts test_language_driver fortran test_language_driver html test_language_driver java +test_language_driver kotlin test_language_driver matlab test_language_driver objc test_language_driver pascal
t/t4034/kotlin/expect new file +43 -0
43 lines not on this page · raw message
t/t4034/kotlin/post new file +30 -0
@@ -0,0 +1,30 @@ +println("Hello World?") +(1) (-1e10) (0xabcdef) 'y' +[x] x->y x.y +!x x.inv() x*y x&y +x*y x/y x%y +x+y x-y +a shl b +x<y x<=y x>y x>=y +x==y x!=y x===y +x and y +x^y +x or y +x&&y x||y +x=y x+=y x-=y x*=y x/=y x%=y x<<=y x>>=y x&=y x^=y x|=y +a+=b c=d e<=f g>=h i/j k%l m<<n o>>p q&r s^t u|v +a<=b +a|b a&b +x,y +--a!=--b +a++!=++b +0xFF_E1_DE_5E 0b100_100 200_000 +a===b +a!=b +_33.find(arr) +X.find() +X.f+1 +X.u+2 +a..b +a?:b +.32_00_446
t/t4034/kotlin/pre new file +30 -0
@@ -0,0 +1,30 @@ +println("Hello World!\n") +1 -1e10 0xabcdef 'x' +[a] a->b a.b +!a a.inv() a*b a&b +a*b a/b a%b +a+b a-b +a shr b +a<b a<=b a>b a>=b +a==b a!=b a===b +a and b +a^b +a or b +a&&b a||b +a=b a+=b a-=b a*=b a/=b a%=b a<<=b a>>=b a&=b a^=b a|=b +a=b c+=d e-=f g*=h i/=j k%=l m<<=n o>>=p q&=r s^=t u|=v +a<<=b +a||b a&&b +a,y +--a==--b +a++==++b +0xFF_EC_DE_5E 0b100_000 100_000 +a==b +a!!b +_32.find(arr) +X.fill() +X.u+1 +X.u-2 +a.b +a?.b +.32_00_456
userdiff.c +12 -0
@@ -168,6 +168,18 @@ PATTERNS("java","|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?" "|[-+*/<>%&^|=!]=" "|--|\\+\\+|<<=?|>>>?=?|&&|\\|\\|"), +PATTERNS ("kotlin" , +"^[ \t]*(([a-z]+[ \t]+)*(fun|class|interface)[ \t]+.*)$" , +/* -- */ +"[a-zA-Z_][a-zA-Z0-9_]*" +/* hexadecimal and binary numbers */ +"|0[xXbB][0-9a-fA-F_]+[lLuU]*" +/* integers and floats */ +"|[0-9][0-9_]*([.][0-9_]*)?([Ee][-+]?[0-9]+)?[fFlLuU]*" +/* floating point numbers beginning with decimal point */ +"|[.][0-9][0-9_]*([Ee][-+]?[0-9]+)?[fFlLuU]?" +/* unary and binary operators */ +"|[-+*/<>%&^|=!]==?|--|\\+\\+|<<=|>>=|&&|\\|\\||->|\\.\\*|!!|[?:.][.:]" ), PATTERNS("markdown", "^ {0,3}#{1,6}[ \t].*",/* -- */
Signature · 1 line
2.35.1
Re: [PATCH v7] userdiff: add builtin diff driver for kotlin language.
Am 12.03.22 um 05:48 schrieb Jaydeep P Das:
Quoted 9 lines
The xfuncname pattern finds func/class declarations in diffs to display as a hunk header. The
word_regexpattern finds individual tokens in Kotlin code to generate appropriate diffs.This patch adds xfuncname regex and
word_regexfor Kotlin language.Signed-off-by Jaydeep P Das <[email protected]>
This round looks good. Thank you for your perseverance.
Quoted 302 lines
--- Documentation/gitattributes.txt | 2 ++ t/t4018/kotlin-class | 5 ++++ t/t4018/kotlin-enum-class | 5 ++++ t/t4018/kotlin-fun | 5 ++++ t/t4018/kotlin-inheritace-class | 5 ++++ t/t4018/kotlin-inline-class | 5 ++++ t/t4018/kotlin-interface | 5 ++++ t/t4018/kotlin-nested-fun | 9 +++++++ t/t4018/kotlin-public-class | 5 ++++ t/t4018/kotlin-sealed-class | 5 ++++ t/t4034-diff-words.sh | 1 + t/t4034/kotlin/expect | 43 +++++++++++++++++++++++++++++++++ t/t4034/kotlin/post | 30 +++++++++++++++++++++++ t/t4034/kotlin/pre | 30 +++++++++++++++++++++++ userdiff.c | 12 +++++++++ 15 files changed, 167 insertions(+) create mode 100644 t/t4018/kotlin-class create mode 100644 t/t4018/kotlin-enum-class create mode 100644 t/t4018/kotlin-fun create mode 100644 t/t4018/kotlin-inheritace-class create mode 100644 t/t4018/kotlin-inline-class create mode 100644 t/t4018/kotlin-interface create mode 100644 t/t4018/kotlin-nested-fun create mode 100644 t/t4018/kotlin-public-class create mode 100644 t/t4018/kotlin-sealed-class create mode 100644 t/t4034/kotlin/expect create mode 100644 t/t4034/kotlin/post create mode 100644 t/t4034/kotlin/preDocumentation/gitattributes.txt +2
-0@@ -829,6 +829,8 @@ patterns are available: - `java` suitable for source code in the Java language. +- `kotlin` suitable for source code in the Kotlin language. + - `markdown` suitable for Markdown documents. - `matlab` suitable for source code in the MATLAB and Octave languages.t/t4018/kotlin-class new file +5
-0@@ -0,0 +1,5 @@ +class RIGHT { + //comment + //comment + return ChangeMe +}t/t4018/kotlin-enum-class new file +5
-0@@ -0,0 +1,5 @@ +enum class RIGHT{ + // Left + // a comment + ChangeMe +}t/t4018/kotlin-fun new file +5
-0@@ -0,0 +1,5 @@ +fun RIGHT(){ + //a comment + //b comment + return ChangeMe() +}t/t4018/kotlin-inheritace-class new file +5
-0@@ -0,0 +1,5 @@ +open class RIGHT{ + // a comment + // b comment + // ChangeMe +}t/t4018/kotlin-inline-class new file +5
-0@@ -0,0 +1,5 @@ +value class RIGHT(Args){ + // a comment + // b comment + ChangeMe +}t/t4018/kotlin-interface new file +5
-0@@ -0,0 +1,5 @@ +interface RIGHT{ + //another comment + //another comment + //ChangeMe +}t/t4018/kotlin-nested-fun new file +9
-0@@ -0,0 +1,9 @@ +class LEFT{ + class CENTER{ + fun RIGHT( a:Int){ + //comment + //comment + ChangeMe + } + } +}t/t4018/kotlin-public-class new file +5
-0@@ -0,0 +1,5 @@ +public class RIGHT{ + //comment1 + //comment2 + ChangeMe +}t/t4018/kotlin-sealed-class new file +5
-0@@ -0,0 +1,5 @@ +sealed class RIGHT { + // a comment + // b comment + ChangeMe +}t/t4034-diff-words.sh +1
-0@@ -324,6 +324,7 @@ test_language_driver dts test_language_driver fortran test_language_driver html test_language_driver java +test_language_driver kotlin test_language_driver matlab test_language_driver objc test_language_driver pascalt/t4034/kotlin/expect new file +43
-0@@ -0,0 +1,43 @@ +<BOLD>diff --git a/pre b/post<RESET> +<BOLD>index 11ea3de..2e1df4c 100644<RESET> +<BOLD>--- a/pre<RESET> +<BOLD>+++ b/post<RESET> +<CYAN>@@ -1,30 +1,30 @@<RESET> +println("Hello World<RED>!\n<RESET><GREEN>?<RESET>") +<GREEN>(<RESET>1<GREEN>) (<RESET>-1e10<GREEN>) (<RESET>0xabcdef<GREEN>)<RESET> '<RED>x<RESET><GREEN>y<RESET>' +[<RED>a<RESET><GREEN>x<RESET>] <RED>a<RESET><GREEN>x<RESET>-><RED>b a<RESET><GREEN>y x<RESET>.<RED>b<RESET><GREEN>y<RESET> +!<RED>a a<RESET><GREEN>x x<RESET>.inv() <RED>a<RESET><GREEN>x<RESET>*<RED>b a<RESET><GREEN>y x<RESET>&<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET>*<RED>b a<RESET><GREEN>y x<RESET>/<RED>b a<RESET><GREEN>y x<RESET>%<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET>+<RED>b a<RESET><GREEN>y x<RESET>-<RED>b<RESET><GREEN>y<RESET> +a <RED>shr<RESET><GREEN>shl<RESET> b +<RED>a<RESET><GREEN>x<RESET><<RED>b a<RESET><GREEN>y x<RESET><=<RED>b a<RESET><GREEN>y x<RESET>><RED>b a<RESET><GREEN>y x<RESET>>=<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET>==<RED>b a<RESET><GREEN>y x<RESET>!=<RED>b a<RESET><GREEN>y x<RESET>===<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET> and <RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET>^<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET> or <RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET>&&<RED>b a<RESET><GREEN>y x<RESET>||<RED>b<RESET> +<RED>a<RESET><GREEN>y<RESET> +<GREEN>x<RESET>=<RED>b a<RESET><GREEN>y x<RESET>+=<RED>b a<RESET><GREEN>y x<RESET>-=<RED>b a<RESET><GREEN>y x<RESET>*=<RED>b a<RESET><GREEN>y x<RESET>/=<RED>b a<RESET><GREEN>y x<RESET>%=<RED>b a<RESET><GREEN>y x<RESET><<=<RED>b a<RESET><GREEN>y x<RESET>>>=<RED>b a<RESET><GREEN>y x<RESET>&=<RED>b a<RESET><GREEN>y x<RESET>^=<RED>b a<RESET><GREEN>y x<RESET>|=<RED>b<RESET><GREEN>y<RESET> +a<RED>=<RESET><GREEN>+=<RESET>b c<RED>+=<RESET><GREEN>=<RESET>d e<RED>-=<RESET><GREEN><=<RESET>f g<RED>*=<RESET><GREEN>>=<RESET>h i<RED>/=<RESET><GREEN>/<RESET>j k<RED>%=<RESET><GREEN>%<RESET>l m<RED><<=<RESET><GREEN><<<RESET>n o<RED>>>=<RESET><GREEN>>><RESET>p q<RED>&=<RESET><GREEN>&<RESET>r s<RED>^=<RESET><GREEN>^<RESET>t u<RED>|=<RESET><GREEN>|<RESET>v +a<RED><<=<RESET><GREEN><=<RESET>b +a<RED>||<RESET><GREEN>|<RESET>b a<RED>&&<RESET><GREEN>&<RESET>b +<RED>a<RESET><GREEN>x<RESET>,y +--a<RED>==<RESET><GREEN>!=<RESET>--b +a++<RED>==<RESET><GREEN>!=<RESET>++b +<RED>0xFF_EC_DE_5E 0b100_000 100_000<RESET><GREEN>0xFF_E1_DE_5E 0b100_100 200_000<RESET> +a<RED>==<RESET><GREEN>===<RESET>b +a<RED>!!<RESET><GREEN>!=<RESET>b +<RED>_32<RESET><GREEN>_33<RESET>.find(arr) +X.<RED>fill<RESET><GREEN>find<RESET>() +X.<RED>u<RESET><GREEN>f<RESET>+1 +X.u<RED>-<RESET><GREEN>+<RESET>2 +a<RED>.<RESET><GREEN>..<RESET>b +a<RED>?.<RESET><GREEN>?:<RESET>b +<RED>.32_00_456<RESET><GREEN>.32_00_446<RESET>t/t4034/kotlin/post new file +30
-0@@ -0,0 +1,30 @@ +println("Hello World?") +(1) (-1e10) (0xabcdef) 'y' +[x] x->y x.y +!x x.inv() x*y x&y +x*y x/y x%y +x+y x-y +a shl b +x<y x<=y x>y x>=y +x==y x!=y x===y +x and y +x^y +x or y +x&&y x||y +x=y x+=y x-=y x*=y x/=y x%=y x<<=y x>>=y x&=y x^=y x|=y +a+=b c=d e<=f g>=h i/j k%l m<<n o>>p q&r s^t u|v +a<=b +a|b a&b +x,y +--a!=--b +a++!=++b +0xFF_E1_DE_5E 0b100_100 200_000 +a===b +a!=b +_33.find(arr) +X.find() +X.f+1 +X.u+2 +a..b +a?:b +.32_00_446t/t4034/kotlin/pre new file +30
-0@@ -0,0 +1,30 @@ +println("Hello World!\n") +1 -1e10 0xabcdef 'x' +[a] a->b a.b +!a a.inv() a*b a&b +a*b a/b a%b +a+b a-b +a shr b +a<b a<=b a>b a>=b +a==b a!=b a===b +a and b +a^b +a or b +a&&b a||b +a=b a+=b a-=b a*=b a/=b a%=b a<<=b a>>=b a&=b a^=b a|=b +a=b c+=d e-=f g*=h i/=j k%=l m<<=n o>>=p q&=r s^=t u|=v +a<<=b +a||b a&&b +a,y +--a==--b +a++==++b +0xFF_EC_DE_5E 0b100_000 100_000 +a==b +a!!b +_32.find(arr) +X.fill() +X.u+1 +X.u-2 +a.b +a?.b +.32_00_456userdiff.c +12
-0@@ -168,6 +168,18 @@ PATTERNS("java","|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?" "|[-+*/<>%&^|=!]=" "|--|\\+\\+|<<=?|>>>?=?|&&|\\|\\|"), +PATTERNS ("kotlin" , +"^[ \t]*(([a-z]+[ \t]+)*(fun|class|interface)[ \t]+.*)$" , +/* -- */ +"[a-zA-Z_][a-zA-Z0-9_]*" +/* hexadecimal and binary numbers */ +"|0[xXbB][0-9a-fA-F_]+[lLuU]*" +/* integers and floats */ +"|[0-9][0-9_]*([.][0-9_]*)?([Ee][-+]?[0-9]+)?[fFlLuU]*" +/* floating point numbers beginning with decimal point */ +"|[.][0-9][0-9_]*([Ee][-+]?[0-9]+)?[fFlLuU]?" +/* unary and binary operators */ +"|[-+*/<>%&^|=!]==?|--|\\+\\+|<<=|>>=|&&|\\|\\||->|\\.\\*|!!|[?:.][.:]" ), PATTERNS("markdown", "^ {0,3}#{1,6}[ \t].*",/* -- */
Re: [PATCH v7] userdiff: add builtin diff driver for kotlin language.
Quoted 6 lines · Johannes Sixt
Am 12.03.22 um 05:48 schrieb Jaydeep P Das:
Quoted 5 lines
The xfuncname pattern finds func/class declarations in diffs to display as a hunk header. The
word_regexpattern finds individual tokens in Kotlin code to generate appropriate diffs.
Quoted 8 lines
Quoted 4 lines
This patch adds xfuncname regex and
word_regexfor Kotlin language.Signed-off-by Jaydeep P Das <[email protected]>This round looks good. Thank you for your perseverance.
Acked-by Johannes Sixt <[email protected]>
Thanks. Should I CC Junio or will it be here for some more reviews?
Re: [PATCH v7] userdiff: add builtin diff driver for kotlin language.
Also, since according to GSoC timeline, the current period is to discuss application ideas with mentoring organizations, what should I do next?
I have seen the GSoC application ideas and integrating
the remaining git commands to work with sparse-index looks interesting. Maybe I could start off with that?
Thanks,
Jaydeep.
Re: [PATCH v7] userdiff: add builtin diff driver for kotlin language.
In reply to [email protected]Am 13.03.22 um 18:02 schrieb [email protected]:
Quoted 1 line
Thanks. Should I CC Junio or will it be here for some more reviews?
In my previous reply I Cc'ed Junio to notify him that we have reached a conclusion. Usually, he'll pick up the patch after that. If you do not see the topic mentioned in the next "What's cooking" report or it refers to an outdated version, that would be an appropriate time for a reminder.
-- Hannes