Skip to content

Commit

Permalink
Add @impl (#104)
Browse files Browse the repository at this point in the history
Per https://elixir-lang.org/getting-started/typespecs-and-behaviours.html#adopting-behaviours, it allows to get more warnings in case the implementation does not respect the behaviour anymore.
  • Loading branch information
thbar authored Jun 16, 2022
1 parent f680914 commit 98e2c9e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/saxy/simple_form/handler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@ defmodule Saxy.SimpleForm.Handler do

@behaviour Saxy.Handler

@impl Saxy.Handler
def handle_event(:start_document, _prolog, stack) do
{:ok, stack}
end

@impl Saxy.Handler
def handle_event(:start_element, {tag_name, attributes}, stack) do
tag = {tag_name, attributes, []}
{:ok, [tag | stack]}
end

@impl Saxy.Handler
def handle_event(:characters, chars, stack) do
[{tag_name, attributes, content} | stack] = stack

Expand All @@ -20,6 +23,7 @@ defmodule Saxy.SimpleForm.Handler do
{:ok, [current | stack]}
end

@impl Saxy.Handler
def handle_event(:cdata, chars, stack) do
[{tag_name, attributes, content} | stack] = stack

Expand All @@ -28,6 +32,7 @@ defmodule Saxy.SimpleForm.Handler do
{:ok, [current | stack]}
end

@impl Saxy.Handler
def handle_event(:end_element, tag_name, [{tag_name, attributes, content} | stack]) do
current = {tag_name, attributes, Enum.reverse(content)}

Expand All @@ -42,6 +47,7 @@ defmodule Saxy.SimpleForm.Handler do
end
end

@impl Saxy.Handler
def handle_event(:end_document, _, stack) do
{:ok, stack}
end
Expand Down

0 comments on commit 98e2c9e

Please sign in to comment.