sdedic commented on a change in pull request #3169:
URL: https://github.com/apache/netbeans/pull/3169#discussion_r709856560
##########
File path:
ide/editor.codetemplates/src/org/netbeans/lib/editor/codetemplates/CodeTemplateCompletionProvider.java
##########
@@ -100,8 +101,9 @@ public boolean collectCompletions(Document doc, int offset,
Completion.Context c
description =
CodeTemplateApiPackageAccessor.get().getSingleLineText(ct);
}
String label = html2text(description.trim());
+ String sortText = String.format("%04d%s", 1650,
"fore".equals(ct.getAbbreviation()) ? label.substring(0, 3) : label);
Review comment:
Is this foreach > for ?
##########
File path:
ide/editor.codetemplates/src/org/netbeans/lib/editor/codetemplates/CodeTemplateCompletionProvider.java
##########
@@ -89,8 +89,9 @@ private static boolean isAbbrevDisabled(JTextComponent
component) {
public static class Collector implements CompletionCollector {
private static final String SELECTED_TEXT_VAR =
"${0:$TM_SELECTED_TEXT}";
- private static final Pattern SNIPPET_VAR_PATTERN =
Pattern.compile("\\$\\{\\s*([-\\w]++)([^}]*)?}");
- private static final Pattern SNIPPET_HINT_PATTERN =
Pattern.compile("([-\\w]++)(?:\\s*=\\s*(\\\"([^\\\"]*)\\\"|\\S*))?");
+ private static final Pattern SNIPPET_VAR_PATTERN =
Pattern.compile("\\$\\{\\s*([-\\w]++)((?:\\s*[-\\w]++(?:\\s*=\\s*(?:\\\"[^\\\"]*\\\"|[-\\w]++))?)*\\s*)?}");
Review comment:
I was trying to decipher ;)) the regexp, took me a while. Consider to
document some informal syntax - is it `"${" word [ word ["=" quoted-string |
word ]? ]* "}"` ?
The quoted-string syntax disallows backslashes - OK ?
##########
File path:
java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/SurroundWithHint.java
##########
@@ -127,14 +132,21 @@
if (sb.length() > 0) {
snippet = sb.append(snippet).toString();
}
- CodeAction codeAction =
createCodeAction(Bundle.DN_SurroundWith(label), CodeActionKind.RefactorRewrite,
COMMAND_INSERT_SNIPPET, Collections.singletonMap(SNIPPET, snippet));
+ int idx = label.indexOf(' ');
+ CodeAction codeAction =
createCodeAction(Bundle.DN_SurroundWith(idx < 0 ? label : label.substring(0,
idx)), CodeActionKind.RefactorRewrite, COMMAND_INSERT_SNIPPET,
Collections.singletonMap(SNIPPET, snippet));
if (!edits.isEmpty()) {
codeAction.setEdit(new
WorkspaceEdit(Collections.singletonMap(params.getTextDocument().getUri(),
edits)));
}
- codeActions.add(codeAction);
+ if (TO_SHOW.contains(codeTemplate.getAbbreviation())) {
+ codeActions.add(codeAction);
+ }
+ items.add(new QuickPickItem(label, null, text, false,
codeAction));
}
}
}
+ if (items.size() > codeActions.size()) {
+ codeActions.add(createCodeAction(Bundle.DN_SurroundWith(DOTS),
CodeActionKind.RefactorRewrite, COMMAND_SURROUND_WITH, items));
Review comment:
I'd rather create a separate message, or make DOTS localizable.
--
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