Skip to content

Commit

Permalink
refactor: use BETWEEN operator (#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
dvic authored Aug 13, 2023
1 parent 4362d66 commit 6098bad
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
6 changes: 3 additions & 3 deletions lib/next_ls.ex
Original file line number Diff line number Diff line change
Expand Up @@ -672,8 +672,8 @@ defmodule NextLS do
SELECT identifier, type, module
FROM "references" refs
WHERE refs.file = ?
AND refs.start_line <= ? AND refs.end_line >= ?
AND refs.start_column <= ? AND refs.end_column >= ?
AND ? BETWEEN refs.start_line AND refs.end_line
AND ? BETWEEN refs.start_column AND refs.end_column
ORDER BY refs.id ASC
LIMIT 1
"""
Expand All @@ -695,7 +695,7 @@ defmodule NextLS do
{:function, module, function}

_unknown_definition ->
case DB.query(database, reference_query, [file, line, line, col, col]) do
case DB.query(database, reference_query, [file, line, col]) do
[[function, "function", module]] ->
{:function, module, function}

Expand Down
8 changes: 3 additions & 5 deletions lib/next_ls/definition.ex
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@ defmodule NextLS.Definition do
'references' AS refs
WHERE
refs.file = ?
AND refs.start_line <= ?
AND ? <= refs.end_line
AND refs.start_column <= ?
AND ? <= refs.end_column
AND ? BETWEEN refs.start_line AND refs.end_line
AND ? BETWEEN refs.start_column AND refs.end_column
ORDER BY refs.id asc
LIMIT 1;
""",
[file, line, line, col, col]
[file, line, col]
) do
query =
~Q"""
Expand Down

0 comments on commit 6098bad

Please sign in to comment.