@@ -62,7 +62,12 @@ static ImmutableList<String> argsAsTexts(
6262 return ImmutableList .of ();
6363 }
6464 LineMap lineMap = state .getPath ().getCompilationUnit ().getLineMap ();
65- boolean inMultiline = inMultiline (position , args , lineMap );
65+ long baseLine = lineMap .getLineNumber (position );
66+ ImmutableList <Long > argLineNumbers =
67+ args .stream ()
68+ .map (arg -> lineMap .getLineNumber (getStartPosition (arg )))
69+ .collect (toImmutableList ());
70+ boolean isMultiline = argLineNumbers .stream ().anyMatch (line -> line > baseLine );
6671 ImmutableList .Builder <String > builder = ImmutableList .builder ();
6772 for (int i = 0 ; i < args .size (); i ++) {
6873 ExpressionTree arg = args .get (i );
@@ -71,10 +76,7 @@ static ImmutableList<String> argsAsTexts(
7176 return ImmutableList .of ();
7277 }
7378 int end =
74- inMultiline
75- && (i == args .size () - 1
76- || lineMap .getLineNumber (next )
77- < lineMap .getLineNumber (getStartPosition (args .get (i + 1 ))))
79+ isMultiline && (i == args .size () - 1 || argLineNumbers .get (i ) < argLineNumbers .get (i + 1 ))
7880 ? locateLineEnd (state , next )
7981 : next ;
8082 builder .add (state .getSourceCode ().subSequence (position , end ).toString ());
@@ -83,13 +85,6 @@ static ImmutableList<String> argsAsTexts(
8385 return builder .build ();
8486 }
8587
86- private static boolean inMultiline (
87- int startPosition , List <? extends ExpressionTree > args , LineMap lineMap ) {
88- long baseLine = lineMap .getLineNumber (startPosition );
89- return args .stream ()
90- .anyMatch (arg -> lineMap .getLineNumber (getStartPosition (arg )) > baseLine );
91- }
92-
9388 private static int locateLineEnd (VisitorState state , int pos ) {
9489 CharSequence source = state .getSourceCode ();
9590 int end = pos ;
0 commit comments