Skip to content
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

Option to disable auto completion of method arguments #197

Open
mirojantti opened this issue Jul 18, 2024 · 1 comment
Open

Option to disable auto completion of method arguments #197

mirojantti opened this issue Jul 18, 2024 · 1 comment
Labels
enhancement New feature or request Settings/Config If there are missing setting or configaration

Comments

@mirojantti
Copy link

Hey, I would like to disable the auto completion of method arguments.

When pressing enter here
image
I don't want the arguments to be guessed or filled in at all like so
image
Instead, I'd rather have it only complete the method name and potentially add the parentheses, nothing more. I can then use the parameter hint box to view the missing parameters without having to worry about unwanted text being inserted in the document.
image

@arvindaprameya arvindaprameya added enhancement New feature or request Settings/Config If there are missing setting or configaration labels Jul 19, 2024
@mirojantti
Copy link
Author

Here's another somewhat related issue with parentheses I've noticed when switching from one method call to another. If I were to change the call to from cos to sin, the existing parentheses are ignored:

image
image
image

sid-srini added a commit to sid-srini/netbeans that referenced this issue Sep 12, 2024
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Settings/Config If there are missing setting or configaration
Projects
None yet
Development

No branches or pull requests

2 participants