From 7c6941b9664451e0452384ccc153a1eb5a9ef72a Mon Sep 17 00:00:00 2001 From: Luca Cervello Date: Thu, 14 Mar 2024 18:26:20 +0100 Subject: [PATCH] feat: add params to symbols table (#397) --- lib/next_ls.ex | 4 ++-- lib/next_ls/db.ex | 17 +++++++++++++---- lib/next_ls/db/schema.ex | 3 ++- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/lib/next_ls.ex b/lib/next_ls.ex index 833120e4..b320f6d5 100644 --- a/lib/next_ls.ex +++ b/lib/next_ls.ex @@ -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{ @@ -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, diff --git a/lib/next_ls/db.ex b/lib/next_ls/db.ex index bd5819a1..6f1d63a2 100644 --- a/lib/next_ls/db.ex +++ b/lib/next_ls/db.ex @@ -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 diff --git a/lib/next_ls/db/schema.ex b/lib/next_ls/db/schema.ex index c9856fcf..455ded65 100644 --- a/lib/next_ls/db/schema.ex +++ b/lib/next_ls/db/schema.ex @@ -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 @@ -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',