| @@ -15,11 +15,30 @@ |
|
|
| 15 |
15 |
*/ |
| 16 |
16 |
package org.intellij.lang.annotations; |
| 17 |
17 |
|
|
18 |
+/** |
|
19 |
+ * Specifies that the method parameter is a printf-style print format pattern, |
|
20 |
+ * as described in {@link java.util.Formatter}. |
|
21 |
+ * |
|
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 |
+ *
|
|
27 |
+ * void myprintf(@PrintFormat String format, Object... args) {...} |
|
28 |
+ * |
|
29 |
+ * |
|
30 |
+ * In this case, code editors might recognize that the following call is erroneous, |
|
31 |
+ * and issue a warning: |
|
32 |
+ *
|
|
33 |
+ * myprintf("%d\n", "hello"); // warning: a number expected instead of "hello" |
|
34 |
+ * |
|
35 |
+ * |
|
36 |
+ * @see Pattern |
|
37 |
+ */ |
| 18 |
38 |
@Pattern(PrintFormatPattern.PRINT_FORMAT) |
| 19 |
39 |
public @interface PrintFormat { |
| 20 |
40 |
} |
| 21 |
41 |
|
| 22 |
|
-// split up complex regex and workaround for IDEA-9173 |
| 23 |
42 |
class PrintFormatPattern { |
| 24 |
43 |
|
| 25 |
44 |
// %[argument_index$][flags][width][.precision]conversion |