Skip to content

Commit

Permalink
feat: add params to symbols table (#397)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucacervello authored Mar 14, 2024
1 parent 4aa157f commit 7c6941b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
4 changes: 2 additions & 2 deletions lib/next_ls.ex
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ defmodule NextLS do
[] ->
nil

[[_pk, _mod, file, _type, _name, line, column | _] | _] ->
[[_pk, _mod, file, _type, _name, _params, line, column | _] | _] ->
%Location{
uri: "file://#{file}",
range: %Range{
Expand Down Expand Up @@ -450,7 +450,7 @@ defmodule NextLS do
[]
)

for [_pk, module, file, type, name, line, column | _] <- rows do
for [_pk, module, file, type, name, _params, line, column | _] <- rows do
%{
module: module,
file: file,
Expand Down
17 changes: 13 additions & 4 deletions lib/next_ls/db.ex
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,23 @@ defmodule NextLS.DB do
)
end

for {name, {:v1, type, _meta, clauses}} <- defs, {meta, _, _, _} <- clauses do
for {name, {:v1, type, _meta, clauses}} <- defs, {meta, params, _, _} <- clauses do
__query__(
{conn, s.logger},
~Q"""
INSERT INTO symbols (module, file, type, name, line, 'column', source)
VALUES (?, ?, ?, ?, ?, ?, ?);
INSERT INTO symbols (module, file, type, name, params, line, 'column', source)
VALUES (?, ?, ?, ?, ?, ?, ?, ?);
""",
[mod, file, type, name, meta[:line], meta[:column] || 1, source]
[
mod,
file,
type,
name,
:erlang.term_to_binary(params),
meta[:line],
meta[:column] || 1,
source
]
)
end

Expand Down
3 changes: 2 additions & 1 deletion lib/next_ls/db/schema.ex
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ defmodule NextLS.DB.Schema do

alias NextLS.DB

@version 5
@version 6

def init(conn) do
# FIXME: this is odd tech debt. not a big deal but is confusing
Expand Down Expand Up @@ -80,6 +80,7 @@ defmodule NextLS.DB.Schema do
file text NOT NULL,
type text NOT NULL,
name text NOT NULL,
params blob,
line integer NOT NULL,
column integer NOT NULL,
source text NOT NULL DEFAULT 'user',
Expand Down

0 comments on commit 7c6941b

Please sign in to comment.