redcar 0.8.1 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (210) hide show
  1. data/CHANGES +41 -1
  2. data/README.md +1 -1
  3. data/Rakefile +5 -6
  4. data/lib/plugin_manager/lib/plugin_manager.rb +1 -2
  5. data/lib/redcar.rb +19 -14
  6. data/lib/redcar/installer.rb +21 -17
  7. data/lib/redcar/runner.rb +10 -7
  8. data/lib/redcar/usage.rb +1 -0
  9. data/lib/redcar_quick_start.rb +8 -12
  10. data/lib/regex_replace.rb +3 -3
  11. data/plugins/application/features/step_definitions/menu_steps.rb +10 -0
  12. data/plugins/application/features/step_definitions/speedbar_steps.rb +8 -2
  13. data/plugins/application/features/step_definitions/tree_steps.rb +48 -6
  14. data/plugins/application/features/step_definitions/window_steps.rb +9 -4
  15. data/plugins/application/features/support/env.rb +20 -1
  16. data/plugins/application/features/support/fake_event.rb +14 -0
  17. data/plugins/application/lib/application.rb +29 -12
  18. data/plugins/application/lib/application/dialogs/filter_list_dialog.rb +19 -0
  19. data/plugins/application/lib/application/speedbar.rb +23 -17
  20. data/plugins/application/lib/application/tab.rb +20 -15
  21. data/plugins/application/lib/application/treebook.rb +10 -7
  22. data/plugins/application/lib/application/window.rb +1 -1
  23. data/plugins/application/plugin.rb +1 -1
  24. data/plugins/application_swt/lib/application_swt/dialog_adapter.rb +4 -4
  25. data/plugins/application_swt/lib/application_swt/dialogs/filter_list_dialog_controller.rb +15 -4
  26. data/plugins/application_swt/lib/application_swt/icon.rb +3 -5
  27. data/plugins/application_swt/lib/application_swt/notebook/tab_drag_and_drop_listener.rb +4 -4
  28. data/plugins/application_swt/lib/application_swt/notebook/tab_transfer.rb +5 -5
  29. data/plugins/application_swt/lib/application_swt/speedbar.rb +34 -120
  30. data/plugins/application_swt/lib/application_swt/speedbar/button_item.rb +20 -0
  31. data/plugins/application_swt/lib/application_swt/speedbar/combo_item.rb +38 -0
  32. data/plugins/application_swt/lib/application_swt/speedbar/label_item.rb +15 -0
  33. data/plugins/application_swt/lib/application_swt/speedbar/slider_item.rb +32 -0
  34. data/plugins/application_swt/lib/application_swt/speedbar/text_box_item.rb +36 -0
  35. data/plugins/application_swt/lib/application_swt/speedbar/toggle_item.rb +29 -0
  36. data/plugins/application_swt/lib/application_swt/tab.rb +1 -3
  37. data/plugins/application_swt/lib/application_swt/toolbar.rb +19 -20
  38. data/plugins/application_swt/lib/application_swt/treebook.rb +24 -9
  39. data/plugins/application_swt/lib/application_swt/window.rb +110 -98
  40. data/plugins/application_swt/lib/swt/vtab_folder.rb +77 -32
  41. data/plugins/application_swt/lib/swt/vtab_item.rb +9 -0
  42. data/plugins/application_swt/lib/swt/vtab_label.rb +63 -23
  43. data/plugins/application_swt/plugin.rb +1 -1
  44. data/plugins/clipboard-viewer/lib/clipboard_viewer/clipboard_bar.rb +2 -2
  45. data/plugins/comment/features/line_comment.feature +116 -4
  46. data/plugins/comment/lib/comment.rb +18 -16
  47. data/plugins/connection_manager/lib/connection_manager/commands.rb +1 -1
  48. data/plugins/connection_manager/lib/connection_manager/private_key_store.rb +5 -3
  49. data/plugins/declarations/lib/declarations.rb +1 -1
  50. data/plugins/declarations/lib/declarations/parser.rb +68 -20
  51. data/plugins/document_search/features/replace.feature +18 -0
  52. data/plugins/document_search/lib/document_search.rb +37 -54
  53. data/plugins/document_search/lib/document_search/replace_all_command.rb +27 -0
  54. data/plugins/document_search/lib/document_search/replace_command.rb +38 -0
  55. data/plugins/document_search/lib/document_search/replace_next_command.rb +27 -0
  56. data/plugins/document_search/lib/document_search/search_and_replace.rb +17 -24
  57. data/plugins/edit_view/features/step_definitions/editing_steps.rb +4 -4
  58. data/plugins/edit_view/features/step_definitions/tab_steps.rb +9 -0
  59. data/plugins/edit_view/features/step_definitions/window_steps.rb +0 -12
  60. data/plugins/edit_view/lib/edit_view/document.rb +2 -0
  61. data/plugins/edit_view/lib/edit_view/document/command.rb +8 -8
  62. data/plugins/edit_view/lib/edit_view/edit_tab.rb +21 -7
  63. data/plugins/edit_view/lib/edit_view/select_font_dialog.rb +6 -0
  64. data/plugins/edit_view/lib/edit_view/select_theme_dialog.rb +6 -0
  65. data/plugins/edit_view_swt/lib/edit_view_swt.rb +92 -43
  66. data/plugins/edit_view_swt/lib/edit_view_swt/document.rb +17 -4
  67. data/plugins/find-in-project/lib/find_in_project.rb +1 -4
  68. data/plugins/find-in-project/lib/find_in_project/commands.rb +0 -14
  69. data/plugins/find-in-project/lib/find_in_project/controllers.rb +12 -0
  70. data/plugins/find-in-project/lib/find_in_project/views/index.html.erb +5 -0
  71. data/plugins/groovy/features/fixtures/test.groovy +0 -0
  72. data/plugins/groovy/features/step_definitions/groovy_steps.rb +27 -0
  73. data/plugins/groovy/features/support/env.rb +27 -0
  74. data/plugins/groovy/features/syntax_check_groovy.feature +72 -0
  75. data/plugins/groovy/lib/syntax_check/groovy.rb +76 -0
  76. data/plugins/groovy/plugin.rb +7 -0
  77. data/plugins/help/lib/help.rb +28 -4
  78. data/plugins/help/lib/help/help_tab.rb +11 -0
  79. data/plugins/help/lib/help/view_controller.rb +25 -0
  80. data/plugins/help/plugin.rb +2 -1
  81. data/plugins/{view_shortcuts → help}/views/default.css +0 -0
  82. data/plugins/{view_shortcuts → help}/views/index.html.erb +1 -1
  83. data/plugins/{view_shortcuts → help}/views/redcar_small_icon.png +0 -0
  84. data/plugins/html_view/features/browser_bar.feature +47 -0
  85. data/plugins/html_view/features/fixtures/other.html +1 -0
  86. data/plugins/html_view/features/fixtures/sample.html +1 -0
  87. data/plugins/html_view/features/step_definitions/html_view_steps.rb +45 -5
  88. data/plugins/html_view/features/support/env.rb +26 -0
  89. data/plugins/html_view/features/web_preview.feature +21 -0
  90. data/plugins/html_view/lib/html_controller.rb +5 -5
  91. data/plugins/html_view/lib/html_view.rb +62 -10
  92. data/plugins/{web_bookmarks/lib/web_bookmarks → html_view/lib/html_view}/browser_bar.rb +32 -20
  93. data/plugins/html_view/lib/html_view/commands.rb +64 -0
  94. data/plugins/{web_bookmarks/lib/web_bookmarks/view_controller.rb → html_view/lib/html_view/default_controller.rb} +7 -6
  95. data/plugins/html_view/lib/html_view/html_tab.rb +17 -6
  96. data/plugins/html_view/plugin.rb +3 -3
  97. data/plugins/{web_bookmarks → html_view}/views/index.html.erb +0 -0
  98. data/plugins/javascript/features/fixtures/test.js +0 -0
  99. data/plugins/javascript/features/support/env.rb +4 -0
  100. data/plugins/javascript/features/syntax_check_javascript.feature +27 -0
  101. data/plugins/javascript/lib/syntax_check/javascript.rb +52 -0
  102. data/plugins/javascript/plugin.rb +7 -0
  103. data/plugins/javascript/vendor/jslint.js +539 -0
  104. data/plugins/macros/lib/macros/commands.rb +3 -3
  105. data/plugins/open_default_app/lib/open_default_app.rb +29 -3
  106. data/plugins/open_default_app/plugin.rb +1 -1
  107. data/plugins/outline_view/features/outline_view.feature +79 -0
  108. data/plugins/outline_view/features/step_definitions/outline_steps.rb +45 -0
  109. data/plugins/outline_view/lib/outline_view.rb +1 -1
  110. data/plugins/outline_view/spec/fixtures/some_project/javascript.js +10 -0
  111. data/plugins/outline_view/spec/fixtures/some_project/nothing_to_see.rb +0 -0
  112. data/plugins/outline_view/spec/fixtures/some_project/one_lonely_class.rb +2 -0
  113. data/plugins/outline_view/spec/fixtures/some_project/similar_names.rb +18 -0
  114. data/plugins/outline_view/spec/fixtures/some_project/something_fancy.rb +736 -0
  115. data/plugins/outline_view/spec/fixtures/some_project/trailing_space.rb +5 -0
  116. data/plugins/outline_view_swt/lib/outline_view_swt.rb +17 -19
  117. data/plugins/pair_highlighter/lib/pair_highlighter/document_controller.rb +1 -4
  118. data/plugins/plugin_manager_ui/lib/plugin_manager_ui.rb +12 -3
  119. data/plugins/project/features/close_directory_tree.feature +27 -0
  120. data/plugins/project/features/highlight_focussed_tab.feature +45 -1
  121. data/plugins/project/features/open_and_save_files.feature +33 -0
  122. data/plugins/project/features/open_directory_tree.feature +37 -11
  123. data/plugins/project/features/step_definitions/directory_steps.rb +1 -1
  124. data/plugins/project/features/step_definitions/drb_steps.rb +40 -0
  125. data/plugins/project/features/support/env.rb +17 -0
  126. data/plugins/project/lib/project.rb +12 -2
  127. data/plugins/project/lib/project/commands.rb +101 -99
  128. data/plugins/project/lib/project/drb_service.rb +55 -65
  129. data/plugins/project/lib/project/manager.rb +29 -4
  130. data/plugins/project/lib/project/project_tree_controller.rb +24 -0
  131. data/plugins/project/lib/project/support/trash.rb +1 -0
  132. data/plugins/redcar/redcar.rb +100 -37
  133. data/plugins/redcar_debug/lib/redcar_debug.rb +3 -3
  134. data/plugins/repl/features/step_definitions/repl_steps.rb +3 -0
  135. data/plugins/repl/lib/repl.rb +4 -11
  136. data/plugins/repl/lib/repl/repl_tab.rb +26 -0
  137. data/plugins/ruby/features/fixtures/test.rb +0 -0
  138. data/plugins/ruby/features/support/env.rb +4 -0
  139. data/plugins/ruby/features/syntax_check_ruby.feature +25 -0
  140. data/plugins/runnables/features/command_tree.feature +28 -0
  141. data/plugins/runnables/lib/runnables.rb +1 -0
  142. data/plugins/runnables/lib/runnables/commands.rb +4 -4
  143. data/plugins/runnables/lib/runnables/output_processor.rb +5 -5
  144. data/plugins/runnables/lib/runnables/tree_mirror/tree_controller.rb +2 -7
  145. data/plugins/runnables/lib/runnables/tree_mirror/tree_mirror.rb +13 -8
  146. data/plugins/scm_git/lib/scm_git/change.rb +5 -5
  147. data/plugins/strip_trailing_spaces/features/fixtures/test.txt +3 -0
  148. data/plugins/strip_trailing_spaces/features/strip_trailing_spaces.feature +34 -0
  149. data/plugins/strip_trailing_spaces/lib/strip_trailing_spaces.rb +3 -38
  150. data/plugins/swt/lib/swt.rb +5 -13
  151. data/plugins/swt/lib/swt/full_swt.rb +15 -13
  152. data/plugins/syntax_check/features/step_definitions/syntax_check_steps.rb +7 -0
  153. data/plugins/syntax_check/lib/syntax_check.rb +21 -3
  154. data/plugins/syntax_check/lib/syntax_check/error.rb +4 -3
  155. data/plugins/task_manager/lib/task_manager.rb +1 -1
  156. data/plugins/textmate/vendor/redcar-bundles/Bundles/Ant.tmbundle/Preferences/Autocompletions.tmPreferences +345 -0
  157. data/plugins/textmate/vendor/redcar-bundles/Bundles/Ant.tmbundle/Preferences/Symbol List Target.tmPreferences +22 -0
  158. data/plugins/textmate/vendor/redcar-bundles/Bundles/Ant.tmbundle/Snippets/Doc Banner.tmSnippet +20 -0
  159. data/plugins/textmate/vendor/redcar-bundles/Bundles/Ant.tmbundle/Syntaxes/Ant.tmLanguage +247 -0
  160. data/plugins/textmate/vendor/redcar-bundles/Bundles/Ant.tmbundle/info.plist +55 -0
  161. data/plugins/textmate/vendor/redcar-bundles/Bundles/RedcarRepl.tmbundle/Syntaxes/GroovyRepl.plist +40 -0
  162. data/plugins/textmate/vendor/redcar-bundles/Bundles/RedcarRepl.tmbundle/info.plist +1 -1
  163. data/plugins/textmate/vendor/redcar-bundles/Bundles/Ruby Haml.tmbundle/Syntaxes/Ruby_Haml.tmLanguage +0 -1
  164. data/plugins/textmate/vendor/redcar-bundles/Bundles/Ruby Sass.tmbundle/Syntaxes/Ruby Sass.tmLanguage +626 -0
  165. data/plugins/textmate/vendor/redcar-bundles/Bundles/Ruby Sass.tmbundle/info.plist +16 -0
  166. data/plugins/todo_list/features/support/env.rb +8 -0
  167. data/plugins/todo_list/features/todo_list.feature +26 -0
  168. data/plugins/todo_list/lib/todo_list.rb +1 -0
  169. data/plugins/todo_list/lib/todo_list/file_parser.rb +23 -19
  170. data/plugins/todo_list/lib/todo_list/todo_controller.rb +60 -100
  171. data/plugins/todo_list/spec/fixtures/project/FIXME.file +3 -0
  172. data/plugins/todo_list/spec/fixtures/project/NOTE.ignored.file +1 -0
  173. data/plugins/todo_list/spec/fixtures/project/OPTIMIZE_colon.file +1 -0
  174. data/plugins/todo_list/spec/fixtures/project/XXX.ignored +1 -0
  175. data/plugins/todo_list/spec/fixtures/project/ignored_directory/TODO.file +2 -0
  176. data/plugins/todo_list/spec/fixtures/settings.rb +11 -0
  177. data/plugins/todo_list/spec/spec_helper.rb +6 -0
  178. data/plugins/todo_list/spec/todo_list/file_parser_spec.rb +35 -0
  179. data/plugins/tree/lib/tree.rb +1 -0
  180. data/plugins/tree/lib/tree/command.rb +5 -0
  181. data/plugins/web_bookmarks/features/bookmark.feature +37 -0
  182. data/plugins/web_bookmarks/features/fixtures/other.html +1 -0
  183. data/plugins/web_bookmarks/features/fixtures/sample.html +1 -0
  184. data/plugins/web_bookmarks/features/step_definitions/web_steps.rb +4 -0
  185. data/plugins/web_bookmarks/features/support/env.rb +26 -0
  186. data/plugins/web_bookmarks/lib/web_bookmarks.rb +0 -10
  187. data/plugins/web_bookmarks/lib/web_bookmarks/bookmark.rb +10 -1
  188. data/plugins/web_bookmarks/lib/web_bookmarks/commands.rb +1 -47
  189. data/plugins/web_bookmarks/lib/web_bookmarks/tree.rb +21 -14
  190. data/{plugins/application → share}/icons/close.png +0 -0
  191. data/{plugins/application → share}/icons/darwin-file.png +0 -0
  192. data/{plugins/application → share}/icons/darwin-folder.png +0 -0
  193. data/share/icons/open-source-flipped.png +0 -0
  194. data/{plugins/application/icons/redcar_icon_beta_dev.png → share/icons/redcar-icon-beta-dev.png} +0 -0
  195. data/{plugins/application/icons/redcar_icon_beta.png → share/icons/redcar-icon-beta.png} +0 -0
  196. data/{plugins/application → share}/icons/redcar-splash.png +0 -0
  197. metadata +90 -30
  198. data/lib/redcar/jvm_options_probe.rb +0 -33
  199. data/plugins/document_search/lib/document_search/replace.rb +0 -113
  200. data/plugins/document_search/lib/document_search/search.rb +0 -45
  201. data/plugins/outline_view_swt/lib/icons/alias.png +0 -0
  202. data/plugins/outline_view_swt/lib/icons/assignment.png +0 -0
  203. data/plugins/outline_view_swt/lib/icons/attribute.png +0 -0
  204. data/plugins/outline_view_swt/lib/icons/class.png +0 -0
  205. data/plugins/outline_view_swt/lib/icons/interface.png +0 -0
  206. data/plugins/outline_view_swt/lib/icons/method.png +0 -0
  207. data/plugins/strip_trailing_spaces/CHANGELOG +0 -12
  208. data/plugins/strip_trailing_spaces/README.md +0 -32
  209. data/plugins/view_shortcuts/lib/view_shortcuts.rb +0 -52
  210. data/plugins/view_shortcuts/plugin.rb +0 -11
