void () { if (myImportBlock.isEmpty()) { return; } analyzeImports(myImportBlock); for (PyImportStatementBase importStatement : myImportBlock) { final AddImportHelper.ImportPriorityChoice choice = AddImportHelper.getImportPriorityWithReason(importStatement); LOG.debug(String.format("Import group for '%s' is %s: %s", importStatement.getText(), choice.getPriority(), choice.getDescription())); myGroups.get(choice.getPriority()).add(importStatement); } boolean hasTransformedImports = false; for (ImportPriority priority : ImportPriority.values()) { final List<PyImportStatementBase> original = myGroups.get(priority); final List<PyImportStatementBase> transformed = transformImportsInGroup(original); hasTransformedImports |= !original.equals(transformed); myGroups.put(priority, transformed); } if (hasTransformedImports || needBlankLinesBetweenGroups() || groupsNotSorted()) { applyResults(); } }