Sha256: 11406cf45e9f2ca410751e930c4044e4b785e49e2a41e95e9eca9964f5ba532b
Contents?: true
Size: 1.66 KB
Versions: 1
Compression:
Stored size: 1.66 KB
Contents
# frozen_string_literal: true # NodeQuery defines a node query language, which is a css like syntax for matching nodes. # # It supports the following selectors: # # * AST node type: +.class+, +.send+ # * attribute value: +.send[receiver = nil]+, +.send[message = create]+ # * attribute regex: <code>.send[key=~/\A:([^'"]+)\z/]</code>, <code>.send[key!~/\A:([^'"]+)\z/]</code> # * attribute conditions: +.send[message != nil]+, +.send[value > 1]+, +.send[value >= 1]+, +.send[value < 1]+, +.send[value <= 1]+ # * nested attribute: +.send[caller.message = map]+, +.send[arguments.size = 2]+ # * descendant: +.class .send+ # * child: +.class > .def+ # * following sibling: <code>.def + .def</code> # * subsequnt sibling: +.def ~ .def+ # * has: +.class:has(.def)+ # # It also supports some custom selectors: # # * not_has: +.class:not_has(.def)+, it's same as +:not(:has())+ in css, just to make implementation easy. # * nested selector: +.send[arguments = [size = 2][first = .sym][last = .hash]]+ # * array value: +.send[arguments = (a b)]+ # * IN operator: +.send[message IN (try try!)]+ # * NOT IN operator: +.send[message NOT IN (create build)]+ # * INCLUDES operator: +.send[arguments INCLUDES &block]+ # * dynamic attribute value: +.hash > .pair[key={{value}}]+ # * goto scope: +.class body > .def+ # # @example # # it matches methods call nodes, like `puts message` or `p message` # Synvert::Core::NodeQuery::Parser.parse('.send[receiver = nil][message IN (puts, p)]').query_nodes(node) module Synvert::Core::NodeQuery autoload :Compiler, 'synvert/core/node_query/compiler' autoload :Lexer, 'synvert/core/node_query/lexer.rex' autoload :Parser, 'synvert/core/node_query/parser.racc' end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
synvert-core-1.4.0 | lib/synvert/core/node_query.rb |