@@ -57,6 +57,7 @@ module Redcar
57
57
  end
58
58
 
59
59
  def offset_at_line(line_ix)
60
+ line_ix = [line_ix, line_count - 1].min
60
61
  jface_document.get_line_offset(line_ix)
61
62
  end
62
63
 
@@ -72,15 +73,27 @@ module Redcar
72
73
  def replace(offset, length, text)
73
74
  @model.verify_text(offset, offset+length, text)
74
75
  jface_document.replace(offset, length, text)
75
- #if length > text.length
76
- # @swt_mate_document.mateText.redraw
77
- #end
78
76
  @model.modify_text
79
77
  end
80
78
 
81
79
  def text=(text)
82
80
  @model.verify_text(0, length, text)
83
- jface_document.set(text)
81
+ top_pixel = styledText.getTopPixel
82
+ caret = cursor_offset
83
+ line = line_at_offset(caret)
84
+ caret = caret - offset_at_line(line)
85
+
86
+ styledText.setRedraw(false)
87
+ styledText.setText(text)
88
+
89
+ unless line > line_count - 1
90
+ # The documents new text is still longer than our previous position, restore position
91
+ line_offset = offset_at_line(line)
92
+ styledText.setCaretOffset([line_offset + caret, offset_at_line(line + 1) - 1].min)
93
+ styledText.setTopPixel(top_pixel)
94
+ end
95
+
96
+ styledText.setRedraw(true)
84
97
  @model.modify_text
