Source... actions insert code templates in wrong place #124

Closed
lombokissues opened this Issue Jul 14, 2015 · 7 comments

Projects

None yet

2 participants

@lombokissues
Collaborator

Migrated from Google Code (issue 51)

@lombokissues
Collaborator

๐Ÿ‘ค mccallum.michael ย  ๐Ÿ•— Sep 18, 2009 at 03:34 UTC

What steps will reproduce the problem?

  1. Add new method to interface
  2. Eclipse prompts for quick fix on an implementor
  3. Choose add unimplemented methods

What is the expected output? What do you see instead?
Expect to see the new stub method appear at the end of the class or
somewhere reasonable.

The code appears directly after the first lombok annotation, before any
parameters...

e.g.

@ Getter
public void methodstub() {
}
private int fieldThatWasAnnotated;

What version of the product are you using? On what operating system?
lombok 0.8.5
eclipse 3.4.2
java 6.0.14
windows xp

Please provide any additional information below.
The effect is the same if a Data or other annotation is at the class level.

Issue #98 alluded to this at the end

@lombokissues
Collaborator

๐Ÿ‘ค mccallum.michael ย  ๐Ÿ•— Sep 18, 2009 at 11:49 UTC

There are two solutions...

  1. change the declarationSourceStart and end to match the largest of any method as
    its added to the end of the list of methods and the template insertion defaults to
    after the last method defined in the type (irregardless of its specified position)
  2. or add as the not the first or last method in the list

I have a patch for the first as the second has complications what to do if you have
only generated methods, i guess the same field approach i've used for 1.

@lombokissues
Collaborator

๐Ÿ‘ค mccallum.michael ย  ๐Ÿ•— Sep 18, 2009 at 11:49 UTC

๐Ÿ”— source-template-insertion.patch View file

@lombokissues
Collaborator

๐Ÿ‘ค reinierz ย  ๐Ÿ•— Sep 21, 2009 at 01:25 UTC

We thought of that fix and rejected it, as it would mean that 'jump to declaration', as well as errors and
warnings related to generated code, would go to/highlight entirely the wrong thing. We'd be fixing this issue
but opening the door for others.

We need eclipse's understanding of position to be one thing some time, and another thing at other times.
There's no quick way out of this - we need to fix eclipse itself and give it a basic notion of generated code.
This will most likely involve more patching work, though the proof of concept fix of the code formatter (
2547ee7 ) may give us a quick way out of this: If we don't generate
anything when the parser is run to determine insertion points, things may work itself out.

@lombokissues
Collaborator

๐Ÿ‘ค askoning ย  ๐Ÿ•— Aug 23, 2011 at 18:53 UTC

This seems to be working in 0.10 RC3; all methods are generated at the place I expect them to be.

Only minor detail I see is that there isn't always an empty line added. In a class with @ Getter/@ Setter annotations present, the unimplemented method is placed one newline below the last method, whereas in a class annotated with @ Data, the method is placed directly below the last method, without newline in between.

@lombokissues
Collaborator

๐Ÿ‘ค reinierz ย  ๐Ÿ•— Nov 28, 2011 at 18:51 UTC

That last issue has now been addressed too. This edge release contains the fixes:

https://projectlombok.org/download-edge.html

@lombokissues lombokissues removed the accepted label Jul 14, 2015
@lombokissues
Collaborator

End of migration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment