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
[NETBEANS-6196] Package code completion doesn't work in empty groovy … #3316
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great contribution Petr!
groovy/groovy.editor/src/org/netbeans/modules/groovy/editor/completion/KeywordCompletion.java
Show resolved
Hide resolved
if (ts.movePrevious()) { | ||
while (ts.isValid() && ts.movePrevious() && ts.offset() >= 0) { | ||
Token<GroovyTokenId> t = ts.token(); | ||
if (!(t.id() == GroovyTokenId.NLS || t.id() == GroovyTokenId.WHITESPACE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be moved off to some utilities a a Predicate<Token<GroovyTokenId>>
as I fear that whitespace-traversing code is on many places and does not take all the WS/comment tokens into account (see for example the package name back traversal code in this PR).
Edit: correction - there's some support already: see findPreviousNonWsNonComment, so maybe SH_COMMENT
and SL_COMMENT
the whitespace set should be added to the WS set there ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is good idea. Do you want to do it in this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps yes, but a possible retrofit of other code (that should use the helper instead of custom WS token checks) should be perhaps done separately. Your call.
This PR allow to complete package keyword in empty groovy file. Also after the package keyword the code completion offers only the packages.
Netbeans Issue: https://issues.apache.org/jira/browse/NETBEANS-6196