Class: Watir::Generator::Base::Visitor

Inherits:
WebIDL::RubySexpVisitor
  • Object
show all
Defined in:
lib/watir/generator/base/visitor.rb

Direct Known Subclasses

HTML::Visitor, SVG::Visitor

Constant Summary collapse

STRING_TYPES =
['WindowProxy', 'ValidityState', 'TimeRanges', 'Location',
'Any', 'TimedTrackArray', 'TimedTrack', 'TextTrackArray', 'TextTrack',
/Media.+/, 'TextTrackKind', 'Function', /.*EventHandler$/,
'Document', 'DocumentFragment', 'DOMTokenList', 'DOMSettableTokenList',
'DOMStringMap', 'HTMLPropertiesCollection', /HTML.*Element/, /HTML.*Collection/,
'CSSStyleDeclaration', /.+List$/, 'Date', 'Element', /DOM.+ReadOnly/,
/SVGAnimated.+/, /SVG.*Element/, /SVG.*Collection/, 'SVGViewSpec',
'Object', 'USVString'].freeze

Instance Method Summary collapse

Constructor Details

#initializeVisitor

Returns a new instance of Visitor.


13
14
15
16
17
18
19
20
21
# File 'lib/watir/generator/base/visitor.rb', line 13

def initialize
  super

  # When an interface has multiple IDL definitions in the spec, the inheritance is sometimes
  # not repeated. So we'll keep track ourselves.
  @inheritance_map = {}

  @already_defined = []
end

Instance Method Details

#visit_implements_statement(stmt) ⇒ Object


53
54
55
# File 'lib/watir/generator/base/visitor.rb', line 53

def visit_implements_statement(stmt)
  # ignored
end

#visit_interface(interface) ⇒ Object

WebIDL visitor interface


27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/watir/generator/base/visitor.rb', line 27

def visit_interface(interface)
  name   = interface.name
  parent = interface.inherits.first

  warn name
  return if name !~ interface_regexp || name =~ /(Collection|Document)$/

  parent = if force_inheritance.key?(name)
             force_inheritance[name]
           else
             @inheritance_map[name] ||= parent&.name
             return unless @inheritance_map[name]

             @inheritance_map[name]
           end

  [:scope,
   [:block,
    element_class(interface.name, extract_attributes(interface), parent),
    collection_class(interface.name)]]
end

#visit_module(mod) ⇒ Object


49
50
51
# File 'lib/watir/generator/base/visitor.rb', line 49

def visit_module(mod)
  # ignored
end