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

Auto complete for dependencies for pom.xml #195

Closed
Eskibear opened this issue Dec 27, 2018 · 5 comments
Closed

Auto complete for dependencies for pom.xml #195

Eskibear opened this issue Dec 27, 2018 · 5 comments
Assignees
Labels
discussion feature-request New feature or request
Milestone

Comments

@Eskibear
Copy link
Member

The upstream issue is #47

An important feature to improve pom.xml editing experience is dependency auto-completion.
The basic use cases are:

  1. For <groupId>[cursor]</groupId>, show a list of available group ids, e.g. from local maven repository.
  2. For <artifactId>[cursor]</artifactId>, show a list of available artifact ids according to the value of groupId.
@Eskibear
Copy link
Member Author

Experiences in Java IDEs

Eclipse photon

I don't see any completion for groupId or artifactId.

IntelliJ IDEA 2018.3

  • For groupId, it always provides a list of all group ids which contains the keyword you've typed in.
  • For artifactId, it lists artifacts of the given group id.
  • For version, it lists versions in the same way above, together with two extra items ("RELEASE" and "LATEST")

Note that all the completion items are from local Maven repository. Every time you open a Maven project, it takes some time to update the Maven indices of your local repository. If you don't have an artifact installed into your local repository, it won't appear in the completion list.

@Eskibear Eskibear self-assigned this Dec 27, 2018
@Eskibear Eskibear added this to the 0.13.0 milestone Dec 27, 2018
@Eskibear Eskibear added feature-request New feature or request discussion labels Dec 27, 2018
@Eskibear
Copy link
Member Author

We need context info of current active pom.xml. E.g. we need to know current cursor position, and if it's located in an artifactId node, the value of groupId is required to calculate available artifacts. And if it's located elsewhere, we don't need to provide the result.

  1. provideCompletionItems has the cursor position as a param, so it's easy to get the whole text before the cursor.
  2. xml-zero-lexer is a lexer which can tokenize the xml file into an array of tokens, so it's feasible to tell which node the cursor is in.

@Eskibear
Copy link
Member Author

The current implementation requires to find all pom files in local Maven Repo, which introduces extra CPU & IO overload. It depends on the size of the local Maven repo, and I'm not sure whether it will lead to performance deterioration. So I think we can disable it by default, and add a flag in settings to enable the feature.

@Eskibear
Copy link
Member Author

Artifact info from local maven repository can only provide limited help. Imagine a user who wants to add a some dependencies related with "docker", without installing it into local maven repository first, the users can not get related suggestions.

So next step is to retrieve information from Maven central repo in real time. By the REST API provided, there's big chance to improve the experience.

@Eskibear
Copy link
Member Author

Eskibear commented Jan 23, 2019

With PR #221 , it's able to consume data from Maven Central repository.
With PR #222 , it improves performance of fetching data from Maven local repository.

TODO

  • Refine sorting of completion items, e.g. versions should be sorted semantically
  • Use effective local repository instead of the hard-coded ~/.m2/repository

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion feature-request New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant