vim-refactor icon indicating copy to clipboard operation
vim-refactor copied to clipboard

Getter or Setter Generation not working (in java)

Open caga opened this issue 7 years ago • 2 comments

I vundle all other dependencies related. When i try to generate getter or setter with ctrl-x g/s, I am getting the following error (and one time Warning):

Error detected while processing function lh#refactor#extract_getter[6]..lh#dev#attribute#analyse[1]..lh#dev#option#call[6]..lh#dev#java#attribute#analyse: line 15: E121: Undefined variable: visibility E15: Invalid expression: { 'visibility': visibility, 'type' : type[1:], 'name' : name, 'static' : static } What can be the problem?

caga avatar Apr 26 '18 12:04 caga

Hi,

I'll have to look at the code, unfortunately I won't be able to do so seriously in the next 4 weeks. Sorry ^^'

At first glance, I'd say the function lh#dev#java#attribute#analyse() takes the line an attribute is defined and tries to extract the visibility. See for instance the result of :echo lh#dev#java#attribute#analyse('public int m_foobar;')

I'd need to know what is under your cursor when you trigger the refactoring. It's likely the regex I use in lh#dev#java#attribute#analyse() (in the file lh-dev/autoload/lh/dev/java/attribute.vim) isn't able to decode the definition of the attribute.

In all cases, I'll need to produce a better error message.

LucHermitte avatar Apr 27 '18 09:04 LucHermitte

Thank you. Sorry for not givin you the necessary feedback on time, i was on vacation without an internet connection.

First Feedback:

Cursor is on the variable which i want to set up the getter/setter. besides that i tried also on the class name, below is the message when i do so:

Error detected while processing function lh#refactor#extract_getter: line 7: E117: Unknown function: lh#dev#naming#variable E15: Invalid expression: lh#dev#naming#variable(attribute.name)

Second Feedback:

output of the function :echo lh#dev#java#attribute#analyse('public int m_foobar;')

{'static': 0, 'name': 'm_foobar', 'type': 'int', 'visibility': 'public'}

caga avatar May 02 '18 06:05 caga