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 <[email protected]>