[WIP] Add JFace-free test cases for LambdaASTVisitor#594
Merged
carstenartur merged 2 commits intoFeb 4, 2026
Merged
Conversation
…ests Co-authored-by: carstenartur <3164220+carstenartur@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implementation Plan: ClassInstanceCreation Visitor Testing
Goal
Create JFace-free test cases to verify that
LambdaASTVisitorcorrectly finds ALLClassInstanceCreationnodes in various scenarios.Checklist
Create mock classes in
sandbox_common_testMockProgressMonitor.javainterfaceMockSubProgressMonitor.javaclassMockSubMonitor.javaclassCreate comprehensive test file
ClassInstanceCreationVisitorTest.javaRun tests to verify behavior
LambdaASTVisitor.javaor related classesUpdate
sandbox_common/TODO.mdwith findingsKey Insight
The scope function in
ASTProcessorcontrols which subtree is traversed. When a scope function navigates to a specific node (e.g., Block), only ClassInstanceCreation nodes within that subtree will be found. This is important for understanding the JFace plugin behavior.Files Created
sandbox_common_test/src/org/sandbox/jdt/ui/tests/quickfix/mock/MockProgressMonitor.javasandbox_common_test/src/org/sandbox/jdt/ui/tests/quickfix/mock/MockSubProgressMonitor.javasandbox_common_test/src/org/sandbox/jdt/ui/tests/quickfix/mock/MockSubMonitor.javasandbox_common_test/src/org/sandbox/jdt/ui/tests/quickfix/ClassInstanceCreationVisitorTest.java(18+ KB, comprehensive tests)Original prompt
Problem Statement
PR #593 identified that the
LambdaASTVisitor.visit(ClassInstanceCreation)method is only finding 3 out of 14+SubProgressMonitorinstances. Before we can fix the JFace cleanup plugin, we need to verify that the coreLambdaASTVisitorimplementation works correctly.Current Situation
Root Cause from PR #593
Task
Create JFace-free test cases in
sandbox_common_testthat:Create mock classes that mimic the
SubProgressMonitor/SubMonitorpattern without JFace dependenciesMockProgressMonitorinterfaceMockSubProgressMonitorclass (old pattern)MockSubMonitorclass (new pattern with staticconvert()method)Write test cases in a new test file
sandbox_common_test/src/org/sandbox/jdt/ui/tests/quickfix/ClassInstanceCreationVisitorTest.javathat:LambdaASTVisitorcorrectly finds ALLClassInstanceCreationnodesClassInstanceCreationnodes in the same methodClassInstanceCreationin nested blocks (if, while, for loops)ClassInstanceCreationinside lambdasClassInstanceCreationin anonymous classesClassInstanceCreationwithout any preceding method calls (likebeginTask())Add tests for the pattern similar to JFace plugin:
ClassInstanceCreationfor a specific type nameMethodInvocationnodes in the same scopeASTProcessorchained visitor pattern used inJFacePlugin.javaIf any tests fail, investigate and fix the issue in:
sandbox_common/src/org/sandbox/jdt/internal/common/LambdaASTVisitor.javasandbox_common/src/org/sandbox/jdt/internal/common/ASTProcessor.javasandbox_common/src/org/sandbox/jdt/internal/common/HelperVisitor.javaTest Code Pattern Example
The test should verify that ALL THREE
MockSubProgressMonitorinstances are found by the visitor, not just some of them.Files to Create/Modify
sandbox_common_test/src/org/sandbox/jdt/ui/tests/quickfix/mock/MockProgressMonitor.javasandbox_common_test/src/org/sandbox/jdt/ui/tests/quickfix/mock/MockSubProgressMonitor.javasandbox_common_test/src/org/sandbox/jdt/ui/tests/quickfix/mock/MockSubMonitor.javasandbox_common_test/src/org/sandbox/jdt/ui/tests/quickfix/ClassInstanceCreationVisitorTest.javasandbox_common/src/org/sandbox/jdt/internal/common/LambdaASTVisitor.javasandbox_common/src/org/sandbox/jdt/internal/common/ASTProcessor.javasandbox_common/TODO.md- add notes about findingsAcceptance Criteria
ASTParserto parse code with mock classesLambdaASTVisitorfinds ALLClassInstanceCreationnodesLambdaASTVisitor, they are fixedTODO.mdupdated with findingsReference
This pull request was created from Copilot chat.
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.