85
98
  notify_listeners(:set_text)
86
99
  end
@@ -7,10 +7,7 @@ module Redcar
7
7
  Redcar::Menu::Builder.build do
8
8
  sub_menu "Edit" do
9
9
  sub_menu "Search" do
10
- sub_menu "Find In Project", :priority => 64 do
11
- item "Find In Project!", Redcar::FindInProject::OpenSearch
12
- item "Edit Preferences", Redcar::FindInProject::EditPreferences
13
- end
10
+ item "Find In Project!", Redcar::FindInProject::OpenSearch
14
11
  end
15
12
  end
16
13
  end
@@ -26,19 +26,5 @@ module Redcar
26
26
  end
27
27
  end
28
28
  end
29
-
30
- class EditPreferences < Redcar::Command
31
- def execute
32
- Redcar.app.make_sure_at_least_one_window_open # open a new window if needed
33
-
34
- Redcar::FindInProject.storage # populate the file if it isn't already
35
-
36
- tab = Redcar.app.focussed_window.new_tab(Redcar::EditTab)
37
- mirror = Project::FileMirror.new(File.join(Redcar.user_dir, "storage", "find_in_project.yaml"))
38
- tab.edit_view.document.mirror = mirror
39
- tab.edit_view.reset_undo
40
- tab.focus
41
- end
42
- end
43
29
  end
