Commit 1339d1ef authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Turn @static into builtin Tag class.

Lots of changes, but they're all pretty much the same - replacing
foo[:meta][:static] with foo[:static].
parent ddc0097b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -260,7 +260,7 @@ module JsDuck
          s = make_property(name, value)
        end

        s[:meta] = {:static => true}
        s[:static] = true
        s.merge!(defaults)

        statics << s if apply_autodetected(s, pair, defaults[:inheritable])
+11 −0
Original line number Diff line number Diff line
require "jsduck/meta_tag"
require "jsduck/builtins/boolean_tag"

module JsDuck::Tag
  # Implementation of @static tag
  class Static < JsDuck::MetaTag
module JsDuck::Builtins
  class Static < BooleanTag
    def initialize
      @name = "static"
      @key = :static
      @signature = {:long => "static", :short => "STA"}
      @boolean = true
      super
    end
  end
end
+3 −3
Original line number Diff line number Diff line
@@ -162,9 +162,9 @@ module JsDuck
      end

      if query[:static] == true
        ms = ms.find_all {|m| m[:meta] && m[:meta][:static] }
        ms = ms.find_all {|m| m[:static] }
      elsif query[:static] == false
        ms = ms.reject {|m| m[:meta] && m[:meta][:static] }
        ms = ms.reject {|m| m[:static] }
      end

      ms
@@ -190,7 +190,7 @@ module JsDuck
    def self.member_id(m)
      # Sanitize $ in member names with something safer
      name = m[:name].gsub(/\$/, 'S-')
      "#{m[:meta][:static] ? 'static-' : ''}#{m[:tagname]}-#{name}"
      "#{m[:static] ? 'static-' : ''}#{m[:tagname]}-#{name}"
    end

    # Loops through all available member types,
+1 −1
Original line number Diff line number Diff line
@@ -129,7 +129,7 @@ module JsDuck
      inherit = m[:inheritdoc] || {}
      name = inherit[:member] || m[:name]
      tagname = inherit[:type] || m[:tagname]
      static = inherit[:static] || m[:meta][:static]
      static = inherit[:static] || m[:static]

      if m[:autodetected]
        # Auto-detected properties can override either a property or a
+4 −4
Original line number Diff line number Diff line
@@ -96,12 +96,12 @@ module JsDuck
            # one when we ignore the static members. If there's more,
            # report ambiguity. If there's only static members, also
            # report ambiguity.
            instance_ms = ms.find_all {|m| !m[:meta][:static] }
            instance_ms = ms.find_all {|m| !m[:static] }
            if instance_ms.length > 1
              alternatives = instance_ms.map {|m| "#{m[:tagname]} in #{m[:owner]}" }.join(", ")
              Logger.warn(:link_ambiguous, "#{full_link} is ambiguous: "+alternatives, file, line)
            elsif instance_ms.length == 0
              static_ms = ms.find_all {|m| m[:meta][:static] }
              static_ms = ms.find_all {|m| m[:static] }
              alternatives = static_ms.map {|m| "static " + m[:tagname].to_s }.join(", ")
              Logger.warn(:link_ambiguous, "#{full_link} is ambiguous: "+alternatives, file, line)
            end
@@ -210,8 +210,8 @@ module JsDuck
      def get_matching_member(cls, query)
        ms = find_members(cls, query)
        if ms.length > 1
          instance_ms = ms.find_all {|m| !m[:meta][:static] }
          instance_ms.length > 0 ? instance_ms[0] : ms.find_all {|m| m[:meta][:static] }[0]
          instance_ms = ms.find_all {|m| !m[:static] }
          instance_ms.length > 0 ? instance_ms[0] : ms.find_all {|m| m[:static] }[0]
        else
          ms[0]
        end
Loading