redcar 0.8.1 → 0.9.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.
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
@@ -27,11 +27,17 @@ module Redcar
27
27
  @map ||=begin
28
28
  c = File.read(Comment.comment_lib_path)
29
29
  map = JSON.parse(c)
30
- Comment.comment_extension_paths.each do |path|
31
- json = File.read(path)
32
- JSON.parse(json).each do |item,content|
33
- map[item] = content
30
+ begin
31
+ path = Comment.comment_extension_path
32
+ if File.exist?(path)
33
+ json = File.read(path)
34
+ JSON.parse(json).each do |item,content|
35
+ map[item] = content
36
+ end
34
37
  end
38
+ rescue Object => e
39
+ Redcar::Application::Dialog.message_box("There was an error parsing Comment extensions file: #{e.message}")
40
+ map = JSON.parse(c)
35
41
  end
36
42
  map
37
43
  end
@@ -40,16 +46,11 @@ module Redcar
40
46
  def self.extensions_file;"comment_extensions.json";end
41
47
 
42
48
  def self.comment_lib_path
43
- File.dirname(__FILE__) + "/../vendor/comment_lib.json"
49
+ File.join(File.dirname(__FILE__),"..","vendor","comment_lib.json")
44
50
  end
45
51
 
46
- def self.comment_extension_paths
47
- project = Redcar::Project::Manager.focussed_project
48
- if project
49
- project.config_files(Comment.extensions_file)
50
- else
51
- Dir[File.join(Redcar.user_dir,Comment.extensions_file)]
52
- end
52
+ def self.comment_extension_path
53
+ File.join(Redcar.user_dir,Comment.extensions_file)
53
54
  end
54
55
 
55
56
  def self.keymaps
@@ -108,7 +109,7 @@ module Redcar
108
109
  doc.replace_line(line,text)
109
110
  else
110
111
  replacement = "#{start}#{text}#{ending}"
111
- replacement += "\n" if doc.get_line(line) =~ /\n$/
112
+ replacement << "\n" if doc.get_line(line) =~ /\n$/
112
113
  doc.replace_line(line,replacement)
113
114
  end
114
115
  end
@@ -156,7 +157,7 @@ module Redcar
156
157
  md[1].length
157
158
  end
158
159
 
159
- def execute
160
+ def execute
160
161
  type = Comment.comment_map["#{tab.edit_view.grammar.gsub("\"","")}"]
161
162
  if type
162
163
  @comment = type["line_comment"]
@@ -198,7 +199,8 @@ module Redcar
198
199
 
199
200
  (start_line..end_line).each do |line|
200
201
  text = doc.get_line(line)
201
- if text.length <= insertion_column + 1 and text =~ /^\s*$/
202
+
203
+ if text =~ /^\s*$/
202
204
  else
203
205
  insertion_column = [insertion_column, comment_insertion_point_for(text)].min
204
206
  end
@@ -254,7 +256,7 @@ module Redcar
254
256
  end
255
257
  end
256
258
  end
257
-
259
+
258
260
  if selected
259
261
  doc.set_selection_range(cursor_offset, selection_offset)
260
262
  else
@@ -5,7 +5,7 @@ module Redcar
5
5
 
6
6
  def execute
7
7
  controller = Controller.new
8
- tab = win.new_tab(HtmlTab)
8
+ tab = win.new_tab(ConfigTab)
9
9
  tab.html_view.controller = controller
10
10
  tab.focus
11
11
  end
@@ -11,9 +11,11 @@ module Redcar
11
11
  paths = []
12
12
  default_key_globs.each do |default_key_glob|
13
13
  Dir[default_key_glob].each do |filename|
14
- first = File.open(filename).read(100)
15
- if first =~ /PRIVATE KEY/
16
- paths << filename
14
+ unless File.directory?(filename) || !File.readable?(filename)
15
+ first = File.open(filename).read(100)
16
+ if first =~ /PRIVATE KEY/
17
+ paths << filename
18
+ end
17
19
  end
18
20
  end
19
21
  end
@@ -17,7 +17,7 @@ module Redcar
17
17
 
18
18
  def self.keymaps
19
19
  linwin = Keymap.build("main", [:linux, :windows]) do
20
- link "Ctrl+G", Declarations::GoToTagCommand
20
+ link "Alt+G", Declarations::GoToTagCommand
21
21
  end
22
22
 
23
23
  osx = Keymap.build("main", :osx) do
@@ -1,6 +1,6 @@
1
1
 
2
2
  module Redcar
3
- JAVA_YAML=<<-YAML
3
+ GROOVY_YAML=<<-YAML
4
4
  - regex: "class\\s+(\\w+)"
