Java completion enhanced to support no insertion of method parameters#7747
Java completion enhanced to support no insertion of method parameters#7747sid-srini wants to merge 3 commits intoapache:masterfrom
Conversation
lahodaj
left a comment
There was a problem hiding this comment.
I went through the patch - overall seems sensible. Added a few comments here and there. But, I think @dbalek should review - he might have some different views.
My probably biggest complaint would be that there are not tests checking the new behavior.
| * Whether the code completion query search will be case-sensitive | ||
| * Values: java.lang.Boolean | ||
| */ | ||
| public static final String COMPLETION_CASE_SENSITIVE = "completion-case-sensitive"; // NOI18N |
There was a problem hiding this comment.
It might make sense to put the option name to the API, as is done for other options.
There was a problem hiding this comment.
I didn't quite understand this suggestion. I refrained from adding to SimpleValueNames because the comment in EditorPreferenceKeys mentioned that the latter is meant for private keys, while the former for public, devel or friend keys.
I can move the key here if I misunderstood. Thanks.
There was a problem hiding this comment.
I have removed the unrelated grammatical change in this file. Thanks.
Thanks a lot @lahodaj. |
|
Is there an IDE options UI for this?! I'm curious at the reasoning for adding this where it is? It seems similar to the guess filled method arguments option? Between them they feel like they cover 3 states? (no fill, parameter names, guess values) |
Thanks @neilcsmith-net. I will try to add this.
Yes, that progression in the complexity for insertions makes sense to me.
Given that the latter is already a defined preference key, it seems easier to maintain backward compatibility and a minimal state increase with the added boolean flag. When implementing the UI above, I could try to introduce joint states for these 2. However, it may become difficult to move the first setting to other languages. Let me know if this analysis makes sense. |
|
Sure, I agree with keeping as two boolean flags. The UI could handle valid combinations / or just visually disable one checkbox if desired. I was just curious as to the different reasons / pros and cons of where the keys are registered. Obviously the guess arguments key is in the options panel UI code itself - https://github.com/apache/netbeans/blob/master/java/java.editor/src/org/netbeans/modules/java/editor/options/CodeCompletionPanel.java#L52 Let's let @dbalek review that. |
… parameters 1. Added the config key "jdk.java.completion.disable.insertMethodParameters" to disable insertion of method arguments. 2. Added an *"in-review"* version of the NB patch PR apache/netbeans#7747 which implements this enhancement in the NBLS. Signed-off-by: Siddharth Srinivasan <siddharth.srinivasan@oracle.com>
2fbdd85 to
bdcf822
Compare
|
I've rebased the PR to the current master and resolved the merge conflicts.
Requesting reviews from @dbalek. Thank you |
|
@sid-srini |
This is based on end-user feedback received in oracle/javavscode#197 1. Added a user preference for insertion of method parameters in code completions. - `"completion-insert-text-parameters"` - default value = `true` - Also available via: - ide/editor.lib2: `EditorPreferencesKeys.COMPLETION_INSERT_TEXT_PARAMETERS` - java/java.completion: `Utilities.isCompletionInsertTextParameters()` 2. Added disabling of the above preference from the LSP client via the client config key `PREFIX + "java.completion.disable.insertMethodParameters"` - Updation occurs in `TextDocumentServiceImpl.completion()` 3. Added an extra arg `insertTextParams` in the following interface methods with the default value `true`: - `JavaCompletionTask.ItemFactory`: - `createExecutableItem` - `createThisOrSuperConstructorItem` - `JavaCompletionTask.TypeCastableItemFactory`: - `createTypeCastableExecutableItem` 4. Invoked the above methods in `JavaCompletionTask` with this parameter value set by `Utilities.isCompletionInsertTextParameters()`. 5. Enhanced the implementations of the above methods in `JavaCompletionCollector` and `JavaCompletionItem` to insert text for method arguments when `insertTextParams` (or `!memberRef`). - The cursor would be placed inside the parentheses if it is not a no-args method completion. 6. Added a follow-up LSP command to the completion item "editor.action.triggerParameterHints" for showing the signature help when not inserting text parameters. - This is a necessary guide for the user. - It would not be triggered without this addition, since the trigger character '(' is not typed by the user. 7. Unrelated minor fixes in `JavaCompletionCollector.ItemFactoryImpl`: - Added the default prefix ("nbls") to the usages of the follow-up command "java.complete.abstract.methods". - Without this, the command would not get launched by the client. - Added to the builder in `createExecutableItem()`, the instantiated follow-up command "nbls.java.complete.abstract.methods". Signed-off-by: Siddharth Srinivasan <siddharth.srinivasan@oracle.com>
Incorporated review feedback about hoisting to existing if conditions; and adding few descriptive comments. Signed-off-by: Siddharth Srinivasan <siddharth.srinivasan@oracle.com>
Updated the java.completion module sig file after rebasing the PR to current master (release-300rc2+). Signed-off-by: Siddharth Srinivasan <siddharth.srinivasan@oracle.com>
bdcf822 to
42c1a62
Compare
This configurable enhancement is based on end-user feedback received in oracle/javavscode#197
Added a user preference for insertion of method parameters in code completions.
"completion-insert-text-parameters"trueEditorPreferencesKeys.COMPLETION_INSERT_TEXT_PARAMETERSUtilities.isCompletionInsertTextParameters()Added disabling of the above preference from the LSP client via the client config key
PREFIX + "java.completion.disable.insertMethodParameters"TextDocumentServiceImpl.completion()Added an extra arg
insertTextParamsin the following interface methods with the default valuetrue:JavaCompletionTask.ItemFactory:createExecutableItemcreateThisOrSuperConstructorItemJavaCompletionTask.TypeCastableItemFactory:createTypeCastableExecutableItemInvoked the above methods in
JavaCompletionTaskwith this parameter value set byUtilities.isCompletionInsertTextParameters().Enhanced the implementations of the above methods in
JavaCompletionCollectorandJavaCompletionItemto insert text for method arguments wheninsertTextParams(or!memberRef).Added a follow-up LSP command to the completion item "editor.action.triggerParameterHints" for showing the signature help when not inserting text parameters.
Unrelated minor fixes in
JavaCompletionCollector.ItemFactoryImpl:createExecutableItem(), the instantiated follow-up command "nbls.java.complete.abstract.methods".