44
30
  end
@@ -51,6 +51,18 @@ module Redcar
51
51
  doc.scroll_to_line(line.to_i)
52
52
  nil
53
53
  end
54
+
55
+ def preferences
56
+ Redcar.app.make_sure_at_least_one_window_open # open a new window if needed
57
+
58
+ Redcar::FindInProject.storage # populate the file if it isn't already
59
+
60
+ tab = Redcar.app.focussed_window.new_tab(Redcar::EditTab)
61
+ mirror = Project::FileMirror.new(File.join(Redcar.user_dir, "storage", "find_in_project.yaml"))
62
+ tab.edit_view.document.mirror = mirror
63
+ tab.edit_view.reset_undo
64
+ tab.focus
65
+ end
54
66
 
55
67
  def close
56
68
  Thread.kill(@thread) if @thread
@@ -40,6 +40,7 @@
40
40
  <label for="match_case">Match case</label>
41
41
  <input type="checkbox" id="with_context" <%="checked=checked" if @with_context %>>
42
42
  <label for="with_context">With context</label>
43
+ <a href="#" title="Edit Preferences" id="edit_preferences">Edit Preferences...</a>
43
44
  </td>
44
45
  <td></td>
45
46
  </tr>
@@ -94,6 +95,10 @@
94
95
  $('#recent_queries').show();
