Results for: "Logger"

Represents the use of the ‘||=` operator for assignment to a global variable.

$target ||= value
^^^^^^^^^^^^^^^^^

Represents assigning to an instance variable using an operator that isn’t ‘=`.

@target += value
^^^^^^^^^^^^^^^^

Represents the use of the ‘&&=` operator for assignment to a local variable.

target &&= value
^^^^^^^^^^^^^^^^

Represents the use of the ‘||=` operator for assignment to a local variable.

target ||= value
^^^^^^^^^^^^^^^^

DesugarCompiler is a compiler that desugars Ruby code into a more primitive form. This is useful for consumers that want to deal with fewer node types.

The dispatcher class fires events for nodes that are found while walking an AST to all registered listeners. It’s useful for performing different types of analysis on the AST while only having to walk the tree once.

To use the dispatcher, you would first instantiate it and register listeners for the events you’re interested in:

class OctalListener
  def on_integer_node_enter(node)
    if node.octal? && !node.slice.start_with?("0o")
      warn("Octal integers should be written with the 0o prefix")
    end
  end
end

dispatcher = Dispatcher.new
dispatcher.register(listener, :on_integer_node_enter)

Then, you can walk any number of trees and dispatch events to the listeners:

result = Prism.parse("001 + 002 + 003")
dispatcher.dispatch(result.value)

Optionally, you can also use ‘#dispatch_once` to dispatch enter and leave events for a single node without recursing further down the tree. This can be useful in circumstances where you want to reuse the listeners you already have registers but want to stop walking the tree at a certain point.

integer = result.value.statements.body.first.receiver.receiver
dispatcher.dispatch_once(integer)

This visitor walks through the tree and copies each node as it is being visited. This is useful for consumers that want to mutate the tree, as you can change subtrees in place without effecting the rest of the tree.

Represents the use of the ‘alias` keyword to alias a global variable.

alias $foo $bar
^^^^^^^^^^^^^^^

Represents an array pattern in pattern matching.

foo in 1, 2
^^^^^^^^^^^

foo in [1, 2]
^^^^^^^^^^^^^

foo in *1
^^^^^^^^^

foo in Bar[]
^^^^^^^^^^^^

foo in Bar[1, 2, 3]
^^^^^^^^^^^^^^^^^^^

Represents block method arguments.

bar(&args)
^^^^^^^^^^

Represents a block of ruby code.

[1, 2, 3].each { |i| puts x }
               ^^^^^^^^^^^^^^

Represents the use of the ‘||=` operator on a call.

foo.bar ||= value
^^^^^^^^^^^^^^^^^

Represents assigning to a method call.

foo.bar, = 1
^^^^^^^

begin
rescue => foo.bar
          ^^^^^^^
end

for foo.bar in baz do end
    ^^^^^^^

Represents assigning to a local variable in pattern matching.

foo => [bar => baz]
       ^^^^^^^^^^^^

Represents referencing a class variable.

@@foo
^^^^^

Represents writing to a class variable in a context that doesn’t have an explicit value.

@@foo, @@bar = baz
^^^^^  ^^^^^

Represents assigning to a constant path using an operator that isn’t ‘=`.

Parent::Child += value
^^^^^^^^^^^^^^^^^^^^^^

Represents writing to a constant path in a context that doesn’t have an explicit value.

Foo::Foo, Bar::Bar = baz
^^^^^^^^  ^^^^^^^^

Represents writing to a constant in a context that doesn’t have an explicit value.

Foo, Bar = baz
^^^  ^^^

Represents a find pattern in pattern matching.

foo in *bar, baz, *qux
       ^^^^^^^^^^^^^^^

foo in [*bar, baz, *qux]
       ^^^^^^^^^^^^^^^^^

foo in Foo(*bar, baz, *qux)
       ^^^^^^^^^^^^^^^^^^^^

Represents the use of the ‘..` or `…` operators to create flip flops.

baz if foo .. bar
       ^^^^^^^^^^

Represents a floating point number literal.

1.0
^^^

Represents the use of the forwarding parameter in a method, block, or lambda declaration.

def foo(...)
        ^^^
end

Represents the use of the ‘super` keyword without parentheses or arguments.

super
^^^^^

Represents writing to a global variable.

$foo = 1
^^^^^^^^
Search took: 8ms  ·  Total Results: 3130