Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return rest in post_traverse to avoid future deprecations #1151

Merged
merged 1 commit into from
Feb 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions lib/absinthe/lexer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -275,13 +275,13 @@ defmodule Absinthe.Lexer do
)
)

defp fill_mantissa(_rest, raw, context, _, _), do: {'0.' ++ raw, context}
defp fill_mantissa(rest, raw, context, _, _), do: {rest, '0.' ++ raw, context}

defp unescape_unicode(_rest, content, context, _loc, _) do
defp unescape_unicode(rest, content, context, _loc, _) do
code = content |> Enum.reverse()
value = :erlang.list_to_integer(code, 16)
binary = :unicode.characters_to_binary([value])
{[binary], context}
{rest, [binary], context}
end

@boolean_words ~w(
Expand Down Expand Up @@ -315,48 +315,48 @@ defmodule Absinthe.Lexer do
do_boolean_value_or_name_or_reserved_word(rest, value, context, loc, byte_offset)
end

defp do_boolean_value_or_name_or_reserved_word(_rest, value, context, loc, byte_offset)
defp do_boolean_value_or_name_or_reserved_word(rest, value, context, loc, byte_offset)
when value in @boolean_words do
{[{:boolean_value, line_and_column(loc, byte_offset, length(value)), value}], context}
{rest, [{:boolean_value, line_and_column(loc, byte_offset, length(value)), value}], context}
end

defp do_boolean_value_or_name_or_reserved_word(_rest, value, context, loc, byte_offset)
defp do_boolean_value_or_name_or_reserved_word(rest, value, context, loc, byte_offset)
when value in @reserved_words do
token_name = value |> List.to_atom()
{[{token_name, line_and_column(loc, byte_offset, length(value))}], context}
{rest, [{token_name, line_and_column(loc, byte_offset, length(value))}], context}
end

defp do_boolean_value_or_name_or_reserved_word(_rest, value, context, loc, byte_offset) do
{[{:name, line_and_column(loc, byte_offset, length(value)), value}], context}
defp do_boolean_value_or_name_or_reserved_word(rest, value, context, loc, byte_offset) do
{rest, [{:name, line_and_column(loc, byte_offset, length(value)), value}], context}
end

defp labeled_token(_rest, chars, context, loc, byte_offset, token_name) do
defp labeled_token(rest, chars, context, loc, byte_offset, token_name) do
value = chars |> Enum.reverse()
{[{token_name, line_and_column(loc, byte_offset, length(value)), value}], context}
{rest, [{token_name, line_and_column(loc, byte_offset, length(value)), value}], context}
end

defp mark_string_start(_rest, chars, context, loc, byte_offset) do
{[chars], Map.put(context, :token_location, line_and_column(loc, byte_offset, 1))}
defp mark_string_start(rest, chars, context, loc, byte_offset) do
{rest, [chars], Map.put(context, :token_location, line_and_column(loc, byte_offset, 1))}
end

defp mark_block_string_start(_rest, _chars, context, loc, byte_offset) do
{[], Map.put(context, :token_location, line_and_column(loc, byte_offset, 3))}
defp mark_block_string_start(rest, _chars, context, loc, byte_offset) do
{rest, [], Map.put(context, :token_location, line_and_column(loc, byte_offset, 3))}
end

defp block_string_value_token(_rest, chars, context, _loc, _byte_offset) do
defp block_string_value_token(rest, chars, context, _loc, _byte_offset) do
value = '"""' ++ (chars |> Enum.reverse()) ++ '"""'
{[{:block_string_value, context.token_location, value}], Map.delete(context, :token_location)}
{rest, [{:block_string_value, context.token_location, value}], Map.delete(context, :token_location)}
end

defp string_value_token(_rest, chars, context, _loc, _byte_offset) do
defp string_value_token(rest, chars, context, _loc, _byte_offset) do
value = '"' ++ tl(chars |> Enum.reverse()) ++ '"'
{[{:string_value, context.token_location, value}], Map.delete(context, :token_location)}
{rest, [{:string_value, context.token_location, value}], Map.delete(context, :token_location)}
end

defp atom_token(_rest, chars, context, loc, byte_offset) do
defp atom_token(rest, chars, context, loc, byte_offset) do
value = chars |> Enum.reverse()
token_atom = value |> List.to_atom()
{[{token_atom, line_and_column(loc, byte_offset, length(value))}], context}
{rest, [{token_atom, line_and_column(loc, byte_offset, length(value))}], context}
end

def line_and_column({line, line_offset}, byte_offset, column_correction) do
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ defmodule Absinthe.Mixfile do

defp deps do
[
{:nimble_parsec, "~> 0.5 or ~> 1.0"},
{:nimble_parsec, "~> 1.2.2 or ~> 1.3.0"},
{:telemetry, "~> 1.0 or ~> 0.4"},
{:dataloader, "~> 1.0.0", optional: true},
{:decimal, "~> 1.0 or ~> 2.0", optional: true},
Expand Down
2 changes: 1 addition & 1 deletion mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
"makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"},
"makeup_graphql": {:hex, :makeup_graphql, "0.1.2", "81e2939aab6d2b81d39ee5d9e13fae02599e9ca6e1152e0eeed737a98a5f96aa", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "3390ab04ba388d52a94bbe64ef62aa4d7923ceaffac43ec948f58f631440e8fb"},
"mix_test_watch": {:hex, :mix_test_watch, "1.0.2", "34900184cbbbc6b6ed616ed3a8ea9b791f9fd2088419352a6d3200525637f785", [:mix], [{:file_system, "~> 0.2.1 or ~> 0.3", [hex: :file_system, repo: "hexpm", optional: false]}], "hexpm", "47ac558d8b06f684773972c6d04fcc15590abdb97aeb7666da19fcbfdc441a07"},
"nimble_parsec": {:hex, :nimble_parsec, "1.2.0", "b44d75e2a6542dcb6acf5d71c32c74ca88960421b6874777f79153bbbbd7dccc", [:mix], [], "hexpm", "52b2871a7515a5ac49b00f214e4165a40724cf99798d8e4a65e4fd64ebd002c1"},
"nimble_parsec": {:hex, :nimble_parsec, "1.2.2", "811e32fb77aabb2b5b6196b21f76fe6ba8b6861c3d8c9eaeedbbf1f4cda627d1", [:mix], [], "hexpm", "dd3504559b0ddfeb7f55297557313fc05340120a037f981a4775b1c43e61d1b9"},
"telemetry": {:hex, :telemetry, "0.4.3", "a06428a514bdbc63293cd9a6263aad00ddeb66f608163bdec7c8995784080818", [:rebar3], [], "hexpm", "eb72b8365ffda5bed68a620d1da88525e326cb82a75ee61354fc24b844768041"},
}