95
96
  }
96
97
  });
98
+
99
+ $('#edit_preferences').click(function(ev) {
100
+ Controller.preferences();
101
+ });
97
102
 
98
103
  // in the case the user wants to search for things like <table>, we need to unescape the entities
99
104
  String.prototype.unescapeHTML = function() {
@@ -0,0 +1,27 @@
1
+ When /^I add "([^"]*)" to the groovy classpath$/ do |dir|
2
+ File.open(File.expand_path("../../fixtures/.redcar/classpath.groovy", __FILE__), "a") do |f|
3
+ f.puts <<-CONFIG
4
+ def redcar_config = new File(getClass().protectionDomain.codeSource.location.path).parentFile
5
+ def project = redcar_config.parentFile
6
+ def classpath = []
7
+
8
+ //installed libraries
9
+ def lib = new File(project.path + File.separator + "lib")
10
+ lib.list().each {name -> classpath << lib.path+File.separator+name}
11
+
12
+ //compiled classes
13
+ def target_classes = new File(
14
+ project.path + File.separator +
15
+ "target" + File.separator +
16
+ "classes"
17
+ )
18
+
19
+ classpath << target_classes.path
20
+
21
+ //other classes
22
+ classpath << project.path + File.separator + "#{dir}"
23
+
24
+ return classpath.toArray()
25
+ CONFIG
26
+ end
27
+ end
@@ -0,0 +1,27 @@
1
+ After do
2
+ # Truncate the test file
3
+ File.open(File.expand_path("../../fixtures/test.groovy", __FILE__), "w")
4
+
5
+ #recreate the classpath file
6
+ File.open(File.expand_path("../../fixtures/.redcar/classpath.groovy", __FILE__), "w") do |f|
7
+ f.puts <<-CONFIG
8
+ def redcar_config = new File(getClass().protectionDomain.codeSource.location.path).parentFile
9
+ def project = redcar_config.parentFile
10
+ def classpath = []
11
+
12
+ //installed libraries
13
+ def lib = new File(project.path + File.separator + "lib")
14
+ lib.list().each {name -> classpath << lib.path+File.separator+name}
15
+
16
+ //compiled classes
17
+ def target_classes = new File(
18
+ project.path + File.separator +
19
+ "target" + File.separator +
20
+ "classes"
21
+ )
22
+ classpath << target_classes.path
23
+
24
+ return classpath.toArray()
25
+ CONFIG
26
+ end
27
+ end
@@ -0,0 +1,72 @@
1
+ Feature: Syntax Checking for Groovy
2
+ As a user
3
+ I want to get annotations on syntax errors in Groovy files
4
+
5
+ Background:
6
+ When I have opened "plugins/groovy/features/fixtures/test.groovy"
7
+
8
+ Scenario: A syntax-clean Groovy file has no syntax error annotations
9
+ When I replace the contents with "class Foo {\n\n}"
10
+ And I save the tab
11
+ Then the tab should not have annotations
12
+
13
+ Scenario: A syntax-error in a Groovy file should cause syntax error annotations
14
+ When I replace the contents with "class Foo {\n sdef\n}"
15
+ And I save the tab
16
+ Then the tab should have annotations
17
+ And the tab should have an annotation on line 2
18
+
19
+ Scenario: Fixing a syntax-error in a Groovy file should cause syntax error annotations to vanish
20
+ When I replace the contents with "class Foo {\n sdef\n}"
21
+ And I save the tab
22
+ Then the tab should have annotations
23
+ When I replace the contents with "class Foo {\n\n}"
24
+ And I save the tab
25
+ Then the tab should not have annotations
26
+
27
+ Scenario: A file which references unknown groovy classes should cause syntax error annotations
28
+ And I replace the contents with "class Foo {\n def x = new Bar(10)\n def y = new FooBar()\n}"
29
+ And I save the tab
30
+ Then the tab should have annotations
31
+ And the tab should have an annotation on line 2
32
+
33
+ Scenario: A project can add libraries and compiled class directories to the groovy classpath
34
+ When I will choose "plugins/groovy/features/fixtures" from the "open_directory" dialog
35
+ And I open a directory
36
+ And I replace the contents with "class Foo {\n def x = new Bar(10)\n def y = new FooBar()\n}"
37
+ And I save the tab
38
+ Then the tab should not have annotations
39
+
40
+ Scenario: If a project classpath.groovy file has syntax errors, there should be an error message and annotations
41
+ And I close the focussed tab
42
+ Given I have not suppressed syntax checking message dialogs
43
+ When I will choose "plugins/groovy/features/fixtures" from the "open_directory" dialog
44
+ And I open a directory
45
+ And I have opened "plugins/groovy/features/fixtures/.redcar/classpath.groovy"
46
+ And I replace the contents with "def x = 4\nsdef"
47
+ And I save the tab
48
+ Then I should see a message box containing "An error occurred while loading groovy classpath file"
49
+
50
+ Scenario: If an error occurs while parsing a groovy file, there should be an error message
51
+ Given I have not suppressed syntax checking message dialogs
52
+ When I will choose "plugins/groovy/features/fixtures" from the "open_directory" dialog
53
+ And I open a directory
54
+ And I add "lib2" to the groovy classpath
55
+ And I replace the contents with "class Foo {\n def x = new Bar(10)\n def y = new FooBaz()\n}"
56
+ And I save the tab
57
+ Then I should see a message box containing "An error occurred while parsing"
58
+ And the tab should have an annotation on line 2
59
+
60
+ Scenario: If syntax message dialogs are suppressed, I should see no message boxes
61
+ Given I have suppressed syntax checking message dialogs
62
+ When I will choose "plugins/groovy/features/fixtures" from the "open_directory" dialog
63
+ And I open a directory
64
+ And I have opened "plugins/groovy/features/fixtures/.redcar/classpath.groovy"
65
+ And I replace the contents with "sdef"
66
+ And I save the tab
67
+ Then the tab should not have annotations
68
+ When I close the focussed tab
69
+ And I add "lib2" to the groovy classpath
70
+ And I replace the contents with "class Foo {\n def x = new Bar(10)\n def y = new FooBaz()\n}"
71
+ And I save the tab
72
+ Then the tab should have an annotation on line 2
@@ -0,0 +1,76 @@
1
+ require 'java'
2
+
3
+ module Redcar
4
+ module SyntaxCheck
5
+ class Groovy < Checker
6
+ supported_grammars "Groovy", "Easyb"
7
+
8
+ def initialize(document)
9
+ super
10
+ unless @loaded
11
+ require File.join(Redcar.asset_dir,"groovy-all")
12
+ import 'groovy.lang.GroovyShell'
13
+ import 'org.codehaus.groovy.control.CompilationFailedException'
14
+ import 'org.codehaus.groovy.control.CompilerConfiguration'
15
+ @loaded = true
16
+ end
17
+ end
18
+
19
+ def check(*args)
20
+ path = manifest_path(doc)
21
+ name = File.basename(path)
22
+ shell = create_shell
23
+ text = doc.get_all_text
24
+ io = java.io.File.new(path)
25
+ begin
26
+ shell.parse(io)
27
+ rescue CompilationFailedException => e
28
+ create_syntax_error(doc, e.message, name).annotate
29
+ rescue Object => e
30
+ SyntaxCheck.message(
31
+ "An error occurred while parsing #{name}: #{e.message}",:error)
32
+ end
33
+ end
34
+
35
+ def create_syntax_error(doc, message, name)
36
+ message =~ /#{Regexp.escape(name)}: (\d+):(.*)/
37
+ line = $1.to_i - 1
38
+ message = $2
39
+ SyntaxCheck::Error.new(doc, line, message)
40
+ end
41
+
42
+ def classpath_files(project)
43
+ project.config_files("classpath.groovy")
44
+ end
45
+
46
+ def classpath(project)
47
+ parts = []
48
+ shell = GroovyShell.new
49
+ files = classpath_files(project)
50
+ return unless files.any?
51
+ files.each do |path|
52
+ begin
53
+ file = java.io.File.new(path)
54
+ part = shell.run(file, [])
55
+ parts += part if part
56
+ rescue Object => e
57
+ SyntaxCheck.message(
58
+ "An error occurred while loading groovy classpath file #{path}: #{e.message}",:error)
59
+ end
60
+ end
61
+ parts
62
+ end
63
+
64
+ def create_shell
65
+ config = CompilerConfiguration.new
66
+ if project = Redcar::Project::Manager.focussed_project
67
+ classpath = classpath(project)
68
+ config.setClasspathList(classpath) if classpath and classpath.any?
69
+ end
70
+ shell = GroovyShell.new(config)
71
+ shell.setProperty("out",nil)
72
+ shell
73
+ end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,7 @@
1
+ Plugin.define do
2
+ name "groovy"
3
+ version "0.1"
4
+ file "lib", "syntax_check", "groovy"
5
+ object "Redcar::SyntaxCheck::Groovy"
6
+ dependencies "syntax_check", ">0"
7
+ end
@@ -1,4 +1,7 @@
1
1
 
