Method: JsDuck::Merger#detect_type

Defined in:
lib/jsduck/merger.rb

#detect_type(tagname, doc_map, code) ⇒ Object



273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
# File 'lib/jsduck/merger.rb', line 273

def detect_type(tagname, doc_map, code)
  main_tag = doc_map[tagname] ? doc_map[tagname].first : {}
  if main_tag[:type]
    return main_tag[:type]
  elsif doc_map[:type]
    return doc_map[:type].first[:type]
  elsif code_matches_doc?(tagname, doc_map, code)
    if code[:type] == :function
      return "Function"
    elsif code[:type] == :assignment && code[:right]
      if code[:right][:type] == :function
        return "Function"
      elsif code[:right][:type] == :literal && code[:right][:class] != nil
        return code[:right][:class]
      end
    end
  end
  return "Object"
end