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: add params to symbols table #397

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading