Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SearchEngine searchDeclarationsOfSentMessages()/searchDeclarationsOfAccessedFields() does not work for anonymous or local classes #3308

Open
jjohnstn opened this issue Nov 14, 2024 · 0 comments · May be fixed by #3314
Assignees
Labels
bug Something isn't working

Comments

@jjohnstn
Copy link
Contributor

In the following example:

public class A {
    public class BaseTargetClass {}

    public class OriginalClass {
        public int data = 60;
        public void memberMethod() {}

        public class NestedOriginalClass extends BaseTargetClass {
            void setup() {
                new BaseTargetClass() {
                	int j = 1;
                    void methodToBePulledUp() {
                    	j = 2;
                        methodHelper();
                    }

                    void methodHelper() {
                        System.out.println("Helper Method in Anonymous Class: " + data);
                    }
                };
            }
        }
    }
}

A search for fields or methods of methodToBePulledUp() will result in an empty result. This is because the logic in MethodLocator and FieldLocator classes cannot find the type by name.

This logic is required by the JDT UI refactoring code to find accessed fields and methods of members that are being moved.

@jjohnstn jjohnstn self-assigned this Nov 14, 2024
@jjohnstn jjohnstn added the bug Something isn't working label Nov 14, 2024
@jjohnstn jjohnstn changed the title SearchEngine.searchDeclarationsOfSentMessages() does not work for anonymous or local classes SearchEngine searchDeclarationsOfSentMessages()/searchDeclarationsOfAccessedFields() does not work for anonymous or local classes Nov 14, 2024
jjohnstn added a commit to jjohnstn/eclipse.jdt.core-1 that referenced this issue Nov 14, 2024
- Fix FieldLocator.reportDeclaration() and
  MethodLocator.reportDeclaration() to find the anonymous or local
  type for the declaration rather than to return
- add new tests to JavaSearchBugsTests
- fixes eclipse-jdt#3308
@jjohnstn jjohnstn moved this to Pending review in Java Tooling Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant