Commit 0cd67f4b authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Allow passing file & linenr to Logger#warn as hash.

Getting rid of lots of code scattered around all over that deals
with extracting the filename and linenr out of some hash and
passing them as separate arguments.
parent 8f2f4f1c
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -87,9 +87,7 @@ module JsDuck
    end

    def warn_alt_name(cls)
      file = cls[:files][0][:filename]
      line = cls[:files][0][:linenr]
      Logger.warn(:alt_name, "Name #{cls[:name]} used as both classname and alternate classname", file, line)
      Logger.warn(:alt_name, "Name #{cls[:name]} used as both classname and alternate classname", cls[:files][0])
    end

    # Merges new class-doc into old one.
+1 −2
Original line number Diff line number Diff line
@@ -115,8 +115,7 @@ module JsDuck
        # simplest thing and ignore it.
        Class.new({:name => classname}, false)
      else
        context = @doc[:files][0]
        Logger.warn(:extend, "Class #{classname} not found", context[:filename], context[:linenr])
        Logger.warn(:extend, "Class #{classname} not found", @doc[:files][0])
        # Create placeholder class
        Class.new({:name => classname}, false)
      end
+1 −1
Original line number Diff line number Diff line
@@ -48,7 +48,7 @@ module JsDuck
              parent[:properties] << it
            else
              msg = "Ignoring subproperty #{$1}.#{$2}, no parent found with name '#{$1}'."
              Logger.warn(:subproperty, msg, pos[:filename], pos[:linenr])
              Logger.warn(:subproperty, msg, pos)
            end
          else
            items << it
+1 −2
Original line number Diff line number Diff line
@@ -78,9 +78,8 @@ module JsDuck
      end

      def warn(msg, tags)
        ctx = @doc_context
        tag_list = tags.map {|tag| "<#{tag}>" }.join(", ")
        Logger.warn(:html, "#{msg}: #{tag_list}", ctx[:filename], ctx[:linenr])
        Logger.warn(:html, "#{msg}: #{tag_list}", @doc_context)
      end

      def void?(tag)
+2 −2
Original line number Diff line number Diff line
@@ -50,9 +50,9 @@ module JsDuck
        else
          context = @formatter.doc_context
          if tp.error == :syntax
            Logger.warn(:type_syntax, "Incorrect type syntax #{type}", context[:filename], context[:linenr])
            Logger.warn(:type_syntax, "Incorrect type syntax #{type}", context)
          else
            Logger.warn(:type_name, "Unknown type #{type}", context[:filename], context[:linenr])
            Logger.warn(:type_name, "Unknown type #{type}", context)
          end
          Util::HTML.escape(type)
        end
Loading