mulang 6.0.0 → 6.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8bb18e555a651ab4f2c24ac12c63c209e542c16f06568e64991f3805f6ade038
4
- data.tar.gz: fe43d0621ccdd7de1fb4456a847500f18643fa7073283fc7383bfd686e56fe2c
3
+ metadata.gz: fd9e7b420eb8e3ca739405ca392944762b50d255a377f23742937d038178efea
4
+ data.tar.gz: 1eb585f9453b54f404a18f069cecd15107845f83060a0f9dca86b27a5b6df121
5
5
  SHA512:
6
- metadata.gz: 54cb641d94595bb9bb7b7a90ca34b1d07c43d16f5e9f4cf1b4c8739e4caf4019a417c72d69dd3823bde6caa9d43b90a7e1214d1e2aa6a0f25010ace70413a4e1
7
- data.tar.gz: e3cc1287c561622172627a476548b0c721a8b3395928e5f0a26eb9ec11a10fe2275839668145a7bc63390be34556fda0e7230ca01675c7bf5df469897fc112ec
6
+ metadata.gz: fcbcee4826c479c36c3467c5ce5847bb2eb8a877c4e0c659c7e0808b9c8267c8b753862726cc3e630c5d8bbc0b16d299c1aadef3d9922b79b87c0548c4d345a0
7
+ data.tar.gz: ee918b2941252550c2758f802c35ba4c66b9aa8c3a4fa09326a1182e2a65ca61a7fe054c122578b3ce7470a7cc9a04a778299f3040b6d9152cd8779fb6d3234d
data/bin/mulang CHANGED
Binary file
@@ -60,8 +60,8 @@ module Mulang
60
60
  native(*args).tap { |it| it.expect('Parses') }
61
61
  end
62
62
 
63
- def self.external(content, &tool)
64
- new Mulang::Language::External.new(&tool), content
63
+ def self.external(language_name = nil, content, &tool)
64
+ new Mulang::Language::External.new(language_name, &tool), content
65
65
  end
66
66
 
67
67
  def self.analyse_many(codes, spec, **options)
@@ -76,13 +76,13 @@ module Mulang
76
76
  run_many(codes, key: 'transformedAsts', **options) { |it| it.transformed_asts_analysis(operations, **options) }
77
77
  end
78
78
 
79
- private
80
-
81
79
  def self.run_many(codes, key: nil, **options)
82
80
  result = Mulang.analyse(codes.map { |it| yield it }, **options)
83
81
  key ? result.map { |it| it[key] } : result
84
82
  end
85
83
 
84
+ private
85
+
86
86
  def expectation_results_for(result)
87
87
  raise result['reason'] if result['tag'] == 'AnalysisFailed'
88
88
  result['expectationResults']
@@ -19,13 +19,13 @@ module Mulang::Expectation
19
19
  OverridesEqualOrHashButNotBoth
20
20
  ReturnsNil
21
21
  ReturnsNull
22
+ DoesTypeTest
22
23
  )
23
24
 
24
25
  IMPERATIVE_SMELLS = %w(
25
26
  HasAssignmentCondition
26
27
  HasAssignmentReturn
27
28
  HasEmptyRepeat
28
- HasRedundantLocalVariableReturn
29
29
  HasRedundantRepeat
30
30
  )
31
31
 
@@ -40,13 +40,13 @@ module Mulang::Expectation
40
40
  GENERIC_SMELLS = %w(
41
41
  DiscardsExceptions
42
42
  DoesConsolePrint
43
- DoesTypeTest
44
43
  HasCodeDuplication
45
44
  HasDeclarationTypos
46
45
  HasEmptyIfBranches
47
46
  HasEqualIfBranches
48
47
  HasLongParameterList
49
48
  HasRedundantBooleanComparison
49
+ HasRedundantLocalVariableReturn
50
50
  HasRedundantIf
51
51
  HasRedundantLambda
52
52
  HasTooShortBindings
@@ -57,7 +57,17 @@ module Mulang::Expectation
57
57
  ShouldUseStrictComparators
58
58
  )
59
59
 
60
- SMELLS = GENERIC_SMELLS + EXPRESSIVENESS_SMELLS + IMPERATIVE_SMELLS + OBJECT_ORIENTED_SMELLS + FUNCTIONAL_SMELLS + LOGIC_SMELLS
60
+ JAVA_SCRIPT_SMELLS = %w(
61
+ JavaScript#UsesVarInsteadOfLet
62
+ )
63
+
64
+ SMELLS = GENERIC_SMELLS +
65
+ EXPRESSIVENESS_SMELLS +
66
+ IMPERATIVE_SMELLS +
67
+ OBJECT_ORIENTED_SMELLS +
68
+ FUNCTIONAL_SMELLS +
69
+ LOGIC_SMELLS +
70
+ JAVA_SCRIPT_SMELLS
61
71
 
62
72
  def self.guess_type(expectation)
63
73
  if expectation[:binding] == '<<custom>>'
@@ -20,6 +20,14 @@ module Mulang::Language
20
20
  options.except(:serialization).presence
21
21
  end
22
22
 
23
+ def ast(content, **options)
24
+ Mulang.analyse(ast_analysis(content, **options), **options)['outputAst'] rescue nil
25
+ end
26
+
27
+ def ast_analysis(content, **options)
28
+ base_analysis content, {includeOutputAst: true}, **options
29
+ end
30
+
23
31
  private
24
32
 
25
33
  def base_analysis(content, spec, **options)
@@ -36,41 +44,52 @@ module Mulang::Language
36
44
  end
37
45
 
38
46
  class Native < Base
39
- def initialize(language)
40
- @language = language
41
- end
42
-
43
- def ast(content, **options)
44
- Mulang.analyse(ast_analysis(content, **options), **options)['outputAst'] rescue nil
45
- end
47
+ attr_accessor :name
46
48
 
47
- def ast_analysis(content, **options)
48
- base_analysis content, {includeOutputAst: true}, **options
49
+ def initialize(language_name)
50
+ @name = language_name
49
51
  end
50
52
 
51
53
  def sample(content)
52
54
  {
53
55
  tag: 'CodeSample',
54
- language: @language,
56
+ language: @name,
55
57
  content: content
56
58
  }
57
59
  end
58
60
  end
59
61
 
60
62
  class External < Base
61
- def initialize(&tool)
63
+ attr_accessor :name
64
+
65
+ def initialize(language_name = nil, &tool)
66
+ @name = language_name
62
67
  @tool = block_given? ? tool : proc { |it| it }
63
68
  end
64
69
 
65
70
  def ast(content, **args)
66
- @tool.call(content) rescue nil
71
+ if args[:serialization]
72
+ super
73
+ else
74
+ call_tool content
75
+ end
67
76
  end
68
77
 
69
78
  def sample(content)
70
79
  {
71
80
  tag: 'MulangSample',
72
- ast: ast(content)
81
+ ast: call_tool(content)
73
82
  }
74
83
  end
84
+
85
+ def base_analysis(*)
86
+ super.deep_merge(spec: {originalLanguage: @name}.compact)
87
+ end
88
+
89
+ private
90
+
91
+ def call_tool(content)
92
+ @tool.call(content) rescue nil
93
+ end
75
94
  end
76
95
  end
@@ -1,4 +1,4 @@
1
1
  module Mulang
2
- VERSION = "6.0.0"
3
- MULANG_VERSION = "6.0.0"
2
+ VERSION = "6.0.1"
3
+ MULANG_VERSION = "6.0.1"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mulang
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.0
4
+ version: 6.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Franco Bulgarelli
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-19 00:00:00.000000000 Z
11
+ date: 2021-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mumukit-core