Community
Participate
Working Groups
AK (8/16/2001 1:27:28 PM) 1. i have 2 projects: junit and P that references junit 2. i want to rename TestCase in junit so i create a java search scope and add junit to it searching for references does not find anything in P because only junit and projects on its classpath are added to the scope this behavior is opposite to what i expected - projects referencing junit should be added, not projects that are referenced see 1GFCQDM: ITPJUI:WIN2000 - Review: check if Refactoring should use JavaSearchScope JBL (10/8/2001 5:40:37 PM) The fact that projects on junit's classpath are also added is a bug. No assumption should be done on this behavior of JavaSearchScope. Only jars and source folders that are on the project's classpath should be added. You should use a WorkspaceScope if you want to find all references to a class. AK (10/9/2001 11:19:14 AM) but this is precisely why we wanted to use some scope that would be limited to a project and all projects that reference it. WorkSpaceScope is too big. from DB: But AFAIK we have problem using the workbench scope. In some situations it renames to much. Or isn't this related to each other (e.g same package names in different project). The example is as follows: JUnit1 JUnit rename TestCase in JUnit also renames TestCase references in JUnit1. This is wrong. JBL (10/9/2001 11:31:12 AM)' I see... In this case, what about using a JavaSearchScope with the project and its referencing projects? IProject project = ...; IProject[] referencingProjects = project.getReferencingProjects(); int length = referencingProjects.length; IResource[] resources; if (length > 0) { resources = new IResource[length+1]; resources[0] = project; System.arraycopy(referencingProjects, 0, resources, 1, length); } else { resources = new IResource[] {project}; } IJavaSearchScope scope = SearchEngine.createJavaSearchScope(resources); AK (10/9/2001 3:57:00 PM) hmm, will not work: 1. project p1 2. project p2 referencing p1 3. package p in p1, classes A and B in it (B references A) 4. package p in p2, classes A and B in it (B references A) now, using the scope defined above, search for references to A (from p2) you find 2 matches, which is incorrect JBL (10/9/2001 4:35:26 PM) AK says they're both accurate He also suggests to add: SearchEngine.createJavaSearchScope(IJavaProject, boolean) -< flag includeReferencedProjects
Wondering if the workbench scope issue is not rather related to ignoring the fact that some matches are inacurrate. Last scenario just seems like a bug. If going for extra flags, this would only be helper methods (include prerequisites and/or include dependents).
Workspace scope issue is due to the fact that bindings don't know where they're coming from. So there is no way to distinguish between a junit.framework.TestCase coming from JUnit and junit.framework.TestCase coming from JUnit1. This is the same problem for last scenario. The only way to solve this is to do what Adam suggested: add a flag that indicates if referenced projects should be included. Added SearchEngine.createJavaSearchScope(IJavaElement[] elements, boolean includeReferencedProjects).
PRODUCT VERSION: 0.9