Commit 91e396df authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Fix crash on subproperty parent name mismatch.

Instead printing out a warning.
parent 54260da8
Loading
Loading
Loading
Loading
+17 −2
Original line number Diff line number Diff line
require 'jsduck/logger'

module JsDuck

  # Takes data from doc-comment and code that follows it and combines
@@ -6,6 +8,15 @@ module JsDuck
  #
  # The main method merge() produces a hash as a result.
  class Merger
    # Allow passing in filename and line for error reporting
    attr_accessor :filename
    attr_accessor :linenr

    def initialize
      @filename = ""
      @linenr = 0
    end

    def merge(docs, code)
      case detect_doc_type(docs, code)
      when :class
@@ -417,8 +428,12 @@ module JsDuck
        if it[:name] =~ /^(.+)\.([^.]+)$/
          it[:name] = $2
          parent = index[$1]
          if parent
            parent[:properties] = [] unless parent[:properties]
            parent[:properties] << it
          else
            Logger.instance.warn("Ignoring subproperty #{$1}.#{$2}, no parent found with name '#{$1}'.", @filename, @linenr)
          end
        else
          items << it
        end
+2 −0
Original line number Diff line number Diff line
@@ -23,7 +23,9 @@ module JsDuck
      @links = {}

      merger = Merger.new
      merger.filename = @filename
      @docs = parse.map do |docset|
        merger.linenr = docset[:linenr]
        link(docset[:linenr], merger.merge(docset[:comment], docset[:code]))
      end
    end