-
-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New project structure / beginning of plugins (#184)
* New project structure / beginning of plugins Making plugins necessitated a new project structure, as we're going to need to publish a separate library for plugin authors so they can use them. We'll also need a bunch of the modules they'll use, so we need the least stressful way of depending on the libraries we publish. Creating a separate repo would make our lives very difficult, so I added a projects directory at the top level, and the published libraries go in there. We utilize path dependencies for our internal libraries. I also added the beginnings of a plugin architecture, but I wanted to get this change out before it gets too big. Plugins are quite complicated, and we're going to need to do a bit of refactoring when we add one. That refactoring, plus all of this moving would make the PR very difficult to review. This PR also includes a new genserver dispatcher so that the compile tracer isn't slowed down by extraneous work. * Renamed lexical library to lexical_shared The name lexical conflicted with the language server's app and formatting would fail because it was using lexical's mix project. This was also reflected by the necessity of creating a unique name for the project, the fix was just masking the problem. * Made best-effort to find formatter options If we can't find the formatter, we were running the formatter with default options, which would be annoying if you've configured the formatter, and you'd just get the defaults. This could be annoying. This change makes a best effort to find the .formatter.exs in the parent directories of your application, and it stops at the app root. If it's not found in any of the parents, you get default options. * Automated included apps I kept having to update the apps at the top of this file whenever I added, removed or renamed a dependency. This is annoying, and I thought it would be a lot easier to just let the mix.exs control which apps are needed by remote_control.
- Loading branch information
Showing
72 changed files
with
662 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
project_dirs = lexical_shared lexical_plugin lexical_test | ||
dialyzer_dirs = lexical_shared lexical_plugin | ||
|
||
compile.all: compile.projects compile.umbrella | ||
|
||
dialyzer.all: compile.all dialyzer.projects dialyzer.umbrella | ||
|
||
test.all: test.projects test.umbrella | ||
|
||
dialyzer.umbrella: | ||
mix dialyzer | ||
|
||
dialyzer.projects: | ||
$(foreach dir, $(dialyzer_dirs), cd projects/$(dir) && mix dialyzer && cd ../..;) | ||
|
||
test.umbrella: | ||
mix test | ||
|
||
test.projects: | ||
cd projects | ||
$(foreach dir, $(project_dirs), cd projects/$(dir) && mix test && cd ../..;) | ||
|
||
compile.umbrella: compile.projects | ||
mix deps.get | ||
mix compile --skip-umbrella-children | ||
|
||
compile.projects: | ||
cd projects | ||
$(foreach dir, $(project_dirs), cd projects/$(dir) && mix deps.get && mix do clean, compile --warnings-as-errors && cd ../..;) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
apps/remote_control/lib/lexical/remote_control/compilation/dispatch.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
defmodule Lexical.RemoteControl.Compilation.Dispatch do | ||
alias Lexical.RemoteControl | ||
alias Lexical.RemoteControl.Api.Messages | ||
alias Lexical.RemoteControl.Build | ||
alias Lexical.RemoteControl.ModuleMappings | ||
alias Lexical.RemoteControl.Plugin | ||
|
||
import Messages | ||
use GenServer | ||
|
||
def dispatch(module_updated() = message) do | ||
GenServer.cast(__MODULE__, {:dispatch, message}) | ||
end | ||
|
||
def start_link(_) do | ||
GenServer.start_link(__MODULE__, [], name: __MODULE__) | ||
end | ||
|
||
def init(_) do | ||
{:ok, nil} | ||
end | ||
|
||
def handle_cast({:dispatch, module_updated() = message}, state) do | ||
module_updated(name: module_name, file: filename) = message | ||
ModuleMappings.update(module_name, filename) | ||
RemoteControl.notify_listener(message) | ||
Plugin.on_module_updated(module_name) | ||
maybe_report_progress(filename) | ||
{:noreply, state} | ||
end | ||
|
||
defp maybe_report_progress(file) do | ||
if Path.extname(file) == ".ex" do | ||
file | ||
|> progress_message() | ||
|> RemoteControl.notify_listener() | ||
end | ||
end | ||
|
||
defp progress_message(file) do | ||
relative_path_elements = | ||
file | ||
|> Path.relative_to_cwd() | ||
|> Path.split() | ||
|
||
base_dir = List.first(relative_path_elements) | ||
file_name = List.last(relative_path_elements) | ||
|
||
message = "compiling: " <> Path.join([base_dir, "...", file_name]) | ||
|
||
label = Build.State.building_label(RemoteControl.get_project()) | ||
project_progress(label: label, message: message) | ||
end | ||
end |
Oops, something went wrong.