5
5
  capture: 1
6
6
  type: id
@@ -9,18 +9,53 @@ module Redcar
9
9
  capture: 1
10
10
  type: id
11
11
  kind: interface
12
- - regex: "(public|private).*\\s+(\\w+)\s*\\("
12
+ - regex: "^\\s*((public|private|protected|)\\s+|)(static\\s+|)(([\\.\\w]+|)[A-Z]\\w*(<\\w+>|)|void|int|boolean|byte|short|long|char|float|def)\\s+(\\w+\\s*\\((.*)\\))"
13
+ capture: 7
14
+ type: id
15
+ kind: method
16
+ - regex: "(def|static)\\s+(\\w+)\\s*=\\s*\\{"
13
17
  capture: 2
14
18
  type: id
19
+ kind: closure
20
+ - regex: "enum\\s+(\\w+)"
21
+ capture: 1
22
+ type: id
23
+ kind: attribute
24
+ - regex: "^\\s*(public|private|protected)\\s+(static\\s+|)([A-Z]\\w+|int|boolean|byte|short|long|char|float|def)\s+(\\w+)\\s*(=|\\n)"
25
+ capture: 4
26
+ type: id
27
+ kind: assignment
28
+ YAML
29
+
30
+ JAVA_YAML=<<-YAML
31
+ - regex: "class\\s+(\\w+)"
32
+ capture: 1
33
+ type: id
34
+ kind: class
35
+ - regex: "interface\\s+(\\w+)"
36
+ capture: 1
37
+ type: id
38
+ kind: interface
39
+ - regex: "^\\s*((public|private|protected|)\\s+|)(static\\s+|)(([\\.\\w]+|)[A-Z]\\w*(<\\w+>|)|void|int|boolean|byte|short|long|char|float)\\s+(\\w+\\s*\\((.*)\\))"
40
+ capture: 7
41
+ type: id
15
42
  kind: method
43
+ - regex: "enum\\s+(\\w*)"
44
+ capture: 1
45
+ type: id
46
+ kind: attribute
47
+ - regex: "^\\s*(public|private|protected)\\s+(static\\s+|)([A-Z]\\w+|int|boolean|byte|short|long|char|float|def)\s+(\\w+)\\s*(=|;)"
48
+ capture: 4
49
+ type: id
50
+ kind: assignment
16
51
  YAML
17
-
52
+
18
53
  RUBY_YAML=<<-YAML
19
54
  - regex: "^[^#]*(class|module)\\s+(?:\\w*::)*(\\w+)(?:$|\\s|<)"
20
55
  capture: 2
21
56
  type: id
22
57
  kind: class
23
- - regex: "^[^#]*def (self\\.)?(\\w+[?!]?)"
58
+ - regex: "^[^#]*def (self\\.)?(\\w+[?!=]?)(\\(.*\\))?(\\s|\\;)+"
24
59
  capture: 2
25
60
  type: id
26
61
  kind: method
@@ -28,11 +63,11 @@ module Redcar
28
63
  capture: 2
29
64
  type: id-list
30
65
  kind: attribute
31
- - regex: "^[^#]*alias\s+:(\\w+)"
66
+ - regex: "^[^#]*alias\\s+:(\\w+)"
32
67
  capture: 1
33
68
  type: id
34
69
  kind: alias
35
- - regex: "^[^#]*alias_method\s+:(\\w+[?!]?)"
70
+ - regex: "^[^#]*alias_method\\s+:(\\w+[?!]?)"
36
71
  capture: 1
37
72
  type: id
38
73
  kind: alias
@@ -56,27 +91,40 @@ module Redcar
56
91
  type: id
57
92
  kind: method
58
93
  YAML
59
-
94
+
95
+ JS_YAML=<<-YAML
96
+ - regex: "function\\s+([A-Z]\\w*)\\(.*\\)"
97
+ capture: 1
98
+ type: id
99
+ kind: class
100
+ - regex: "function\\s+([a-z]\\w*)\\(.*\\)"
101
+ capture: 1
102
+ type: id
103
+ kind: method
104
+ YAML
105
+
60
106
  class Declarations
61
107
  class Parser
62
108
  DEFINITIONS = {
63
- /\.rb$/ => YAML.load(RUBY_YAML),
64
- /\.java$/ => YAML.load(JAVA_YAML),
65
- /\.php$/ => YAML.load(PHP_YAML)
109
+ /\.rb$/ => YAML.load(RUBY_YAML),
110
+ /\.java$/ => YAML.load(JAVA_YAML),
111
+ /\.groovy$/ => YAML.load(GROOVY_YAML),
112
+ /\.php$/ => YAML.load(PHP_YAML),
113
+ /\.js$/ => YAML.load(JS_YAML)
66
114
  }
