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

@Data in Eclipse Neon: Extract Interface, Pull Up not working #1309

Closed
coding-jj opened this issue Feb 21, 2017 · 4 comments · Fixed by #3015
Closed

@Data in Eclipse Neon: Extract Interface, Pull Up not working #1309

coding-jj opened this issue Feb 21, 2017 · 4 comments · Fixed by #3015
Assignees
Labels
Milestone

Comments

@coding-jj
Copy link

coding-jj commented Feb 21, 2017

With @DaTa the Eclipse features "Extract Interface" and "Pull Up" (to interface) do not work.

Steps to reproduce - Extract Interface

Create Class:

import lombok.Data;

@Data
public class TestClass {
    public String testString;
}

Select Refactor - Extract Interface

  • Interface name: TestInterface
  • Mark: getTestString()
  • Mark: setTestString(String)
  • Click OK

No Error, but an empty interface will be created:

public interface TestInterface {

}

Steps to reproduce - Pull Up

Use TestClass and TestInterface from previous example.

Open TestClass

  • In Eclipse Outline View: Right Click on getTestString()
  • Select Refactor - Pull Up ...
  • Click Finished

Error:

An unexpected exception occurred while performing the refactoring. See the error log for more details. 

(See Log Message at End of Post)

Expected Behavior

The Interface should be created in default format:

public interface TestInterface {
    String getTestString();
    void setTestString(String testString);
}

Version info

  • Neon.2 Release (4.6.2) Build id: 20161208-0600
  • Lombok v1.16.14
  • Java Version "1.8.0_121"

It's not working in an older Version of Eclipse too:

  • Mars.2 Release (4.5.2) Build id: 20160218-0600

Eclipse Error

java.lang.reflect.InvocationTargetException
    at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:398)
    at org.eclipse.jface.wizard.WizardDialog.run(WizardDialog.java:993)
    at org.eclipse.ltk.ui.refactoring.RefactoringWizard.internalPerformFinish(RefactoringWizard.java:636)
    at org.eclipse.ltk.ui.refactoring.UserInputWizardPage.performFinish(UserInputWizardPage.java:145)
    at org.eclipse.jdt.internal.ui.refactoring.PullUpMemberPage.performFinish(PullUpMemberPage.java:942)
    at org.eclipse.ltk.ui.refactoring.RefactoringWizard.performFinish(RefactoringWizard.java:710)
    at org.eclipse.jface.wizard.WizardDialog.finishPressed(WizardDialog.java:790)
    at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog.finishPressed(RefactoringWizardDialog.java:106)
    at org.eclipse.jface.wizard.WizardDialog.buttonPressed(WizardDialog.java:423)
    at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:618)
    at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:249)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4418)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1079)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4236)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3824)
    at org.eclipse.jface.window.Window.runEventLoop(Window.java:818)
    at org.eclipse.jface.window.Window.open(Window.java:794)
    at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation$1.run(RefactoringWizardOpenOperation.java:188)
    at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
    at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run(RefactoringWizardOpenOperation.java:203)
    at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run(RefactoringWizardOpenOperation.java:122)
    at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate(RefactoringStarter.java:38)
    at org.eclipse.jdt.internal.corext.refactoring.RefactoringExecutionStarter.startPullUpRefactoring(RefactoringExecutionStarter.java:423)
    at org.eclipse.jdt.ui.actions.PullUpAction.run(PullUpAction.java:125)
    at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:271)
    at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:249)
    at org.eclipse.jface.action.Action.runWithEvent(Action.java:473)
    at org.eclipse.ui.actions.RetargetAction.runWithEvent(RetargetAction.java:235)
    at org.eclipse.ui.internal.WWinPluginAction.runWithEvent(WWinPluginAction.java:233)
    at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:565)
    at org.eclipse.jface.action.ActionContributionItem.lambda$4(ActionContributionItem.java:397)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4418)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1079)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4236)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3824)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1121)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1022)
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:150)
    at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:693)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:610)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:148)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:138)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:673)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:610)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1519)
