Git Product home page Git Product logo

intellij-elixir's Introduction

Table of Contents generated with DocToc

Elixir plugin

Build Status

This is a plugin that adds support for Elixir to JetBrains IntelliJ IDEA platform IDEs (0xDBE, AppCode, IntelliJ IDEA, PHPStorm, PyCharm, Rubymine, WebStorm).

It works with the free, open source Community edition of IntelliJ IDEA in addition to the paid JetBrains IDEs like Ultimate edition of IntelliJ. No feature is locked to a the paid version of the IDEs, but the plugin works best in IntelliJ because only IntelliJ supports projects with different languages than the default (Java for IntelliJ, Ruby for Rubymine, etc).

The plugin itself is free. Once you have your IDE of choice installed, you can install this plugin

Features

Project

NOTE: This feature only works in IntelliJ IDEA as it depends on an extension point unavailable in language-specific IDEs, like Rubymine.

New

If you want to create a basic (non-mix) Elixir project with a lib directory, perform the following steps.

  1. File > New > Project File > New > Project
  2. Select Elixir from the project type menu on the left
  3. Click Next File > New > Project > Elixir
  4. Select a Project SDK directory by clicking Configure. Project SDK
  5. Select a Project SDK directory by clicking Configure.
  6. The plugin will automatically find the newest version of Elixir installed. (NOTE: SDK detection only works for Linux, homebrew installs on OSX, and Windows. Open an issue with information about Elixir install locations on your operating system and package manager to have SDK detection added for it.)
  7. If the automatic detection doesn't find your Elixir SDK or you want to use an older version, manually select select the directory above the bin directory containing elixir, elixirc, iex, and mix.
  8. Click Next after you select SDK name from the Project SDK list.
  9. Change the Project name to the name your want for the project File > New > Project > Settings
  10. (Optionally) change the Project location if the directory does not match what you want
  11. (Optionally) expand More Settings to change the Module name, Content root, Module file location, and/or Project format. The defaults derived from the Project name and Project location should work for most projects.
  12. Click Finish
  13. Choose whether to open in a New Window or in This Window. File > New > Project > Window

From Existing Sources

Create project from existing sources

If you've already created a (non-mix) project, you can load it as an Elixir project into the plugin.

  1. File > New > Project From Existing Sources...
  2. Select the root directory of your project.
  3. Leave the default selection, "Create project from existing sources"
  4. Click Next
  5. Project name will be filled with the basename of the root directory. Customize it if you like.
  6. Project location will be the root directory.
  7. Click Next.
  8. If you previously opened the directory in IntelliJ or another JetBrains IDE, you'll be prompted to overwrite the .idea directory. Click Yes.
  9. You'll be prompted with a list of detected Elixir project roots to add to the project. Each root contains a mix.exs. Uncheck any project roots that you don't want added.
  10. Click Next.
  11. Select a Project SDK directory by clicking Configure.
  12. The plugin will automatically find the newest version of Elixir installed. (NOTE: SDK detection only works for Linux, homebrew installs on OSX, and Windows. Open an issue with information about Elixir install locations on your operating system and package manager to have SDK detection added for it.)
  13. If the automatic detection doesn't find your Elixir SDK or you want to use an older version, manually select select the directory above the bin directory containing elixir, elixirc, iex, and mix.
  14. Click Next after you select SDK name from the Project SDK list.
  15. Click Finish on the framework page. (No framework detection is implemented yet for Elixir.)
  16. Choose whether to open in a New Window or in This Window.
Import project from external model

