-
Notifications
You must be signed in to change notification settings - Fork 26.4k
userdiff: add builtin diff driver for TypeScript language #1746
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
userdiff: add builtin diff driver for TypeScript language #1746
Conversation
Welcome to GitGitGadgetHi @matthewhughes934, and welcome to GitGitGadget, the GitHub App to send patch series to the Git mailing list from GitHub Pull Requests. Please make sure that either:
You can CC potential reviewers by adding a footer to the PR description with the following syntax:
NOTE: DO NOT copy/paste your CC list from a previous GGG PR's description, Also, it is a good idea to review the commit messages one last time, as the Git project expects them in a quite specific form:
It is in general a good idea to await the automated test ("Checks") in this Pull Request before contributing the patches, e.g. to avoid trivial issues such as unportable code. Contributing the patchesBefore you can contribute the patches, your GitHub username needs to be added to the list of permitted users. Any already-permitted user can do that, by adding a comment to your PR of the form Both the person who commented An alternative is the channel
Once on the list of permitted usernames, you can contribute the patches to the Git mailing list by adding a PR comment If you want to see what email(s) would be sent for a After you submit, GitGitGadget will respond with another comment that contains the link to the cover letter mail in the Git mailing list archive. Please make sure to monitor the discussion in that thread and to address comments and suggestions (while the comments and suggestions will be mirrored into the PR by GitGitGadget, you will still want to reply via mail). If you do not want to subscribe to the Git mailing list just to be able to respond to a mail, you can download the mbox from the Git mailing list archive (click the curl -g --user "<EMailAddress>:<Password>" \
--url "imaps://imap.gmail.com/INBOX" -T /path/to/raw.txt To iterate on your change, i.e. send a revised patch or patch series, you will first want to (force-)push to the same branch. You probably also want to modify your Pull Request description (or title). It is a good idea to summarize the revision by adding something like this to the cover letter (read: by editing the first comment on the PR, i.e. the PR description):
To send a new iteration, just add another PR comment with the contents: Need help?New contributors who want advice are encouraged to join git-mentoring@googlegroups.com, where volunteers who regularly contribute to Git are willing to answer newbie questions, give advice, or otherwise provide mentoring to interested contributors. You must join in order to post or view messages, but anyone can join. You may also be able to find help in real time in the developer IRC channel, |
There are issues in commit bfe2820: |
bfe2820
to
c6c1b82
Compare
/allow |
User matthewhughes934 is now allowed to use GitGitGadget. WARNING: matthewhughes934 has no public email address set on GitHub; |
/preview |
Preview email sent as pull.1746.git.git.1720989699838.gitgitgadget@gmail.com |
c6c1b82
to
8fb1183
Compare
0c7ce73
to
0efa26b
Compare
TypeScript[1] is an open-source programming language that builds on JavaScript. This patch adds builtin diff driver support for this language. As far as I can tell there is no official syntax specification for the language (see[2] for some discussion) so this patch is based off some existing work[3]. The docs[4] probably provide the best reference as to what this driver should satisfy. See[5] for discussion/motivation for this change from the TypeScript language team. This is my first time developing a diff driver, so as such the implementation borrows quite a bit from existing drivers. The funcname attribute matches function and class definitions, the list of keywords used to define functions was take from[3], I could not find an exhaustive list for these. The word-regex borrows much from other existing diff engines, with the addition of the rather unique right-shifting operators (>>> and >>>=) available in JavaScript (and hence Typescript)[6] [1] https://www.typescriptlang.org/ [2] microsoft/TypeScript#15711 [3] git#859 [4] https://www.typescriptlang.org/docs/ [5] microsoft/TypeScript#36185 [6] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Unsigned_right_shift Signed-off-by: Matthew Hughes <matthewhughes934@gmail.com>
0efa26b
to
63b6a46
Compare
/preview |
Preview email sent as pull.1746.git.git.1721060847706.gitgitgadget@gmail.com |
/submit |
Submitted as pull.1746.git.git.1721061218993.gitgitgadget@gmail.com To fetch this version into
To fetch this version to local tag
|
This patch series was integrated into seen via 0ca8316. |
This patch series was integrated into seen via ac7da8b. |
On the Git mailing list, Matthew Hughes wrote (reply to this): On Mon, Jul 15, 2024 at 04:33:38PM +0000, Matthew Hughes via GitGitGadget wrote:
> diff --git a/userdiff.c b/userdiff.c
> index c4ebb9ff734..7247d351cde 100644
> --- a/userdiff.c
> +++ b/userdiff.c
> @@ -333,6 +333,17 @@ PATTERNS("scheme",
> "|([^][)(}{[ \t])+"),
> PATTERNS("tex", "^(\\\\((sub)*section|chapter|part)\\*{0,1}\\{.*)$",
> "\\\\[a-zA-Z@]+|\\\\.|([a-zA-Z0-9]|[^\x01-\x7f])+"),
> +PATTERNS("typescript",
> + "^[\t ]*((class|constructor|public|private|protected|function|interface)[ \t].*)$\n"
> + // arrow funcs
> + "^[\t ]*((const|let|var)?[^()]*)=[\t ]*\\([^()]*\\)[\t ]*.*=>.*$",
> + /* -- */
> + "[a-zA-Z_][a-zA-Z0-9_]*"
> + // numeric constants
> + "|[-+0-9.e]+|0[xX]?[0-9a-fA-F]"
> + // operators
> + "|[-+*/<>%&^|=!]"
> + "|--|\\+\\+|//=?|<<=?|>>?=?"),
> { .name = "default", .binary = -1 },
> };
> #undef PATTERNS
>
> base-commit: a7dae3bdc8b516d36f630b12bb01e853a667e0d9
> --
> gitgitgadget
This needs some updates. For the arrow function, definitions can cover multiple
lines e.g.:
const bar = (
name: string
) => console.log(name)
The funcname pattern should also consider the `export` keyword, since both of
the following are valid:
export const bar = (
name: string
) => console.log(name)
export function foo() {}
Some docs: https://www.typescriptlang.org/docs/handbook/modules/reference.html#module-syntax |
On the Git mailing list, Junio C Hamano wrote (reply to this): Matthew Hughes <matthewhughes934@gmail.com> writes:
> This needs some updates.
What does it mean?
The patterns that were posted were so broken that they are unusable
and harm the users by giving misleading information?
Or do the patterns work just fine in basic or tutorial cases, but
with more advanced or realistic uses of the language construct, they
highlight wrong lines as the function header and/or split at wrong
word boundaries that are obviously much less optimal than ideal that
any human users would find questionable?
In the latter case, how far from the ideal are the decisions done by
the current patterns, and what's the rough percentage of usual code
we see in the real world, for which the current patterns do not work
well?
What I am trying to gauge is if it is so broken that it should not
exist (in other words, you regret sending the patch to the list
before doing these updates), or is "already serviceable, but not
perfect yet". Waiting for perfection takes forever. If the latter,
letting the general public to use it to gather feedbacks by waiting
for the dust to settle before making such updates is often better.
|
On the Git mailing list, Matthew Hughes wrote (reply to this): Oe Tue, Jul 16, 2024 at 08:45:08AM -0700, Junio C Hamano wrote:
> What does it mean?
>
> The patterns that were posted were so broken that they are unusable
> and harm the users by giving misleading information?
I think this would be a good summary. It's sufficient for some simpler cases
considered, and does even give some benefits e.g. for function headers for
nested functions. However, the cases where it fails can be significant, e.g.
hundreds of lines away from the correct function header for files with multiple
consecutive multi-line arrow functions.
> In the latter case, how far from the ideal are the decisions done by
> the current patterns, and what's the rough percentage of usual code
> we see in the real world, for which the current patterns do not work
> well?
I think just the missing `export` keyword handling would be equivalent to
missing all public functions in other programming languages, so that alone
would be a decent percentage.
> What I am trying to gauge is if it is so broken that it should not
> exist (in other words, you regret sending the patch to the list
> before doing these updates), or is "already serviceable, but not
> perfect yet". Waiting for perfection takes forever. If the latter,
> letting the general public to use it to gather feedbacks by waiting
> for the dust to settle before making such updates is often better.
I'm leaning towards the former case: that this patch was premature. I think
it's far enough from perfect that it would greatly benefit from me more
actively reaching out to the TypeScript language team and asking some devs
there try out the changes and gather some more input (and identify some more
missing cases, of which I now expect that are many) before getting
something out to general users. |
On the Git mailing list, Johannes Sixt wrote (reply to this): We have had a submission for typescript just recently:
https://lore.kernel.org/git/20240404163827.5855-1-utsavp0213@gmail.com/
And two for Javascript
https://lore.kernel.org/git/20240301074048.188835-1-sergiusnyah@gmail.com/
https://lore.kernel.org/git/20220403132508.28196-1-a97410985new@gmail.com/
Please review these earlier submissions. If you think you can improve on
them, you are very welcome to do so. But you can also just resend one of
these series with a note that they are sufficiently mature and that you
support the submitted version.
I may very well mistaken, but I think that Typescript is a syntactical
superset of Javascript, so we need just one language driver and mention
in the documentation that it can be used for both languages.
Thanks,
-- Hannes
|
User |
On the Git mailing list, Junio C Hamano wrote (reply to this): Matthew Hughes <matthewhughes934@gmail.com> writes:
> I'm leaning towards the former case: that this patch was premature.
OK. Then let's take sufficient time. After all, we are never in a
hurry ;-)
Thanks for giving an honest assessment. Will keep the topic in
'seen' without marking it for 'next' (at least until it gets
replaced with a version that is more suitable to the public).
|
This branch is now known as |
There was a status update in the "Discarded" section about the branch Retracted for now. cf. <20240716193344.bjb62zsfnrfw3ngf@archP14s> source: <pull.1746.git.git.1721061218993.gitgitgadget@gmail.com> |
cc: Johannes Sixt j6t@kdbg.org