diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e48fd3f..8da3c355 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -92,6 +92,7 @@ - Отключение проверок для заимствованных объектов в расширении #1076 - Проверка: form-self-reference не находит ошибку #1086 - Ложное срабатывание проверки: module-structure-event-regions для обработчиков событий расположенных в общем модуле #1102 +- Автосортировка падает при переводе кода #1106 ## 0.2.0 diff --git a/bundles/com.e1c.v8codestyle.autosort/src/com/e1c/v8codestyle/internal/autosort/SortJob.java b/bundles/com.e1c.v8codestyle.autosort/src/com/e1c/v8codestyle/internal/autosort/SortJob.java index 000882bf..bc1f8c4f 100644 --- a/bundles/com.e1c.v8codestyle.autosort/src/com/e1c/v8codestyle/internal/autosort/SortJob.java +++ b/bundles/com.e1c.v8codestyle.autosort/src/com/e1c/v8codestyle/internal/autosort/SortJob.java @@ -77,30 +77,13 @@ public class SortJob return Status.CANCEL_STATUS; } - Object handler = workspaceOrchestrator.beginBackgroundOperation("Sort-MD-objects", //$NON-NLS-1$ - Arrays.asList(dtProject), ProjectPipelineJob.BUILD); - - try + while (!queue.isEmpty() && !monitor.isCanceled()) { - while (!queue.isEmpty() && !monitor.isCanceled()) - { - execute(monitor); - } - if (monitor.isCanceled()) - { - queue.clear(); - } + execute(monitor); } - finally + if (monitor.isCanceled()) { - if (monitor.isCanceled()) - { - workspaceOrchestrator.cancelOperation(handler); - } - else - { - workspaceOrchestrator.endOperation(handler); - } + queue.clear(); } if (monitor.isCanceled()) @@ -122,16 +105,32 @@ public class SortJob private void execute(IProgressMonitor monitor) { - List items = new ArrayList<>(); - SortItem item = null; - while ((item = queue.poll()) != null && !monitor.isCanceled()) + Object handler = workspaceOrchestrator.beginHalfExclusiveOperation("Sort-MD-objects", //$NON-NLS-1$ + Arrays.asList(dtProject), ProjectPipelineJob.BUILD); + try { - items.add(item); - } + List items = new ArrayList<>(); + SortItem item = null; + while ((item = queue.poll()) != null && !monitor.isCanceled()) + { + items.add(item); + } - if (!monitor.isCanceled() && !items.isEmpty()) + if (!monitor.isCanceled() && !items.isEmpty()) + { + sortService.sortObject(dtProject, items, monitor); + } + } + finally { - sortService.sortObject(dtProject, items, monitor); + if (monitor.isCanceled()) + { + workspaceOrchestrator.cancelOperation(handler); + } + else + { + workspaceOrchestrator.endOperation(handler); + } } }