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

feat(language-service): Provide ability to rename pipes #40523

Closed
wants to merge 6 commits into from

Commits on May 4, 2021

  1. refactor(language-service): Update file names for references and rename

    This commit renames the files for the references and rename functionality to indicate
    that they deal with _both_ references and rename, not just references.
    atscott committed May 4, 2021
    Copy the full SHA
    cf3fea6 View commit details
    Browse the repository at this point in the history
  2. refactor(language-service): extract utility functions for reference a…

    …nd rename
    
    This commit extracts utility functions and separates them from the core logic of the
    references and rename builder.
    atscott committed May 4, 2021
    Copy the full SHA
    cd83b61 View commit details
    Browse the repository at this point in the history
  3. refactor(language-service): Separate reference and rename capabilities

    This commit separates the reference and rename functions into separate builders so it's easier
    to locate functions specific to each
    atscott committed May 4, 2021
    Copy the full SHA
    2f87b26 View commit details
    Browse the repository at this point in the history

Commits on May 6, 2021

  1. feat(language-service): Enable renaming of pipes

    This commit updates the logic in the LS renaming to handle renaming of
    pipes, both from the name expression in the pipe metadata as well as
    from the template.
    
    The approach here is to introduce a new concept for renaming: an
    "indirect" rename. In this type of rename, we find rename locations
    in with the native TS Language Service using a different node than the
    one we are renaming. Using pipes as an example, if we want to rename the
    pipe name from the string literal expression, we use the transform
    method to find rename locations rather than the string literal itself
    (which will not return any results because it's just a string).
    
    So the general approach is:
    * Determine the details about the requested rename location, i.e. the
      targeted template node and symbol for a template rename, or the TS
      node for a rename outside a template.
    * Using the details of the location, determine if the node is attempting
      to rename something that is an indirect rename (pipes, selectors,
      bindings). Other renames are considered "direct" and we use whatever
      results the native TSLS returns for the rename locations.
    * In the case of indirect renames, we throw out results that do not
      appear in the templates (in this case, the shim files). These results will be
      for the "indirect" rename that we don't want to touch, but are only
      using to find template results.
    * Create an additional rename result for the string literal expression
      that is used for the input/output alias, the pipe name, or the
      selector.
    
     Note that renaming is moving towards being much more accurate in its
     results than "find references". When the approach for renaming
     stabilizes, we may want to then port the changes back to being shared
     with the approach for retrieving references.
    atscott committed May 6, 2021
    Copy the full SHA
    f2330c2 View commit details
    Browse the repository at this point in the history
  2. refactor(compiler-cli): Adjust generated TCB when checkTypeOfPipes is…

    … false
    
    When `checkTypeOfPipes` is set to `false`, our TCB currently generates
    the a statement like the following when pipes appear in the template:
    `(_pipe1 as any).transform(args)`
    
    This did enable us to get _some_ information from the Language Service
    about pipes in this case because we still had access to the pipe
    instance. However, because it is immediately cast to `any`, we cannot
    get type information about the transform access. That means actions like "go to
    definition", "find references", "quick info", etc. will return
    incomplete information or fail altogether.
    
    Instead, this commit changes the TCB to generate `(_pipe1.transform as any)(args)`.
    This gives us the ability to get complete information for the LS
    operations listed above.
    atscott committed May 6, 2021
    Copy the full SHA
    cb1f5c4 View commit details
    Browse the repository at this point in the history
  3. fix(language-service): fully de-duplicate reference and rename results

    Rather than de-duplicating results as we build them, a final de-duplication can be done at the end.
    This way, there's no forgetting to de-duplicate results at some level.
    
    Prior to this commit, results from template locations that mapped to
    multiple different typescript locations would not be de-duplicated (e.g.
    an input binding that is bound to two separate directives).
    atscott committed May 6, 2021
    Copy the full SHA
    3b961b4 View commit details
    Browse the repository at this point in the history