Repository navigation
Add entry point to search the test items - #322
Conversation
| private static Map<TestLevel, TestItemSearcher[]> initializeSearcherMap() { | ||
| final Map<TestLevel, TestItemSearcher[]> map = new HashMap<TestLevel, TestItemSearcher[]>(); | ||
| map.put(TestLevel.FOLDER, new TestItemSearcher[] {new PackageSearcher()}); | ||
| map.put(TestLevel.PACKAGE, new TestItemSearcher[] {new ClassSearcher() }); |
There was a problem hiding this comment.
An extra white space here. Do you have related checkstyle rules for it?
There was a problem hiding this comment.
Not yet, but will consider adding more check rules in the future.
| IProgressMonitor monitor) { | ||
| final List<TestItem> resultList = new ArrayList<>(); | ||
| final TestItemSearcher[] searchers = searcherMap.get(parentType); | ||
| if (searchers != null) { |
There was a problem hiding this comment.
Is it feasible to use something like searcherMap.getOrDefault(parentType, []) to avoid the null check? The code would be more neat, but may consume more memory (for the default empty list)
There was a problem hiding this comment.
Let's keep current implementation for now. Since generate a new empty array will also add more codes.
|
|
||
| @SuppressWarnings("restriction") | ||
| public class TestSearchUtils { | ||
| private static final Map<TestLevel, TestItemSearcher[]> searcherMap = initializeSearcherMap(); |
There was a problem hiding this comment.
It's more simplier to use static block static { ... } to initialize searcherMap.
| final IType parentClass = (IType) method.getParent(); | ||
| if (!JUnitUtility.isAccessibleClass(parentClass) || Flags.isAbstract(parentClass.getFlags()) || | ||
| parentClass.getFullyQualifiedName().equals(fullyQualifiedName)) { | ||
| !parentClass.getFullyQualifiedName().equals(fullyQualifiedName)) { |
There was a problem hiding this comment.
why need neg?
There was a problem hiding this comment.
If the parent class of the method is not equal to fullyQualifiedName for searching. Then this method is not the child of the class we are searching
| map.put(TestLevel.PACKAGE, new TestItemSearcher[] {new ClassSearcher()}); | ||
| map.put(TestLevel.CLASS, new TestItemSearcher[] {new NestedClassSearcher(), new MethodSearcher()}); | ||
| map.put(TestLevel.NESTED_CLASS, new TestItemSearcher[] {new NestedClassSearcher(), new MethodSearcher()}); | ||
| return map; |
There was a problem hiding this comment.
can you put the hierarchy relationship in ts side? Let the java code just play as an utility role.
| final SearchRequest request = gson.fromJson((String) arguments.get(0), SearchRequest.class); | ||
| final List<TestItem> resultList = searchTestItems(request.getLevel(), | ||
| request.getUri(), request.getFullName(), monitor); | ||
| if (request.isFetchAll()) { |
There was a problem hiding this comment.
fetchAll is not necessary for tree view refresh.
No description provided.