Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Critical] No completions on field initialiser with @Default and @Builder Lombok annotations #2669

Closed
gayanper opened this issue May 26, 2023 · 11 comments · Fixed by #2673
Closed

Comments

@gayanper
Copy link
Contributor

Take the following example

@Data
@Builder
public class Request {
     @Default
      private Integer offset = ;
}

Now if you try to get completions behind private Integer offset = completions doesn't work. But if you remove @Default or @Builder the completions work.

@fbricon
Copy link
Contributor

fbricon commented May 26, 2023

does it work in Eclipse IDE?

@fbricon
Copy link
Contributor

fbricon commented May 26, 2023

also not a "critical" issue, as it doesn't break user code (e.g. compilation failure)

@snjeza
Copy link
Contributor

snjeza commented May 26, 2023

does it work in Eclipse IDE?

Yes, it does.

@gayanper
Copy link
Contributor Author

also not a "critical" issue, as it doesn't break user code (e.g. compilation failure)

Its ok to change the title to remove critical. But its kind of loss of vital functionality when using Lombok. Its not a blocker since it doesn't cause any compilation issue and it also has a workaround which needs to remove one of lombok annotations to edit the initialise expression.

@gayanper
Copy link
Contributor Author

I kind of suspect its due to the completion location. Because when builder and default annotation is used to gather the initialiser is moved to Builder class which is generated. And the current source location we are at doesn't really have what we are looking for when things are resolved.

If this works in Eclipse, I doubt that the Lombok eclipse plugin takes a different approach by making sure the current source is resolved as it is rather than using the one after Lombok generation.

Its just a assumption though 🙂

@snjeza
Copy link
Contributor

snjeza commented May 26, 2023

@gayanper @fbricon The issue is an upstream VS Code issue. I'm working on that.
The issue is an upstream jdt.core or lombok issue.

@gayanper
Copy link
Contributor Author

@gayanper @fbricon The issue is an upstream VS Code issue. I'm working on that.

Thanks @snjeza , When you say upstream vscode issue, do you mean a jdt.core issue or jdt.ls issue ?

@snjeza
Copy link
Contributor

snjeza commented May 26, 2023

@gayanper I think a VS Code issue.
There is an upstream jdt.core or lombok issue.
The completion in Eclipse throws

