You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2021/11/12 00:23:28 UTC
[GitHub] [netbeans] ppisl opened a new pull request #3316: [NETBEANS-6196] Package code completion doesn't work in empty groovy …
ppisl opened a new pull request #3316:
URL: https://github.com/apache/netbeans/pull/3316
This PR allow to complete package keyword in empty groovy file. Also after the package keyword the code completion offers only the packages.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
[GitHub] [netbeans] ppisl commented on a change in pull request #3316: [NETBEANS-6196] Package code completion doesn't work in empty groovy …
Posted by GitBox <gi...@apache.org>.
ppisl commented on a change in pull request #3316:
URL: https://github.com/apache/netbeans/pull/3316#discussion_r749322491
##########
File path: groovy/groovy.editor/src/org/netbeans/modules/groovy/editor/completion/KeywordCompletion.java
##########
@@ -98,6 +110,27 @@ public boolean complete(Map<Object, CompletionProposal> proposals, CompletionCon
return true;
}
+ boolean isFirstStatement(final CompletionContext request) {
+ TokenSequence<GroovyTokenId> ts = LexUtilities.getGroovyTokenSequence(request.doc, 1);
+
+ if (ts != null) {
+ ts.move(request.lexOffset);
+ 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
Review comment:
This is good idea. Do you want to do it in this PR?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
[GitHub] [netbeans] sdedic commented on pull request #3316: [NETBEANS-6196] Package code completion doesn't work in empty groovy …
Posted by GitBox <gi...@apache.org>.
sdedic commented on pull request #3316:
URL: https://github.com/apache/netbeans/pull/3316#issuecomment-970053203
Seems that Travis failures relate to 77cd083d9a (#2959) rather than this PR.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
[GitHub] [netbeans] sdedic commented on a change in pull request #3316: [NETBEANS-6196] Package code completion doesn't work in empty groovy …
Posted by GitBox <gi...@apache.org>.
sdedic commented on a change in pull request #3316:
URL: https://github.com/apache/netbeans/pull/3316#discussion_r749230138
##########
File path: groovy/groovy.editor/src/org/netbeans/modules/groovy/editor/completion/KeywordCompletion.java
##########
@@ -98,6 +110,27 @@ public boolean complete(Map<Object, CompletionProposal> proposals, CompletionCon
return true;
}
+ boolean isFirstStatement(final CompletionContext request) {
+ TokenSequence<GroovyTokenId> ts = LexUtilities.getGroovyTokenSequence(request.doc, 1);
+
+ if (ts != null) {
+ ts.move(request.lexOffset);
+ 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
Review comment:
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).
##########
File path: groovy/groovy.editor/src/org/netbeans/modules/groovy/editor/completion/KeywordCompletion.java
##########
@@ -98,6 +110,27 @@ public boolean complete(Map<Object, CompletionProposal> proposals, CompletionCon
return true;
}
+ boolean isFirstStatement(final CompletionContext request) {
+ TokenSequence<GroovyTokenId> ts = LexUtilities.getGroovyTokenSequence(request.doc, 1);
+
+ if (ts != null) {
+ ts.move(request.lexOffset);
+ if (ts.movePrevious()) {
+ while (ts.isValid() && ts.movePrevious() && ts.offset() >= 0) {
Review comment:
Nitpick: IMHO ts.offset() >= 0 is redundant on all places -- if `movePrevious` had failed bcs there's no previous token, it would return `false`; and the 1st token is always at offset 0.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
[GitHub] [netbeans] sdedic commented on a change in pull request #3316: [NETBEANS-6196] Package code completion doesn't work in empty groovy …
Posted by GitBox <gi...@apache.org>.
sdedic commented on a change in pull request #3316:
URL: https://github.com/apache/netbeans/pull/3316#discussion_r749230138
##########
File path: groovy/groovy.editor/src/org/netbeans/modules/groovy/editor/completion/KeywordCompletion.java
##########
@@ -98,6 +110,27 @@ public boolean complete(Map<Object, CompletionProposal> proposals, CompletionCon
return true;
}
+ boolean isFirstStatement(final CompletionContext request) {
+ TokenSequence<GroovyTokenId> ts = LexUtilities.getGroovyTokenSequence(request.doc, 1);
+
+ if (ts != null) {
+ ts.move(request.lexOffset);
+ 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
Review comment:
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](https://github.com/apache/netbeans/blob/a5302866a02a0a5db189a07429b56213424d56dd/groovy/groovy.editor/src/org/netbeans/modules/groovy/editor/api/lexer/LexUtilities.java#L767), so maybe `SH_COMMENT` and `SL_COMMENT` the whitespace set should be added to the WS set there ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
[GitHub] [netbeans] ppisl commented on a change in pull request #3316: [NETBEANS-6196] Package code completion doesn't work in empty groovy …
Posted by GitBox <gi...@apache.org>.
ppisl commented on a change in pull request #3316:
URL: https://github.com/apache/netbeans/pull/3316#discussion_r749305257
##########
File path: groovy/groovy.editor/src/org/netbeans/modules/groovy/editor/completion/KeywordCompletion.java
##########
@@ -98,6 +110,27 @@ public boolean complete(Map<Object, CompletionProposal> proposals, CompletionCon
return true;
}
+ boolean isFirstStatement(final CompletionContext request) {
+ TokenSequence<GroovyTokenId> ts = LexUtilities.getGroovyTokenSequence(request.doc, 1);
+
+ if (ts != null) {
+ ts.move(request.lexOffset);
+ if (ts.movePrevious()) {
+ while (ts.isValid() && ts.movePrevious() && ts.offset() >= 0) {
Review comment:
I wanted to be consistent with the rest of the code. Else this should be changed in more places, not only in my patch.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
[GitHub] [netbeans] sdedic merged pull request #3316: [NETBEANS-6196] Package code completion doesn't work in empty groovy …
Posted by GitBox <gi...@apache.org>.
sdedic merged pull request #3316:
URL: https://github.com/apache/netbeans/pull/3316
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
[GitHub] [netbeans] sdedic commented on a change in pull request #3316: [NETBEANS-6196] Package code completion doesn't work in empty groovy …
Posted by GitBox <gi...@apache.org>.
sdedic commented on a change in pull request #3316:
URL: https://github.com/apache/netbeans/pull/3316#discussion_r749330498
##########
File path: groovy/groovy.editor/src/org/netbeans/modules/groovy/editor/completion/KeywordCompletion.java
##########
@@ -98,6 +110,27 @@ public boolean complete(Map<Object, CompletionProposal> proposals, CompletionCon
return true;
}
+ boolean isFirstStatement(final CompletionContext request) {
+ TokenSequence<GroovyTokenId> ts = LexUtilities.getGroovyTokenSequence(request.doc, 1);
+
+ if (ts != null) {
+ ts.move(request.lexOffset);
+ 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
Review comment:
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 is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists