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

Java completion enhanced to support no insertion of method parameters #7747

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Commits on Sep 12, 2024

  1. Java completion enhanced to support no insertion of method parameters

    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]>
    sid-srini committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    53d4b06 View commit details
    Browse the repository at this point in the history
  2. Java completion enhanced to support no insertion of method parameters

    Incorporated review feedback about hoisting to existing if conditions; and adding few descriptive comments.
    
    Signed-off-by: Siddharth Srinivasan <[email protected]>
    sid-srini committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    2fbdd85 View commit details
    Browse the repository at this point in the history