Skip to content

Add contribution points for completion customization#2110

Merged
testforstephen merged 3 commits intoeclipse-jdtls:masterfrom
jdneo:cs/completion-api
Nov 24, 2022
Merged

Add contribution points for completion customization#2110
testforstephen merged 3 commits intoeclipse-jdtls:masterfrom
jdneo:cs/completion-api

Conversation

@jdneo
Copy link
Copy Markdown
Contributor

@jdneo jdneo commented Jun 1, 2022

This PR adds a set of contribution points which allows JDT.LS plugins(for example: intellicode) participate into the completion processing - mostly the ranking stuff.

With this PR, intellicode will not need to redirect the completion requests anymore, instead it can have the chance to use its own ranking algorithm during completion processing.

Signed-off-by: sheche [email protected]

@jdneo
Copy link
Copy Markdown
Contributor Author

jdneo commented Jun 1, 2022

@Eskibear

@rgrunber
Copy link
Copy Markdown
Contributor

rgrunber commented Jun 2, 2022

This could be abused to some extent if multiple plugins decide to take control. I would have liked to see some kind of extension point contribution where plugins can contribute their relevance score (or sorter), and ultimately let JDT-LS decide. A score is a bit nicer than just a sorter, because with a score the result can be combined.

I'll have a closer look at this.

@Eskibear
Copy link
Copy Markdown
Contributor

Eskibear commented Jun 6, 2022

For better designing the API, let me briefly introduce how IntelliCode (probably the first consumer of this contribution point) ranks the items.

To make smarter ranking, it needs to know context information of the triggerred postion (including AST, bindings etc.). Besides, extra info is appened (using item.command.args) to items for diagnosic use, (e.g. elapsed time of the completion, ranking of each item...) That's why it interferes in an early stage, ranking the CompletionProposals before converting them to CompletionItem.

For clearer and easier implementation, IntelliCode has below requirements:

  • the ranking provider should provide enough context information as parameters.
  • there should be an approach to report diagnotic information (esp. completion performance that we want to monitor and improve). (currently it's using CompletionItem.command which will be executed when an item is selected)

@jdneo
Copy link
Copy Markdown
Contributor Author

jdneo commented Jun 6, 2022

@Eskibear Thanks for sharing the context. I'll propose a more general one later.

@jdneo

This comment was marked as outdated.

@jdneo jdneo force-pushed the cs/completion-api branch from 410c04b to 0214b2c Compare June 27, 2022 06:47
@jdneo
Copy link
Copy Markdown
Contributor Author

jdneo commented Jun 27, 2022

@rgrunber @Eskibear

I update the proposal. Please take a look when you have time. 😃

No need to include it in next release. But we can do some implementation verification at the IntelliCode side if no big issues are found in the proposal.

@jdneo
Copy link
Copy Markdown
Contributor Author

jdneo commented Oct 24, 2022

@testforstephen This is the PR to open a contribution point for completion ranking.

@jdneo jdneo force-pushed the cs/completion-api branch from 0214b2c to 92c5cca Compare November 15, 2022 04:35
@jdneo
Copy link
Copy Markdown
Contributor Author

jdneo commented Nov 15, 2022

@Eskibear @testforstephen I've updated the PR per our discussion about the APIs

@jdneo
Copy link
Copy Markdown
Contributor Author

jdneo commented Nov 16, 2022

@rgrunber Feel free to take a look. I think the latest change should address the comment about plugins can contribute their relevance score

@Eskibear
Copy link
Copy Markdown
Contributor

Tested b397c2c , migrating intellicode-java with the new API. so far so good.

- Extension contributors can call JavaLanguageServerPlugin.getCompletionRankingService()
  to get the ranking service, which is used to register and un-register
  the completion ranking provider.
- Extension contributors can implement the ICompletionRankingProvider which
  contributes scores/label prefix/addition data for each completion proposal.
- JDT.LS will aggregate all the ranking results from the ranking providers.

Signed-off-by: Sheng Chen <[email protected]>
@jdneo jdneo force-pushed the cs/completion-api branch from b397c2c to 7105880 Compare November 17, 2022 01:49
@jdneo
Copy link
Copy Markdown
Contributor Author

jdneo commented Nov 17, 2022

The last change I would like to make is to rename ICompletionRankingService to ICompletionContributionService, so that in the future we can allow contributors register other kinds of providers, e.g. ICompletionItemProvider to provide completion items (like jbang).

@rgrunber @fbricon @snjeza Feel free to leave comments if you have any. If everything looks good, I will start to add test cases.

Signed-off-by: Sheng Chen <[email protected]>
@jdneo jdneo force-pushed the cs/completion-api branch from 917a5fe to 1f3cc6b Compare November 21, 2022 07:55
Copy link
Copy Markdown
Contributor

@testforstephen testforstephen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one small comment about API naming. If no one else has any further comments, I think this PR is ready to be merged.

@testforstephen testforstephen marked this pull request as ready for review November 22, 2022 02:15
@testforstephen testforstephen added this to the End November milestone Nov 22, 2022
@jdneo jdneo force-pushed the cs/completion-api branch from a37ec88 to f151711 Compare November 22, 2022 02:36
@jdneo jdneo changed the title [WIP] Add contribution points for completion customization Add contribution points for completion customization Nov 22, 2022
@testforstephen testforstephen merged commit 250ac4f into eclipse-jdtls:master Nov 24, 2022
@jdneo jdneo deleted the cs/completion-api branch November 24, 2022 02:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants