Skip to content

Commit

Permalink
Minor housekeeping (#784)
Browse files Browse the repository at this point in the history
* Update erlex, remove unused `require Logger`, add test for `prefix_stream/2`

* fix credo errors
  • Loading branch information
Moosieus authored Jul 3, 2024
1 parent ef171d2 commit af93050
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 2 deletions.
1 change: 0 additions & 1 deletion apps/common/lib/lexical/ast/tokens.ex
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
defmodule Lexical.Ast.Tokens do
alias Lexical.Document
alias Lexical.Document.Position
require Logger

@doc """
Returns a stream of tokens starting at the given position and working backwards through
Expand Down
51 changes: 51 additions & 0 deletions apps/common/test/lexical/ast/tokens_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
defmodule Lexical.Ast.TokensTest do
alias Lexical.Ast.Tokens

import Lexical.Test.CodeSigil
import Lexical.Test.CursorSupport

use ExUnit.Case, async: true

describe "prefix_stream/2" do
test "works as intended" do
text = ~q[
defmodule Foo do
def bar do
|
end
end
]

{position, document} = pop_cursor(text, as: :document)

tokens = Tokens.prefix_stream(document, position)

assert Enum.to_list(tokens) == [
{:eol, ~c"\n", []},
{:operator, :do, {2, 11}},
{:do_identifier, ~c"bar", {2, 7}},
{:identifier, ~c"def", {2, 3}},
{:eol, ~c"\n", []},
{:operator, :do, {1, 15}},
{:alias, ~c"Foo", {1, 11}},
{:identifier, ~c"defmodule", {1, 1}}
]
end

test "returns nothing when cursor is at start" do
text = ~q[
|defmodule Foo do
def bar do
:bar
end
end
]

{position, document} = pop_cursor(text, as: :document)

tokens = Tokens.prefix_stream(document, position)

assert Enum.to_list(tokens) == []
end
end
end
2 changes: 1 addition & 1 deletion mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"dialyxir": {:hex, :dialyxir, "1.4.3", "edd0124f358f0b9e95bfe53a9fcf806d615d8f838e2202a9f430d59566b6b53b", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "bf2cfb75cd5c5006bec30141b131663299c661a864ec7fbbc72dfa557487a986"},
"earmark_parser": {:hex, :earmark_parser, "1.4.32", "fa739a0ecfa34493de19426681b23f6814573faee95dfd4b4aafe15a7b5b32c6", [:mix], [], "hexpm", "b8b0dd77d60373e77a3d7e8afa598f325e49e8663a51bcc2b88ef41838cca755"},
"elixir_sense": {:git, "https://github.com/elixir-lsp/elixir_sense.git", "4adfc55dc6902f56e6d070e14fba768a0ff05bd3", []},
"erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"},
"erlex": {:hex, :erlex, "0.2.7", "810e8725f96ab74d17aac676e748627a07bc87eb950d2b83acd29dc047a30595", [:mix], [], "hexpm", "3ed95f79d1a844c3f6bf0cea61e0d5612a42ce56da9c03f01df538685365efb0"},
"ex_doc": {:hex, :ex_doc, "0.29.4", "6257ecbb20c7396b1fe5accd55b7b0d23f44b6aa18017b415cb4c2b91d997729", [:mix], [{:earmark_parser, "~> 1.4.31", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "2c6699a737ae46cb61e4ed012af931b57b699643b24dabe2400a8168414bc4f5"},
"file_system": {:hex, :file_system, "1.0.0", "b689cc7dcee665f774de94b5a832e578bd7963c8e637ef940cd44327db7de2cd", [:mix], [], "hexpm", "6752092d66aec5a10e662aefeed8ddb9531d79db0bc145bb8c40325ca1d8536d"},
"jason": {:hex, :jason, "1.4.1", "af1504e35f629ddcdd6addb3513c3853991f694921b1b9368b0bd32beb9f1b63", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "fbb01ecdfd565b56261302f7e1fcc27c4fb8f32d56eab74db621fc154604a7a1"},
Expand Down

0 comments on commit af93050

Please sign in to comment.