On Wed, 24 Nov 2021 16:11:37 GMT, Pavel Rappo <[email protected]> wrote:
>> The initial integration (JDK-8266666) of JEP 413 did not support properties
>> files. This commit rights that wrong.
>
> Pavel Rappo has updated the pull request incrementally with one additional
> commit since the last revision:
>
> Remove unrelated comment
Approved, for now. It's good to have simplified `CoarseParser` down to regular
expressions.
I look forward to the next step of cleanup (for 19?) where the design contained
here can be extended to additional languages, perhaps dynamically (in some
fashion TBD).
The regular expressions are a function on the comment character(s), and whether
the comment is a "line comment" or "end-of-line comment". These properties
could be described in members of `Language` and the corresponding regauylr
expressions generated by the following method:
Pattern getPattern(String cmt, boolean eol) {
Pattern payload = eol
? Pattern.compile("(?<payload>.*)")
: Pattern.compile("(?<payload>[ \t]*(" + cmt + ".*)?)");
Pattern prefix = Pattern.compile(cmt + "(?=[ \t]*@[a-z]+\\b)");
Pattern markup = Pattern.compile("(?<markup>.*)");
return Pattern.compile(payload.pattern() + prefix.pattern() +
markup.pattern());
}
Related, `Language` could usefully be converted from an `enum` to a `record`,
and maybe have a cache-map of `Map<Language, Pattern>` to reduce the costs of
creating those patterns.
-------------
Marked as reviewed by jjg (Reviewer).
PR: https://git.openjdk.java.net/jdk/pull/6397