Class: Steep::Drivers::Annotations
- Inherits:
-
Object
- Object
- Steep::Drivers::Annotations
- Includes:
- Utils::EachSignature
- Defined in:
- lib/steep/drivers/annotations.rb
Instance Attribute Summary collapse
-
#labeling ⇒ Object
readonly
Returns the value of attribute labeling.
-
#source_paths ⇒ Object
readonly
Returns the value of attribute source_paths.
-
#stderr ⇒ Object
readonly
Returns the value of attribute stderr.
-
#stdout ⇒ Object
readonly
Returns the value of attribute stdout.
Instance Method Summary collapse
-
#initialize(source_paths:, stdout:, stderr:) ⇒ Annotations
constructor
A new instance of Annotations.
- #run ⇒ Object
Methods included from Utils::EachSignature
#each_file_in_dir, #each_file_in_path
Constructor Details
#initialize(source_paths:, stdout:, stderr:) ⇒ Annotations
Returns a new instance of Annotations.
11 12 13 14 15 16 17 |
# File 'lib/steep/drivers/annotations.rb', line 11 def initialize(source_paths:, stdout:, stderr:) @source_paths = source_paths @stdout = stdout @stderr = stderr @labeling = ASTUtils::Labeling.new end |
Instance Attribute Details
#labeling ⇒ Object (readonly)
Returns the value of attribute labeling.
7 8 9 |
# File 'lib/steep/drivers/annotations.rb', line 7 def labeling @labeling end |
#source_paths ⇒ Object (readonly)
Returns the value of attribute source_paths.
4 5 6 |
# File 'lib/steep/drivers/annotations.rb', line 4 def source_paths @source_paths end |
#stderr ⇒ Object (readonly)
Returns the value of attribute stderr.
6 7 8 |
# File 'lib/steep/drivers/annotations.rb', line 6 def stderr @stderr end |
#stdout ⇒ Object (readonly)
Returns the value of attribute stdout.
5 6 7 |
# File 'lib/steep/drivers/annotations.rb', line 5 def stdout @stdout end |
Instance Method Details
#run ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/steep/drivers/annotations.rb', line 19 def run project = Project.new() source_paths.each do |path| each_file_in_path(".rb", path) do |file_path| file = Project::SourceFile.new(path: file_path, options: Project::Options.new) file.content = file_path.read project.source_files[file_path] = file end end project.source_files.each_value do |file| file.parse file.source.each_annotation.sort_by {|node, _| [node.loc.expression.begin_pos, node.loc.expression.end_pos] }.each do |node, annotations| loc = node.loc stdout.puts "#{file.path}:#{loc.line}:#{loc.column}:#{node.type}:\t#{node.loc.expression.source.lines.first}" annotations.each do |annotation| stdout.puts " #{annotation.location.source}" end end end 0 end |