Caused by: java.lang.NullPointerException
    at org.eclipse.jdt.internal.corext.refactoring.structure.HierarchyProcessor.createPlaceholderForType(HierarchyProcessor.java:402)
    at org.eclipse.jdt.internal.corext.refactoring.structure.HierarchyProcessor.copyReturnType(HierarchyProcessor.java:645)
    at org.eclipse.jdt.internal.corext.refactoring.structure.PullUpRefactoringProcessor.createAbstractMethod(PullUpRefactoringProcessor.java:1031)
    at org.eclipse.jdt.internal.corext.refactoring.structure.PullUpRefactoringProcessor.createChangeManager(PullUpRefactoringProcessor.java:1177)
    at org.eclipse.jdt.internal.corext.refactoring.structure.PullUpRefactoringProcessor.checkFinalConditions(PullUpRefactoringProcessor.java:767)
    at org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring.checkFinalConditions(ProcessorBasedRefactoring.java:222)
    at org.eclipse.ltk.core.refactoring.CheckConditionsOperation.run(CheckConditionsOperation.java:83)
    at org.eclipse.ltk.core.refactoring.CreateChangeOperation.run(CreateChangeOperation.java:119)
    at org.eclipse.ltk.core.refactoring.PerformChangeOperation.run(PerformChangeOperation.java:207)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2240)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2267)
    at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:86)
    at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:119)
Root exception:
java.lang.NullPointerException
    at org.eclipse.jdt.internal.corext.refactoring.structure.HierarchyProcessor.createPlaceholderForType(HierarchyProcessor.java:402)
    at org.eclipse.jdt.internal.corext.refactoring.structure.HierarchyProcessor.copyReturnType(HierarchyProcessor.java:645)
    at org.eclipse.jdt.internal.corext.refactoring.structure.PullUpRefactoringProcessor.createAbstractMethod(PullUpRefactoringProcessor.java:1031)
    at org.eclipse.jdt.internal.corext.refactoring.structure.PullUpRefactoringProcessor.createChangeManager(PullUpRefactoringProcessor.java:1177)
    at org.eclipse.jdt.internal.corext.refactoring.structure.PullUpRefactoringProcessor.checkFinalConditions(PullUpRefactoringProcessor.java:767)
    at org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring.checkFinalConditions(ProcessorBasedRefactoring.java:222)
    at org.eclipse.ltk.core.refactoring.CheckConditionsOperation.run(CheckConditionsOperation.java:83)
    at org.eclipse.ltk.core.refactoring.CreateChangeOperation.run(CreateChangeOperation.java:119)
    at org.eclipse.ltk.core.refactoring.PerformChangeOperation.run(PerformChangeOperation.java:207)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2240)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2267)
    at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:86)
    at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:119)
@coding-jj coding-jj changed the title @Date in Eclipse Neon: Extract Interface, Pull Up not working @Data in Eclipse Neon: Extract Interface, Pull Up not working Feb 21, 2017
@drgeb
Copy link

drgeb commented Apr 8, 2017

I am observing the same issue. Is there a fix for this ?
Thanks

@Paulomart
Copy link

I also have this issue, is there a workaround?

@Rawi01 Rawi01 self-assigned this Oct 6, 2021
@Rawi01
Copy link
Collaborator

Rawi01 commented Oct 6, 2021

@rzwitserloot I fixed the extract interface code and added a few patches for the pull up refactoring. This works fine as long as no one tries to pull up generated fields (e.g. @Log) or methods to classes. In both cases eclipse inserts the annotation instead of the actual initializer/method body. I can try to fix this and create some proper code but this actually is the first method that transforms a generated method into source code and I'm not sure if this is something we really want to add. I can also simply ignore this problem (at least it works) or always skip fields and method bodys. WDYT?

@rzwitserloot
Copy link
Collaborator

@Rawi01 Nah, if the user does something that they can reasonably expect is a nonsensical operation, I don't think we should bend over backwards to try to make it make sense anyway. Just erroring out is great. Doing something bizarre (such as removing the annotation from where it is and moving it, on its own, to a newly created file, thus resulting in a nonsensical uplifted file) is fine too.

Rawi01 added a commit to Rawi01/lombok that referenced this issue Oct 26, 2021
@rzwitserloot rzwitserloot added this to the next-version milestone Oct 26, 2021
sadv1r pushed a commit to sadv1r/lombok that referenced this issue Nov 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants