Module: Wool::SexpAnalysis
- Extended by:
- ModuleExtensions
- Included in:
- Warning
- Defined in:
- lib/wool/analysis/sexp_analysis.rb,
lib/wool/analysis/scope.rb,
lib/wool/analysis/symbol.rb,
lib/wool/analysis/visitor.rb,
lib/wool/analysis/protocols.rb,
lib/wool/analysis/signature.rb,
lib/wool/analysis/wool_class.rb,
lib/wool/analysis/annotations.rb,
lib/wool/analysis/protocol_registry.rb,
lib/wool/analysis/annotations/next_annotation.rb,
lib/wool/analysis/annotations/scope_annotation.rb,
lib/wool/analysis/annotations/parent_annotation.rb
Overview
This is a set of methods that get provided to Warnings so they can perform parse-tree analysis of their bodies.
Defined Under Namespace
Modules: BasicAnnotation, NextPrevAnnotation, ParentAnnotation, ProtocolRegistry, Protocols, ScopeAnnotation, Visitor Classes: Scope, Sexp, Signature, Symbol, WoolClass, WoolMethod
Instance Method Summary collapse
-
#find_sexps(type, tree = self.parse(self.body)) ⇒ Array<Sexp>
Finds all sexps of the given type in the given Sexp tree.
-
#parse(body = self.body) ⇒ Sexp, NilClass
Parses the given text.
Methods included from ModuleExtensions
attr_accessor_with_default, cattr_accessor, cattr_accessor_with_default, cattr_get_and_setter, cattr_reader, cattr_writer
Instance Method Details
#find_sexps(type, tree = self.parse(self.body)) ⇒ Array<Sexp>
Finds all sexps of the given type in the given Sexp tree.
90 91 92 93 94 95 96 |
# File 'lib/wool/analysis/sexp_analysis.rb', line 90 def find_sexps(type, tree = self.parse(self.body)) result = tree[0] == type ? [tree] : [] tree.each do |node| result.concat find_sexps(type, node) if node.is_a?(Array) end result end |
#parse(body = self.body) ⇒ Sexp, NilClass
Parses the given text.
77 78 79 80 81 |
# File 'lib/wool/analysis/sexp_analysis.rb', line 77 def parse(body = self.body) result = Sexp.new Ripper.sexp(body) SexpAnalysis.global_annotations.each {|annotator| annotator.annotate!(result)} result end |