From 068faeba5e77a040c389ac8b3f8d923f27ded437 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Dinis=20Ferreira?= Date: Thu, 2 Apr 2026 18:43:38 +0200 Subject: [PATCH] fix: replace global needRebuild() with project-scoped rebuild APIs BuildContext.needRebuild() called IncrementalProjectBuilder.needRebuild() which sets a global rebuildRequested flag on Eclipse's BuildManager, causing ALL projects in the build cycle to be rebuilt -- not just the current project. This was redundant because the DDK's RebuildingXtextBuilder already handles generated-source reprocessing via an internal rebuild loop (up to 2 extra iterations in doBuild()). The global call was a leftover from a 2014 workaround (Eclipse Bug #452399, Comment #8) that was superseded by the internal loop approach (Comment #10) but never removed when the DDK was open-sourced in 2016. It caused cascading builder re-invocations across the workspace dependency graph, resulting in unrelated projects being fully rebuilt when editing files in completely unrelated projects. Changes: - Remove builder.needRebuild() from the no-arg needRebuild(), keeping only the internal rebuildRequired flag - Override needRebuild(IProject) using the modern Eclipse 3.17+ APIs (triggerRequestProjectRebuild / triggerRequestProjectsRebuild) instead of relying on the IBuildContext default method that falls through to the deprecated global needRebuild(). This matches the upstream Xtext 2.27+ pattern (PR eclipse/xtext#1821, Eclipse Bug 579082). The DDK now has two complementary rebuild mechanisms: 1. Internal loop: immediate reprocessing within the same build() invocation (up to 2 extra iterations) 2. Project-scoped Eclipse API: safety net if the loop is exhausted, without cascading to unrelated projects Co-Authored-By: Claude Opus 4.6 (1M context) --- .../avaloq/tools/ddk/xtext/builder/BuildContext.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/com.avaloq.tools.ddk.xtext.builder/src/com/avaloq/tools/ddk/xtext/builder/BuildContext.java b/com.avaloq.tools.ddk.xtext.builder/src/com/avaloq/tools/ddk/xtext/builder/BuildContext.java index 5dc840baf7..f39bd0bb50 100644 --- a/com.avaloq.tools.ddk.xtext.builder/src/com/avaloq/tools/ddk/xtext/builder/BuildContext.java +++ b/com.avaloq.tools.ddk.xtext.builder/src/com/avaloq/tools/ddk/xtext/builder/BuildContext.java @@ -117,8 +117,17 @@ public ResourceSet getResourceSet() { @Override public void needRebuild() { rebuildRequired = true; + } + + @Override + public void needRebuild(final IProject project) { + rebuildRequired = true; if (builder != null) { - builder.needRebuild(); + if (getBuiltProject().equals(project)) { + builder.triggerRequestProjectRebuild(); + } else { + builder.triggerRequestProjectsRebuild(project); + } } }