Skip to content

Commit

Permalink
bring back partial support for 1.12
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszsamson committed Nov 2, 2023
1 parent 993221f commit db0f834
Show file tree
Hide file tree
Showing 15 changed files with 37,616 additions and 26 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ jobs:
fail-fast: false
matrix:
include:
- elixir: 1.12.x
otp: 22.x
- elixir: 1.12.x
otp: 23.x
- elixir: 1.12.x
otp: 24.x
- elixir: 1.13.x
otp: 22.x
- elixir: 1.13.x
Expand Down Expand Up @@ -58,6 +64,12 @@ jobs:
fail-fast: false
matrix:
include:
- elixir: 1.12.x
otp: 22.x
- elixir: 1.12.x
otp: 23.x
- elixir: 1.12.x
otp: 24.x
- elixir: 1.13.x
otp: 22.x
- elixir: 1.13.x
Expand Down
9 changes: 5 additions & 4 deletions lib/elixir_sense.ex
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ defmodule ElixirSense do
alias ElixirSense.Providers.References
alias ElixirSense.Providers.Signature
alias ElixirSense.Providers.Suggestion
alias ElixirSense.Core.Normalized.Code, as: NormalizedCode

@type callee_t :: {module, atom, non_neg_integer}

Expand Down Expand Up @@ -58,7 +59,7 @@ defmodule ElixirSense do
}
| nil
def docs(code, line, column) do
case Code.Fragment.surround_context(code, {line, column}) do
case NormalizedCode.Fragment.surround_context(code, {line, column}) do
:none ->
nil

Expand Down Expand Up @@ -100,7 +101,7 @@ defmodule ElixirSense do
"""
@spec definition(String.t(), pos_integer, pos_integer) :: Location.t() | nil
def definition(code, line, column) do
case Code.Fragment.surround_context(code, {line, column}) do
case NormalizedCode.Fragment.surround_context(code, {line, column}) do
:none ->
nil

Expand Down Expand Up @@ -133,7 +134,7 @@ defmodule ElixirSense do
"""
@spec implementations(String.t(), pos_integer, pos_integer) :: [Location.t()]
def implementations(code, line, column) do
case Code.Fragment.surround_context(code, {line, column}) do
case NormalizedCode.Fragment.surround_context(code, {line, column}) do
:none ->
[]

Expand Down Expand Up @@ -430,7 +431,7 @@ defmodule ElixirSense do
call_trace_t()
) :: [References.reference_info()]
def references(code, line, column, trace) do
case Code.Fragment.surround_context(code, {line, column}) do
case NormalizedCode.Fragment.surround_context(code, {line, column}) do
:none ->
[]

Expand Down
48 changes: 41 additions & 7 deletions lib/elixir_sense/core/normalized/code/cursor_context.ex
Original file line number Diff line number Diff line change
@@ -1,16 +1,50 @@
defmodule ElixirSense.Core.Normalized.Code.CursorContext do
defmodule ElixirSense.Core.Normalized.Code.Fragment do
@moduledoc false

def cursor_context(string, opts \\ [])
def cursor_context(string, opts \\ []) do
cond do
Version.match?(System.version(), ">= 1.14.0-dev") ->
apply(Code.Fragment, :cursor_context, [string, opts])

true ->
# fall back to bundled on < 1.13
# on 1.13 use our version as it has all the fixes from last 1.13 release
apply(ElixirSense.Core.Normalized.Code.ElixirSense.Fragment, :cursor_context, [
string,
opts
])
end
end

def surround_context(fragment, position, options \\ []) do
cond do
Version.match?(System.version(), ">= 1.14.0-dev") ->
apply(Code.Fragment, :surround_context, [fragment, position, options])

true ->
# fall back to bundled on < 1.13
# on 1.13 use our version as it has all the fixes from last 1.13 release
apply(ElixirSense.Core.Normalized.Code.ElixirSense.Fragment, :surround_context, [
fragment,
position,
options
])
end
end

# credo:disable-for-lines:10
def cursor_context(binary, opts) do
def container_cursor_to_quoted(fragment, opts \\ []) do
cond do
Version.match?(System.version(), ">= 1.13.0-dev") ->
apply(Code.Fragment, :cursor_context, [binary, opts])
Version.match?(System.version(), ">= 1.14.0-dev") ->
apply(Code.Fragment, :container_cursor_to_quoted, [fragment, opts])

true ->
apply(Code, :cursor_context, [binary, opts])
# fall back to bundled on < 1.13
# on 1.13 use our version as it has all the fixes from last 1.13 release
apply(
ElixirSense.Core.Normalized.Code.ElixirSense.Fragment,
:container_cursor_to_quoted,
[fragment, opts]
)
end
end
end
Loading

0 comments on commit db0f834

Please sign in to comment.