void () { int lineStart = myDocument.getLineStartOffset(myLine); int indentEnd = CharArrayUtil.shiftForward(myDocument.getCharsSequence(), lineStart, " \t"); RangeMarker indentMarker = myDocument.createRangeMarker(lineStart, indentEnd); CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(myProject); if (isSynchronousAdjustment(myDocument, myFile)) { updateIndent(indentMarker, codeStyleManager.getLineIndent(myFile, lineStart, FormattingMode.ADJUST_INDENT_ON_ENTER)); } else { ReadAction .nonBlocking(() -> codeStyleManager.getLineIndent(myFile, lineStart, FormattingMode.ADJUST_INDENT_ON_ENTER)) .withDocumentsCommitted(myProject) .finishOnUiThread(ModalityState.nonModal(), indentString -> updateIndent(indentMarker, indentString)) .submit(AppExecutorUtil.getAppExecutorService()); } }