From 6963421745aebef4954feab4ba2fb60ddb0e7562 Mon Sep 17 00:00:00 2001 From: Tagir Valeev Date: Fri, 3 Dec 2021 10:16:58 +0700 Subject: [PATCH] PrintFormat documentation --- .../lang/annotations/PrintFormat.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/org/intellij/lang/annotations/PrintFormat.java b/common/src/main/java/org/intellij/lang/annotations/PrintFormat.java index fc810b0..d69f1f7 100644 --- a/common/src/main/java/org/intellij/lang/annotations/PrintFormat.java +++ b/common/src/main/java/org/intellij/lang/annotations/PrintFormat.java @@ -15,11 +15,30 @@ */ package org.intellij.lang.annotations; +/** + * Specifies that the method parameter is a printf-style print format pattern, + * as described in {@link java.util.Formatter}. + *

+ * Code editors that support {@link Pattern} annotation will check + * the syntax of this value automatically. It could also be especially recognized to + * check whether the subsequent var-arg arguments match the expected arguments + * mentioned in the pattern. E. g., consider that the following method is annotated: + *


+ * void myprintf(@PrintFormat String format, Object... args) {...}
+ * 
+ *

+ * In this case, code editors might recognize that the following call is erroneous, + * and issue a warning: + *


+ * myprintf("%d\n", "hello"); // warning: a number expected instead of "hello"
+ * 
+ * + * @see Pattern + */ @Pattern(PrintFormatPattern.PRINT_FORMAT) public @interface PrintFormat { } -// split up complex regex and workaround for IDEA-9173 class PrintFormatPattern { // %[argument_index$][flags][width][.precision]conversion