Class: TypeScript::Merge::FileAnalysis

Inherits:
Object
  • Object
show all
Defined in:
lib/typescript/merge/file_analysis.rb,
sig/typescript/merge.rbs

Overview

Native TreeHaver analysis of safely attributable top-level TypeScript source. rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity -- one AST pass establishes ordered ownership and comment attachment

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, dialect: :typescript) ⇒ FileAnalysis

Returns a new instance of FileAnalysis.

Parameters:

  • source (String)
  • dialect: (Symbol) (defaults to: :typescript)


10
11
12
13
14
15
16
17
18
19
20
# File 'lib/typescript/merge/file_analysis.rb', line 10

def initialize(source, dialect: :typescript)
  @source = source
  @dialect = dialect.to_sym
  @backend = TREE_SITTER_BACKEND.id.to_sym
  @errors = []
  parse!
rescue StandardError => e
  @root_node = nil
  @declarations = [].freeze
  @errors = [e].freeze
end

Instance Attribute Details

#backendSymbol (readonly)

Returns the value of attribute backend.

Returns:

  • (Symbol)


8
9
10
# File 'lib/typescript/merge/file_analysis.rb', line 8

def backend
  @backend
end

#declarationsArray[NodeWrapper] (readonly)

Returns the value of attribute declarations.

Returns:



8
9
10
# File 'lib/typescript/merge/file_analysis.rb', line 8

def declarations
  @declarations
end

#dialectSymbol (readonly)

Returns the value of attribute dialect.

Returns:

  • (Symbol)


8
9
10
# File 'lib/typescript/merge/file_analysis.rb', line 8

def dialect
  @dialect
end

#errorsArray[StandardError] (readonly)

Returns the value of attribute errors.

Returns:

  • (Array[StandardError])


8
9
10
# File 'lib/typescript/merge/file_analysis.rb', line 8

def errors
  @errors
end

#root_nodeObject (readonly)

Returns the value of attribute root_node.

Returns:

  • (Object)


8
9
10
# File 'lib/typescript/merge/file_analysis.rb', line 8

def root_node
  @root_node
end

#sourceString (readonly)

Returns the value of attribute source.

Returns:

  • (String)


8
9
10
# File 'lib/typescript/merge/file_analysis.rb', line 8

def source
  @source
end