If you've already created a mix project, you can load it as an Elixir project into the plugin.

  1. File > New > Project From Existing Sources...
  2. Select the root directory of your project.
  3. Select "Import project from external model"
  4. Select Mix File > New Project > From Existing Sources > Import project from external model > Mix
  5. Click Next
  6. The "Mix project root" will be filled in with the selected directory.
  7. (Optional) Uncheck "Fetch dependencies with mix" if you don't want to run mix deps.get when importing the project
  8. Ensure the correct "Mix Path" is detected. On Windows, the mix.bat, such as C:\Program Files (x86)\Elixir\bin\mix.bat should be used instead of the mix file without the extension.
  9. Ensure the "Mix Version" is as expected. The number in parentheses should match the Elixir version.
  10. Click Next
  11. All directories with mix.exs files will be selected as "Mix projects to import". To import just the main project and not its dependencies, click Unselect All.
  12. Check the box next to the project root to use only its mix.exs. (It will likely be the first checkbox at the top.)
  13. Click Next
  14. Select a Project SDK directory by clicking Configure.
  15. The plugin will automatically find the newest version of Elixir installed. (NOTE: SDK detection only works for Linux, homebrew installs on OSX, and Windows. Open an issue with information about Elixir install locations on your operating system and package manager to have SDK detection added for it.)
  16. If the automatic detection doesn't find your Elixir SDK or you want to use an older version, manually select select the directory above the bin directory containing elixir, elixirc, iex, and mix. (On Windows it is the directory containing elixir.bat, elixirc.bat, iex.bat, and mix.bat.)
  17. Click Finish after you select SDK name from the Project SDK list.

Project Structure

Project View

  • Excluded
    • _build (Output from mix)
    • rel (Output from exrm)
  • Sources
    • lib
  • Test Sources
    • test

Project Settings

Project Settings

The Project Settings include

  • Project Name
  • Project SDK

Module Settings

Sources

Module Settings > Sources

The Module Settings include Marking directories as

  • Excluded
  • Sources
  • Tests

Paths

Module Settings > Paths

Module paths list the output directories when compiling code in the module. There is a an "Output path" for dev MIX_ENV and "Test output path" for the test MIX_ENV.

Dependencies

Module Settings > Dependencies

Module dependencies are currently just the SDK and the sources for the module. Dependencies in deps are not automatically detected at this time.

New Elixir File

  1. Right-click a directory (such as lib or test in the standard mix new layout)
  2. Select New > Elixir File. New > Elixir File
  3. Enter an Alias for the Module name, such as MyModule or MyNamespace.MyModule.
  4. Select a Kind of Elixir File to use a different template. New > Elixir File > Kind

Empty module

An underscored file will be created in an underscored directory lib/my_namespace/my_module.ex) with the given module name with be created:

defmodule MyNamespace.MyModule do
  @moduledoc false
  
end

Elixir Application

An underscored file will be created in an underscored directory lib/my_namespace/my_module.ex) with the given module name with be created. It will have a start/2 function that calls MyNamespace.MyModule.Supervisor.start_link/0.

defmodule MyNamespace.MyModule do
  @moduledoc false
  
  use Application

  def start(_type, _args) do
    MyNamespace.MyModule.Supervisor.start_link()
  end
end

Elixir Supervisor

An underscored file will be created in an underscored directory lib/my_namespace/my_module.ex) with the given module name with be created. It will have a start_link/1 function that calls Supervisor.start_link/0 and init/1 that sets up the child specs. It assumes a MyWorker child that should be supervised :one_for_one.

defmodule MyNamespace.MyModule.Supervisor do
  @moduledoc false
  
  use Supervisor

  def start_link(arg) do
    Supervisor.start_link(__MODULE__, arg)
  end

  def init(arg) do
    children = [
      worker(MyWorker, [arg], restart: :temporary)
    ]

    supervise(children, strategy: :one_for_one)
  end
end

Elixir GenServer

An underscored file will be created in an underscored directory lib/my_namespace/my_module.ex) with the given module name with be created. It will have a start_link/2 function that calls GenServer.start_link/3 and the minimal callback implementations for init/1, handle_call/3, and handle_cast/2.

The Elixir use GenServer supplies these callbacks, so this template is for when you want to change the callbacks, but would like the stubs to get started without having to look them up in the documentation.

defmodule MyNamespace.MyModule do
  @moduledoc false
  
  use GenServer

  def start_link(state, opts) do
    GenServer.start_link(__MODULE__, state, opts)
  end

  def init(_opts) do
    {:ok, %{}}
  end

  def handle_call(_msg, _from, state) do
    {:reply, :ok, state}
  end

  def handle_cast(_msg, state) do
    {:noreply, state}
  end
end

Elixir GenEvent

An underscored file will be created in an underscored directory lib/my_namespace/my_module.ex) with the given module name with be created. The minimal callback implementations for init/1, handle_event/2, and handle_call/2, handle_info/2.