2
+ require 'help/view_controller'
3
+ require 'help/help_tab'
4
+
2
5
  module Redcar
3
6
  class Help
4
7
  def self.menus
@@ -7,6 +10,7 @@ module Redcar
7
10
  group(:priority => :first) do
8
11
  item "Online Help", :command => OnlineHelpCommand
9
12
  item "Submit a Bug", :command => SubmitABugCommand
13
+ item "Keyboard Shortcuts", :command => ViewShortcutsCommand
10
14
  end
11
15
  end
12
16
  end
@@ -19,20 +23,40 @@ module Redcar
19
23
  [map]
20
24
  end
21
25
 
26
+ def self.toolbars
27
+ ToolBar::Builder.build do
28
+ item "Keyboard Shortcuts", :command => ViewShortcutsCommand, :icon => File.join(Redcar::ICONS_DIRECTORY, "/keyboard.png"), :barname => :help
29
+ item "Help", :command => OnlineHelpCommand, :icon => File.join(Redcar::ICONS_DIRECTORY, "/question.png"), :barname => :help
30
+ end
31
+ end
32
+
33
+ class ViewShortcutsCommand < Redcar::Command
34
+ def execute
35
+ controller = Help::ViewController.new
36
+ tab = win.new_tab(Help::HelpTab)
37
+ tab.html_view.controller = controller
38
+ tab.focus
39
+ end
40
+ end
41
+
22
42
  class SubmitABugCommand < Redcar::Command
