mbien commented on code in PR #9737:
URL: https://github.com/apache/netbeans/pull/9737#discussion_r4415660555


##########
ide/projectapi/src/org/netbeans/api/project/ProjectManager.java:
##########
@@ -141,8 +139,35 @@ public Project findProject(@NonNull final FileObject 
projectDirectory) throws IO
         }
         return impl.findProject(projectDirectory);
     }
-        
-    
+
+    /**
+     * Finds the project for the given directory or, if there is none,
+     * asks the registered {@link DirectoryProjectProvider}s to create one.
+     * This first calls {@link #findProject} and returns its result when the
+     * directory already is a project; otherwise the first
+     * {@link DirectoryProjectProvider} able to promote the directory wins.
+     * @param projectDirectory the project top directory
+     * @return the project found or created, or null if the directory is not
+     *         a project and no provider could create one
+     * @throws IOException if a project could not be determined
+     * @throws IllegalArgumentException if the supplied file object is null or 
not a folder
+     * @since 1.107
+     */
+    @CheckForNull
+    public Project findOrCreateDirProject(@NonNull FileObject 
projectDirectory) throws IOException, IllegalArgumentException {
+        Project existing = findProject(projectDirectory);
+        if (existing != null) {
+            return existing;
+        }
+        for (DirectoryProjectProvider provider : 
Lookup.getDefault().lookupAll(DirectoryProjectProvider.class)) {
+            Project project = provider.createProject(projectDirectory);
+            if (project != null) {
+                return project;
+            }
+        }
+        return null;

Review Comment:
   assuming we keep this this way: we could probably move this whole section 
into a default method in `impl` which is a constant of type 
`ProjectManagerImplementaiton`  (yes its an interface despite its name)
   
   since there never can be enough abstraction layers between the client and 
the impl. This would be layer 3 I believe.



-- 
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