The Elixir use GenEvent supplies these callbacks, so this template is for when you want to change the callbacks, but would like the stubs to get started without having to look them up in the documentation.

defmodule MyNamespace.MyModule do
  @moduledoc false
  
  use GenEvent

  # Callbacks

  def init(_opts) do
    {:ok, %{}}
  end

  def handle_event(_msg, state) do
    {:ok, state}
  end

  def handle_call(_msg, state) do
    {:ok, :ok, state}
  end

  def handle_info(_msg, state) do
    {:ok, state}
  end
end

Syntax Highlighting

Syntax highlighting for the following tokens:

  • Aliases, in other words, module names.
  • Atoms (:, :'', or :"")
  • Anonymous functions (fn end)
  • Access/Bracket expressions (foo[key] and @foo[key])
  • Binaries/Bit Strings (<<>>)
  • Character Tokens (?<character> or ?<escape_sequence>)
  • Comments (#)
  • Documentation Module Attributes (@doc, @moduledoc, and @typedoc)
  • Documentation Text (the string or heredoc value to @doc, @moduledoc, and @typedoc)
  • End of Lines (;, \n, \r\n)
  • Escape Sequences (\\<character>, \\x<hexadecimal>, or \\x{<hexadecimal>})
  • Heredocs (""" or ''')
  • Identifiers, in other words, variable, function and macro names.
  • Kernel Functions
    • abs
    • apply
    • apply
    • binary_part
    • bit_size
    • byte_size
    • div
    • elem
    • exit
    • function_exported?
    • get_and_update_in
    • get_in
    • hd
    • inspect
    • is_atom
    • is_binary
    • is_bitstring
    • is_boolean
    • is_float
    • is_function
    • is_function
    • is_integer
    • is_list
    • is_map
    • is_number
    • is_pid
    • is_port
    • is_reference
    • is_tuple
    • length
    • macro_exported?
    • make_ref
    • map_size
    • max
    • min
    • node
    • node
    • not
    • put_elem
    • put_in
    • rem
    • round
    • self
    • send
    • spawn
    • spawn
    • spawn_link
    • spawn_link
    • spawn_monitor
    • spawn_monitor
    • struct
    • throw
    • tl
    • trunc
    • tuple_size
    • update_in
  • Kernel Macros
    • @
    • alias!
    • and
    • binding
    • def
    • defdelegate
    • defexception
    • defimpl
    • defmacro
    • defmacrop
    • defmodule
    • defoverridable
    • defp
    • defprotocol
    • defstruct
    • destructure
    • get_and_update_in
    • if
    • in
    • is_nil
    • match?
    • or
    • put_in
    • raise
    • raise
    • reraise
    • reraise
    • sigil_C
    • sigil_R
    • sigil_S
    • sigil_W
    • sigil_c
    • sigil_r
    • sigil_s
    • sigil_w
    • to_char_list
    • to_string
    • unless
    • update_in
    • use
    • var!
  • Kernel.SpecialForms Macros
    • __CALLER__
    • __DIR__
    • __ENV__
    • __MODULE__
    • __aliases__
    • __block__
    • alias
    • case
    • cond
    • fn
    • for
    • import
    • quote
    • receive
    • require
    • super
    • try
    • unquote
    • unquote_splicing
  • Keywords (after, catch, do, else, end, fn, and rescue)
  • Maps (%{} and %{ current | <update> })
  • Numbers
    • Binary (0b) with invalid digit highlighting and missing digit recovery
    • Decimal with invalid digit highlighting
    • Hexadecimal (0x) with invalid digit highlighting and missing digit recovery
    • Obsolete Binary (0B) with invalid digit highlighting and missing digit recovery
    • Obsolete Hexadecimal (0X) with invalid digit highlighting and missing digit recovery
    • Octal (0o) with invalid digit highlighting and missing digit recovery
    • Unknown Non-Decimal (0[A-Za-z]) with invalid digit highlighting and missing digit recovery
  • Operators with arity, associativity, and precedence:
    • Addition (+ and -)
    • And (&&, &&&, and and)
    • Arrow (|>, <<<, >>>, ~>>, <<~, ~>, <~, <~>, and <|>)
    • Association (=>)
    • At (@)
    • Capture (&)
    • Comparison (==, !=, =~, ===, and !==)
    • Dot (.)
    • Hat (^^^)
    • In (in)
    • In Match (<- and \\)
    • Match (=)
    • Multiplication (* and /)
    • Or (||, |||, and or)
    • Pipe (|)
    • Relational (<, >, <=, and >=)
    • Stab (->)
    • Two (++, --, .., and <>)
    • Type (::)
    • Unary (+, -, !, ^, not, and ~~~)
    • When (when)
  • Parentheticals ((1 + 2))
  • Regular Keywords (end, false, fn, nil, and true)
  • Sigils (~)
    • CharList Sigils (~c and ~C)
    • Regex Sigils (~r and ~R)
    • String Sigils (~s and ~S)
    • Word Sigils (~w and ~W)
    • Custom Sigils (~<lower_case_character> and ~<UPPER_CASE_CHARACTER>)
  • Specifications (function names passed to @callback, @macrocallback or @spec
  • Stabs (->)
  • Structs (%MyStruct{})
  • Strings and Char List (" or ')
  • [Tuples] ({})
  • Type (Variables/calls in the parameters and return of @callback, @macrocallback, @spec)
  • Type Parameters
    • Parameters of @opaque, @type, @typep name
    • Keyword keys from the when clause of @callback, @macrocallback or @spec definitions and their usage

The syntax highlighting colors can be customized in the Color Settings page for Elixir (Preferences > Editor > Color & Fonts > Elixir).

Module Attribute annotator

Grammar parsing

Built on top of highlighted tokens above, the parser understands the following parts of Elixir grammar as valid or allows the grammar because they contain correctable errors:

  • Empty Parentheses (())
  • Keyword Lists
    • Keyword Keys - Aliases, identifiers, quotes, or operators when followed immediately by a colon and horizontal or vertical space.
    • Keyword Values - Empty parentheses (()) and matched expressions.
  • Matched Expressions, in other words, unary and binary operations on variable, function, and macro names and values (numbers, strings, char lists, sigils, heredocs, true, false, and nil).
  • No Parentheses expressions, which are function calls with neither parentheses nor do blocks that have either (1) a positional argument and keyword arguments OR (2) two or more positional arguments with optional keyword arguments.
  • Anonymous function calls .() with either no arguments; a no parentheses arguments expression as an argument; keywords as an argument; positional argument(s); or positional arguments followed by keywords as arguments.
  • Remote function calls (Alias.function, :atom.function, etc) and local function calls (function) with...
    • No Parentheses with...
      • No Arguments (Alias.function)
      • Keywords (Alias.function key: value)
      • Nested No Parentheses Call (Alias.function Inner.function positional, key: value)
      • Positional and Keyword arguments (Alias.function positional, key: value)
      • Matched Expression (Alias.function 1 + 2)
    • Parentheses with...
      • No arguments (Alias.function())
      • No Parentheses Call (Alias.function(Inner.function positional, key: value)
      • Keywords (Alias.function(key: value))
      • Positional and Keyword arguments (Alias.function(positional, key: value))
      • Trailing parentheses for quoting (def unquote(variable)(positional))
  • Bracket expression (variable[key])
  • Block expressions (function do end)
  • Unmatched expressions, in other words combinations of block expressions and matched expressions.

Inspections

Inspections mark sections of code with warnings and errors. They can be customized from the Preferences > Inspections > Elixir.

Elixir Inspections

Ambiguous nested calls

Detects when compiler will throw unexpected comma. Parentheses are required to solve ambiguity in nested calls. Function calls with multiple arguments without parentheses cannot take as arguments functions with multiple arguments without parentheses because which functional gets which arguments is unclear as in the following example:

outer_function first_outer_argument,
               # second argument is another function call without parentheses, but with multiple arguments
               inner_function first_inner_argument,
               ambiguous_keyword_key: ambiguous_keyword_value

To fix the ambiguity if first_inner_keyword_key: first_inner_keyword_value should be associated, add parentheses around the inner function's arguments:

# keywords are for inner function
outer_function first_outer_argument
               inner_function(
                 first_inner_argument
                 ambiguous_keyword_key: ambiguous_keyword_value
               )

# keywords are for outer function
outer_function first_outer_argument
               inner_function(
                 first_inner_argument
               ),
               ambiguous_keyword_key: ambiguous_keyword_value

Ambiguous nested calls preferences


Preferences > Inspections > Elixir > Ambiguous nested calls

Ambiguous nested calls error


Ambiguous nested call inspection marks the error on the comma that causes the ambiguity.

Ambiguous nested calls inspection


Mousing over the comma marked as an error in red (or over the red square in the right gutter) will show the inspection describing the error.

Ambiguous parentheses

Detects when compiler will throw unexpected parenthesis. If you are making a function call, do not insert spaces in between the function name and the opening parentheses. Function calls with space between the function name and the parentheses cannot distinguish between function calls with parentheses, but with an accidental space before the ( and function calls without parentheses where the first positional argument is in parentheses.

Empty Parentheses
function ()

To fix the ambiguity remove the space or add outer parentheses without the space if the first argument should be ():

# extra space, no arguments to function
function()

# first argument is `()`
function(())
Keywords in Parentheses
function (key: value)

Keywords inside parentheses is not valid, so the only way to fix this is to remove the space

function(key: value)
Positional arguments in Parentheses
function (first_positional, second_positional)

A list of positional arguments in parenthenses is not valid, so the only way to fix this is to remove the space

function(first_positional, second_positional)

Ambiguous parentheses preferences


Preferences > Inspections > Elixir > Ambiguous parentheses

Ambiguous parentheses error


Ambiguous parentheses inspection marks the error on the parenthetical group surrounded by the parentheses that are ambiguous due to the preceding space.

Ambiguous parentheses


Mousing over the parenthetical group marked as an error in red (or over the red square in the right gutter) will show the inspection describing the error.

Keywords appear before the end of list.

one.(
  one,
  two positional, key: value,
  three
)

Keywords can only appear at the end of an argument list, so either surround the no parentheses expression argument with parentheses, or move the the keywords to the end of the list if it wasn't meant to be a no parentheses expression.

one.(
  one
  two(positional, key: value),
  three
)

OR

one.(
  one,
  two,
  three,
  key: value
)

Keywords Not At End


Preferences > Inspections > Elixir > Keywords Not At End

Keywords Not At End error


Keywords Not At End inspection marks the error over the keywords that need to be surrounded by parentheses or moved to the end of the list.

Keywords Not At End inspection


Mousing over the keywords marked as an error in red (or over the red square in the right gutter) will show the inspection describing the error.

Quick Fixes

Quick Fixes are actions IntelliJ can take to change your code to correct errors (accessed with Alt+Enter by default).

Remove space in front of ambiguous parentheses

If a set of parentheses is marked as ambiguous then the space before it can be removed to disambiguate the parentheses with Alt+Enter. (Will vary based on keymap.)

Remove spaces before ambiguous parentheses


Hitting Alt+Enter on ambiguous parentheses error will bring up the Local Quick Fix, "Remove spaces between function name and parentheses". Hit Enter to accept and remove the space.

Commenter

You can comment or uncomment the current line or selected block of source. By selecting a block of source first you can quickly comment out and entire function if you're trying to track down a compiling or testing error that's not giving a helpful line number.

Using the menus

  1. Highlight one or more lines
  2. Comment (or Uncomment) with one of the following: a. Code > Comment with Line Comment b. On OSX the key binding is normally Cmd+/.

Building/Compiling

Settings

Build, Execution, Deployment > Compiler > Elixir Compiler

  • Compile project with mix (use mix compile instead of elixirc directly)
  • Attach docs (don't use --no-docs elixirc flag)
  • Attach debug info (don't use --no-debug-info elixirc flag)
  • Ignore module conflict (use --ignore-module-conflict elixirc flag)

Individual File

  1. Have a file selected in Project view with the Project view in focus OR have an Editor tab in focus
  2. Build > Compile 'FILE_NAME'
  3. Build results will be shown
    • If compilation is successful, you'll see "Compilation completed successfully" in the Event Log
    • If compilation had errors, you'll see "Compilation completed with N errors and M warnings" in the Event Log and the Messages Compile tab will open showing a list of Errors Messages Compile

Project

  1. Build > Make Project
  2. Build results will be shown
    • If compilation is successful, you'll see "Compilation completed successfully" in the Event Log
    • If compilation had errors, you'll see "Compilation completed with N errors and M warnings" in the Event Log and the Messages Compile tab will open showing a list of Errors Messages Compile

Live Templates

Live Templates are snippets of code that can be inserted quickly and have placeholder locations that the cursor will automatically jump to when using the template. Whenever you start typing, Live Templates will start matching against the shortcuts. A template can be selected with Tab.

Live Templates can be customized in Preferences > Editor > Live Templates > Elixir.

Metasyntactic variables are locations where the cursor will jump to. END is the final location of the cursor.
Shortcut Code
case

case ONE do
  TWO -> END
end
cond

cond do
  END
end
def

def NAME do
  END
end        
def,

def NAME, do: END        
defi

defimpl PROTOCOL, for: TYPE do
  END
end  
defm

defmodule ALIAS do
  END
end
defmac

defmacro MACRO_NAME do
  END
end
defmacp

defmacrop MACRO_NAME do
  END
end
defover

defoverridable [NAME: END]
defp

defp NAME do
  END
end
defpro

defprotocol PROTOCOL do
  END
end
defs

defstruct [END]
do
 
do
  END
end
doc

@doc """
ONE
"""
END
fn

fn ARGS -> END end
for

for A <- B do
  END
end
if

if TRUE do
  END
end
ife

if TRUE do
  OK
else
  END
end
ii

IO.inspect(END)
mdoc

@moduledoc """
ONE
"""
END
rec

receive do
  ONE -> END
end
test

test "TESTDESC" do
  END
end
try

try do
  ONE 
rescue
  TWO -> END

Run Configurations

Mix Tasks

Much like rake tasks in Rubymine, this plugin can run mix tasks.

  1. Run > Edit Configurations... Edit Run Configurations
  2. Click +
  3. Select "Elixir Mix" Add New Elixir Mix
  4. Fill in the "Name" for the Run Configuration
  5. Fill in the command (mix task) to run Edit Elixir Mix Run Configuration
  6. Click "OK" to save the Run Configuration and close the dialog
  7. Click the Run arrow in the Toolbar to run the mix task Run
  8. The Run pane will open, showing the results of the mix task.
    • If there is an error with a FILE:LINE stack frame, it will be a clickable link that will take you to that location Error link

Go To Declaration

Go To Declaration is a feature of JetBrains IDEs that allows you to jump from the usage of a symbol, such as a Module Alias, to its declaration, such as the defmodule call.

Module

  1. Place the cursor over an Alias
  2. Activate the Go To Declaration action with one of the following: a. Cmd+B b. Select Navigate > Declaration from the menu. c. Cmd+Click

If you hold Cmd and hover over the Alias before clicking, the target declaration will be shown.

Go To Declaration Demonstration

Module Attribute

  1. Place the cursor over a @module_attribute
  2. Activate the Go To Declaration action with one of the following: a. Cmd+B b. Select Navigate > Declaration from the menu. c. Cmd+Click

If you hold Cmd and hover over the @module_attribute before clicking, the target declaration will be shown.

Go To Symbol

Go To Symbol is a way to search for any of the following by name:

  • Call definition clauses (def, defp, defmacro, and defmacrop)
  • Callbacks (@callback and @macrocallback)
  • Call definition specifications (@spec)
  • Call definition heads (foo(bar)) for delegation (defdelegate foo(bar), to: BAZ)
  • Implementations (defimpl)
  • Protocols (defprotocol)

You can bring up Go To Symbol with the keyboard shortcut (โŒฅโŒ˜O on OSX) or using the menus (Navigate > Symbol...).

Find Usage

Find Usage is a feature of JetBrains IDEs that allows you to find all the places a declared symbol, such a Module Alias in a defmodule, is used, including in strings and comments.

Module

  1. Place cursor over an defmodule Alias.
  2. Activate the Find Usage action with one of the following: a. i. Right-click the Alias ii. Select "Find Usages" from the context menu b. Select Edit > Find > Find Usages from the menu c. Alt+F7

Find Module Usage Demonstration

Module Attribute

  1. Place cursor over the @module_attribute part of the declaration @module_attribute value.
  2. Activate the Find Usage action with one of the following: a. i. Right-click the module attribute ii. Select "Find Usages" from the context menu b. Select Edit > Find > Find Usages from the menu c. Alt+F7

Refactor

Rename

Module Attribute
  1. Place the cursor over the @module_attribute usage or declaration.
  2. Active the Rename Refactoring action with one of the following: a. i. Right-click the module attribute ii. Select Refactoring from the context menu iii. Select "Rename..." from the Refactoring submenu b. Shift+F6
  3. Edit the name inline and have the declaration and usages update.

Structure

You can view the structure of the currently open editor tab using the Structure tool window.

Viewing Structure

  • View > Tool Windows > Structure
  • Click the Structure Button (normally in the left tool buttons)
    1. If you can't see the Tool Buttons, they can be enabled with View > Tool Buttons
  • Cmd+7

Buttons

Structure Buttons

The buttons in the Structure tool are broken into 4 categories:

Sorters

Structure Sorter Buttons

Icon Tooltip Description
Sort by Time Sort by Time When the defined callable is usable:
  1. Compile time
  2. Both or None
  3. Runtime
Macros are compile time while functions are runtime.
Sort by Visibility Sort by Visibility Whether the element visible outside its defining module:
  1. Public
  2. Private
Sort Alphabetically Sort Alphabetically Sort by name

NOTE: When any combination of sorters is turned on, they are sorted from left to right (as shown in the button bar), so with all 3 sorters on, the elements are first grouped by Time, then inside each Time group, they are sorted by Visibility, then in each Visibility group, they are sorted by name.

Providers

Structure Provider Buttons

The providers add nodes not in the text of the file, but that will appear in the compiled Module.

Icon Tooltip Description
Show Used Show Used In Modules that `use ` or `use , arg`, the elements from the last `quote` block in the `__using__/1` for `` are injected.
Expanders

Structure Expander Buttons

The expanders expand or collapse all the elements in the Structure tool window.

Icon Tooltip Description
Expand All Expand All Expand All Elements in the Structure tool window
Expand All Collapse All Collapse All Elements in the Structure tool window
Autoscrollers

Structure Autoscroller Buttons

The autoscrollers link together the editor tab's location and the Structure tool windows selected element.

Icon Tooltip Description
Autoscroll to Source Autoscroll to Source Clicking an element in the Structure tool window will scroll the editor window to the location of the corresponding source.
Autoscroll from Source Autoscroll from Source When moving the cursor in the editor window, the selected element in the Structure tool window will change to the corresponding element.

Elements

Icons
Time

The Time icons indicate whether the element is usable at compile time or runtime.

Icon Tooltip Description
Compile Time Compile Time The element is used or checked at compile time and (may) not even be accessible at run time, such as macros.
Runtime Runtime The element is usable at runtime, such as a function.
Visibility

The Visibility icons indicated whether the element is usable outside its defining Module.

Icon Tooltip Description
Public Public Public elements are accessible outside their defining Module.
Private Private Private elements are only accessible in their defining Module. The macros that define private elements usually end in p.
Call to Element
Call Icons Text Description
Macro Type Time Visibility Function Module Local Overridable Override
def Runtime Public Function NAME/ARITY Groups together def with the same name and arity.
Runtime Public Function Module Local NAME[(][ARGUMENTS][)][when ...] The function head for function clause, including the name, arguments, and when if present
defdelegate Runtime Module Local defdelegate append_first: false|true, to: ALIAS|ATOM Groups together all the delegated functions for a single defdelegate call.
defdelegate func(arg), to: ALIAS Runtime Public Function NAME/ARITY Groups together implied def and any explicit @spec for the given function head (func(arg))
defdelegate func(arg), to: ALIAS Runtime Public Function Module Local func(arg) The function head implied by the defdelegate list of function heads.
defexception Exception RELATIVE_ALIAS The exception has the same name as the parent Module, but will display with only the relative name (the last Alias without a .) with its location as the qualifying Alias.
defexception Struct %RELATIVE_ALIAS{} Exceptions are defined as structs, so any defexception also defines a struct with the same name.
defexception list_or_keywords Field NAME: DEFAULT_VALUE The fields and default values (or nil if a list is used instead of a keyword list) for the struct as passed in the first argument to defexception.
defimpl PROTOCOL, for: MODULE Protocol Override MODULE (PROTOCOL) defimpl defines a protocol implementation that defines a Module that concatenates the PROTOCOL name and the MODULE name. If no :for is given, then the outer Module is used.
defmacro Compile Time Public Function NAME/ARITY Groups together defmacro with the same name and arity.
Compile Time Public Function Module Local NAME[(][ARGUMENTS][)][when ...] The macro head for macro clause, including the name, arguments, and when if present
defmacrop Compile Time Private Function NAME/ARITY Groups together defmacrop with the same name and arity.
Compile Time Private Function Module Local NAME[(][ARGUMENTS][)][when ...] The macro head for macro clause, including the name, arguments, and when if present
defmacro AND defmacrop Compile Time Unknown Function NAME/ARITY Groups together defmacro AND defmacrop with the same name and arity. This will be a compile error, but is represented with Unknown Unknown for the Visibility until corrected.
defmodule ALIAS Module RELATIVE_ALIAS (QUALIFIER) Top-level Modules show only the ALIAS with no location, while qualified Aliases or nested Modules show the RELATIVE_ALIAS and the QUALIFIER as the location.
defoverridable Overridable Mark previously declared functions as overridable. Overridable functions are listed as children of this element.
defoverridable NAME: ARITY, ... Runtime Public Function Overridable NAME/ARITY The NAME and ARITY of the function that is overridable. Matches the icon and text for def, but with the addition of Overridable Overridable
defp Runtime Private Function NAME/ARITY Groups together def with the same name and arity.
Runtime Private Function Module Local NAME[(][ARGUMENTS][)][when ...] The function head for function clause, including the name, arguments, and when if present
def AND defp Runtime Unknown Function NAME/ARITY Groups together def AND defp with the same name and arity. This will be a compile error, but is represented with Unknown Unknown for the Visibility until corrected.
defprotocol PROTOCOL Protocol Overridable PROTOCOL The protocol name. Functions required by the protocol are children of this element.
defstruct Struct %RELATIVE_ALIAS{} Structs have the same RELATIVE_ALIAS as their parent Module.
defstruct NAME: DEFAULT_VALUE, ... Field NAME: DEFAULT_VALUE The fields and default values (or nil if a list is used instead of a keyword list) for the struct.

Installation

Inside IDE using JetBrains repository

  1. Preferences
  2. Plugins
  3. Browse Repositories
  4. Select Elixir
  5. Install plugin
  6. Apply
  7. Restart the IDE

Inside IDE using Github releases

In browser

  1. Go to releases.
  2. Download the lastest zip.

In IDE

  1. Preferences
  2. Plugins
  3. Install plugin from disk...
  4. Select the downloaded zip.
  5. Apply
  6. Restart the IDE.

Screenshots

Color Settings New Elixir File

Error reporting

If the plugin encounters an error, there is a custom error handler registered, so you can open a pre-populated issue in your browser.

  1. Click the red error notification in bottom right corner of the IDE window. Fatal IDE Errors
  2. Fill in a description of what you were doing when the error occurred.
  3. Click "Open Issue against https://github.com/KronicDeth/intellij-elixir"
  4. The IDE will open your browser to https://github.com/KronicDeth/intellij-elixir/issues/new Write New Issue
  5. The title will be filled as [auto-generated], but if you can summarize the issue, change the title.
  6. If the "Fatal IDE Errors" dialog has Attachments, copy their contents to the Attachments section of the issue body.
  7. Review for IP disclosures. This will be public, so use your best judgement of how much of your code to post in the issue.
  8. Click the "Preview" tab to ensure the Markdown formatting looks correct.
  9. Click "Submit new issue".

Donations

If you would like to make a donation you can use Paypal:

Donate

If you'd like to use a different donation mechanism (such as Patreon), please open an issue.

Donors

I'd like to thank those who have donated to help support this project.

intellij-elixir's People

Contributors

abaire avatar bitgamma avatar f-lombardo avatar folz avatar jaketrent avatar kronicdeth avatar limhoff-r7 avatar pfitz avatar shalecraig avatar sholden avatar zhyu avatar zyuyou avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.