Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions patches/7893-draft.diff
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/LspTemplateUI.java b/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/LspTemplateUI.java
index 891bfa328d..ed80b903a5 100644
index 891bfa328d..91172fda4b 100644
--- a/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/LspTemplateUI.java
+++ b/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/LspTemplateUI.java
@@ -27,6 +27,7 @@ import java.net.MalformedURLException;
Expand Down Expand Up @@ -103,7 +103,7 @@ index 891bfa328d..ed80b903a5 100644
});
}

@@ -229,9 +253,21 @@ final class LspTemplateUI {
@@ -229,9 +253,23 @@ final class LspTemplateUI {
FileObject template = desc.getTemplate();
Object handler = template.getAttribute(FileBuilder.ATTR_TEMPLATE_HANDLER);
if (handler == null) {
Expand All @@ -114,8 +114,10 @@ index 891bfa328d..ed80b903a5 100644
+
+ @Override
+ public CompletionStage<String> apply(String name) {
+ if (!SourceVersion.isName(name)) {
+ client.showMessage(new MessageParams(MessageType.Error, Bundle.ERR_InvalidObjectName(name)));
+ if (!name.equals("package-info") && !name.equals("module-info")
+ && (SourceVersion.isKeyword(name) || !SourceVersion.isIdentifier(name)))
+ {
+ client.showMessage(new MessageParams(MessageType.Error,Bundle.ERR_InvalidObjectName(name)));
+ return client.showInputBox(new ShowInputBoxParams(Bundle.CTL_TemplateUI_SelectName(), desc.getProposedName())).thenCompose(this);
+ }
+ return CompletableFuture.completedFuture(name);
Expand All @@ -128,7 +130,7 @@ index 891bfa328d..ed80b903a5 100644
}
return CompletableFuture.completedFuture(builder);
}
@@ -242,7 +278,7 @@ final class LspTemplateUI {
@@ -242,7 +280,7 @@ final class LspTemplateUI {
suggestion = Utilities.toFile(new URI(folders.get(0).getUri())).getParent();
} catch (URISyntaxException ex) {
}
Expand Down