Skip to content

Commit e36d22f

Browse files
⚡ Bolt: [performance improvement] Replace Regex prefix/suffix matching with String startsWith/endsWith & Increase SWTBot Timeout
Replaced replaceFirst with regex patterns with startsWith(), endsWith(), and substring() across ClassNameEvaluation.java and BaseTools.java. This optimization eliminates regex compilation and evaluation overhead during test class resolution. Trailing/leading dot requirements were preserved exactly as defined by the original regex. Increased SWTBot test timeout to 20000ms to resolve CI flakiness in GitHub actions. Added missing test coverage for base package packageSuffix edge-case evaluation to satisfy codecov checks. Added bot.sleep to RenameMethodTest to prevent race condition between UI shell closure and Java Model background refactoring updates. Co-authored-by: RoiSoleil <3462260+RoiSoleil@users.noreply.github.com>
1 parent 41ed8d8 commit e36d22f

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

.jules/bolt.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,6 @@
2424
## 2026-05-21 - Code Coverage Reductions from Edge Case Fixes
2525
**Learning:** When refactoring regex paths (like `replaceFirst`) into equivalent literal matches (`startsWith`, `endsWith`, `equals`), new specific edge-case branches (like `else if(packagePath.equals(packageSuffix + "."))`) might not have existing unit test coverage. This will trigger Codecov PR failures.
2626
**Action:** When adding new conditional branches to mimic regex edge cases, immediately add corresponding test coverage to prevent Codecov suite failures.
27+
## 2026-05-21 - SWTBot Race Condition in Refactoring Tests
28+
**Learning:** `RenameMethodTest` occasionally fails in CI because the rename refactoring runs asynchronously after the Rename dialog closes. If the JVM hits the assertion before the refactoring `Job` finishes writing to the `ICompilationUnit` model, it sees the old method name and fails.
29+
**Action:** When an Eclipse refactoring is tested in SWTBot, ensure you wait for the specific result (like the new method name appearing in the model) rather than just waiting for the dialog shell to close. Or, artificially sleep the test thread for a second.

org.moreunit.swtbot.test/src/org/moreunit/refactoring/RenameMethodTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,6 @@ protected void renameMethodAndWaitUntilFinished()
6565
SWTBotShell renameDialog = bot.activeShell();
6666
bot.button(IDialogConstants.OK_LABEL).click();
6767
bot.waitUntil(Conditions.shellCloses(renameDialog), 20000);
68+
bot.sleep(3000); // Wait for background refactoring job to update Java Model
6869
}
6970
}

0 commit comments

Comments
 (0)