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

Member predicate ConstantWriteAccess::getAQualifiedName

Gets a fully qualified name for this constant, based on the context in which it is defined.

For example, given

module Foo
  module Bar
    class Baz
    end
  end
  CONST_A = "a"
end

the constant Baz has the fully qualified name Foo::Bar::Baz, and CONST_A has the fully qualified name Foo::CONST_A.

Important note: This can return more than one value, because there are situations where there can be multiple possible “fully qualified” names. For example:

module Mod4
  include Mod1
  module Mod3::Mod5 end
end

In the above snippet, Mod5 has two valid fully qualified names it can be referred to by: Mod1::Mod3::Mod5, or Mod4::Mod3::Mod5.

Another example has to do with the order in which module definitions are executed at runtime. Because of the way that ruby dynamically looks up constants up the namespace chain, the fully qualified name of a nested constant can be ambiguous from just statically looking at the AST.

string getAQualifiedName()