23
43
  def execute
24
- Redcar::WebBookmarks::DisplayWebContent.new(
44
+ Redcar::HtmlView::DisplayWebContent.new(
25
45
  "Submit a Bug",
26
- "https://redcar.lighthouseapp.com/projects/25090-redcar/tickets/new"
46
+ "https://redcar.lighthouseapp.com/projects/25090-redcar/tickets/new",
47
+ true,
48
+ Help::HelpTab
27
49
  ).run
28
50
  end
29
51
  end
30
52
 
31
53
  class OnlineHelpCommand < Redcar::Command
32
54
  def execute
33
- Redcar::WebBookmarks::DisplayWebContent.new(
55
+ Redcar::HtmlView::DisplayWebContent.new(
34
56
  "Online Help",
35
- "http://github.com/redcar/redcar/wiki/Users-Guide"
57
+ "http://github.com/redcar/redcar/wiki/Users-Guide",
58
+ true,
59
+ Help::HelpTab
36
60
  ).run
37
61
  end
38
62
  end
@@ -0,0 +1,11 @@
1
+ module Redcar
2
+ class Help
3
+ class HelpTab < HtmlTab
4
+ DEFAULT_ICON = HELP_ICON
5
+
6
+ def icon
7
+ DEFAULT_ICON
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,25 @@
1
+ module Redcar
2
+ class Help
3
+ class ViewController
4
+ include HtmlController
5
+
6
+ def title
7
+ "Shortcuts"
8
+ end
9
+
10
+ def clean_name(command)
11
+ name = command.to_s.sub("Command","")
12
+ idx = name.rindex("::")
13
+ unless idx.nil?
14
+ name = name[idx+2,name.length]
15
+ end
16
+ name = name.split(/(?=[A-Z])/).map{|w| w}.join(" ").sub("R E P L","REPL")
17
+ end
18
+
19
+ def index
20
+ rhtml = ERB.new(File.read(File.join(File.dirname(__FILE__), "..", "..", "views", "index.html.erb")))
21
+ rhtml.result(binding)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -4,5 +4,6 @@ Plugin.define do
4
4
  version "1.0"
5
5
  file "lib", "help"
6
6
  object "Redcar::Help"
7
- dependencies "web_bookmarks", ">0"
7
+ dependencies "web_bookmarks", ">0",
8
+ "open_default_app", ">0.1"
8
9
  end
@@ -1,7 +1,7 @@
1
1
  <html>
2
2
  <head>
3
3
  <title>Keyboard Shortcuts</title>
4
- <% redcar_css = File.expand_path(File.join(Redcar.root, %w(plugins view_shortcuts views default.css))) %>
4
+ <% redcar_css = File.expand_path(File.join(Redcar.root, %w(plugins help views default.css))) %>
5
5
  <link rel="stylesheet" href="file://<%= redcar_css %>" type="text/css" media="screen">
6
6
  </head>
7
7
  <body>