Skip to content

Add exported members of all project files in the global completion list - #13921

Closed
Zhengbo Li (zhengbli) wants to merge 9 commits into
microsoft:masterfrom
zhengbli:importsInCompletion
Closed

Add exported members of all project files in the global completion list#13921
Zhengbo Li (zhengbli) wants to merge 9 commits into
microsoft:masterfrom
zhengbli:importsInCompletion

Conversation

@zhengbli

Copy link
Copy Markdown

Fixes #7849

This PR adds several things:

  1. It adds the exported members of all project files in the global completion list, no matter if the file was imported by the current file or not;
  2. however, for members coming from not-yet-imported file, the returned CompletionEntry now has a new property hasAction, indicating if the user commits it, additional code actions will be needed to avoid errors;
  3. after emitting a completion entry with hasAction set to true, the editor can send a CommitCompletionWithCodeAction request to the server to get the corresponding code actions, and then apply them just like other code actions.

@zhengbli

Copy link
Copy Markdown
Author

@prog110

Copy link
Copy Markdown

Zhengbo Li (@zhengbli) Does this include files under node_modules aswell?

@zhengbli

Copy link
Copy Markdown
Author

Yes as long as they have been used in the project at least once

@prog110

Copy link
Copy Markdown

Will the first time import of a class work (this class has not been imported into my source, but the node_modules contains the definition file for this class I'm trying to import)?

@zhengbli

Zhengbo Li (zhengbli) commented Feb 14, 2017

Copy link
Copy Markdown
Author

No you have to import that module at least once anywhere in your project, so that module becomes part of your project. Otherwise it would be too expensive to search all the folders all the time. The same applies to how we implements the current quick fix now.

@prog110

prog110 (prog110) commented Feb 14, 2017

Copy link
Copy Markdown

Zhengbo Li (@zhengbli) The sheer mention of a dependency in package.json & the presence of the dependency in node_modules implies that the user is wanting to use the module. Most of the time (~99%) user does not modify any file under node_modules manually.

Only npm (or) yarn would trigger a change to the node_modules directory structure, which user would not run very frequently in the project.

So the amount of change cycles that trigger autocomplete index to change are relatively limited from the point of view of the files under node_modules.

Unless I'm missing something, forcing user to import at least once in the project is an arbitrary expectation.

Please let me know if I've missed something

@zhengbli

Copy link
Copy Markdown
Author

I agree parsing package.json is a good estimate. Though that belongs to a bigger question: whether we should eagerly include modules listed in package.json into the program, which would have impacts on not only completion list, also other features like navigate-to. The changes made in this PR serves as the first step towards and is building based on how the program is currently constructed. That proposed changes to make the program bigger eagerly may go to a separate PR later.

@prog110

prog110 (prog110) commented Mar 17, 2017

Copy link
Copy Markdown

Zhengbo Li (@zhengbli) Is this change going to be part of 2.3?

@zhengbli

Copy link
Copy Markdown
Author

@thekalinga at this point I'm not sure, depends on if the team has the time to review the changes

@zhengbli Zhengbo Li (zhengbli) changed the title Add exported members of all project files in the global completion list [WIP] Add exported members of all project files in the global completion list Apr 3, 2017
@zhengbli Zhengbo Li (zhengbli) changed the title [WIP] Add exported members of all project files in the global completion list Add exported members of all project files in the global completion list Apr 5, 2017
@zhengbli

Copy link
Copy Markdown
Author

Updated with the feature embedded in the "CompletionEntryDetails" API call.

@mjbvz

Copy link
Copy Markdown

The API looks good to me for VSCode. Looking forward to picking up this change

@angelozerr

Copy link
Copy Markdown

I'm looking for too for this great feature to integrate it inside Eclipse. Do you know when you think you could merge this issue to master to consume it with typescript@dev ?

@angelozerr

Copy link
Copy Markdown

Mohamed Hegazy (@mhegazy) do you know when this PR will be accepted? The auto import feature is not in the RoadMap Do you know for which version of TypeScript, it will be available? Thanks!

@minestarks

Copy link
Copy Markdown
Contributor

This is redone in #17851

@mhegazy

Copy link
Copy Markdown
Contributor

Merged in #19069. thanks Zhengbo Li (@zhengbli) !

@microsoft Microsoft (microsoft) locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants