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

new implementation of Resolver #84

Open
wants to merge 36 commits into
base: master
Choose a base branch
from
Open

new implementation of Resolver #84

wants to merge 36 commits into from

Conversation

ajafff
Copy link
Owner

@ajafff ajafff commented Nov 21, 2018

This new API is going to replace the existing collectVariableUsage.
Main differences:

  • fully incremental and cached
    • weak cache cleans up if node is no longer referenced
    • should even work with updated SourceFiles
  • references contain export statements
  • falls back to TypeChecker if necessary (and available)
    • correctly handles merged namespaces and enums, even across files
  • returns no result if correctness cannot be guaranteed (missing TypeChecker, crossing with scope boundary, ...)
  • several bug fixes
    • imports and namespaces are treated with their actual type rather than guessing something
    • correct handling of arguments in functions
    • computed method names cannot access type parameters and regular parameters
    • (class, method, parameter) decorators cannot access type parameters and parameters
    • typeof in type parameters cannot access function parameters
    • return type can access declarations in function body
    • resolves uses within a with block, but stops at the scope boundary
    • treats every value use in with statement as unknown
  • adds an API to find the declaration at a use site

Fixes: #38

@ajafff
Copy link
Owner Author

ajafff commented Dec 8, 2018

TODOs:

  • refactor the API to use iterators all the way to the consumer
    • this allows aborting analysis if no more information is needed
    • API user can decide whether to use potentially shadowed uses
  • add tests
  • look for possible performance optimizations
    • this is optional as the cache already saves quite a bit of redundant work
    • but still generators are pretty slow

@ajafff
Copy link
Owner Author

ajafff commented Dec 26, 2018

More things to consider for final API design:

  • should be able to modify scopes by adding removing declarations
    • should only work on a forked Resolver to not interfere with other users of that Resolver
  • should be able to get a Symbol by name (e.g. arguments)
    • probably requires direct access to Scope (would also simplify the previous bullet point)
  • needs a way to distinguish the following cases
    • implicitly available identifier (arguments)
    • identifier from merged declaration (namespace and enum)
    • no declaration found

@ajafff
Copy link
Owner Author

ajafff commented Jan 12, 2019

If possible it should also track this and super. These are treated as identifiers without declaration like arguments. That means we also need to look for this and super keywords.
In addition this lives in the type and value domain.

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.

Refactor collectVariableUsage
1 participant