Skip to content

Commit

Permalink
Simplify optional callback computation
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Feb 27, 2024
1 parent 7e83e8c commit cdf1bcc
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions lib/ex_doc/language/source.ex
Original file line number Diff line number Diff line change
Expand Up @@ -207,21 +207,14 @@ defmodule ExDoc.Language.Source do
|> Map.new()
end

def get_optional_callbacks(module, type) do
optional_callbacks =
type == :behaviour &&
try do
module.behaviour_info(:optional_callbacks)
rescue
FunctionClauseError -> :undefined
end

case optional_callbacks do
:undefined -> []
_ -> optional_callbacks
end
def get_optional_callbacks(module, :behaviour) do
module.behaviour_info(:optional_callbacks)
rescue
FunctionClauseError -> []
end

def get_optional_callbacks(_module, _type), do: []

def find_ast(ast, source_basedir, fun) do
filtermap_ast(ast, source_basedir, fun) |> hd()
end
Expand Down

0 comments on commit cdf1bcc

Please sign in to comment.