@@ -56,36 +56,37 @@ static String normalizeForComparison(String code) {
5656 }
5757
5858 static ImmutableList <String > argsAsTexts (
59- ExpressionTree invocationStart , List <? extends ExpressionTree > args , VisitorState state ) {
60- int position = state .getEndPosition (invocationStart );
59+ ExpressionTree methodName , List <? extends ExpressionTree > args , VisitorState state ) {
60+ int position = state .getEndPosition (methodName );
6161 if (position < 0 ) {
6262 return ImmutableList .of ();
6363 }
6464 LineMap lineMap = state .getPath ().getCompilationUnit ().getLineMap ();
65+ if (lineMap == null ) {
66+ return ImmutableList .of ();
67+ }
6568 long startingLine = lineMap .getLineNumber (position );
66- ImmutableList <Long > argLineNumbers =
69+ ImmutableList <Long > argLines =
6770 args .stream ()
6871 .map (arg -> lineMap .getLineNumber (getStartPosition (arg )))
6972 .collect (toImmutableList ());
70- boolean isMultiline = argLineNumbers .stream ().anyMatch (line -> line > startingLine );
73+ boolean isMultiline = argLines .stream ().anyMatch (line -> line > startingLine );
7174 ImmutableList .Builder <String > builder = ImmutableList .builder ();
7275 for (int i = 0 ; i < args .size (); i ++) {
7376 ExpressionTree arg = args .get (i );
7477 int next = state .getEndPosition (arg );
7578 if (next < 0 ) {
7679 return ImmutableList .of ();
7780 }
78- boolean lastArgOfLine =
79- i == args .size () - 1 || argLineNumbers .get (i ) < argLineNumbers .get (i + 1 );
80- int end = isMultiline && lastArgOfLine ? locateLineEnd (state , next ) : next ;
81+ boolean lastArgOfLine = i == args .size () - 1 || argLines .get (i ) < argLines .get (i + 1 );
82+ int end = isMultiline && lastArgOfLine ? locateLineEnd (state .getSourceCode (), next ) : next ;
8183 builder .add (state .getSourceCode ().subSequence (position , end ).toString ());
8284 position = end ;
8385 }
8486 return builder .build ();
8587 }
8688
87- private static int locateLineEnd (VisitorState state , int pos ) {
88- CharSequence source = state .getSourceCode ();
89+ private static int locateLineEnd (CharSequence source , int pos ) {
8990 int end = pos ;
9091 while (end < source .length () && source .charAt (end ) != '\n' ) {
9192 end ++;
0 commit comments