git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Patrick Steinhardt <ps@pks.im>
To: Utsav Parmar <utsavp0213@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] userdiff: add builtin driver for typescript language
Date: Mon, 25 Mar 2024 08:37:02 +0100	[thread overview]
Message-ID: <ZgEpnmdKtSvMH8SQ@tanuki> (raw)
In-Reply-To: <20240324174423.55508-1-utsavp0213@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 9720 bytes --]

On Sun, Mar 24, 2024 at 11:14:23PM +0530, Utsav Parmar wrote:
> There are no implementation or test changes in this patch. It simply relies on the git formatting rather than the IDE git UI formatting that I believe messed up in the parent email.

Commit messages are supposed to be at most 72 characters wide, so please
reflow the commit message to match that limit. Furthermore, when you
send an updated patch, please make sure to increment the patch version
so that folks have an easier time to follow the evolution of your patch.
This can be done by passing e.g. `-v2` to git-format-patch(1) or
git-send-email(1).

Other than that I don't have a lot to say about this patch and will hope
for somebody else to review the TypeScript-related things.

Thanks!

Patrick

> Signed-off-by: Utsav Parmar <utsavp0213@gmail.com>
> ---
>  Documentation/gitattributes.txt          |  2 ++
>  t/t4018/typescript-arrow-function        |  4 +++
>  t/t4018/typescript-class-member-function |  7 +++++
>  t/t4018/typescript-enum                  |  6 +++++
>  t/t4018/typescript-function              |  4 +++
>  t/t4018/typescript-function-assignment   |  4 +++
>  t/t4018/typescript-interface             |  4 +++
>  t/t4018/typescript-type                  |  4 +++
>  t/t4034-diff-words.sh                    |  1 +
>  t/t4034/typescript/expect                | 33 ++++++++++++++++++++++++
>  t/t4034/typescript/post                  | 16 ++++++++++++
>  t/t4034/typescript/pre                   | 16 ++++++++++++
>  userdiff.c                               | 16 ++++++++++++
>  13 files changed, 117 insertions(+)
>  create mode 100644 t/t4018/typescript-arrow-function
>  create mode 100644 t/t4018/typescript-class-member-function
>  create mode 100644 t/t4018/typescript-enum
>  create mode 100644 t/t4018/typescript-function
>  create mode 100644 t/t4018/typescript-function-assignment
>  create mode 100644 t/t4018/typescript-interface
>  create mode 100644 t/t4018/typescript-type
>  create mode 100644 t/t4034/typescript/expect
>  create mode 100644 t/t4034/typescript/post
>  create mode 100644 t/t4034/typescript/pre
> 
> diff --git a/Documentation/gitattributes.txt b/Documentation/gitattributes.txt
> index 4338d023d9..4461c41054 100644
> --- a/Documentation/gitattributes.txt
> +++ b/Documentation/gitattributes.txt
> @@ -902,6 +902,8 @@ patterns are available:
>  
>  - `tex` suitable for source code for LaTeX documents.
>  
> +- `typescript` suitable for source code for TypeScript language.
> +
>  
>  Customizing word diff
>  ^^^^^^^^^^^^^^^^^^^^^
> diff --git a/t/t4018/typescript-arrow-function b/t/t4018/typescript-arrow-function
> new file mode 100644
> index 0000000000..85a3d9cd6b
> --- /dev/null
> +++ b/t/t4018/typescript-arrow-function
> @@ -0,0 +1,4 @@
> +const RIGHT = (one) => {
> +    someMethodCall();
> +    return ChangeMe;
> +}
> diff --git a/t/t4018/typescript-class-member-function b/t/t4018/typescript-class-member-function
> new file mode 100644
> index 0000000000..f34b0a2bac
> --- /dev/null
> +++ b/t/t4018/typescript-class-member-function
> @@ -0,0 +1,7 @@
> +class Test {
> +	var one;
> +	function RIGHT(two: string) {
> +		someMethodCall();
> +		return ChangeMe;
> +	}
> +}
> diff --git a/t/t4018/typescript-enum b/t/t4018/typescript-enum
> new file mode 100644
> index 0000000000..8c045a45ec
> --- /dev/null
> +++ b/t/t4018/typescript-enum
> @@ -0,0 +1,6 @@
> +enum RIGHT {
> +    ONE = 1,
> +    TWO,
> +    THREE,
> +    ChangeMe
> +}
> diff --git a/t/t4018/typescript-function b/t/t4018/typescript-function
> new file mode 100644
> index 0000000000..62cf63f669
> --- /dev/null
> +++ b/t/t4018/typescript-function
> @@ -0,0 +1,4 @@
> +function RIGHT<Type implements AnotherType>(one: number): Type {
> +    someMethodCall();
> +    return ChangeMe;
> +}
> diff --git a/t/t4018/typescript-function-assignment b/t/t4018/typescript-function-assignment
> new file mode 100644
> index 0000000000..49c528713e
> --- /dev/null
> +++ b/t/t4018/typescript-function-assignment
> @@ -0,0 +1,4 @@
> +const RIGHT = function(one: number): Type {
> +    someMethodCall();
> +    return ChangeMe;
> +}
> diff --git a/t/t4018/typescript-interface b/t/t4018/typescript-interface
> new file mode 100644
> index 0000000000..6f3665c2af
> --- /dev/null
> +++ b/t/t4018/typescript-interface
> @@ -0,0 +1,4 @@
> +interface RIGHT {
> +  one?: string;
> +  [propName: ChangeMe]: any;
> +}
> \ No newline at end of file
> diff --git a/t/t4018/typescript-type b/t/t4018/typescript-type
> new file mode 100644
> index 0000000000..e1bb2d8371
> --- /dev/null
> +++ b/t/t4018/typescript-type
> @@ -0,0 +1,4 @@
> +type RIGHT = {
> +  one: number,
> +  ChangeMe: CustomType
> +}
> \ No newline at end of file
> diff --git a/t/t4034-diff-words.sh b/t/t4034-diff-words.sh
> index 74586f3813..4e3cf415c2 100755
> --- a/t/t4034-diff-words.sh
> +++ b/t/t4034-diff-words.sh
> @@ -338,6 +338,7 @@ test_language_driver python
>  test_language_driver ruby
>  test_language_driver scheme
>  test_language_driver tex
> +test_language_driver typescript
>  
>  test_expect_success 'word-diff with diff.sbe' '
>  	cat >pre <<-\EOF &&
> diff --git a/t/t4034/typescript/expect b/t/t4034/typescript/expect
> new file mode 100644
> index 0000000000..19605fec4d
> --- /dev/null
> +++ b/t/t4034/typescript/expect
> @@ -0,0 +1,33 @@
> +<BOLD>diff --git a/pre b/post<RESET>
> +<BOLD>index e4a51a2..9c56465 100644<RESET>
> +<BOLD>--- a/pre<RESET>
> +<BOLD>+++ b/post<RESET>
> +<CYAN>@@ -1,16 +1,16 @@<RESET>
> +log("Hello World<RED>!\n<RESET><GREEN>?<RESET>")
> +<GREEN>(<RESET>1<GREEN>) (<RESET>-1e10<GREEN>) (<RESET>0xabcdef<GREEN>) u<RESET>'<RED>x<RESET><GREEN>y<RESET>'
> +!<RED>a<RESET><GREEN>x<RESET> ~<RED>a a<RESET><GREEN>x x<RESET>++ <RED>a<RESET><GREEN>x<RESET>-- <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><<<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
> <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
> <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
> <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><GREEN>y<RESET>:z
> +<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 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/typescript/post b/t/t4034/typescript/post
> new file mode 100644
> index 0000000000..b1b03a7666
> --- /dev/null
> +++ b/t/t4034/typescript/post
> @@ -0,0 +1,16 @@
> +log("Hello World?")
> +(1) (-1e10) (0xabcdef) u'y'
> +!x ~x x++ x-- 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!=y
> +x&y
> +x^y
> +x|y
> +x&&y
> +x||y
> +x?y:z
> +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/typescript/pre b/t/t4034/typescript/pre
> new file mode 100644
> index 0000000000..13a0b2138c
> --- /dev/null
> +++ b/t/t4034/typescript/pre
> @@ -0,0 +1,16 @@
> +log("Hello World!\n")
> +1 -1e10 0xabcdef 'x'
> +!a ~a a++ a-- 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 a!=b
> +a&b
> +a^b
> +a|b
> +a&&b
> +a||b
> +a?b:z
> +a=b a+=b a-=b a*=b a/=b a%=b a<<=b a>>=b a&=b a^=b a|=b
> +a,y
> diff --git a/userdiff.c b/userdiff.c
> index 92ef649c99..dbb5d7c072 100644
> --- a/userdiff.c
> +++ b/userdiff.c
> @@ -297,6 +297,22 @@ PATTERNS("scheme",
>  	 "|([^][)(}{[ \t])+"),
>  PATTERNS("tex", "^(\\\\((sub)*section|chapter|part)\\*{0,1}\\{.*)$",
>  	 "\\\\[a-zA-Z@]+|\\\\.|([a-zA-Z0-9]|[^\x01-\x7f])+"),
> +PATTERNS("typescript",
> +         "^[ \t]*((enum|interface|type)[ \t]+([a-zA-Z][a-zA-Z0-9]*)+.*)$\n"
> +         /* Method definitions */
> +         "^[ \t]*[a-z]+[ \t]+([A-Za-z_][A-Za-z_0-9]*)+([ \t]*=[ \t]*(function)?)?([ \t]*[A-Za-z_<>&][?&<>|.,A-Za-z_]*[ \t]*)*[ \t]*\\([^;]*$",
> +         /* -- */
> +         "[a-zA-Z_][a-zA-Z0-9_]*"
> +         /* Integers and floats */
> +         "|[-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?"
> +         /* Binary */
> +         "|0[bB][01]+"
> +         /* Hexadecimals */
> +         "|0[xX][0-9a-fA-F]+"
> +         /* Floats starting with a decimal point */
> +         "|[-+]?([0-9]*\\.?[0-9]+|[0-9]+\\.?[0-9]*)([eE][-+]?[0-9]+)?"
> +         /* Operators */
> +         "[-+*/%&|^!=<>]=?|===|!==|<<=?|>>=?|&&|\\|\\||\\?\\?|\\+\\+|--|~"),
>  { "default", NULL, NULL, -1, { NULL, 0 } },
>  };
>  #undef PATTERNS
> -- 
> 2.34.1
> 
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2024-03-25 13:30 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-19 18:59 [GSoC][PATCH] userdiff: add funcname regex and wordregex for typescript language Utsav Parmar
2024-03-21 12:21 ` Patrick Steinhardt
2024-03-23 15:07   ` Utsav Parmar
     [not found]   ` <CAD6u1kiaFDcyRX7-iZBb9LtoQ1F+M18UkyJuTXsQPE0YQGafmw@mail.gmail.com>
2024-03-25  7:33     ` Patrick Steinhardt
2024-03-24 17:44 ` [PATCH] userdiff: add builtin driver " Utsav Parmar
2024-03-25  7:37   ` Patrick Steinhardt [this message]
2024-03-25 17:23   ` Karthik Nayak
2024-04-04 16:38   ` [PATCH v2] " Utsav Parmar
2024-04-05 17:43     ` Junio C Hamano
2024-04-05 17:47     ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZgEpnmdKtSvMH8SQ@tanuki \
    --to=ps@pks.im \
    --cc=git@vger.kernel.org \
    --cc=utsavp0213@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).