Skip to content

Fix/issue 545 auto import unbound files#1802

Open
joaoheusi wants to merge 3 commits into
DetachHead:mainfrom
joaoheusi:fix/issue-545-auto-import-unbound-files
Open

Fix/issue 545 auto import unbound files#1802
joaoheusi wants to merge 3 commits into
DetachHead:mainfrom
joaoheusi:fix/issue-545-auto-import-unbound-files

Conversation

@joaoheusi
Copy link
Copy Markdown

Fixes #545

This makes auto-import completions bind tracked workspace files on demand when they have not yet been opened or analyzed. This way symbols from unopened workspace modules can still appear in completion results.

Tested:

  • npx jest autoImporter.test --runInBand
  • npm run build
  • npx eslint src/languageService/autoImporter.ts src/languageService/completionProvider.ts src/tests/autoImporter.test.ts
  • npx prettier -c src/languageService/autoImporter.ts src/languageService/completionProvider.ts src/tests/
    autoImporter.test.ts
  • npx jest fourSlashRunner.test --runInBand --testNamePattern completions.autoimport.fourslash

Copy link
Copy Markdown
Owner

@DetachHead DetachHead left a comment

Choose a reason for hiding this comment

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

thanks!

Comment thread packages/pyright-internal/src/tests/autoImporter.test.ts Outdated
Comment thread packages/pyright-internal/src/languageService/autoImporter.ts Outdated
Comment thread packages/pyright-internal/src/languageService/autoImporter.ts Outdated
Comment thread packages/pyright-internal/src/tests/autoImporter.test.ts Outdated
Comment thread packages/pyright-internal/src/tests/autoImporter.test.ts Outdated
Comment thread packages/pyright-internal/src/tests/autoImporter.test.ts
@github-actions
Copy link
Copy Markdown
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

- Drop redundant isTracked check (implied by isUserCode)
- Use getBoundSourceFileInfo instead of getParseResults to avoid
  the extra parse work; expose it on ProgramView
- Remove duplicate manual test in favor of the fourslash one and
  switch remaining assertions to tExpect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Language server does't offer autocomplete for functions in modules or packages that haven't been opened or loaded

2 participants