java.lang.StringIndexOutOfBoundsException: Range [0, 78) out of bounds for length 19
	at java.base/jdk.internal.util.Preconditions$1.apply(Preconditions.java:55)
	at java.base/jdk.internal.util.Preconditions$1.apply(Preconditions.java:52)
	at java.base/jdk.internal.util.Preconditions$4.apply(Preconditions.java:213)
	at java.base/jdk.internal.util.Preconditions$4.apply(Preconditions.java:210)
	at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:98)
	at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckFromToIndex(Preconditions.java:112)
	at java.base/jdk.internal.util.Preconditions.checkFromToIndex(Preconditions.java:349)
	at java.base/java.lang.String.checkBoundsBeginEnd(String.java:4608)
	at java.base/java.lang.String.substring(String.java:2720)
	at org.eclipse.jdt.internal.ui.text.java.AbstractJavaCompletionProposal.getPatternMatchRule(AbstractJavaCompletionProposal.java:929)
	at org.eclipse.jdt.internal.ui.text.java.LazyJavaTypeCompletionProposal.getPatternToEmphasizeMatch(LazyJavaTypeCompletionProposal.java:321)
	at org.eclipse.jdt.internal.ui.text.java.LazyJavaCompletionProposal.getStyledDisplayString(LazyJavaCompletionProposal.java:475)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup.handleSetData(CompletionProposalPopup.java:879)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:5855)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1529)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1555)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1538)
	at org.eclipse.swt.widgets.Table.checkData(Table.java:289)
	at org.eclipse.swt.widgets.Table.cellDataProc(Table.java:227)
	at org.eclipse.swt.widgets.Display.cellDataProc(Display.java:994)
	at org.eclipse.swt.internal.gtk.GTK.gtk_tree_view_column_cell_set_cell_data(Native Method)
	at org.eclipse.swt.widgets.Table.getItemHeightInPixels(Table.java:1693)
	at org.eclipse.swt.widgets.Table.getItemHeight(Table.java:1664)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup.getMinimalHeight(CompletionProposalPopup.java:720)
	at org.eclipse.jface.text.contentassist.ContentAssistant$LayoutManager.computeBoundsBelowAbove(ContentAssistant.java:704)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup.getLocation(CompletionProposalPopup.java:1207)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup.setProposals(CompletionProposalPopup.java:1192)
	at org.eclipse.jface.text.contentassist.AsyncCompletionProposalPopup.computeAndPopulateProposals(AsyncCompletionProposalPopup.java:221)
	at org.eclipse.jface.text.contentassist.AsyncCompletionProposalPopup.showProposals(AsyncCompletionProposalPopup.java:172)
	at org.eclipse.jface.text.contentassist.ContentAssistant.showPossibleCompletions(ContentAssistant.java:1873)
	at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor$AdaptedSourceViewer.doOperation(CompilationUnitEditor.java:189)
	at org.eclipse.ui.texteditor.ContentAssistAction.lambda$0(ContentAssistAction.java:85)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67)
	at org.eclipse.ui.texteditor.ContentAssistAction.run(ContentAssistAction.java:84)
	at org.eclipse.ui.texteditor.RetargetTextEditorAction.run(RetargetTextEditorAction.java:232)
	at org.eclipse.jface.action.Action.runWithEvent(Action.java:474)
	at org.eclipse.jface.commands.ActionHandler.execute(ActionHandler.java:121)
	at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:97)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
	at java.base/java.lang.reflect.Method.invoke(Method.java:578)
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58)
	at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:317)
	at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:251)
	at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:173)
	at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.execute(HandlerServiceHandler.java:156)
	at org.eclipse.core.commands.Command.executeWithChecks(Command.java:488)
	at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:485)
	at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:213)
	at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.executeCommand(KeyBindingDispatcher.java:308)
	at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.press(KeyBindingDispatcher.java:580)
	at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.processKeyEvent(KeyBindingDispatcher.java:647)
	at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.filterKeySequenceBindings(KeyBindingDispatcher.java:439)
	at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher$KeyDownFilter.handleEvent(KeyBindingDispatcher.java:96)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
	at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1953)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1528)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1555)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1538)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1577)
	at org.eclipse.swt.widgets.Widget.gtk_key_press_event(Widget.java:937)
	at org.eclipse.swt.widgets.Control.gtk_key_press_event(Control.java:4013)
	at org.eclipse.swt.widgets.Composite.gtk_key_press_event(Composite.java:931)
	at org.eclipse.swt.widgets.Widget.windowProc(Widget.java:2507)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:6834)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:6163)
	at org.eclipse.swt.internal.gtk3.GTK3.gtk_main_do_event(Native Method)
	at org.eclipse.swt.widgets.Display.eventProc(Display.java:1597)
	at org.eclipse.swt.internal.gtk3.GTK3.gtk_main_iteration_do(Native Method)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:4514)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1155)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1046)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155)
	at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:643)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:550)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:171)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:152)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:136)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:402)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
	at java.base/java.lang.reflect.Method.invoke(Method.java:578)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:596)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1467)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1440)

and apply completion doesn't work.

@gayanper
Copy link
Contributor Author

Thanks for the clarification @snjeza

snjeza added a commit to snjeza/eclipse.jdt.ls that referenced this issue May 29, 2023
No completions on field initializer with @default and @builder Lombok annotations
Related issue: eclipse-jdtls#2669

Signed-off-by: Snjezana Peco <[email protected]>
@rgrunber rgrunber added this to the End May 2023 milestone May 31, 2023
rgrunber pushed a commit that referenced this issue May 31, 2023
No completions on field initializer with @default and @builder Lombok annotations
Related issue: #2669

Signed-off-by: Snjezana Peco <[email protected]>
@rgrunber
Copy link
Contributor

rgrunber commented May 31, 2023

@snjeza Since the completion responses (from JDT) come back as having the incorrect offset, I assume this is an upstream JDT/lombok issue and that we can revert the PR once it's fixed ? When you said it's an upstream VS Code issue, did you just mean in the sense that VS Code was refusing to display the completion items (I'm assuming because there may be some check somewhere in VS Code or in vscode-languageserver-node that filters out items with improper ranges) ?

@snjeza
Copy link
Contributor

snjeza commented May 31, 2023

Since the completion responses (from JDT) come back as having the incorrect offset, I assume this is an upstream JDT/lombok issue and that we can revert the PR once it's fixed ?

+1

When you said it's an upstream VS Code issue, did you just mean in the sense that VS Code was refusing to display the completion items (I'm assuming because there may be some check somewhere in VS Code or in vscode-languageserver-node that filters out items with improper ranges)

It is an upstream jdt.core or lombok issue.

@snjeza snjeza reopened this Jun 1, 2023
@rgrunber rgrunber modified the milestones: End May 2023, End June 2023 Jun 1, 2023
@rgrunber rgrunber closed this as completed Jun 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants