mumuki-java-runner 1.5.1 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 023122917d42a6f19f684a74788fba8504047391228c7e6d79d674e432625614
4
- data.tar.gz: ec1365ba7c159817c67369005f17a8d3b47f7df54d3bc66b67a0c7a4e3351980
3
+ metadata.gz: a3e49fce3563aa66a7604c91f88cdd8f1d8410c0531c7c03973cbdb9f86311e8
4
+ data.tar.gz: 970a07892790c2d723436f3a3cce059345ca8f82d9f3cfefef6b23b89c88843b
5
5
  SHA512:
6
- metadata.gz: 317d813cf478b75cce92c34c4abac903e05d156775e11eb8c914ee0f4c0e0eae14f6cdd5868a555c69a35166f930ebba057688933e7017d70902a97f047b549f
7
- data.tar.gz: 9f5ae68faa9b891f62c18cd18e569fd2dff89d54bd4e6aebbb188a937d7047d2db310e161b7841d82b1c61a1d0c76964d289955db3cd14b8bb292e636aaada8e
6
+ metadata.gz: 9f16499caf666e4d009b921f5be08407a5c7be624b1db52bfd4c6d7b2d46ca04f14fb8771f63086988485dd5aadb11e2e4accfbbf9a6a066d174c03ca89186d1
7
+ data.tar.gz: ab72b1133f8c40c567ed87d08a957615cce92e36b2eff9991460b1899fe5a762a1c836bedcee173474514a63f26f553da48a1215ba14bcbfaffb2fae81f6087c
@@ -34,13 +34,32 @@ class JavaFeedbackHook < Mumukit::Hook
34
34
 
35
35
  def explain_cannot_find_symbol(_, result)
36
36
  (/#{error} cannot find symbol#{near_regex}#{symbol_regex}#{location_regex}/.match result).try do |it|
37
- {near: it[1], symbol: it[2].strip, location: it[3].strip}
37
+ symbol = it[2].strip
38
+ location = it[3].strip
39
+
40
+ {near: it[1], symbol: localize_symbol(symbol), at_location: at_location(symbol, location) }
41
+ end
42
+ end
43
+
44
+ def explain_lossy_conversion(_, result)
45
+ (/#{error} incompatible types: possible lossy conversion from (.*) to (.*)#{near_regex}/.match result).try do |it|
46
+ { from: it[1], to: it[2], near: it[3] }
38
47
  end
39
48
  end
40
49
 
41
50
  def explain_incompatible_types(_, result)
42
51
  (/#{error} incompatible types: (.*) cannot be converted to (.*)#{near_regex}/.match result).try do |it|
43
- {down: it[1], up: it[2], near: it[3]}
52
+ actual = it[1]
53
+ expected = it[2]
54
+ near = it[3]
55
+
56
+ { message: I18n.t(type_incompatibilty_kind(actual, expected), actual: actual, expected: expected, near: near) }
57
+ end
58
+ end
59
+
60
+ def explain_wrong_constructor_arguments(_, result)
61
+ (/#{error} constructor (.*) in class (.*) cannot be applied to given types;#{near_regex}/.match result).try do |it|
62
+ { class: it[2] }
44
63
  end
45
64
  end
46
65
 
@@ -56,6 +75,24 @@ class JavaFeedbackHook < Mumukit::Hook
56
75
  end
57
76
  end
58
77
 
78
+ def explain_implemented_method_should_be_public(_, result)
79
+ (/#{error} (.*) in (.*) cannot implement (.*) in (.*)#{near_regex}\n attempting to assign weaker access privileges/.match result).try do |it|
80
+ {method: it[1], class: it[2], near: it[5]}
81
+ end
82
+ end
83
+
84
+ def explain_missing_implementation(_, result)
85
+ (/#{error} (.*) is not abstract and does not override abstract method (.*) in (.*)#{near_regex}/.match result).try do |it|
86
+ {down: it[1], method: it[2], up: it[3] }
87
+ end
88
+ end
89
+
90
+ def explain_missing_return_type(_, result)
91
+ (/#{error} invalid method declaration; return type required#{near_regex}/.match result).try do |it|
92
+ { near: it[1] }
93
+ end
94
+ end
95
+
59
96
  private
60
97
 
61
98
  def start_regex(symbol=' ')
@@ -74,6 +111,14 @@ class JavaFeedbackHook < Mumukit::Hook
74
111
  start_regex 'location:'
75
112
  end
76
113
 
114
+ def type_incompatibilty_kind(a_type, another)
115
+ [a_type, another].any? { |it| primitive_types.include?(it) } ? :incompatible_types_primitives : :incompatible_types_classes
116
+ end
117
+
118
+ def primitive_types
119
+ ['byte', 'short', 'int', 'long', 'float', 'double', 'boolean', 'char']
120
+ end
121
+
77
122
  def error
78
123
  '[eE]rror:'
79
124
  end
@@ -84,5 +129,34 @@ class JavaFeedbackHook < Mumukit::Hook
84
129
  end
85
130
  end
86
131
 
132
+ def at_location(symbol, location)
133
+ symbol_type, _ = parse_symbol symbol
134
+ return '' if symbol_type == 'class'
135
+
136
+ ' ' + I18n.t(:at_location, {
137
+ location: localize_symbol(location)
138
+ })
139
+ end
140
+
141
+ def localize_symbol(symbol)
142
+ symbol_type, name, type = parse_symbol symbol
143
+ i18n_key = "symbol_#{symbol_type}"
144
+ return "`#{symbol}`" unless I18n.exists? i18n_key
145
+
146
+ I18n.t(i18n_key, { name: name }) + localize_of_type(type)
147
+ end
148
+
149
+ def localize_of_type(type)
150
+ return '' if type.nil?
151
+
152
+ ' ' + I18n.t(:of_type, type: type)
153
+ end
154
+
155
+ def parse_symbol(result)
156
+ parts = /^(\w+) ([\w\(\)]+)( of type (\w+))?/.match result
157
+ return ['', '', ''] if parts.nil?
158
+
159
+ [parts[1], parts[2], parts[4]]
160
+ end
87
161
  end
88
162
  end
@@ -1,10 +1,19 @@
1
1
  en:
2
- missing_semicolon: "Missing ';' near `%{near}`"
3
- missing_parenthesis: "Missing '(' near `%{near}`"
2
+ at_location: "in %{location}"
3
+ cannot_find_symbol: "Cannot find `%{symbol}` declaration%{at_location}"
4
+ implemented_method_should_be_public: "Method `%{method}` in class `%{class}` should be public. Check if it has the right visibility near `%{near}`."
5
+ incompatible_types_classes: "Class `%{actual}` should be a `%{expected}`. Probably an _extends_ or _implements_ is missing near `%{near}`."
6
+ incompatible_types_primitives: "You are returning a `%{actual}` where a `%{expected}` is needed near `%{near}`"
7
+ incompatible_types: "%{message}"
4
8
  missing_bracket: "Missing { near `%{near}`. Maybe you misspelled a class or method declaration."
9
+ missing_implementation: "An implementation of method `%{method}` is missing in class `%{down}`, since it is defined at `%{up}`"
10
+ missing_parenthesis: "Missing '(' near `%{near}`"
5
11
  missing_parameter_type: "Missing parameter type near `%{near}`"
6
- cannot_find_symbol: "Cannot find `%{symbol}` declaration in `%{location}`"
7
12
  missing_return_statement: "There is a method that must return something, but doesn't. Check your code again!"
8
- incompatible_types: "Class `%{down}` should be a `%{up}`. Probably an _extends_ or _implements_ is missing near `%{near}`."
13
+ missing_return_type: "Missing return type near `%{near}`"
14
+ missing_semicolon: "Missing ';' near `%{near}`"
15
+ lossy_conversion: "You are trying to convert a `%{from}` into a `%{to}`, but `%{from}` is more specific, and data may be lost. If you are sure about doing this, add a `(%{to})` to the left side of the expression near `%{near}`."
16
+ of_type: "of type `%{type}`"
9
17
  unexpected_close_curly: "You have a syntax error. Check if you're missing a `;` or a `{` near line %{line}."
10
18
  unexpected_close_paren: "You have a syntax error. Check if you're missing a `(` or have an extra `)` near line %{line}. Also make sure all parameters declare their types."
19
+ wrong_constructor_arguments: "Constructor of class `%{class}` doesn't exist or it expects another amount or type of arguments"
@@ -1,10 +1,22 @@
1
1
  es:
2
- missing_semicolon: "Parece que falta un ';' cerca de `%{near}`"
3
- missing_parenthesis: "Parece que falta un '(' cerca de `%{near}`"
4
- missing_bracket: "Se esperaba una { cerca de `%{near}`. Fijate si tal vez, introdujiste un paréntesis de más o está mal escrita la declaración de clase o método."
5
- missing_parameter_type: "Parece que falta el tipo de un parámetro cerca de `%{near}`"
6
- cannot_find_symbol: "No se encontró la definición de `%{symbol}` en `%{location}`"
2
+ at_location: "en %{location}"
3
+ cannot_find_symbol: "Te falta la definición de %{symbol}%{at_location}"
4
+ implemented_method_should_be_public: "El método `%{method}` en la clase `%{class}` debería ser público. Revisá si tiene la visibilidad correcta cerca de `%{near}`."
5
+ incompatible_types_classes: "La clase `%{actual}` debería ser un `%{expected}`. Revisá si no te falta un _extends_ o _implements_ cerca de `%{near}`."
6
+ incompatible_types_primitives: "Estás devolviendo un `%{actual}` donde se necesitaba un `%{expected}` cerca de `%{near}`"
7
+ incompatible_types: "%{message}"
8
+ missing_bracket: "Te falta una `{` cerca de `%{near}`. Fijate si te sobran paréntesis o está mal escrita la declaración de clase o método."
9
+ missing_implementation: "Te está faltando implementar el método `%{method}` en la clase `%{down}`, ya que está definido en `%{up}`"
10
+ missing_parenthesis: "Parece que te falta un '(' cerca de `%{near}`"
11
+ missing_parameter_type: "Parece que te falta el tipo de un parámetro cerca de `%{near}`"
7
12
  missing_return_statement: "Hay un método que debería retornar algo, pero no está retornando nada. ¡Revisá bien tu código!"
8
- incompatible_types: "La clase `%{down}` debería ser un `%{up}`. Revisá si no te falta un _extends_ o _implements_ cerca de `%{near}`."
9
- unexpected_close_curly: "Tenés un error de sintaxis. Fijate si no te falta un `;` o una `{` cerca de la línea %{line}."
10
- unexpected_close_paren: "Tenés un error de sintaxis. Fijate si no te falta un `(` o te sobra un `)` cerca de la línea %{line}. Asegurate también de que todos los parámetros declaren sus tipos."
13
+ missing_return_type: "Te falta especificar el tipo de retorno cerca de `%{near}`"
14
+ missing_semicolon: "Parece que te falta un ';' cerca de `%{near}`"
15
+ lossy_conversion: "Estás intentando convertir un `%{from}` a un `%{to}`, pero `%{from}` es más específico y se podrían perder datos. Si realmente querés hacerlo, agregá un `(%{to})` a la izquierda de la expresión, cerca de `%{near}`."
16
+ of_type: "de tipo `%{type}`"
17
+ symbol_class: "la clase `%{name}`"
18
+ symbol_method: "método `%{name}`"
19
+ symbol_variable: "la variable `%{name}`"
20
+ unexpected_close_curly: "Fijate si no te falta un `;` o una `{` cerca de la línea %{line}."
21
+ unexpected_close_paren: "Fijate si no te falta un `(` o te sobra un `)` cerca de la línea %{line}. Asegurate también de que todos los parámetros declaren sus tipos."
22
+ wrong_constructor_arguments: "El constructor de la clase `%{class}` no existe o espera otra cantidad o tipo de argumentos"
@@ -1,3 +1,3 @@
1
1
  module JavaVersionHook
2
- VERSION = '1.5.1'
2
+ VERSION = '1.6.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mumuki-java-runner
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.1
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Franco Leonardo Bulgarelli
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-24 00:00:00.000000000 Z
11
+ date: 2019-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mumukit
@@ -128,8 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
128
128
  - !ruby/object:Gem::Version
129
129
  version: '0'
130
130
  requirements: []
131
- rubyforge_project:
132
- rubygems_version: 2.7.7
131
+ rubygems_version: 3.0.2
133
132
  signing_key:
134
133
  specification_version: 4
135
134
  summary: Java Runner for Mumuki