dukehoff commented on code in PR #9650:
URL: https://github.com/apache/netbeans/pull/9650#discussion_r4155728220


##########
ide/projectapi.nb/src/org/netbeans/modules/projectapi/nb/NbProjectManager.java:
##########
@@ -212,6 +212,17 @@ public Mutex getMutex(
      */
     @Override
     public Project findProject(final FileObject projectDirectory) throws 
IOException, IllegalArgumentException {
+        return findProjectImpl(projectDirectory, false);

Review Comment:
   Once a fallback exists, `findProject()` returns it, and 
`SimpleFileOwnerQueryImplementation` builds file ownership on `findProject()`. 
So the fallback becomes the owner of every file under it that has no nearer 
project. This test fails on the branch at the first `getOwner` assertion:
   
   ```java
   public void testFallbackProjectBecomesFileOwner() throws Exception {
       FileObject script = justADir.createData("Hello.java");
       FileObject nested = 
justADir.createFolder("sub").createData("Other.java");
       assertNull("Loose file has no owner before", 
FileOwnerQuery.getOwner(script));
       assertFalse("justADir is not a project", pm.isProject(justADir));
   
       Project fallback = pm.findProjectOrFallback(justADir);
   
       assertFalse("isProject still says justADir is not a project", 
pm.isProject(justADir));
       assertSame("but findProject returns the fallback", fallback, 
pm.findProject(justADir));
       assertNull("Loose file should stay unowned", 
FileOwnerQuery.getOwner(script));
       assertNull("Nested loose file should stay unowned", 
FileOwnerQuery.getOwner(nested));
   }
   ```
   
   The Java single-file support needs `FileOwnerQuery.getOwner(file) == null` 
(`SingleSourceFileUtil.isSupportedFile`, and `MultiSourceRootProvider` for the 
classpath). So loose `.java` files in an opened folder would lose Run/Debug and 
their editor classpath, exactly in the "open any folder" scenario. It also 
leaves `isProject(dir) == false` while `findProject(dir) != null`.
   
   Would it work to keep fallbacks in their own cache, so 
`findProject()`/`isProject()` keep their current contract? If the ownership 
behavior is wanted, it should at least be documented on `findProject`. Feel 
free to take the test.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to