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

Fix suggestions when using typespecs returning a remote type #282

Merged
merged 1 commit into from
Nov 27, 2023
Merged

Fix suggestions when using typespecs returning a remote type #282

merged 1 commit into from
Nov 27, 2023

Conversation

sarahkw
Copy link
Contributor

@sarahkw sarahkw commented Nov 20, 2023

As shown in the following code:

  defmodule Mod do
    @spec fun() :: NaiveDateTime.t()
    def fun(), do: NaiveDateTime.new(1, 2)

    def some do
      var = fun()
      var.h
      #    ^  suggestion here
    end
  end

It should be able to suggest from NaiveDateTime.

This wasn't working before because the __aliases__ weren't being handled:

iex(1)> Code.string_to_quoted("@spec fun() :: NaiveDateTime.t()")
{:ok,
 {:@, [line: 1],
  [
    {:spec, [line: 1],
     [
       {:"::", [line: 1],
        [
          {:fun, [line: 1], []},
          {{:., [line: 1], [{:__aliases__, [line: 1], [:NaiveDateTime]}, :t]},
           [line: 1], []}
        ]}
     ]}
  ]}}

As shown in the following code:

```
  defmodule Mod do
    @SPEC fun() :: NaiveDateTime.t()
    def fun(), do: NaiveDateTime.new(1, 2)

    def some do
      var = fun()
      var.h
      #    ^  suggestion here
    end
  end
```

It should be able to suggest from NaiveDateTime.

This wasn't working before because the `__aliases__` weren't being
handled:

```
iex(1)> Code.string_to_quoted("@SPEC fun() :: NaiveDateTime.t()")
{:ok,
 {:@, [line: 1],
  [
    {:spec, [line: 1],
     [
       {:"::", [line: 1],
        [
          {:fun, [line: 1], []},
          {{:., [line: 1], [{:__aliases__, [line: 1], [:NaiveDateTime]}, :t]},
           [line: 1], []}
        ]}
     ]}
  ]}}
```
@lukaszsamson
Copy link
Collaborator

Thanks

@lukaszsamson lukaszsamson merged commit 876f166 into elixir-lsp:master Nov 27, 2023
25 of 26 checks passed
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.

2 participants