From c68d2371eebda3b26e8746b9121e9263d284ec33 Mon Sep 17 00:00:00 2001 From: Carm Date: Wed, 12 Feb 2025 02:35:59 +0800 Subject: [PATCH] feat(comment): Support regex inline comments --- .../annotation/InlineComment.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/features/commentable/src/main/java/cc/carm/lib/configuration/annotation/InlineComment.java b/features/commentable/src/main/java/cc/carm/lib/configuration/annotation/InlineComment.java index d042da4..763f896 100644 --- a/features/commentable/src/main/java/cc/carm/lib/configuration/annotation/InlineComment.java +++ b/features/commentable/src/main/java/cc/carm/lib/configuration/annotation/InlineComment.java @@ -31,4 +31,23 @@ public @interface InlineComment { @NotNull String value() default ""; + /** + * If the regex is not empty, the comment will be added to + * all sub paths if the regex matches the value. + * If the regex is empty, the comment will be added to the current path. + *

e.g. "^foo\\.*\\.bar" will be set like + *

+     *     foo:
+     *       some:
+     *         lover: "bar" <- not matched so no comments
+     *         bar: "foobar" # Comment Contents
+     *       other:
+     *         bar: "foobar" # Comment Contents
+     * 
+ * + * @return The path regexes of this comment + */ + @NotNull + String[] regex() default {}; + }