-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
993221f
commit db0f834
Showing
15 changed files
with
37,616 additions
and
26 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
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 |
---|---|---|
@@ -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 |
Oops, something went wrong.