@@ -213,13 +213,11 @@ private void processElement(Element element, OptionsDeclarer optionsDeclarer) {
213
213
}
214
214
215
215
String briefHelp = helpLines .getFirst ();
216
- List <String > extraHelp ;
217
216
if (briefHelp .isEmpty ()) {
218
217
if (helpLines .size () > 1 ) {
219
218
processingEnv .getMessager ().printMessage (Kind .ERROR , "First line of multi-line help text cannot be empty" , element );
220
219
return ;
221
220
}
222
- extraHelp = List .of ();
223
221
} else {
224
222
if (helpLines .size () > 1 ) {
225
223
if (briefHelp .charAt (briefHelp .length () - 1 ) != '.' && !helpLines .get (1 ).isBlank ()) {
@@ -233,7 +231,6 @@ private void processElement(Element element, OptionsDeclarer optionsDeclarer) {
233
231
processingEnv .getMessager ().printMessage (Kind .ERROR , "Option help text must start with an upper case letter" , element );
234
232
return ;
235
233
}
236
- extraHelp = helpLines .subList (1 , helpLines .size ());
237
234
}
238
235
239
236
String stability = getAnnotationValue (annotation , "stability" , VariableElement .class ).getSimpleName ().toString ();
@@ -252,12 +249,16 @@ private void processElement(Element element, OptionsDeclarer optionsDeclarer) {
252
249
}
253
250
boolean deprecated = getAnnotationValue (annotation , "deprecated" , Boolean .class );
254
251
String deprecationMessage = getAnnotationValue (annotation , "deprecationMessage" , String .class );
255
- OptionInfo info = new OptionInfo (optionName , optionTypeName , briefHelp , extraHelp , optionType , declaringClass , fieldName , stability , deprecated , deprecationMessage );
252
+ OptionInfo info = new OptionInfo (optionName , optionTypeName , String . join ( " \n " , helpLines ) , optionType , declaringClass , fieldName , stability , deprecated , deprecationMessage );
256
253
optionsDeclarer .options .add (info );
257
254
}
258
255
259
256
private static String literal (String help ) {
260
- return "\" " + help .replace ("\\ " , "\\ \\ " ).replace ("\" " , "\\ \" " ) + "\" " ;
257
+ String quoted = help .replace ("\\ " , "\\ \\ " ).replace ("\" " , "\\ \" " );
258
+ if (help .indexOf ('\n' ) != -1 ) {
259
+ return "\" \" \" \n " + quoted + "\" \" \" " ;
260
+ }
261
+ return "\" " + quoted + "\" " ;
261
262
}
262
263
263
264
static void createOptionsDescriptorsFile (ProcessingEnvironment processingEnv , OptionsDeclarer optionsDeclarer ) {
@@ -310,7 +311,6 @@ static void createOptionsDescriptorsFile(ProcessingEnvironment processingEnv, Op
310
311
String optionType = option .optionType ;
311
312
String type = option .type ;
312
313
String help = option .help ;
313
- List <String > extraHelp = option .extraHelp ;
314
314
String fieldName = option .field ;
315
315
String stability = option .stability ;
316
316
boolean deprecated = option .deprecated ;
@@ -320,16 +320,9 @@ static void createOptionsDescriptorsFile(ProcessingEnvironment processingEnv, Op
320
320
out .printf (" /*optionType*/ %s.%s,\n " , getSimpleName (OPTION_TYPE_CLASS_NAME ), optionType );
321
321
out .printf (" /*optionValueType*/ %s.class,\n " , type );
322
322
out .printf (" /*help*/ %s,\n " , literal (help ));
323
- if (!extraHelp .isEmpty ()) {
324
- out .printf (" /*extraHelp*/ new String[] {\n " );
325
- for (String line : extraHelp ) {
326
- out .printf (" %s,\n " , literal (line ));
327
- }
328
- out .printf (" },\n " );
329
- }
330
323
out .printf (" /*container*/ getContainer(),\n " );
331
- out .printf (" /*fieldName*/ \" %s\" ,\n " , fieldName );
332
324
out .printf (" /*option*/ %s,\n " , optionField );
325
+ out .printf (" /*fieldName*/ \" %s\" ,\n " , fieldName );
333
326
out .printf (" /*stability*/ %s.%s,\n " , getSimpleName (OPTION_STABILITY_CLASS_NAME ), stability );
334
327
out .printf (" /*deprecated*/ %b,\n " , deprecated );
335
328
out .printf (" /*deprecationMessage*/ \" %s\" );\n " , deprecationMessage );
@@ -368,7 +361,7 @@ static void createOptionsDescriptorsFile(ProcessingEnvironment processingEnv, Op
368
361
/**
369
362
* The details of a single option, derived from an {@code @Option} annotated field.
370
363
*/
371
- record OptionInfo (String name , String optionType , String help , List < String > extraHelp , String type ,
364
+ record OptionInfo (String name , String optionType , String help , String type ,
372
365
String declaringClass , String field , String stability , boolean deprecated ,
373
366
String deprecationMessage ) implements Comparable <OptionInfo > {
374
367
0 commit comments