Skip to content

Commit

Permalink
Fix issue with namespace definition lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
tonini committed Sep 19, 2015
1 parent 378206d commit f6aeca0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 6 additions & 0 deletions alchemist-server/lib/source.exs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ defmodule Alchemist.Source do
end
defp source(module), do: do_source(module)

defp do_source([head|tail]) do
[head] ++ tail
|> Module.concat
|> do_source
end

defp do_source(module) do
if Code.ensure_loaded? module do
case module.module_info(:compile)[:source] do
Expand Down
6 changes: 5 additions & 1 deletion alchemist-server/test/source_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ defmodule SourceTest do
assert find([String, nil, context]) =~ "lib/elixir/lib/string.ex"
end

test "find call with module namespace" do
context = [context: Elixir, imports: [], aliases: []]
assert find([String.Chars, :to_string, context]) =~ "lib/elixir/lib/string/chars.ex"
end

test "find call for erlang module" do
context = [ context: Elixir, imports: [], aliases: [] ]
assert find([:lists, :duplicate, context]) =~ "lib/stdlib/src/lists.erl"
Expand All @@ -40,5 +45,4 @@ defmodule SourceTest do
context = [ context: Elixir, imports: [], aliases: [] ]
assert find([Rock, :duplicate, context]) == nil
end

end

0 comments on commit f6aeca0

Please sign in to comment.