Class: Hind::SCIP::Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/hind/scip/generator.rb

Defined Under Namespace

Classes: ScipVisitor

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project_root) ⇒ Generator

Returns a new instance of Generator.



9
10
11
12
13
# File 'lib/hind/scip/generator.rb', line 9

def initialize(project_root)
  @project_root = project_root
  @documents = []
  @package_info = detect_package_info
end

Instance Attribute Details

#documentsObject (readonly)

Returns the value of attribute documents.



7
8
9
# File 'lib/hind/scip/generator.rb', line 7

def documents
  @documents
end

#project_rootObject (readonly)

Returns the value of attribute project_root.



7
8
9
# File 'lib/hind/scip/generator.rb', line 7

def project_root
  @project_root
end

Instance Method Details

#execute(files) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/hind/scip/generator.rb', line 15

def execute(files)
  GlobalState.instance.reset

  # Pass 1: Collect all definitions
  files.each do |file|
    collect_definitions(file)
  end

  # Pass 2: Process files and references
  files.each do |file|
    process_file(file)
  end

  Index.new(
    metadata: .new(
      version: ProtocolVersion::UnspecifiedProtocolVersion,
      tool_info: ToolInfo.new(
        name: 'hind',
        version: Hind::VERSION,
        arguments: []
      ),
      project_root: "file://#{File.expand_path(@project_root)}",
      text_document_encoding: TextEncoding::UTF8
    ),
    documents: @documents
  )
end