Script:490
Talk0
1,599pages on
this wiki
this wiki
Use this page to discuss script 490 java_getset: automatically add getter/setters for Java properties
- Add constructive comments, bug reports, or discuss improvements (see the guideline).
- Do not document the script here (the author should do that on vim.org).
- This page may be out of date: check the script's vim.org page above, and its release notes.
Problem with generics
Edit
Superb script really great, however it seems to fail on generics.
private List<String> foo;
getset won't generate methods for this field.
private List foo;
but it will when generics are removed. --January 16, 2012
- A quick hack to support generics:
- Open your
java_getset.vimfile - Search for definition of
s:variable(i.e.let s:variable = ......) - Before that line add a new definition:
let s:generics = '\%(\s*\%(<.*>\)\)\=' - Change the definition of
s:variableto (see underlined part):let s:variable = '\(\s*\)\(\(' . s:modifier . '\s\+\)*\)\(' . s:javaname . s:generics . '\)' . s:brackets . '\s\+\(' . s:javaname . '\)\s*\(;\|=[^;]\+;\)'
- Open your
- What this does is it extends the regular expression matching the field definitions by adding "
<...>" to the type part. Actually it does not check for what's inside the angle brackets and since allowing for multi-type generics and nested generics, too. - (As with the nature of quick hacks this one does not fix the javadoc creation where angle brackets will still appear as angle brackets instead of HTML-code.)
- --February 27, 2012
Comments
Edit
Unrelated, but I love the comments in this script! Great job commenting your code!!! Very organized and easy to follow!!