Skip to content

Commit 6963421

Browse files
committed
PrintFormat documentation
1 parent 03116fd commit 6963421

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

common/src/main/java/org/intellij/lang/annotations/PrintFormat.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,30 @@
1515
*/
1616
package org.intellij.lang.annotations;
1717

18+
/**
19+
* Specifies that the method parameter is a printf-style print format pattern,
20+
* as described in {@link java.util.Formatter}.
21+
* <p>
22+
* Code editors that support {@link Pattern} annotation will check
23+
* the syntax of this value automatically. It could also be especially recognized to
24+
* check whether the subsequent var-arg arguments match the expected arguments
25+
* mentioned in the pattern. E. g., consider that the following method is annotated:
26+
* <pre><code>
27+
* void myprintf(&#64;PrintFormat String format, Object... args) {...}
28+
* </code></pre>
29+
* <p>
30+
* In this case, code editors might recognize that the following call is erroneous,
31+
* and issue a warning:
32+
* <pre><code>
33+
* myprintf("%d\n", "hello"); // warning: a number expected instead of "hello"
34+
* </code></pre>
35+
*
36+
* @see Pattern
37+
*/
1838
@Pattern(PrintFormatPattern.PRINT_FORMAT)
1939
public @interface PrintFormat {
2040
}
2141

22-
// split up complex regex and workaround for IDEA-9173
2342
class PrintFormatPattern {
2443

2544
// %[argument_index$][flags][width][.precision]conversion

0 commit comments

Comments
 (0)