67
-
115
+
68
116
  attr_reader :tags
69
-
117
+
70
118
  def initialize
71
119
  @tags = []
72
120
  end
73
-
121
+
74
122
  def parse(files)
75
123
  files.each do |path|
76
124
  @tags += match_in_file(path)
77
125
  end
78
126
  end
79
-
127
+
80
128
  def decls_for_file(path)
81
129
  DEFINITIONS.each do |fn_re, decls|
82
130
  if path =~ fn_re
@@ -85,7 +133,7 @@ module Redcar
85
133
  end
86
134
  nil
87
135
  end
88
-
136
+
89
137
  def match_kind(path, match)
90
138
  if decls = decls_for_file(path)
91
139
  decls.each do |decl|
@@ -95,9 +143,9 @@ module Redcar
95
143
  end
96
144
  end
97
145
  end
98
-
146
+
99
147
  private
100
-
148
+
101
149
  def match_in_file(path)
102
150
  tags = []
103
151
  begin
@@ -117,7 +165,7 @@ module Redcar
117
165
  []
118
166
  end
119
167
  end
120
-
168
+
121
169
  def process_file(path, &block)
122
170
  if decls = decls_for_file(path)
123
171
  decls.each do |decl|
@@ -127,11 +175,11 @@ module Redcar
127
175
  end
128
176
  end
129
177
  end
130
-
178
+
131
179
  def file(path)
132
180
  ::File.read(path)
133
181
  end
134
-
182
+
135
183
  end
136
184
  end
137
185
  end
@@ -92,6 +92,24 @@ Feature: Replace in file
92
92
  And the selected text should be "Rab"
93
93
  And the selection should be on line 3
94
94
 
95
+ Scenario: Replace all replaces two on the same line
96
+ When I replace the contents with "abcabc"
97
+ And I run the command DocumentSearch::SearchAndReplaceCommand
98
+ And I type "bc" into the "Search" field in the speedbar
99
+ And I type "xx" into the "Replace" field in the speedbar
100
+ Then I should see a message box containing "Replaced 2 occurrences"
101
+ When I press "Replace All" in the speedbar
102
+ Then the contents should be "axxaxx"
103
+
104
+ Scenario: Replace all replaces overlapping occurences on the same line
105
+ When I replace the contents with "deedeedeed"
106
+ And I run the command DocumentSearch::SearchAndReplaceCommand
107
+ And I type "deed" into the "Search" field in the speedbar
108
+ And I type "misdeed" into the "Replace" field in the speedbar
109
+ Then I should see a message box containing "Replaced 2 occurrences"
110
+ When I press "Replace All" in the speedbar
111
+ Then the contents should be "misdeedeemisdeed"
112
+
95
113
  Scenario: Replace next occurrence test bug
96
114
  When I replace the contents with "the\n* Speedbars have access to the properties of the widgets in them."
97
115
  And I move the cursor to 0
@@ -1,5 +1,7 @@
1
- require "document_search/search"
2
- require "document_search/replace"
1
+ require 'strscan'
2
+ require "document_search/replace_command"
3
+ require "document_search/replace_all_command"
4
+ require "document_search/replace_next_command"
3
5
  require "document_search/search_and_replace"
4
6
 
5
7
  module DocumentSearch
@@ -15,14 +17,14 @@ module DocumentSearch
15
17
  end
16
18
  end
17
19
  end
18
-
20
+
19
21
  def self.toolbars
20
22
  Redcar::ToolBar::Builder.build do
21
23
  item "Search Document", :command => DocumentSearch::SearchForwardCommand, :icon => File.join(Redcar::ICONS_DIRECTORY, "magnifier.png"), :barname => :edit
22
24
  item "Repeat Last Search", :command => DocumentSearch::RepeatPreviousSearchForwardCommand, :icon => File.join(Redcar::ICONS_DIRECTORY, "magnifier--arrow.png"), :barname => :edit
23
25
  end
24
26
  end
25
-
27
+
26
28
  class SearchSpeedbar < Redcar::Speedbar
27
29
  class << self
28
30
  attr_accessor :previous_query
@@ -31,7 +33,7 @@ module DocumentSearch
31
33
  end
32
34
 
33
35
  attr_accessor :initial_query
34
-
36
+
35
37
  def after_draw
36
38
  SearchSpeedbar.previous_query ||= ""
37
39
  self.query.value = @initial_query || SearchSpeedbar.previous_query
@@ -39,26 +41,26 @@ module DocumentSearch
39
41
  self.match_case.value = SearchSpeedbar.previous_match_case
