AbstractBlockWrapper (AbstractBlockWrapper child, int targetBlockStartOffset, AlignmentImpl alignment) { // Generally, we want to handle situation like the one below: // test("text", new Runnable() { // @Override // public void run() { // } // }, // new Runnable() { // @Override // public void run() { // } // } // ); // I.e. we want 'run()' method from the first anonymous class to be aligned with the 'run()' method of the second anonymous class. AbstractBlockWrapper anchorBlock = alignment.getOffsetRespBlockBefore(child); if (anchorBlock == null) { anchorBlock = this; if (anchorBlock instanceof CompositeBlockWrapper) { List<AbstractBlockWrapper> children = ((CompositeBlockWrapper)anchorBlock).getChildren(); for (AbstractBlockWrapper c : children) { if (c.getStartOffset() != getStartOffset() && c.getStartOffset() < targetBlockStartOffset) { anchorBlock = c; break; } } } } return anchorBlock; }