-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Ability to set packages and/or directories that should be indexed by analysis server for code completion #35680
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
Comments
Some additional clarification. If both files are in the same project, or even in analysis roots set in DAS, then these folders are already know to DAS, and we could provide completion suggestions from them. Same is for The problem starts when we live in mono-repository, where in theory everything is available for completion. In this case we require the client to provide additional directories for DAS to parse and provide suggestions from. It is OK is these new directories will have some intersection with analysis roots, we always can merge two sets. |
Are you asking for a server protocol, or a method on some class (and if the latter, which class)? Independent of the actual API, what I think you're asking for is a way to set the scope for finding names to suggest. It isn't clear to me that we ought to allow this to be set. The alternative is that we pick the "right" scope and just use it everywhere without the need/ability for it to be set externally. There are a few scopes that I can think of, each described as a delta from the previous scope:
So which of those scopes would match our user's expectations?
I think we can solve that problem by choosing a scope that is smaller than the whole workspace. |
A new protocol message
Yes. What I really want is for all of my declared dependencies (whether pub or bazel) to show up in code completion results. If analysis server is able to make that determination, that's even better :).
My expectation coming from Java development with IntelliJ + Bazel is that there's a build file which declares my project's sources and dependencies. A dependency might be a package or a library. Any interfaces, classes, etc defined in one of my sources or dependencies would be available in code completion, but I don't expect that the transitive closure (dependencies' dependencies) will show up as code completion suggestions. |
I think we agree. That sounds like the most reasonable choice. But just to be a little more precise, I think we want to suggest
|
We're developing the analysis server protocol changes in https://dart-review.googlesource.com/c/sdk/+/90125. |
interest in receiving not yet imported code completions from specific packages and libraries. The design of this interaction aims to avoid forcing analysis server to send every public symbol from dependent packages at every completion. Instead, clients express interest in certain packages and/or libraries and analysis server will notify with the entire set of symbols for each of them only once. Then it is the client's responsibility to save these pre-computed completions in memory, and analysis server can instruct the client on how to union them with the base set of completion suggestions at code completion time. Bug: #35680 Change-Id: I42c6fddc5d8daa2b546daa81456c0992e3ef547d Reviewed-on: https://dart-review.googlesource.com/c/90125 Commit-Queue: Ari Aye <[email protected]> Reviewed-by: Konstantin Shcheglov <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]>
We did it, thanks @bwilkerson and @scheglov for all of your work on this! |
Currently analysis server only suggests code completions which are already imported. For example, if I have two sibling classes
Foo
andBar
and ask analysis server for completions onBa^
fromfoo.dart
before importingbar.dart
,Bar
will not be suggested. Likewise, if I ask forProces
,Process
will not be suggested fromdart:io
unless I've already imported it.In order to have Java parity in IntelliJ, we need to be able to do this, and code completion will be much more useful overall with this ability.
The additional API I would like is something along the lines of
completion.setActiveTargets(List<String> targets)
./cc @jwren @scheglov @bwilkerson
The text was updated successfully, but these errors were encountered: