On Mon, 22 Nov 2021 17:34:51 GMT, Pavel Rappo <pra...@openjdk.org> 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:
> 
>   Address feedback

Here's a suggestion for a method to generate a pattern to do the coarse parsing 
of snippet lines, to see if they contain markup comments.



    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());
    }
 ```

The `cmt` parameter can be one of
* a pattern-safe literal string, such as `//`, or
* a pattern-quoted string, using `Pattern.quote`
* a pattern denoting alternative acceptable comment sequences, such as `[#!]` 
for properties files
 
  The `boolean eol` parameter indicates whether end-of-line comments are 
supported, or just whole-line comments.  

The pattern contains named groups for the `payload` and `markup` parts of the 
line, which can be used to determine the start and end of those regions.

-------------

PR: https://git.openjdk.java.net/jdk/pull/6397

Reply via email to