Class: JavaFeedbackHook::JavaExplainer

Inherits:
Mumukit::Explainer
  • Object
show all
Defined in:
lib/feedback_hook.rb

Instance Method Summary collapse

Instance Method Details

#explain_cannot_find_symbol(_, result) ⇒ Object



35
36
37
38
39
40
41
42
# File 'lib/feedback_hook.rb', line 35

def explain_cannot_find_symbol(_, result)
  (/#{error} cannot find symbol#{near_regex}#{symbol_regex}#{location_regex}/.match result).try do |it|
    symbol = it[2].strip
    location = it[3].strip

    {near: it[1], symbol: localize_symbol(symbol), at_location: at_location(symbol, location) }
  end
end

#explain_implemented_method_should_be_public(_, result) ⇒ Object



78
79
80
81
82
# File 'lib/feedback_hook.rb', line 78

def explain_implemented_method_should_be_public(_, result)
 (/#{error} (.*) in (.*) cannot implement (.*) in (.*)#{near_regex}\n  attempting to assign weaker access privileges/.match result).try do |it|
   {method: it[1], class: it[2], near: it[5]}
 end
end

#explain_incompatible_types(_, result) ⇒ Object



50
51
52
53
54
55
56
57
58
# File 'lib/feedback_hook.rb', line 50

def explain_incompatible_types(_, result)
  (/#{error} incompatible types: (.*) cannot be converted to (.*)#{near_regex}/.match result).try do |it|
    actual = it[1]
    expected = it[2]
    near = it[3]

    { message: I18n.t(type_incompatibilty_kind(actual, expected), actual: actual, expected: expected, near: near) }
  end
end

#explain_lossy_conversion(_, result) ⇒ Object



44
45
46
47
48
# File 'lib/feedback_hook.rb', line 44

def explain_lossy_conversion(_, result)
  (/#{error} incompatible types: possible lossy conversion from (.*) to (.*)#{near_regex}/.match result).try do |it|
    { from: it[1], to: it[2], near: it[3] }
  end
end

#explain_missing_bracket(_, result) ⇒ Object



19
20
21
# File 'lib/feedback_hook.rb', line 19

def explain_missing_bracket(_, result)
  missing_character result, '\{'
end

#explain_missing_implementation(_, result) ⇒ Object



84
85
86
87
88
# File 'lib/feedback_hook.rb', line 84

def explain_missing_implementation(_, result)
  (/#{error} (.*) is not abstract and does not override abstract method (.*) in (.*)#{near_regex}/.match result).try do |it|
    {down: it[1], method: it[2], up: it[3] }
  end
end

#explain_missing_parameter_type(_, result) ⇒ Object



23
24
25
26
27
# File 'lib/feedback_hook.rb', line 23

def explain_missing_parameter_type(_, result)
  (/#{error} <identifier> expected#{near_regex}/.match result).try do |it|
    {near: it[1]}
  end
end

#explain_missing_parenthesis(_, result) ⇒ Object



15
16
17
# File 'lib/feedback_hook.rb', line 15

def explain_missing_parenthesis(_, result)
  missing_character result, '\('
end

#explain_missing_return_statement(_, result) ⇒ Object



29
30
31
32
33
# File 'lib/feedback_hook.rb', line 29

def explain_missing_return_statement(_, result)
  (/#{error} missing return statement#{near_regex}/.match result).try do |it|
    {near: it[1]}
  end
end

#explain_missing_return_type(_, result) ⇒ Object



90
91
92
93
94
# File 'lib/feedback_hook.rb', line 90

def explain_missing_return_type(_, result)
  (/#{error} invalid method declaration; return type required#{near_regex}/.match result).try do |it|
    { near: it[1] }
  end
end

#explain_missing_semicolon(_, result) ⇒ Object



11
12
13
# File 'lib/feedback_hook.rb', line 11

def explain_missing_semicolon(_, result)
  missing_character result, ';'
end

#explain_unexpected_close_curly(_, result) ⇒ Object



66
67
68
69
70
# File 'lib/feedback_hook.rb', line 66

def explain_unexpected_close_curly(_, result)
  (/\(line (.*), .*\):\nunexpected CloseCurly/.match result).try do |it|
    {line: it[1]}
  end
end

#explain_unexpected_close_paren(_, result) ⇒ Object



72
73
74
75
76
# File 'lib/feedback_hook.rb', line 72

def explain_unexpected_close_paren(_, result)
  (/\(line (.*), .*\):\nunexpected CloseParen/.match result).try do |it|
    {line: it[1]}
  end
end

#explain_wrong_constructor_arguments(_, result) ⇒ Object



60
61
62
63
64
# File 'lib/feedback_hook.rb', line 60

def explain_wrong_constructor_arguments(_, result)
  (/#{error} constructor (.*) in class (.*) cannot be applied to given types;#{near_regex}/.match result).try do |it|
    { class: it[2] }
  end
end