CodeQL library for Ruby
codeql/ruby-all 0.8.15-dev (changelog, source)
Search

Member predicate API::Node::getInstance

Gets a node that may refer to an instance of the module or class represented by this API node.

This includes the following:

  • Calls to new on this module or class or a descendent thereof
  • References to self in instance methods declared in any ancestor of any descendent of this module or class

For example:

A.new # API::getTopLevelMember("A").getInstance()

class B < A
  def m
    self # API::getTopLevelMember("A").getInstance()
  end
end

B.new # API::getTopLevelMember("A").getInstance()

class C < A
  include Mixin
end
module Mixin
  def m
    # Although 'Mixin' is not directly related to 'A', 'self' may refer to an instance of 'A'
    # due to its inclusion in a subclass of 'A'.
    self # API::getTopLevelMember("A").getInstance()
  end
end
Node getInstance()