@@ -269,8 +269,14 @@ private Map<TreePath, String> computeCustomTextBlocksIndent(List<TreePath> textB
269269 if (parentToIndent .containsKey (parent )) {
270270 continue ;
271271 }
272+ // Tree finalParent = (((JCMethodInvocation) parent).getMethodSelect() instanceof JCFieldAccess ?
273+ // ((JCMethodInvocation) parent).getMethodSelect() : parent;
272274 List <Tree > allArguments = new ArrayList <>(((JCMethodInvocation ) parent ).getArguments ());
273- parentToIndent .put (parent , computePrefixIndentation (parent , allArguments ));
275+
276+ parentToIndent .put (
277+ parent ,
278+ computePrefixIndentation (
279+ ((JCMethodInvocation ) parent ).getMethodSelect (), allArguments , false ));
274280 } else if (parent .getKind () == Kind .PLUS ) {
275281 while (parentPath .getParentPath ().getLeaf ().getKind () == Kind .PLUS ) {
276282 parentPath = parentPath .getParentPath ();
@@ -280,19 +286,24 @@ private Map<TreePath, String> computeCustomTextBlocksIndent(List<TreePath> textB
280286 if (parentToIndent .containsKey (parent )) {
281287 continue ;
282288 }
283- parentToIndent .put (parent , computePrefixIndentation (parent , flattenExpressionTree (parent )));
289+ parentToIndent .put (parent , computePrefixIndentation (parent , flattenExpressionTree (parent ), true ));
284290 }
285291 }
286292
287293 return textBlockToParent .entrySet ().stream ()
288294 .collect (Collectors .toMap (Map .Entry ::getKey , e -> parentToIndent .get (e .getValue ())));
289295 }
290296
291- private String computePrefixIndentation (Tree parentPath , List <Tree > childExpressions ) {
297+ private String computePrefixIndentation (
298+ Tree parentPath , List <Tree > childExpressions , boolean shouldUseStartLineParent ) {
292299 int startParentPosition = getStartPosition (parentPath );
293300 int startParentLine = lineMap .getLineNumber (startParentPosition );
294301 int endParentPosition = getEndPosition (unit , parentPath );
295- int lineParentStartPosition = lineMap .getStartPosition (startParentLine );
302+ int endParentLine = lineMap .getLineNumber (endParentPosition );
303+ // the only relevant lineParentEndPosition should be the one that doesn't end with a """
304+ // because that one is not valid
305+ int lineParentStartPosition =
306+ lineMap .getStartPosition (shouldUseStartLineParent ? startParentLine : endParentLine );
296307 int startParentColumn = CharMatcher .whitespace ()
297308 .negate ()
298309 .indexIn (input .substring (lineParentStartPosition , endParentPosition ));
@@ -305,8 +316,9 @@ private String computePrefixIndentation(Tree parentPath, List<Tree> childExpress
305316 int endPos = getEndPosition (unit , expression );
306317 int endLine = lineMap .getLineNumber (endPos );
307318 allRanges .add (Range .closed (startLine , endLine ));
319+ int parentLine = shouldUseStartLineParent ? startParentLine : endParentLine ;
308320 // ignore indentation if the current argument is on the same line as the parent
309- if (startLine == startParentLine ) {
321+ if (startLine == parentLine ) {
310322 continue ;
311323 }
312324 // if this is a line that ends with a textBlock (ending with a textBlock if the line starts with
0 commit comments