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

Re: [PATCH v3 0/3] userdiff: Java updates

From
Johannes Sixt <j6t@kdbg.org>
Date
Feb 8, 2023, 20:51 UTC
Message-ID
<e16e4190-9db0-1519-0114-858118882d5d@kdbg.org>
In-Reply-To
<20230207234259.452141-1-rybak.a.v@gmail.com>
Am 08.02.23 um 00:42 schrieb Andrei Rybak:
Show 26 quoted lines
> On 2023-02-05T22:33 Johannes Sixt wrote:
>> Having seen all these examples, I think the following truncated
>> expression might do the right thing for all cases that are valid Java:
>>
>> "^[ \t]*(([a-z-]+[ \t]+)*(class|enum|interface|record)[ \t].*)$"
> 
> Only the '\n' is missing at the end, but otherwise I concur, so here's a v3.
> 
>> i.e., we recognize a whitespace in order to identify the keyword, and
>> then capture anything that follows without being specific. My reasoning
>> is that "class", "enum", "interface", and "record" cannot occur in any
>> other context than the beginning of a class definition. (But please do
>> correct me; I know next to nothing about Java syntax.)
> 
> The word "class" can also occur as part of a class literal, for example:
> 
>     Class<String> c = String.class;
> 
> but valid uses of class literals won't interfere with our regex, unless some
> wild formatting is applied.  This is technically valid Java:
> 
>     Class<String> c = String.
>     class 
>     ;
> 
> and with a space after lowercase "class", the v3 regex will trip.
Yeah, let's assume that nobody writes code like this.
This iteration is all good!
Reviewed-by: Johannes Sixt <j6t@kdbg.org>
-- Hannes
Previous: Andrei RybakNext: Junio C Hamano
Message 18 of 19 in “userdiff: Java updates”
  1. 0/3 userdiff: Java updatesAndrei Rybak, Feb 3, 2023
  2. 1/3 userdiff: support Java type parametersAndrei Rybak, Feb 3, 2023
  3. 2/3 userdiff: support Java record typesAndrei Rybak, Feb 3, 2023
  4. 3/3 userdiff: support Java sealed classesAndrei Rybak, Feb 3, 2023
  5. Tassilo HornFeb 4, 2023
  6. 0/3 userdiff: Java updatesAndrei Rybak, Feb 4, 2023
  7. 1/3 userdiff: support Java type parametersAndrei Rybak, Feb 4, 2023
  8. 2/3 userdiff: support Java record typesAndrei Rybak, Feb 4, 2023
  9. 3/3 userdiff: support Java sealed classesAndrei Rybak, Feb 4, 2023
  10. Johannes SixtFeb 5, 2023
  11. Andrei RybakFeb 5, 2023
  12. Johannes SixtFeb 5, 2023
  13. 0/3 userdiff: Java updatesAndrei Rybak, Feb 7, 2023
  14. 1/3 userdiff: support Java type parametersAndrei Rybak, Feb 7, 2023
  15. Andrei RybakFeb 8, 2023
  16. 2/3 userdiff: support Java record typesAndrei Rybak, Feb 7, 2023
  17. 3/3 userdiff: support Java sealed classesAndrei Rybak, Feb 7, 2023
  18. Johannes SixtFeb 8, 2023
  19. Junio C HamanoFeb 8, 2023

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.