git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] userdiff: add builtin diff driver for Kotlin language.

From
Johannes Sixt <j6t@kdbg.org>
Date
Mar 1, 2022, 19:47 UTC
Message-ID
<5df2c9ce-b243-0173-befb-e13a6a74e387@kdbg.org>
In-Reply-To
<20220301155431.2534136-1-jaydeepjd.8914@gmail.com>
Am 01.03.22 um 16:54 schrieb Jaydeep P Das:
Show 15 quoted lines
> diff --git a/t/t4018/kotlin-nested-fun b/t/t4018/kotlin-nested-fun
> new file mode 100644
> index 0000000000..12186858cb
> --- /dev/null
> +++ b/t/t4018/kotlin-nested-fun
> @@ -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...

Show 83 quoted lines
> diff --git a/t/t4034/kotlin/expect b/t/t4034/kotlin/expect
> new file mode 100644
> index 0000000000..80eea3e386
> --- /dev/null
> +++ b/t/t4034/kotlin/expect
> @@ -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
> diff --git a/t/t4034/kotlin/post b/t/t4034/kotlin/post
> new file mode 100644
> index 0000000000..e6ebebb5e9
> --- /dev/null
> +++ b/t/t4034/kotlin/post
> @@ -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
> diff --git a/t/t4034/kotlin/pre b/t/t4034/kotlin/pre
> new file mode 100644
> index 0000000000..e8a199adb0
> --- /dev/null
> +++ b/t/t4034/kotlin/pre
> @@ -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

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 =.

Show 10 quoted lines
> diff --git a/userdiff.c b/userdiff.c
> index 8578cb0d12..f23f098f19 100644
> --- a/userdiff.c
> +++ b/userdiff.c
> @@ -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.

> +	 /* -- */
> +	 "[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?
Show 5 quoted lines
> +	 "|[-+*/<>%&^|=!]="
> +	 "|--|\\+\\+|<<=?|>>>?=?|&&|\\|\\|"),
>  PATTERNS("markdown",
>  	 "^ {0,3}#{1,6}[ \t].*",
>  	 /* -- */
-- Hannes
Previous: Johannes SixtNext: Jaydeep P Das
Message 10 of 48 in “userdiff: Add diff driver for Kotlin lang and tests”
  1. Jaydeep P DasMar 1, 2022
  2. userdiff: Add diff driver for Kotlin lang and testsJaydeep P Das, Mar 1, 2022
  3. Junio C HamanoMar 1, 2022
  4. Ævar Arnfjörð BjarmasonMar 1, 2022
  5. jaydeepjd.8914@gmail.comMar 1, 2022
  6. userdiff: add builtin diff driver for Kotlin language.Jaydeep P Das, Mar 1, 2022
  7. Junio C HamanoMar 1, 2022
  8. jaydeepjd.8914@gmail.comMar 1, 2022
  9. Johannes SixtMar 1, 2022
  10. Johannes SixtMar 1, 2022
  11. [GSoC][PATCHv2] userdiff: add builtin driver for kotlin languageJaydeep P Das, Mar 2, 2022
  12. userdiff: add builtin driver for kotlin languageJaydeep P Das, Mar 2, 2022
  13. Johannes SixtMar 2, 2022
  14. jaydeepjd.8914@gmail.comMar 2, 2022
  15. jaydeepjd.8914@gmail.comMar 2, 2022
  16. [GSoC][PATCHv3] userdiff: add builtin driver for kotlin languageJaydeep P Das, Mar 2, 2022
  17. userdiff: add builtin driver for kotlin languageJaydeep P Das, Mar 2, 2022
  18. Johannes SixtMar 2, 2022
  19. Jaydeep DasMar 3, 2022
  20. Ævar Arnfjörð BjarmasonMar 3, 2022
  21. Junio C HamanoMar 3, 2022
  22. Johannes SixtMar 3, 2022
  23. Jaydeep DasMar 4, 2022
  24. Johannes SixtMar 4, 2022
  25. userdiff: add builtin diff driver for Kotlin language.Jaydeep P Das, Mar 3, 2022
  26. Junio C HamanoMar 4, 2022
  27. jaydeepjd.8914@gmail.comMar 4, 2022
  28. Johannes SixtMar 4, 2022
  29. userdiff: add builtin diff driver for Kotlin language.Jaydeep P Das, Mar 5, 2022
  30. Johannes SixtMar 5, 2022
  31. jaydeepjd.8914@gmail.comMar 5, 2022
  32. Johannes SixtMar 5, 2022
  33. userdiff: add builtin diff driver for kotlin language.Jaydeep P Das, Mar 6, 2022
  34. Johannes SixtMar 7, 2022
  35. jaydeepjd.8914@gmail.comMar 8, 2022
  36. Johannes SixtMar 8, 2022
  37. jaydeepjd.8914@gmail.comMar 10, 2022
  38. Jaydeep DasMar 10, 2022
  39. Johannes SixtMar 10, 2022
  40. userdiff: add builtin diff driver for kotlin language.Jaydeep P Das, Mar 11, 2022
  41. Johannes SixtMar 11, 2022
  42. jaydeepjd.8914@gmail.comMar 12, 2022
  43. Johannes SixtMar 12, 2022
  44. userdiff: add builtin diff driver for kotlin language.Jaydeep P Das, Mar 12, 2022
  45. Johannes SixtMar 12, 2022
  46. jaydeepjd.8914@gmail.comMar 13, 2022
  47. jaydeepjd.8914@gmail.comMar 13, 2022
  48. Johannes SixtMar 13, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.