View | Details | Raw Unified | Return to bug 163984
Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java (+41 lines)
Lines 7697-7700 Link Here
7697
		"src/A.java int A.x(int) [param] EXACT_MATCH"
7697
		"src/A.java int A.x(int) [param] EXACT_MATCH"
7698
	);
7698
	);
7699
}
7699
}
7700
7701
/**
7702
 * @bug 163984: [search] no results from SearchEngine.searchAllTypeNames with types in scope
7703
 * @test Ensure that types are found with scope made of elements
7704
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=163984"
7705
 */
7706
public void testONLY_Bug163984() throws CoreException {
7707
	// Search all type names with TypeNameMatchRequestor
7708
	TypeNameMatchCollector collector = new TypeNameMatchCollector() {
7709
		public String toString(){
7710
			return toFullyQualifiedNamesString();
7711
		}
7712
	};
7713
	ICompilationUnit[] elements = getCompilationUnits("JavaSearchBugs", "src", "b163984");
7714
	IJavaSearchScope scope = SearchEngine.createJavaSearchScope(elements);
7715
	new SearchEngine().searchAllTypeNames(
7716
		null,
7717
		SearchPattern.R_EXACT_MATCH,
7718
		new char[] { '*' },
7719
		SearchPattern.R_PATTERN_MATCH,
7720
		IJavaSearchConstants.TYPE,
7721
		scope,
7722
		collector,
7723
		IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
7724
		null);
7725
	// Search all type names with TypeNameRequestor
7726
	TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor();
7727
	new SearchEngine().searchAllTypeNames(
7728
		null,
7729
		SearchPattern.R_EXACT_MATCH,
7730
		new char[] { '*' },
7731
		SearchPattern.R_PATTERN_MATCH,
7732
		IJavaSearchConstants.TYPE,
7733
		scope,
7734
		requestor,
7735
		IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
7736
		null);
7737
	// Should have same types with these 2 searches
7738
	assertEquals("We should get 3 types!", 3, collector.size());
7739
	assertEquals("Found types sounds not to be correct", requestor.toString(), collector.toString());
7740
}
7700
}
7741
}
(-)workspace/JavaSearchBugs/src/b163984/B.java (+4 lines)
Added Link Here
1
package b163984;
2
public class B {
3
	public static void main(String[] args) {}
4
}
(-)workspace/JavaSearchBugs/src/b163984/A.java (+4 lines)
Added Link Here
1
package b163984;
2
public class A {
3
	public static void main(String[] args) {}
4
}
(-)workspace/JavaSearchBugs/src/b163984/C.java (+4 lines)
Added Link Here
1
package b163984;
2
public class C {
3
	public static void main(String[] args) {}
4
}
(-)search/org/eclipse/jdt/internal/core/search/JavaSearchScope.java (-1 / +2 lines)
Lines 584-590 Link Here
584
			}
584
			}
585
			Object target = JavaModel.getTarget(ResourcesPlugin.getWorkspace().getRoot(), new Path(this.containerPaths[index]+'/'+this.relativePaths[index]), false);
585
			Object target = JavaModel.getTarget(ResourcesPlugin.getWorkspace().getRoot(), new Path(this.containerPaths[index]+'/'+this.relativePaths[index]), false);
586
			if (target instanceof IResource) {
586
			if (target instanceof IResource) {
587
				return project.getPackageFragmentRoot((IResource)target);
587
				IJavaElement element = JavaCore.create((IResource)target);
588
				return (IPackageFragmentRoot) element.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
588
			}
589
			}
589
		}
590
		}
590
	}
591
	}

Return to bug 163984