40
42
  self.query.edit_view.document.select_all
41
43
  end
42
-
44
+
43
45
  label :label, "Search:"
44
46
  textbox :query
45
-
47
+
46
48
  toggle :is_regex, 'Regex', nil, false do |v|
47
49
  # v is true or false
48
50
  SearchSpeedbar.previous_is_regex = v
49
51
  end
50
-
52
+
51
53
  toggle :match_case, 'Match case', nil, false do |v|
52
54
  SearchSpeedbar.previous_match_case = v
53
55
  end
54
-
56
+
55
57
  button :search, "Search", "Return" do
56
58
  SearchSpeedbar.previous_query = query.value
57
59
  SearchSpeedbar.previous_match_case = match_case.value
58
60
  SearchSpeedbar.previous_is_regex = is_regex.value
59
61
  success = SearchSpeedbar.repeat_query
60
62
  end
61
-
63
+
62
64
  def self.repeat_query
63
65
  current_query = @previous_query
64
66
  if !@previous_is_regex
@@ -68,9 +70,9 @@ module DocumentSearch
68
70
  cmd.run_in_focussed_tab_edit_view
69
71
  end
70
72
  end
71
-
73
+
72
74
  class SearchForwardCommand < Redcar::EditTabCommand
73
-
75
+
74
76
  def execute
75
77
  @speedbar = SearchSpeedbar.new
76
78
  if doc.selection?
@@ -79,13 +81,13 @@ module DocumentSearch
79
81
  win.open_speedbar(@speedbar)
80
82
  end
81
83
  end
82
-
84
+
83
85
  class RepeatPreviousSearchForwardCommand < Redcar::EditTabCommand
84
86
  def execute
85
87
  SearchSpeedbar.repeat_query
86
88
  end
87
89
  end
88
-
90
+
89
91
  class SearchAndReplaceCommand < Redcar::EditTabCommand
90
92
  def execute
91
93
  @speedbar = SearchAndReplaceSpeedbar.new
@@ -101,51 +103,32 @@ module DocumentSearch
101
103
  @re = re
102
104
  @wrap = wrap
103
105
  end
104
-
106
+
105
107
  def to_s
106
108
  "<#{self.class}: @re:#{@re.inspect} wrap:#{!!@wrap}>"
107
109
  end
108
-
110
+
109
111
  def execute
110
- # first search the remainder of the current line
111
- curr_line = doc.get_line(doc.cursor_line)
112
- cursor_line_offset = doc.cursor_offset - doc.offset_at_line(doc.cursor_line)
113
- curr_line = curr_line[cursor_line_offset..-1]
114
- if curr_line =~ @re
115
- line_start = doc.offset_at_line(doc.cursor_line)
116
- startoff = line_start + $`.length + cursor_line_offset
117
- endoff = startoff + $&.length
118
- doc.set_selection_range(endoff, startoff)
119
- elsif doc.cursor_line < doc.line_count - 1
120
- # next search the rest of the lines
121
- found_line_offset = nil
122
- found_line_num = nil
123
- found_length = nil
124
- line_nums = ((doc.cursor_line() + 1)..(doc.line_count() - 1)).to_a # the rest of the document
125
- if @wrap
126
- line_nums += (0..doc.cursor_line()).to_a
127
- end
128
- for line_num in line_nums do
129
- curr_line = doc.get_line(line_num)
130
- if new_offset = (curr_line.to_s =~ @re)
131
- found_line_offset = new_offset
132
- found_line_num = line_num
133
- found_length = $&.length
134
- break
135
- end
136
- end
137
- if found_line_num
138
- line_start = doc.offset_at_line(found_line_num)
139
- startoff = line_start + found_line_offset
140
- endoff = startoff + found_length
141
- doc.scroll_to_line(found_line_num)
142
- doc.set_selection_range(endoff, startoff)
143
- true
144
- else
145
- false
146
- end
112
+ position = doc.cursor_offset
113
+ sc = StringScanner.new(doc.get_all_text)
114
+ sc.pos = position
115
+ sc.scan_until(@re)
116
+
117
+ if @wrap and !sc.matched?
118
+ # No match was found in the remainder of the document, search from beginning
119
+ sc.reset
120
+ sc.scan_until(@re)
147
121
  end
122
+
123
+ if sc.matched?
124
+ endoff = sc.pos
125
+ startoff = sc.pos - sc.matched_size
126
+ doc.set_selection_range(sc.pos, sc.pos - sc.matched_size)
127
+ doc.scroll_to_line(doc.line_at_offset(startoff))
128
+ return true
129
+ end
130
+ false
148
131
  end
149
132
  end
150
-
133
+
151
134
  end