Skip to content

Commit 9345e31

Browse files
authored
fix: revert dev server (#48)
* Revert "fix: use correct build directory when namespacing expert" This reverts commit b6540dd. * Revert "fix: properly set the mix env when building expert" This reverts commit 4caf258. * Revert "chore: support dev server using tcp transport (#43)" This reverts commit 15581e7. * chore: remove just start docs
1 parent b6540dd commit 9345e31

File tree

20 files changed

+205
-369
lines changed

20 files changed

+205
-369
lines changed

.iex.exs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
use Expert.IEx.Helpers
2+
3+
try do
4+
Mix.ensure_application!(:observer)
5+
rescue
6+
_ -> nil
7+
end

.iex.namespaced.exs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
use XPExpert.Server.IEx.Helpers
2+
alias XPExpert, as: EXpert

apps/engine/lib/engine/plugin/discovery.ex

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ defmodule Engine.Plugin.Discovery do
1717

1818
@namespaced_document_module [:Forge, :Document]
1919
|> Module.concat()
20-
|> Forge.Namespace.Module.run(apps: [:forge], roots: [Forge])
20+
|> Forge.Namespace.Module.apply()
2121

2222
def run do
2323
for {app_name, _, _} <- :application.loaded_applications(),
@@ -49,12 +49,10 @@ defmodule Engine.Plugin.Discovery do
4949
end
5050

5151
defp namespace_module(module) when is_atom(module) do
52-
app = Application.get_application(module)
53-
5452
module
5553
|> :code.which()
5654
|> List.to_string()
57-
|> Forge.Namespace.Transform.Beams.apply_to_all(apps: [app])
55+
|> Forge.Namespace.Transform.Beams.apply()
5856
end
5957

6058
defp unload_module(module) do

apps/expert/.iex.exs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
alias Forge.Project
2+
3+
other_project =
4+
[
5+
File.cwd!(),
6+
"..",
7+
"..",
8+
"..",
9+
"eakins"
10+
]
11+
|> Path.join()
12+
|> Path.expand()
13+
14+
project = Forge.Project.new("file://#{other_project}")

apps/expert/lib/expert/application.ex

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,13 @@ defmodule Expert.Application do
1212

1313
@impl true
1414
def start(_type, _args) do
15-
{m, f, a} = Application.get_env(:expert, :arg_parser)
16-
17-
argv = apply(m, f, a)
18-
19-
{opts, _, _invalid} =
20-
OptionParser.parse(argv,
21-
strict: [port: :integer]
22-
)
23-
24-
buffer_opts =
25-
case opts[:port] do
26-
port when is_integer(port) ->
27-
[communication: {GenLSP.Communication.TCP, [port: port]}]
28-
29-
_ ->
30-
[]
31-
end
32-
3315
children = [
3416
document_store_child_spec(),
3517
{DynamicSupervisor, Expert.Project.DynamicSupervisor.options()},
3618
{DynamicSupervisor, name: Expert.DynamicSupervisor},
3719
{GenLSP.Assigns, [name: Expert.Assigns]},
3820
{Task.Supervisor, name: :expert_task_queue},
39-
{GenLSP.Buffer, [name: Expert.Buffer] ++ buffer_opts},
21+
{GenLSP.Buffer, name: Expert.Buffer},
4022
{Expert,
4123
name: Expert,
4224
buffer: Expert.Buffer,

apps/expert/lib/expert/engine_node.ex

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -166,19 +166,11 @@ defmodule Expert.EngineNode do
166166
# When Engine is built in CI for a version matrix, we'll need to check if
167167
# we have the right version downloaded, and if not, we should download it.
168168
defp glob_paths do
169-
engine_path = System.get_env("EXPERT_ENGINE_PATH", default_engine_path())
170-
171-
Logger.info("Using Engine path: #{Path.expand(engine_path)}")
172-
173-
engine_path
174-
|> Path.expand()
169+
:expert
170+
|> :code.priv_dir()
175171
|> Path.join("lib/**/ebin")
176172
|> Path.wildcard()
177173
end
178-
179-
defp default_engine_path do
180-
:expert |> :code.priv_dir() |> Path.join("engine")
181-
end
182174
end
183175

184176
@stop_timeout 1_000

apps/expert/lib/expert/release.ex

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
defmodule Expert.Release do
22
def assemble(release) do
3+
Mix.Task.run(:namespace, [release.path])
4+
35
engine_path = Path.expand("../../../engine", __DIR__)
46

57
source = Path.join([engine_path, "_build/dev_ns"])
@@ -8,13 +10,10 @@ defmodule Expert.Release do
810
Path.join([
911
release.path,
1012
"lib",
11-
"#{release.name}-#{release.version}",
12-
"priv",
13-
"engine"
13+
"xp_expert-#{release.version}",
14+
"priv"
1415
])
1516

16-
File.mkdir_p!(dest)
17-
1817
File.cp_r!(source, dest)
1918

2019
release

apps/expert/mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ defmodule Expert.MixProject do
2323

2424
def application do
2525
[
26-
extra_applications: [:logger, :runtime_tools, :kernel, :erts, :observer, :wx],
26+
extra_applications: [:logger, :runtime_tools, :kernel, :erts, :observer],
2727
mod: {Expert.Application, []}
2828
]
2929
end

apps/forge/lib/forge/namespace/abstract.ex

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,6 @@ defmodule Forge.Namespace.Abstract do
66
https://www.erlang.org/doc/apps/erts/absform.html
77
"""
88

9-
def code_from(path) do
10-
with {:ok, {_orig_module, code_parts}} <- :beam_lib.chunks(path, [:abstract_code]),
11-
{:ok, {:raw_abstract_v1, forms}} <- Keyword.fetch(code_parts, :abstract_code) do
12-
{:ok, forms}
13-
else
14-
_ ->
15-
{:error, :not_found}
16-
end
17-
end
18-
19-
def run(abstract_format, opts) when is_list(abstract_format) do
20-
fn ->
21-
Process.put(:abstract_code_opts, opts)
22-
Enum.map(abstract_format, fn af -> rewrite(af) end)
23-
end
24-
|> Task.async()
25-
|> Task.await()
26-
end
27-
289
def rewrite(abstract_format) when is_list(abstract_format) do
2910
Enum.map(abstract_format, &rewrite/1)
3011
end
@@ -313,7 +294,6 @@ defmodule Forge.Namespace.Abstract do
313294
end
314295

315296
defp rewrite_module(module) do
316-
opts = Process.get(:abstract_code_opts)
317-
Forge.Namespace.Module.run(module, opts)
297+
Forge.Namespace.Module.apply(module)
318298
end
319299
end

apps/forge/lib/forge/namespace/module.ex

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
11
defmodule Forge.Namespace.Module do
22
@namespace_prefix "XP"
33

4-
def run(module_name, opts) do
5-
apps = Keyword.fetch!(opts, :apps)
6-
roots = Keyword.fetch!(opts, :roots)
7-
4+
def apply(module_name) do
85
cond do
96
prefixed?(module_name) ->
107
module_name
118

12-
opts[:do_apps] && module_name in apps ->
9+
module_name in Mix.Tasks.Namespace.app_names() ->
1310
:"xp_#{module_name}"
1411

1512
true ->
1613
module_name
1714
|> Atom.to_string()
18-
|> apply_namespace(roots)
15+
|> apply_namespace()
1916
end
2017
end
2118

@@ -31,7 +28,7 @@ defmodule Forge.Namespace.Module do
3128
def prefixed?(@namespace_prefix <> _),
3229
do: true
3330

34-
def prefixed?("xp_" <> _),
31+
def prefixed?("xp" <> _),
3532
do: true
3633

3734
def prefixed?([?x, ?p, ?_ | _]), do: true
@@ -41,9 +38,8 @@ defmodule Forge.Namespace.Module do
4138
def prefixed?(_),
4239
do: false
4340

44-
defp apply_namespace("Elixir." <> rest, roots) do
45-
roots
46-
|> Enum.filter(fn module -> Macro.classify_atom(module) == :alias end)
41+
defp apply_namespace("Elixir." <> rest) do
42+
Mix.Tasks.Namespace.root_modules()
4743
|> Enum.map(fn module -> module |> Module.split() |> List.first() end)
4844
|> Enum.reduce_while(rest, fn root_module, module ->
4945
if has_root_module?(root_module, module) do
@@ -61,14 +57,8 @@ defmodule Forge.Namespace.Module do
6157
|> Module.concat()
6258
end
6359

64-
defp apply_namespace(erlang_module, roots) do
65-
erlang_module = String.to_atom(erlang_module)
66-
67-
if erlang_module in roots do
68-
:"xp_#{erlang_module}"
69-
else
70-
erlang_module
71-
end
60+
defp apply_namespace(erlang_module) do
61+
String.to_atom(erlang_module)
7262
end
7363

7464
defp has_root_module?(root_module, root_module), do: true

0 commit comments

Comments
 (0)