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

Re: [GSoC][PATCH v2] Add a diff driver for JavaScript languages.

From
xing zhi jiang <a97410985new@gmail.com>
Date
Apr 3, 2022, 13:21 UTC
Message-ID
<CAN_FRNKbQAFr5fL-giffKADHjBN2QUt5fUQriTpjOv-g5=9QHw@mail.gmail.com>
In-Reply-To
<kl6lwngwqwm2.fsf@chooglen-macbookpro.roam.corp.google.com>

Sorry for the late reply. Because I was busy last two weeks. And grateful for your review.

On Tue, 15 Mar 2022 at 01:20, Glen Choo <chooglen@google.com> wrote:
Show 38 quoted lines
>
> > diff --git a/t/t4018/javascript-function b/t/t4018/javascript-function
> > new file mode 100644
> > index 0000000000..0cc0bf54e7
> > --- /dev/null
> > +++ b/t/t4018/javascript-function
> > @@ -0,0 +1,4 @@
> > +function RIGHT(a, b) {
> > +
> > +  return a + b; // ChangeMe
> > +}
> > diff --git a/t/t4018/javascript-function-2 b/t/t4018/javascript-function-2
> > new file mode 100644
> > index 0000000000..06cfb779f0
> > --- /dev/null
> > +++ b/t/t4018/javascript-function-2
> > @@ -0,0 +1,10 @@
> > +function test(a, b) {
> > +  return {
> > +                     RIGHT: function () {
> > +                             currentUpdateRemovedChunks.forEach(function (chunkId) {
> > +                                     delete $installedChunks$[chunkId];
> > +                             });
> > +                             currentUpdateRemovedChunks = ChangeMe;
> > +   }
> > +  }
> > +}
>
> There is also the ES2015 'method shorthand' syntax [3], e.g. `bar` in:
>
>   const foo = {
>     bar() {
>       console.log('hi');
>     }
>   }
>
> [3] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Method_definitions
>

The ES2015 method shorthand is already matched by the regex for function in class "^[\t ]*((static[\t ]+)?((async|get|set)[\t ]+)?[$_[:alpha:]][$_[:alnum:]]*[\t ]*\\(.*)" So I update the comment for this regex in the v3 patch. The comment is "/* match function in class and ES5 method shorthand */"

Show 30 quoted lines
> > diff --git a/t/t4018/javascript-function-belong-to-IIFE b/t/t4018/javascript-function-belong-to-IIFE
> > new file mode 100644
> > index 0000000000..6e5fe858c0
> > --- /dev/null
> > +++ b/t/t4018/javascript-function-belong-to-IIFE
> > @@ -0,0 +1,6 @@
> > +(function () {
> > +  this.$RIGHT = function (needle, modifier) {
> > +      let a = 5;
> > +      return ChangeMe;
> > +  };
> > +}).call(aaaa.prototype);
>
>  Does the IIFE matter in this case? This line:
>
>   this.$RIGHT = function (needle, modifier) {
>
> looks extremely similar to the previous test of `foo = function bar()`.
>
> Or perhaps this is meant to demonstrate the edge case of "matching in a
> complicated construct"? If so, perhaps we should test other edge cases
> like:
>
>    function WRONG() {
>      let RIGHT = function (needle, modifier) {
>          let a = 5;
>          return ChangeMe;
>      };
>    }
>

Currently, I realize this test case is redundant. Because I trust the function keyword. So the regex "^(.*=[\t ]*function[\t ]*([$_[:alnum:]]+[\t ]*)?\\(.*)\n" is loose for LHS. I will remove this case in the v3 patch.

Previous: xing zhi jiangNext: xing zhi jiang
Message 18 of 25 in “userdiff: add buildin diff driver for JavaScript language”
  1. xing zhi jiangMar 4, 2022
  2. [GSoC][PATCH 1/1] Add a diff driver for JavaScript languages.xing zhi jiang, Mar 4, 2022
  3. Johannes SixtMar 5, 2022
  4. xing-zhi jiangMar 7, 2022
  5. Johannes SixtMar 8, 2022
  6. xing zhi jiangMar 12, 2022
  7. Johannes SixtMar 5, 2022
  8. [GSoC][PATCH v2] Add a diff driver for JavaScript languages.xing zhi jiang, Mar 12, 2022
  9. Johannes SixtMar 13, 2022
  10. xing zhi jiangApr 3, 2022
  11. Glen ChooMar 14, 2022
  12. Johannes SixtMar 15, 2022
  13. Glen ChooMar 15, 2022
  14. Junio C HamanoMar 15, 2022
  15. Glen ChooMar 15, 2022
  16. xing zhi jiangApr 3, 2022
  17. xing zhi jiangApr 3, 2022
  18. xing zhi jiangApr 3, 2022
  19. [GSoC][PATCH v3] Add a diff driver for JavaScript languages.xing zhi jiang, Apr 3, 2022
  20. Johannes SixtApr 3, 2022
  21. Ævar Arnfjörð BjarmasonApr 4, 2022
  22. Johannes SixtApr 4, 2022
  23. Junio C HamanoApr 4, 2022
  24. Ævar Arnfjörð BjarmasonApr 5, 2022
  25. Glen ChooApr 4, 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.