eclipse.jdt.ls icon indicating copy to clipboard operation
eclipse.jdt.ls copied to clipboard

Add more postfix completions

Open fbricon opened this issue 2 years ago • 4 comments

Compare jdt.ls postfix proposals:

Screenshot 2022-10-24 at 09 44 23

to IDEA's:

Screenshot 2022-10-24 at 09 41 28

I'd prioritize the for* and sou* proposals

fbricon avatar Oct 24 '22 07:10 fbricon

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) {}

jdneo avatar Oct 26 '22 02:10 jdneo

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

rgrunber avatar Jun 08 '23 15:06 rgrunber

I can not use postfix in lambda. for example: image there is no .var postfix for cmp

baober90 avatar Sep 14 '23 17:09 baober90

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

jdneo avatar Sep 18 '23 02:09 jdneo