sdedic commented on code in PR #7177:
URL: https://github.com/apache/netbeans/pull/7177#discussion_r1532133482
##########
java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/TestClassGenerator.java:
##########
@@ -264,18 +267,30 @@ private static String getTestingFrameworkSuffix(String
selectedFramework) {
return selectedFramework.equals(testngFramework) ? "NG" : "";
}
- private static FileObject getTargetFolder(Object selectedLocation) {
+ private static String getTargetFolderUri(Object selectedLocation) throws
URISyntaxException {
if (selectedLocation == null) {
return null;
}
if (selectedLocation instanceof SourceGroup) {
- return ((SourceGroup) selectedLocation).getRootFolder();
+ return Utils.toUri(((SourceGroup)
selectedLocation).getRootFolder());
}
if (selectedLocation instanceof URL) {
- return URLMapper.findFileObject((URL) selectedLocation);
+ return URITranslator.getDefault().uriToLSP(((URL)
selectedLocation).toURI().toString());
}
assert selectedLocation instanceof FileObject;
- return (FileObject) selectedLocation;
+ return Utils.toUri((FileObject) selectedLocation);
+ }
+
+ private static FileObject getTargetFolder(String uri) throws
MalformedURLException {
+ FileObject targetFolder = Utils.fromUri(uri);
+ if (targetFolder == null) {
+ File file = BaseUtilities.toFile(URI.create(uri));
+ if (file != null && !file.exists()) {
+ file.mkdirs();
+ }
+ targetFolder = Utils.fromUri(uri);
+ }
+ return targetFolder;
Review Comment:
Though unlikely, `uri` may resolve to an (existing) regular file; perhaps
`null` can be returned to trigger IllegalArgumentException in caller
--
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