redhat-developer / vscode-java

Java Language Support for Visual Studio Code
Eclipse Public License 2.0
2.08k stars 442 forks source link

No quick actions available when targetting class name in ctor invocation #2531

Open Nightenom opened 2 years ago

Nightenom commented 2 years ago

Given a short (static/nonstatic, probably visibility independent) method with just return statement and ctor call there are no quick actions available. Log is empty - no stacktraces nor errors. High reproducibility (will try to provide 100% repro case if this is not enough) image

Current Result

Only lower method has quick actions.

Expected Result

Both methods have quick actions.

Environment
Nightenom commented 2 years ago

Also another thing which seems heavily related, might be even the same bug.

Working states: Targeting method: image Targeting whole statement using text selection: image Targeting the "new" keyword: image

Broken state: Targeting the the class name: image

jdneo commented 2 years ago

@CsCherrYY You can test it with File f = new File(new String());, and try to peek code actions when the cursor is in new or in String

Nightenom commented 5 months ago

This is still an issue after 2 yrs

rgrunber commented 2 months ago

I think the issue is with the ExtractTempRefactoring API in JDT. It relies on the selection being an expression and it seems to fail to retrieve it under certain circumstances : https://github.com/eclipse-jdt/eclipse.jdt.ui/blob/b83ffe1bbcad393d4e35874d1ecc6af59f90874f/org.eclipse.jdt.core.manipulation/refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ExtractTempRefactoring.java#L1058-L1063 .

FATALERROR: An expression must be selected to activate this refactoring.
Context: <Unspecified context>
code: none
Data: null