Class: Mulang::Language::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/mulang/language.rb

Direct Known Subclasses

External, Native

Instance Method Summary collapse

Instance Method Details

#ast(content, **options) ⇒ Object



37
38
39
# File 'lib/mulang/language.rb', line 37

def ast(content, **options)
  Mulang.analyse(ast_analysis(content, **options), **options)['outputAst'] rescue nil
end

#ast_analysis(content, **options) ⇒ Object



41
42
43
# File 'lib/mulang/language.rb', line 41

def ast_analysis(content, **options)
  build_analysis content, {includeOutputAst: true}, **options
end

#build_analysis(content, spec, **options) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
# File 'lib/mulang/language.rb', line 45

def build_analysis(content, spec, **options)
  {
    sample: sample(content),
    spec: {
      expectations: [],
      smellsSet: { tag: 'NoSmells' },
      includeOutputAst: false,
      normalizationOptions: normalization_options(**options)
    }.merge(spec).compact
  }
end

#identifiers(content, **options) ⇒ Object



17
18
19
# File 'lib/mulang/language.rb', line 17

def identifiers(content, **options)
  Mulang.analyse(identifiers_analysis(content, **options), **options)['outputIdentifiers'] rescue nil
end

#identifiers_analysis(content, **options) ⇒ Object



21
22
23
# File 'lib/mulang/language.rb', line 21

def identifiers_analysis(content, **options)
  build_analysis content, {includeOutputIdentifiers: true}, **options
end

#normalization_options(**options) ⇒ Object



33
34
35
# File 'lib/mulang/language.rb', line 33

def normalization_options(**options)
  options.except(:serialization).presence
end

#transformed_asts(content, operations, **options) ⇒ Object



25
26
27
# File 'lib/mulang/language.rb', line 25

def transformed_asts(content, operations, **options)
  Mulang.analyse(transformed_asts_analysis(content, operations, **options), **options)['transformedAsts'] rescue nil
end

#transformed_asts_analysis(content, operations, **options) ⇒ Object



29
30
31
# File 'lib/mulang/language.rb', line 29

def transformed_asts_analysis(content, operations, **options)
  build_analysis content, {transformationSpecs: operations}, **options
end