Sha256: 60d3305e1306a569c22668ceebe6bb6a2a4c1253082da5d8f96c81dc57747b49

Contents?: true

Size: 848 Bytes

Versions: 7

Compression:

Stored size: 848 Bytes

Contents

require "jsduck/util/singleton"

module JsDuck
  module Js

    # Auto-detection of listeners.
    class Listener
      include Util::Singleton

      # Checks if AST node is a listener, and if so, returns doc-hash
      # with listener name and various auto-detected properties.
      # When not an listener returns nil.
	  # Note: currently this is not implemented.  Needs to check for methods under the "listeners:" item
      def detect(ast)
        exp = ast.expression_statement? ? ast["expression"] : nil

        # this.fireEvent("foo", ...)
        if exp && 1==2
          make(exp["arguments"][0].to_value)
        else
          nil
        end
      end

      # Produces a doc-hash for an listener.
      def make(name)
        return {
          :tagname => :listener,
          :name => name,
        }
      end

    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
solvas-jsduck-6.0.0.30539 lib/jsduck/js/listener.rb
solvas-jsduck-6.0.0.9571 lib/jsduck/js/listener.rb
solvas-jsduck-6.0.0.6154 lib/jsduck/js/listener.rb
solvas-jsduck-6.0.0.4021 lib/jsduck/js/listener.rb
solvas-jsduck-6.0.0.2554 lib/jsduck/js/listener.rb
solvas-jsduck-6.0.0.1891 lib/jsduck/js/listener.rb
solvas-jsduck-6.0.0.beta.1888 lib/jsduck/js/listener.rb