eclipse.jdt.ls
eclipse.jdt.ls copied to clipboard
Add more postfix completions
Compare jdt.ls postfix proposals:

to IDEA's:

I'd prioritize the for* and sou* proposals
The list of postfix (from IDEA):
Status | key in JDT.LS | key in IDEA | template content |
---|---|---|---|
! | !expr | ||
arg | functionCall(expr) | ||
assert | assert expr | ||
✅ | cast | cast | ((SomeType) expr) |
castvar | T name = (T)expr | ||
✅ | else | else | if (!expr) |
field | myField = expr | ||
✅ | for | for, iter | for (T item : expr) |
✅ | fori | fori | for (int i = 0; i < expr.length; i++) |
✅ | format | format | String.format(expr) |
✅ | forr | forr | for (int i = expr.length-1; i >= 0; i--) |
✅ | if | if | if (expr) |
instanceof, inst | expr instanceof Type ? ((Type) expr). : null") | ||
lambda | () -> expr | ||
new | new T() | ||
✅ | not | not | !expr |
✅ | nnull | notnull, nn | if (expr != null) |
✅ | null | null | if (expr == null) |
opt | Optional.ofNullable(expr) | ||
✅ | par | par | (expr) |
reqnonnull | Objects.requireNonNull(expr) | ||
return | return expr | ||
✅ | syserr | serr | System.err.println(expr) |
✅ | sysouf | souf | System.out.printf("", expr) |
✅ | sysout | sout | System.out.println(expr) |
✅ | sysoutv | soutv | System.out.println(expr) |
stream | Arrays.stream(expr) | ||
switch | switch(expr) | ||
synchronized | synchronized (expr) | ||
✅ | throw | throw | throw expr |
try | try { exp } catch(Exception e) | ||
twr | try(Type f = new Type()) catch (Exception e) | ||
val, varl | lombok.var name = expr | ||
✅ | var | var | T name = expr |
✅ | while | while | while (expr) {} |
Clients may need to consolidate their snippets (if such support exists) the more we start offering from the server-side. For example, vscode-java provides its own switch
snippet (no context), but if we did add our own switch
server-side (for postfix), there would be an annoying duplicate. Clients would need to enable/disable certain snippets based on whether postfix is enabled.
We'll definitely need to review how we contribute snippets as there's advantages/disadvantages to server-side & recommending client-side.
Update: Similar discussion at https://github.com/redhat-developer/vscode-java/issues/2867 (regarding snippet consolidation) .
I can not use postfix in lambda.
for example:
there is no .var postfix for cmp
@baober90 We do have some issues about the lambda support. Root cause is that the AST parser could not properly parse the AST when it comes to lambda expression.