Skip to content

Commit

Permalink
Add OTP 25 and 25 builtin types
Browse files Browse the repository at this point in the history
Fixes #212
Fixes #190
  • Loading branch information
lukaszsamson committed Oct 14, 2023
1 parent 5587135 commit 4e625ba
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 17 deletions.
34 changes: 22 additions & 12 deletions lib/elixir_sense/core/builtin_types.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ defmodule ElixirSense.Core.BuiltinTypes do
params: [],
doc: "The bottom type, contains no terms"
},
"dynamic" => %{
params: [],
doc: "A type compatible with every type"
},
"atom" => %{
params: [],
doc:
Expand All @@ -32,10 +36,6 @@ defmodule ElixirSense.Core.BuiltinTypes do
doc:
"A reference is a term that is unique in an Erlang runtime system, created by calling `make_ref/0`"
},
"struct" => %{
params: [],
doc: "Any struct"
},
"tuple" => %{
params: [],
doc: "Tuple of any size"
Expand Down Expand Up @@ -63,22 +63,22 @@ defmodule ElixirSense.Core.BuiltinTypes do
"list/1" => %{
params: [:t],
doc: "Proper list ([]-terminated)",
signature: "list(t)"
signature: "list(t())"
},
"nonempty_list/1" => %{
params: [:t],
doc: "Non-empty proper list",
signature: "nonempty_list(t)"
signature: "nonempty_list(t())"
},
"maybe_improper_list/2" => %{
params: [:type1, :type2],
doc: "Proper or improper list (type1=contents, type2=termination)",
signature: "maybe_improper_list(type1, type2)"
signature: "maybe_improper_list(type1(), type2())"
},
"nonempty_improper_list/2" => %{
params: [:type1, :type2],
doc: "Improper list (type1=contents, type2=termination)",
signature: "nonempty_improper_list(type1, type2)"
signature: "nonempty_improper_list(type1(), type2())"
},
"nonempty_maybe_improper_list/2" => %{
params: [:type1, :type2],
Expand All @@ -105,14 +105,24 @@ defmodule ElixirSense.Core.BuiltinTypes do
},
"binary" => %{
params: [],
spec: quote(do: binary() :: <<_::size(8)>>),
spec: quote(do: binary() :: <<_::_*8>>),
doc: "A blob of binary data"
},
"nonempty_binary" => %{
params: [],
spec: quote(do: nonempty_binary() :: <<_::8, _::_*8>>),
doc: "A `binary()` that contains some data"
},
"bitstring" => %{
params: [],
spec: quote(do: bitstring() :: <<_::size(1)>>),
spec: quote(do: bitstring() :: <<_::_*1>>),

Check warning on line 118 in lib/elixir_sense/core/builtin_types.ex

View workflow job for this annotation

GitHub Actions / static analysis (Elixir 1.15.x | Erlang/OTP 26.x)

Operation will always return the left side of the expression.
doc: "A bunch of bits"
},
"nonempty_bitstring" => %{
params: [],
spec: quote(do: nonempty_bitstring() :: <<_::1, _::_*1>>),

Check warning on line 123 in lib/elixir_sense/core/builtin_types.ex

View workflow job for this annotation

GitHub Actions / static analysis (Elixir 1.15.x | Erlang/OTP 26.x)

Operation will always return the left side of the expression.
doc: "A `bitstring()` that contains some data"
},
"boolean" => %{
params: [],
spec: quote(do: boolean() :: false | true),
Expand Down Expand Up @@ -140,7 +150,7 @@ defmodule ElixirSense.Core.BuiltinTypes do
},
"fun" => %{
params: [],
spec: quote(do: fun() :: (... -> any)),
spec: quote(do: fun() :: (... -> any())),
doc: "A function"
},
"function" => %{
Expand Down Expand Up @@ -171,7 +181,7 @@ defmodule ElixirSense.Core.BuiltinTypes do
},
"keyword/1" => %{
params: [:t],
spec: quote(do: keyword(t) :: [{atom(), t}]),
spec: quote(do: keyword(t()) :: [{atom(), t()}]),
doc: "A keyword list with values of type `t`"
},
"list" => %{
Expand Down
4 changes: 2 additions & 2 deletions test/elixir_sense/docs_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -1664,7 +1664,7 @@ defmodule ElixirSense.DocsTest do
arity: 1,
module: nil,
metadata: %{builtin: true},
spec: "@type keyword(t) :: [{atom(), t}]",
spec: "@type keyword(t()) :: [{atom(), t()}]",
docs: "A keyword list with values of type `t`",
kind: :type
}
Expand Down Expand Up @@ -1728,7 +1728,7 @@ defmodule ElixirSense.DocsTest do
type: :list,
arity: 1,
module: nil,
spec: "@type list(t)",
spec: "@type list(t())",
metadata: %{builtin: true},
docs: "Proper list ([]-terminated)",
kind: :type
Expand Down
6 changes: 3 additions & 3 deletions test/elixir_sense/suggestions_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -3454,7 +3454,7 @@ defmodule ElixirSense.SuggestionsTest do

assert suggestion.type_spec == "keyword(term())"
assert suggestion.origin == ""
assert suggestion.expanded_spec =~ "@type keyword(t) ::"
assert suggestion.expanded_spec =~ "@type keyword(t()) ::"
assert suggestion.doc == "A keyword list with values of type `t`"
end

Expand Down Expand Up @@ -3835,8 +3835,8 @@ defmodule ElixirSense.SuggestionsTest do

[_, suggestion | _] = suggestions_by_type(:type_spec, buffer)

assert suggestion.spec == "@type list(t)"
assert suggestion.signature == "list(t)"
assert suggestion.spec == "@type list(t())"
assert suggestion.signature == "list(t())"
assert suggestion.arity == 1
assert suggestion.doc == "Proper list ([]-terminated)"
assert suggestion.origin == nil
Expand Down

0 comments on commit 4e625ba

Please sign in to comment.