Repository navigation
Conversation
| checkShare = share != SharabilityQuery.Sharability.SHARABLE; | ||
| // don't need to check the sharability if the current folder is marked as recursively sharable | ||
|
|
||
| processFolderChildren(em, projects, h, counter, checkShare); |
There was a problem hiding this comment.
- this PR changes the behavior when a valid "root"
Projectis found- previously the scan continued inside of project structure
- now it stops and relies on open subprojects behavior of
OpenProjects.open
- such a behavior is way faster
- scanning NetBeans repository now takes just 4s
- while previously it took 16s
- the new behavior is more predictable
- some Git repositories (like NetBeans or Maven) contain a lot of "testing projects" hidden in test data
- the previous behavior found those projects ...
- ... which was greatly unexpected ...
- ... and also dangerous as those projects are often (intentionally) corrupted, misconfigured or otherwise broken
- in case of NetBeans there was more than three hundred of such modules
- lowering the number might even improve the Matthias warning a bit
- although tons of time is then going to be spend while parsing the projects anyway ...
- ... to be addressed in some future PR
- the speed gain and the matched expectations are the major UX improvements of this PR
| long then = System.currentTimeMillis(); | ||
| Set<Project> newOpen = g != null ? g.getProjects(h, 10, 100) : Collections.emptySet(); | ||
| long now = System.currentTimeMillis(); | ||
| LOG.log(Level.FINE, "Found {0} projects of group {1} in {2} ms", new Object[] { newOpen.size(), g, now - then }); |
There was a problem hiding this comment.
- I am using
netbeans -J-Dorg.netbeans.modules.project.ui.groups.Group.level=FINEto enabled this log message - and then
grep Group nbbuild/testuserdir/var/log/messages.logfor it - previously it would print
Found 1 206 projects of group DirectoryGroup[id=netbeans,|projects|=1203] in 16 779 ms - now it prints
Found 857 projects of group DirectoryGroup[id=netbeans,|projects|=857] in 3 665 ms
DirectoryGroup up
24f0959 to
75dd243
Compare
| assertEquals("Fresh empty group is opened", 0, backToNoGroup.length); | ||
| } | ||
|
|
||
| public void testDirectoryGroupFindsJustRootProjects() throws Exception { |
There was a problem hiding this comment.
Stopping the directory scan at root projects and letting OpenProjectList open the subprojects makes sense, and the speedup is impressive. I checked that OpenProjectList.open(..., openSubprojects=true) uses the same ProjectContainerProvider / SubprojectProvider logic as the removed visitSubprojects, so that part is equivalent. Some observations from tracing the code; I didn't build or run it.
Common root of the Group.java inline comment and the next point: Group.getProjects() used to include the subprojects and now returns only the roots, but Group.open and setMainProject still treat getProjects() as the full set of projects in the group.
setMainProject (not in the diff) keeps the main project only if getProjects().contains(mainProject). If the user picks a subproject as main project (e.g. a module of the master in a SubprojectsGroup, or a nested module in a DirectoryGroup), KEY_MAIN is now removed with a warning, so the main project is lost the next time the group is opened.
Also worth mentioning in the release notes: standalone projects nested inside another project but not declared as its subprojects (e.g. an examples/ folder not listed in the parent pom) are no longer found by a DirectoryGroup. I understand that's intended for test data, but it is a user-visible change.
The new test covers DirectoryGroup.findProjects; a test for switching between groups that share a root (see the Group.java comment) and for SubprojectsGroup would cover the rest.
| } | ||
| } | ||
| } | ||
| projects.add(p); |
There was a problem hiding this comment.
The old code had if (p != null) here. projectForPath returns null when the master project folder was deleted or moved, so null now ends up in the set. With assertions enabled that trips assert !projects.contains(null) in Group.getProjects; without them, the null is passed on to opl.open.
| //open the projects with current group | ||
| opl.open(toOpen.toArray(new Project[0]), false, false, h, null); | ||
| Project[] arrOpen = toOpen.toArray(new Project[0]); | ||
| opl.open(arrOpen, false, g != null && g.isSubprojects(), h, null); |
There was a problem hiding this comment.
Since newOpen now contains only the root projects, subprojects can get closed without being reopened. Example: group A is a SubprojectsGroup of X, so X and its subprojects are open. Switching to group B, a DirectoryGroup that also contains X, gives toClose = oldOpen - newOpen = the subprojects of X. X itself stays open, so it is not in toOpen, and openSubprojects never runs for it, so the subprojects stay closed. For the same reason the subprojects drop out of stayOpened, so their open documents are no longer persisted or restored per group.
| if (!dir.isFolder()) { | ||
| return null; | ||
| } | ||
| if (checkShare) { |
There was a problem hiding this comment.
findProject is now inside the if (checkShare) block, so with checkShare == false no project would ever be found. The only caller passes true, so it works today, but it looks unintended. Also, the old code skipped further sharability queries below a folder that was SHARABLE; that optimization is gone. On the plus side, the new code queries dir, while the old one queried the parent fo by mistake.
OpenProjectListProjectContainerProviderandSubprojectProviderup is also possible...