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

Improved hover support: Structs, qualified calls and types, more info for modules #356

Merged
merged 33 commits into from
Sep 22, 2023

Commits on Sep 21, 2023

  1. Support struct hover

    zachallaun committed Sep 21, 2023
    Configuration menu
    Copy the full SHA
    f69137a View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    f6cc0f8 View commit details
    Browse the repository at this point in the history
  3. Clean up Lexical.RemoteControl.CodeIntelligence.Docs

    This moves all of the fetching of docs, specs, types, and callbacks into
    `Lexical.RemoteControl.Modules`. Those functions now also operate on
    BEAM object code, which means the object code doesn't need to be
    repeatedly read from disk. The object code for a module also appears to
    be available immediately after calling `Code.ensure_compiled(module)`,
    which allows us to get rid of a timeout/loop that was waiting for it to
    be written to disk.
    zachallaun committed Sep 21, 2023
    Configuration menu
    Copy the full SHA
    2321c40 View commit details
    Browse the repository at this point in the history
  4. Add Lexical.Ast.is_call/2 guard

    The correct guard logic for a call is quite verbose, as you must ensure
    that the call in a `{call, meta, args}` node isn't a special form, like
    `:__aliases__`.
    zachallaun committed Sep 21, 2023
    Configuration menu
    Copy the full SHA
    c020e0d View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    392ae41 View commit details
    Browse the repository at this point in the history
  6. Include callbacks in module hover and fix Ast position finding

    This commit currently pulls in a to-be-merged branch of `Sourceror` which
    contains fixes and changes around `Sourceror.get_range/1`. These are required
    in order to accurately determine the cursor position in an AST.
    
    An additional important change that this commit makes is to add the `unescape:
    false` option when converting strings to quoted forms. This is needed to
    determine whether newlines in strings were escaped literals (`\n`) or
    multi-line.
    
    Take this example:
    
        iex> Code.string_to_quoted!(~S|"foo\nbar"|)
        "foo\nbar"
    
        iex> Code.string_to_quoted!(~S|"foo
        ...> bar"|)
        "foo\nbar"
    
        iex> Code.string_to_quoted!(~S|"foo\nbar"|, unescape: false)
        "foo\\nbar"
    
        iex> Code.string_to_quoted!(~S|"foo
        ...> bar"|, unescape: false)
        "foo\nbar"
    
    Note that, with `unescape: false`, there is a difference between the strings.
    zachallaun committed Sep 21, 2023
    Configuration menu
    Copy the full SHA
    34e2e55 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    0371755 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    d0d8f57 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    7517e85 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    48d8848 View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    0815f4b View commit details
    Browse the repository at this point in the history
  12. Fix spec

    zachallaun committed Sep 21, 2023
    Configuration menu
    Copy the full SHA
    201f422 View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    e74c754 View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    6b44721 View commit details
    Browse the repository at this point in the history
  15. Remove dead code

    zachallaun committed Sep 21, 2023
    Configuration menu
    Copy the full SHA
    de36f18 View commit details
    Browse the repository at this point in the history
  16. Simplify is_call guard

    zachallaun committed Sep 21, 2023
    Configuration menu
    Copy the full SHA
    9bfa9aa View commit details
    Browse the repository at this point in the history
  17. Configuration menu
    Copy the full SHA
    9592956 View commit details
    Browse the repository at this point in the history
  18. Remove old comment

    zachallaun committed Sep 21, 2023
    Configuration menu
    Copy the full SHA
    3b68808 View commit details
    Browse the repository at this point in the history
  19. Configuration menu
    Copy the full SHA
    5327e47 View commit details
    Browse the repository at this point in the history
  20. Configuration menu
    Copy the full SHA
    4f2591f View commit details
    Browse the repository at this point in the history
  21. Improve Lexical.Test.CursorSupport API

    There were a few commonalities in all existing usage of `CursorSupport`:
    
    1. In almost all usage, `cursor_position` and `strip_cursor` are used
       together.
    2. In all usage, the returned `{line, column}` tuple could/should be
       a `Lexical.Document.Position`.
    3. In many cases, the stripped text is then used to create
       a `Lexical.Document`.
    
    To address these, a higher level `pop_cursor/2` has been added, returning
    `{%Position{}, stripped_text}` by default. However, by using the `:as` or
    `:document` options, `pop_cursor/2` can return `{%Position{}, %Document{}}`,
    reducing a significant amount of boilerplate.
    
    This change also has the effect of reducing the number of tests requiring
    `PositionSupport`.
    zachallaun committed Sep 21, 2023
    Configuration menu
    Copy the full SHA
    1258b5e View commit details
    Browse the repository at this point in the history
  22. Configuration menu
    Copy the full SHA
    0bafbd8 View commit details
    Browse the repository at this point in the history
  23. Configuration menu
    Copy the full SHA
    306b78e View commit details
    Browse the repository at this point in the history
  24. Configuration menu
    Copy the full SHA
    9c899a6 View commit details
    Browse the repository at this point in the history
  25. Configuration menu
    Copy the full SHA
    492ae8d View commit details
    Browse the repository at this point in the history
  26. Configuration menu
    Copy the full SHA
    a960337 View commit details
    Browse the repository at this point in the history
  27. Configuration menu
    Copy the full SHA
    bc0b963 View commit details
    Browse the repository at this point in the history
  28. Bump Sourceror

    zachallaun committed Sep 21, 2023
    Configuration menu
    Copy the full SHA
    ef6e777 View commit details
    Browse the repository at this point in the history
  29. Configuration menu
    Copy the full SHA
    916c211 View commit details
    Browse the repository at this point in the history
  30. Configuration menu
    Copy the full SHA
    cfc3476 View commit details
    Browse the repository at this point in the history
  31. Configuration menu
    Copy the full SHA
    fb4d977 View commit details
    Browse the repository at this point in the history
  32. When resolving a struct, always resolve full alias

    When resolving modules, we'll exclude segments trailing the cursor so
    that you can walk up a module to better understand its context. For
    instance, for `My.|Nested.Module`, we resolve to `My.Nested`.
    
    Using the same behavior for structs makes less sense. If you're hovering
    a module being used as a struct, often only the full alias is actually
    a struct; the parents might not be. For instance, with
    `%My.|Nested.Struct{}`, resolving to `My.Nested` will not yield useful
    results. Because of this, the full alias is now always resolved in a
    struct context, so the above would resolve to the struct
    `My.Nested.Struct`.
    zachallaun committed Sep 21, 2023
    Configuration menu
    Copy the full SHA
    bac214e View commit details
    Browse the repository at this point in the history
  33. Configuration menu
    Copy the full SHA
    d46b08f View commit details
    Browse the repository at this point in the history