redcar 0.9.2 → 0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (234) hide show
  1. data/CHANGES +34 -4
  2. data/Rakefile +2 -1
  3. data/lib/redcar.rb +3 -3
  4. data/lib/redcar/installer.rb +2 -3
  5. data/plugins/application/features/step_definitions/dialog_steps.rb +7 -0
  6. data/plugins/application/features/step_definitions/key_steps.rb +18 -0
  7. data/plugins/application/features/step_definitions/menu_steps.rb +5 -6
  8. data/plugins/application/features/step_definitions/speedbar_steps.rb +29 -9
  9. data/plugins/application/features/step_definitions/tree_steps.rb +13 -0
  10. data/plugins/application/features/support/env.rb +39 -5
  11. data/plugins/application/features/support/fake_event.rb +12 -0
  12. data/plugins/application/lib/application.rb +5 -6
  13. data/plugins/application/lib/application/dialog.rb +53 -10
  14. data/plugins/application/lib/application/dialogs/modeless_list_dialog.rb +85 -0
  15. data/plugins/application/lib/application/keymap.rb +10 -8
  16. data/plugins/application/lib/application/menu.rb +38 -16
  17. data/plugins/application/lib/application/treebook.rb +30 -0
  18. data/plugins/application/lib/application/window.rb +20 -2
  19. data/plugins/application/spec/application/command/executor_spec.rb +1 -0
  20. data/plugins/application/spec/application/menu_spec.rb +26 -26
  21. data/plugins/application/spec/application/treebook_spec.rb +6 -6
  22. data/plugins/application/spec/spec_helper.rb +10 -1
  23. data/plugins/application_swt/lib/application_swt.rb +25 -3
  24. data/plugins/application_swt/lib/application_swt/dialog_adapter.rb +48 -27
  25. data/plugins/application_swt/lib/application_swt/dialogs/filter_list_dialog_controller.rb +22 -11
  26. data/plugins/application_swt/lib/application_swt/dialogs/modeless_dialog.rb +113 -0
  27. data/plugins/application_swt/lib/application_swt/dialogs/modeless_html_dialog.rb +85 -0
  28. data/plugins/application_swt/lib/application_swt/dialogs/modeless_list_dialog_controller.rb +143 -0
  29. data/plugins/application_swt/lib/application_swt/gradient.rb +61 -0
  30. data/plugins/application_swt/lib/application_swt/menu/binding_translator.rb +4 -4
  31. data/plugins/application_swt/lib/application_swt/notebook.rb +5 -8
  32. data/plugins/application_swt/lib/application_swt/speedbar.rb +1 -0
  33. data/plugins/application_swt/lib/application_swt/treebook.rb +6 -8
  34. data/plugins/application_swt/lib/application_swt/window.rb +85 -57
  35. data/plugins/application_swt/lib/swt/graphics_utils.rb +23 -0
  36. data/plugins/application_swt/lib/swt/vtab_folder.rb +7 -0
  37. data/plugins/application_swt/lib/swt/vtab_label.rb +1 -1
  38. data/plugins/application_swt/spec/application_swt/gradient_spec.rb +142 -0
  39. data/plugins/auto_completer/lib/auto_completer.rb +10 -42
  40. data/plugins/auto_completer/lib/auto_completer/list_dialog.rb +21 -0
  41. data/plugins/clojure/lib/clojure.rb +33 -0
  42. data/plugins/{repl/lib/repl/clojure_mirror.rb → clojure/lib/clojure/repl_mirror.rb} +16 -20
  43. data/plugins/clojure/plugin.rb +9 -0
  44. data/plugins/{repl/spec/repl/clojure_mirror_spec.rb → clojure/spec/clojure/repl_mirror_spec.rb} +12 -13
  45. data/plugins/clojure/spec/spec_helper.rb +5 -0
  46. data/plugins/{repl → clojure}/vendor/Wrapper.clj +0 -0
  47. data/plugins/{repl → clojure}/vendor/dummy +0 -0
  48. data/plugins/{repl → clojure}/vendor/enclojure-wrapper.jar +0 -0
  49. data/plugins/connection_manager/lib/connection_manager.rb +13 -13
  50. data/plugins/declarations/lib/declarations.rb +17 -6
  51. data/plugins/document_search/features/find.feature +389 -0
  52. data/plugins/document_search/features/find_and_replace.feature +723 -0
  53. data/plugins/document_search/features/replace.feature +69 -62
  54. data/plugins/document_search/lib/document_search.rb +81 -64
  55. data/plugins/document_search/lib/document_search/commands.rb +258 -0
  56. data/plugins/document_search/lib/document_search/find_and_replace_speedbar.rb +142 -0
  57. data/plugins/document_search/lib/document_search/find_speedbar.rb +102 -0
  58. data/plugins/document_search/lib/document_search/query_options.rb +45 -0
  59. data/plugins/edit_view/features/case_change.feature +9 -5
  60. data/plugins/edit_view/features/step_definitions/editing_steps.rb +19 -0
  61. data/plugins/edit_view/lib/edit_view.rb +15 -12
  62. data/plugins/edit_view/lib/edit_view/actions/arrow_keys.rb +12 -2
  63. data/plugins/edit_view/lib/edit_view/commands/text_conversion_commands.rb +1 -1
  64. data/plugins/edit_view/lib/edit_view/document.rb +129 -99
  65. data/plugins/edit_view_swt/lib/edit_view_swt.rb +33 -15
  66. data/plugins/encryption/encryption.rb +2 -0
  67. data/plugins/find-in-project/lib/find_in_project.rb +3 -5
  68. data/plugins/find-in-project/lib/find_in_project/views/index.html.erb +2 -0
  69. data/plugins/groovy/features/step_definitions/groovy_steps.rb +2 -2
  70. data/plugins/groovy/features/syntax_check_groovy.feature +3 -3
  71. data/plugins/groovy/lib/groovy.rb +38 -0
  72. data/plugins/groovy/lib/groovy/commands.rb +10 -0
  73. data/plugins/{repl/lib/repl/groovy_mirror.rb → groovy/lib/groovy/repl_mirror.rb} +33 -13
  74. data/plugins/groovy/lib/{syntax_check/groovy.rb → groovy/syntax_checker.rb} +13 -8
  75. data/plugins/groovy/plugin.rb +5 -4
  76. data/plugins/{repl/spec/repl/groovy_mirror_spec.rb → groovy/spec/groovy/repl_mirror_spec.rb} +14 -13
  77. data/plugins/groovy/spec/spec_helper.rb +5 -0
  78. data/plugins/html_view/assets/json2.js +476 -0
  79. data/plugins/html_view/lib/html_view.rb +1 -0
  80. data/plugins/java/features/fixtures/test.java +0 -0
  81. data/plugins/java/features/support/env.rb +27 -0
  82. data/plugins/java/features/syntax_check_java.feature +86 -0
  83. data/plugins/java/lib/syntax_check/java.rb +86 -0
  84. data/plugins/java/plugin.rb +7 -0
  85. data/plugins/javascript/features/fixtures/test2.js +5 -0
  86. data/plugins/javascript/features/step_definitions/javascript_steps.rb +16 -0
  87. data/plugins/javascript/features/support/env.rb +14 -0
  88. data/plugins/javascript/features/syntax_check_javascript.feature +46 -3
  89. data/plugins/javascript/lib/syntax_check/javascript.rb +15 -9
  90. data/plugins/line_tools/features/trim_line.feature +49 -0
  91. data/plugins/line_tools/lib/line_tools.rb +5 -1
  92. data/plugins/mirah/README +7 -0
  93. data/plugins/mirah/features/fixtures/test.mirah +2 -0
  94. data/plugins/mirah/features/syntax_check_mirah.feature +46 -0
  95. data/plugins/mirah/lib/mirah.rb +43 -0
  96. data/plugins/mirah/lib/mirah/my_error_handler.rb +22 -0
  97. data/plugins/mirah/lib/mirah/repl_mirror.rb +50 -0
  98. data/plugins/mirah/lib/mirah/syntax_checker.rb +38 -0
  99. data/plugins/mirah/plugin.rb +8 -0
  100. data/plugins/mirah/spec/mirah/repl_mirror_spec.rb +188 -0
  101. data/plugins/mirah/spec/spec_helper.rb +5 -0
  102. data/plugins/mirah/vendor/mirah-parser.jar +0 -0
  103. data/plugins/pair_highlighter/lib/pair_highlighter/document_controller.rb +24 -23
  104. data/plugins/plugin_manager_ui/lib/plugin_manager_ui.rb +10 -1
  105. data/plugins/plugin_manager_ui/views/index.html.erb +2 -0
  106. data/plugins/project/features/find_file.feature +40 -16
  107. data/plugins/project/features/highlight_focussed_tab.feature +16 -10
  108. data/plugins/project/features/step_definitions/find_file_steps.rb +11 -0
  109. data/plugins/project/features/step_definitions/project_tree_steps.rb +5 -1
  110. data/plugins/project/features/support/env.rb +5 -0
  111. data/plugins/project/lib/project/commands.rb +8 -1
  112. data/plugins/project/lib/project/dir_controller.rb +4 -1
  113. data/plugins/project/lib/project/find_file_dialog.rb +16 -12
  114. data/plugins/project/lib/project/manager.rb +30 -1
  115. data/plugins/project_search/vendor/lucene/CHANGELOG +147 -0
  116. data/plugins/project_search/vendor/lucene/CONTRIBUTORS +17 -0
  117. data/plugins/project_search/vendor/lucene/Gemfile +9 -0
  118. data/plugins/project_search/vendor/lucene/Gemfile.lock +33 -0
  119. data/plugins/project_search/vendor/lucene/LICENSE +19 -0
  120. data/plugins/project_search/vendor/lucene/README.rdoc +283 -0
  121. data/plugins/project_search/vendor/lucene/Rakefile +35 -0
  122. data/plugins/project_search/vendor/lucene/examples/active_model/serializers.rb +25 -0
  123. data/plugins/project_search/vendor/lucene/examples/active_model/validation.rb +26 -0
  124. data/plugins/project_search/vendor/lucene/examples/admin/Rakefile +4 -0
  125. data/plugins/project_search/vendor/lucene/examples/admin/admin.rb +29 -0
  126. data/plugins/project_search/vendor/lucene/examples/admin/public/jquery.js +4376 -0
  127. data/plugins/project_search/vendor/lucene/examples/admin/public/neo4j.css +153 -0
  128. data/plugins/project_search/vendor/lucene/examples/admin/public/neo_admin.js +18 -0
  129. data/plugins/project_search/vendor/lucene/examples/admin/spec/admin_spec.rb +26 -0
  130. data/plugins/project_search/vendor/lucene/examples/admin/views/index.erb +21 -0
  131. data/plugins/project_search/vendor/lucene/examples/filetree/README.rdoc +9 -0
  132. data/plugins/project_search/vendor/lucene/examples/filetree/app.rb +7 -0
  133. data/plugins/project_search/vendor/lucene/examples/filetree/batch.props +5 -0
  134. data/plugins/project_search/vendor/lucene/examples/filetree/features/step_definitions/add_steps.rb +121 -0
  135. data/plugins/project_search/vendor/lucene/examples/filetree/features/support/env.rb +30 -0
  136. data/plugins/project_search/vendor/lucene/examples/filetree/features/support/rspec_helper.rb +50 -0
  137. data/plugins/project_search/vendor/lucene/examples/filetree/features/treesizes.feature +19 -0
  138. data/plugins/project_search/vendor/lucene/examples/imdb/1_create_neo_db.rb +66 -0
  139. data/plugins/project_search/vendor/lucene/examples/imdb/2_index_db.rb +23 -0
  140. data/plugins/project_search/vendor/lucene/examples/imdb/README +12 -0
  141. data/plugins/project_search/vendor/lucene/examples/imdb/find_actors.rb +56 -0
  142. data/plugins/project_search/vendor/lucene/examples/imdb/install.sh +12 -0
  143. data/plugins/project_search/vendor/lucene/examples/imdb/model.rb +37 -0
  144. data/plugins/project_search/vendor/lucene/examples/railway/README +111 -0
  145. data/plugins/project_search/vendor/lucene/examples/railway/railnet-app.rb +31 -0
  146. data/plugins/project_search/vendor/lucene/examples/railway/railnet-data.rb +42 -0
  147. data/plugins/project_search/vendor/lucene/examples/rest/example.rb +41 -0
  148. data/plugins/project_search/vendor/lucene/examples/you_might_know/YouMightKnow.java +60 -0
  149. data/plugins/project_search/vendor/lucene/examples/you_might_know/all_simple_paths.rb +34 -0
  150. data/plugins/project_search/vendor/lucene/examples/you_might_know/nodes.rb +34 -0
  151. data/plugins/project_search/vendor/lucene/examples/you_might_know/you_might_know.rb +50 -0
  152. data/plugins/project_search/vendor/lucene/lib/lucene.rb +15 -0
  153. data/plugins/project_search/vendor/lucene/lib/lucene/config.rb +145 -0
  154. data/plugins/project_search/vendor/lucene/lib/lucene/document.rb +96 -0
  155. data/plugins/project_search/vendor/lucene/lib/lucene/field_info.rb +144 -0
  156. data/plugins/project_search/vendor/lucene/lib/lucene/hits.rb +54 -0
  157. data/plugins/project_search/vendor/lucene/lib/lucene/index.rb +267 -0
  158. data/plugins/project_search/vendor/lucene/lib/lucene/index_info.rb +146 -0
  159. data/plugins/project_search/vendor/lucene/lib/lucene/index_searcher.rb +157 -0
  160. data/plugins/project_search/vendor/lucene/lib/lucene/jars.rb +5 -0
  161. data/plugins/project_search/vendor/lucene/lib/lucene/query_dsl.rb +135 -0
  162. data/plugins/project_search/vendor/lucene/lib/lucene/transaction.rb +117 -0
  163. data/plugins/project_search/vendor/lucene/lib/lucene/version.rb +3 -0
  164. data/plugins/project_search/vendor/lucene/lucene.gemspec +23 -0
  165. data/plugins/project_search/vendor/lucene/spec/lucene/document_spec.rb +32 -0
  166. data/plugins/project_search/vendor/lucene/spec/lucene/field_info_spec.rb +70 -0
  167. data/plugins/project_search/vendor/lucene/spec/lucene/index_info_spec.rb +76 -0
  168. data/plugins/project_search/vendor/lucene/spec/lucene/index_spec.rb +643 -0
  169. data/plugins/project_search/vendor/lucene/spec/lucene/query_dsl_spec.rb +142 -0
  170. data/plugins/project_search/vendor/lucene/spec/lucene/sort_spec.rb +101 -0
  171. data/plugins/project_search/vendor/lucene/spec/lucene/spec_helper.rb +10 -0
  172. data/plugins/project_search/vendor/lucene/spec/lucene/transaction_spec.rb +118 -0
  173. data/plugins/redcar/features/alter_font_size.feature +25 -0
  174. data/plugins/redcar/features/step_definitions/font_steps.rb +34 -0
  175. data/plugins/redcar/redcar.rb +256 -43
  176. data/plugins/repl/features/command_editing.feature +55 -0
  177. data/plugins/repl/features/command_history.feature +75 -0
  178. data/plugins/repl/features/step_definitions/repl_steps.rb +17 -1
  179. data/plugins/repl/features/support/env.rb +24 -0
  180. data/plugins/repl/features/support/fake_repl.rb +16 -0
  181. data/plugins/repl/lib/repl.rb +17 -74
  182. data/plugins/repl/lib/repl/repl_command.rb +20 -0
  183. data/plugins/repl/lib/repl/repl_mirror.rb +168 -22
  184. data/plugins/repl/lib/repl/repl_tab.rb +131 -6
  185. data/plugins/repl/plugin.rb +1 -1
  186. data/plugins/repl/spec/repl/repl_mirror_spec.rb +72 -0
  187. data/plugins/repl/spec/spec_helper.rb +1 -1
  188. data/plugins/repl_swt/lib/repl_swt.rb +7 -0
  189. data/plugins/repl_swt/lib/repl_swt/key_listener.rb +43 -0
  190. data/plugins/repl_swt/plugin.rb +8 -0
  191. data/plugins/ruby/lib/ruby.rb +35 -0
  192. data/plugins/{repl/lib/repl/ruby_mirror.rb → ruby/lib/ruby/repl_mirror.rb} +12 -12
  193. data/plugins/ruby/lib/{syntax_check/ruby.rb → ruby/syntax_checker.rb} +3 -3
  194. data/plugins/ruby/plugin.rb +5 -4
  195. data/plugins/{repl/spec/repl/ruby_mirror_spec.rb → ruby/spec/ruby/repl_mirror_spec.rb} +38 -29
  196. data/plugins/ruby/spec/spec_helper.rb +5 -0
  197. data/plugins/runnables/lib/runnables.rb +2 -0
  198. data/plugins/runnables/lib/runnables/command_output_controller.rb +5 -0
  199. data/plugins/runnables/lib/runnables/output_processor.rb +14 -3
  200. data/plugins/runnables/views/command_output.html.erb +3 -2
  201. data/plugins/scm/lib/scm.rb +4 -2
  202. data/plugins/scm/lib/scm/diff_mirror.rb +6 -6
  203. data/plugins/scm_git/lib/scm_git.rb +136 -107
  204. data/plugins/scm_git/lib/scm_git/change.rb +28 -19
  205. data/plugins/snippets/lib/snippets/explorer.rb +2 -2
  206. data/plugins/swt/lib/swt/full_swt.rb +1 -0
  207. data/plugins/syntax_check/features/step_definitions/syntax_check_steps.rb +4 -0
  208. data/plugins/syntax_check/features/support/env.rb +3 -0
  209. data/plugins/syntax_check/lib/syntax_check.rb +71 -5
  210. data/plugins/syntax_check/lib/syntax_check/annotation.rb +61 -0
  211. data/plugins/test_runner/lib/test_runner.rb +39 -0
  212. data/plugins/test_runner/lib/test_runner/rspec_runner.rb +20 -0
  213. data/plugins/test_runner/lib/test_runner/run_test_command.rb +63 -0
  214. data/plugins/test_runner/lib/test_runner/runnable_test_runner.rb +26 -0
  215. data/plugins/test_runner/plugin.rb +8 -0
  216. data/plugins/test_runner/spec/run_test_command_spec.rb +51 -0
  217. data/plugins/test_runner/spec/spec_helper.rb +5 -0
  218. data/plugins/textmate/lib/textmate.rb +12 -2
  219. data/plugins/textmate/vendor/redcar-bundles/Bundles/HTML.tmbundle/Syntaxes/HTML.plist +0 -2
  220. data/plugins/textmate/vendor/redcar-bundles/Bundles/Mirah.tmbundle/Syntaxes/Mirah.plist +22 -0
  221. data/plugins/textmate/vendor/redcar-bundles/Bundles/Mirah.tmbundle/info.plist +12 -0
  222. data/plugins/textmate/vendor/redcar-bundles/Bundles/Ruby.tmbundle/Syntaxes/Ruby.plist +2 -0
  223. data/plugins/todo_list/lib/todo_list.rb +7 -0
  224. data/plugins/todo_list/lib/todo_list/todo_controller.rb +3 -1
  225. data/plugins/tree/lib/tree.rb +4 -0
  226. data/plugins/tree_view_swt/lib/tree_view_swt.rb +5 -0
  227. data/plugins/web_bookmarks/lib/web_bookmarks.rb +10 -0
  228. metadata +137 -22
  229. data/plugins/document_search/features/search.feature +0 -163
  230. data/plugins/document_search/lib/document_search/replace_all_command.rb +0 -27
  231. data/plugins/document_search/lib/document_search/replace_command.rb +0 -38
  232. data/plugins/document_search/lib/document_search/replace_next_command.rb +0 -27
  233. data/plugins/document_search/lib/document_search/search_and_replace.rb +0 -81
  234. data/plugins/ruby/README +0 -6
@@ -4,7 +4,7 @@ module Redcar
4
4
  module Git
5
5
  class Change
6
6
  include Redcar::Scm::ScmChangesMirror::Change
7
-
7
+
8
8
  STATUS_MAP_INDEXED = {
9
9
  'M ' => [:indexed],
10
10
  'A ' => [:indexed],
@@ -20,7 +20,7 @@ module Redcar
20
20
  'RD' => [:moved],
21
21
  'CD' => [:moved],
22
22
  }
23
-
23
+
24
24
  STATUS_MAP_UNINDEXED = {
25
25
  '??' => [:new],
26
26
  'UU' => [:unmerged],
@@ -35,17 +35,17 @@ module Redcar
35
35
  ' M' => [:changed],
36
36
  ' D' => [:missing],
37
37
  }
38
-
38
+
39
39
  attr_reader :repo, :type
40
-
40
+
41
41
  def initialize(file, repo, type=:file, indexed=false, children=[])
42
- @file = file
43
- @repo = repo
44
- @type = type
45
- @indexed = indexed
42
+ @file = file
43
+ @repo = repo
44
+ @type = type
45
+ @indexed = indexed
46
46
  @children = children
47
47
  end
48
-
48
+
49
49
  def path
50
50
  if @file.type_raw[0,1] == "R" or @file.type_raw[0,1] == "C"
51
51
  paths = @file.path.split(' -> ')
@@ -54,11 +54,11 @@ module Redcar
54
54
  @file.path
55
55
  end
56
56
  end
57
-
57
+
58
58
  def git_status
59
59
  @file.type_raw
60
60
  end
61
-
61
+
62
62
  def status
63
63
  # Subprojects should be commitable, but we can't update the
64
64
  # current index while they are dirty.
@@ -72,15 +72,24 @@ module Redcar
72
72
  STATUS_MAP_UNINDEXED[@file.type_raw] || []
73
73
  end
74
74
  end
75
-
75
+
76
76
  def text
77
77
  if @file.type_raw[0,1] == "R" or @file.type_raw[0,1] == "C"
78
78
  @file.path
79
79
  else
80
- "#{File.basename(@file.path)} (#{File.dirname(@file.path)})"
80
+ begin
81
+ pathname = Pathname.new(
82
+ File.expand_path(File.dirname(@file.path),@repo.repo.dir.path)
83
+ )
84
+ repopath = Pathname.new(@repo.path)
85
+ relpath = pathname.relative_path_from(repopath).to_s
86
+ rescue Object => e
87
+ relpath = File.dirname(@file.path)
88
+ end
89
+ "#{File.basename(@file.path)} (#{relpath})"
81
90
  end
82
91
  end
83
-
92
+
84
93
  def icon
85
94
  icon = (@type == :file ? "notebook" : "folder")
86
95
  case
@@ -99,15 +108,15 @@ module Redcar
99
108
  end
100
109
  icon.to_sym
101
110
  end
102
-
111
+
103
112
  def leaf?
104
113
  icon == :file
105
114
  end
106
-
115
+
107
116
  def children
108
117
  @children
109
118
  end
110
-
119
+
111
120
  def diff
112
121
  if (not @indexed) and @file.type_raw == "??"
113
122
  # No diff available
@@ -118,11 +127,11 @@ module Redcar
118
127
  @repo.repo.lib.diff_full('HEAD', nil, {:path_limiter => path})
119
128
  end
120
129
  end
121
-
130
+
122
131
  def to_data
123
132
  "#{@file.type_raw}:#{@file.path}:#{@repo.repo.dir.path}:#{@type.to_s}:#{@indexed}"
124
133
  end
125
134
  end
126
135
  end
127
136
  end
128
- end
137
+ end
@@ -11,7 +11,7 @@ module Redcar
11
11
  matching_snippets = filter_and_rank_by(all_snippets, query, 1000) do |s|
12
12
  display(s)
13
13
  end
14
- current_scope = @document.cursor_scope
14
+ current_scope = Redcar.update_gui { @document.cursor_scope }
15
15
  @last_list = matching_snippets.select do |snippet|
16
16
  if snippet.scope
17
17
  !!JavaMateView::ScopeMatcher.get_match(snippet.scope, current_scope)
@@ -45,4 +45,4 @@ module Redcar
45
45
  end
46
46
  end
47
47
  end
48
- end
48
+ end
@@ -34,6 +34,7 @@ module Swt
34
34
  import org.eclipse.swt.custom.SashForm
35
35
  import org.eclipse.swt.custom.StackLayout
36
36
  import org.eclipse.swt.custom.ST
37
+ import org.eclipse.swt.custom.StyleRange
37
38
  import org.eclipse.swt.custom.StyledText
38
39
  import org.eclipse.swt.custom.TreeEditor
39
40
  end
@@ -5,3 +5,7 @@ Given /^I have (not )?suppressed syntax checking message dialogs$/ do |negate|
5
5
  Redcar::SyntaxCheck.storage['supress_message_dialogs'] = false
6
6
  end
7
7
  end
8
+
9
+ Given /^I excluded "(.*)" files from being checked for syntax errors$/ do |grammar|
10
+ Redcar::SyntaxCheck.storage['excluded_grammars'] << grammar.downcase
11
+ end
@@ -0,0 +1,3 @@
1
+ Before do
2
+ Redcar::SyntaxCheck.storage['excluded_grammars'] = []
3
+ end
@@ -1,10 +1,59 @@
1
1
  require 'syntax_check/checker'
2
- require 'syntax_check/error'
2
+ require 'syntax_check/annotation'
3
3
 
4
4
  module Redcar
5
5
  module SyntaxCheck
6
6
  def self.remove_syntax_error_annotations(edit_view)
7
- edit_view.remove_all_annotations :type => Error::Type
7
+ edit_view.remove_all_annotations :type => Annotation.type
8
+ edit_view.remove_all_annotations :type => Warning.type
9
+ edit_view.remove_all_annotations :type => Error.type
10
+ end
11
+
12
+ def self.menus
13
+ Redcar::Menu::Builder.build do
14
+ sub_menu "Plugins" do
15
+ lazy_sub_menu "Syntax Checking" do
16
+ item "Enabled", :type => :check, :active => SyntaxCheck.enabled?, :command => ToggleSyntaxChecking
17
+ separator
18
+ Checker.checkers.each do |checker|
19
+ grammar = checker[0]
20
+ item "#{grammar}", :type => :check, :active => SyntaxCheck.check_type?(grammar), :command => ToggleGrammarChecking, :value => grammar
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+
27
+ def self.enabled=(state)
28
+ SyntaxCheck.storage['suppress_syntax_checking'] = !state
29
+ end
30
+
31
+ def self.enabled?
32
+ if SyntaxCheck.storage['suppress_syntax_checking']
33
+ false
34
+ else
35
+ true
36
+ end
37
+ end
38
+
39
+ def self.check_type?(grammar)
40
+ excluded = SyntaxCheck.storage['excluded_grammars']
41
+ unless grammar and (excluded.include? grammar or
42
+ excluded.include? grammar.downcase)
43
+ true
44
+ end
45
+ end
46
+
47
+ def self.set_check_type(grammar,value)
48
+ if grammar
49
+ excluded = SyntaxCheck.storage['excluded_grammars']
50
+ if check_type?(grammar)
51
+ excluded << grammar.downcase
52
+ else
53
+ excluded = excluded - [grammar,grammar.downcase]
54
+ end
55
+ SyntaxCheck.storage['excluded_grammars'] = excluded
56
+ end
8
57
  end
9
58
 
10
59
  def self.storage
@@ -12,6 +61,7 @@ module Redcar
12
61
  storage = Plugin::Storage.new('syntax_checking')
13
62
  storage.set_default('suppress_message_dialogs',false)
14
63
  storage.set_default('suppress_syntax_checking',false)
64
+ storage.set_default('excluded_grammars',[])
15
65
  storage
16
66
  end
17
67
  end
@@ -24,11 +74,27 @@ module Redcar
24
74
  end
25
75
 
26
76
  def self.after_save(doc)
27
- unless SyntaxCheck.storage['suppress_syntax_checking']
28
- remove_syntax_error_annotations(doc.edit_view)
77
+ grammar = doc.edit_view.grammar
78
+ remove_syntax_error_annotations(doc.edit_view)
79
+ if SyntaxCheck.enabled? and SyntaxCheck.check_type?(grammar)
29
80
  checker = Checker[doc.edit_view.grammar]
30
81
  checker.new(doc).check if checker
31
82
  end
32
83
  end
84
+
85
+ class ToggleGrammarChecking < Redcar::Command
86
+ def execute(options)
87
+ if grammar = options[:value]
88
+ value = !SyntaxCheck.check_type?(grammar)
89
+ SyntaxCheck.set_check_type(grammar,value)
90
+ end
91
+ end
92
+ end
93
+
94
+ class ToggleSyntaxChecking < Redcar::Command
95
+ def execute
96
+ SyntaxCheck.enabled = !SyntaxCheck.enabled?
97
+ end
98
+ end
33
99
  end
34
- end
100
+ end
@@ -0,0 +1,61 @@
1
+ module Redcar
2
+ module SyntaxCheck
3
+ class Annotation
4
+
5
+ def self.type
6
+ "syntax.annotation.type"
7
+ end
8
+
9
+ def icon
10
+ "application--exclamation"
11
+ end
12
+
13
+ def color
14
+ [255, 255, 255]
15
+ end
16
+
17
+ attr_accessor :line, :char, :message, :doc
18
+
19
+ def initialize(doc, line, message, char=0)
20
+ @doc = doc
21
+ @line = line
22
+ @message = message
23
+ @char = char
24
+ end
25
+
26
+ def annotate
27
+ edit_view = doc.edit_view
28
+ edit_view.add_annotation_type(self.class.type, icon, color)
29
+ edit_view.add_annotation(self.class.type, line, message, @char, doc.get_line(line).length-@char)
30
+ end
31
+ end
32
+
33
+ class Error < Annotation
34
+ def self.type
35
+ "syntax.error.type"
36
+ end
37
+
38
+ def icon
39
+ "compile-error"
40
+ end
41
+
42
+ def color
43
+ [255, 32, 32]
44
+ end
45
+ end
46
+
47
+ class Warning < Annotation
48
+ def self.type
49
+ "syntax.warning.type"
50
+ end
51
+
52
+ def icon
53
+ "compile-warning"
54
+ end
55
+
56
+ def color
57
+ [255, 194, 10]
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,39 @@
1
+ require 'test_runner/runnable_test_runner'
2
+ require 'test_runner/rspec_runner'
3
+ require 'test_runner/run_test_command'
4
+ #
5
+ # $:.push(File.expand_path(File.join(File.dirname(__FILE__),
6
+ # "vendor", "activesupport-3.0.3", "lib")))
7
+ #
8
+ # require 'active_support'
9
+ # require 'active_support/inflections'
10
+ module Redcar
11
+ # This class is your plugin. Try adding new commands in here
12
+ # and putting them in the menus.
13
+ class TestRunner
14
+
15
+ # This method is run as Redcar is booting up.
16
+ def self.menus
17
+ # Here's how the plugin menus are drawn. Try adding more
18
+ # items or sub_menus.
19
+ Menu::Builder.build do
20
+ sub_menu "Plugins" do
21
+ sub_menu "Test Runner", :priority => 139 do
22
+ item "Run Test", RunTestCommand
23
+ end
24
+ end
25
+ end
26
+ end
27
+
28
+ def self.keymaps
29
+ osx = Redcar::Keymap.build("main", :osx) do
30
+ link "Cmd+Alt+T", RunTestCommand
31
+ end
32
+ linwin = Redcar::Keymap.build("main", [:linux, :windows]) do
33
+ link "Ctrl+Alt+T", RunTestCommand
34
+ end
35
+ [osx, linwin]
36
+ end
37
+
38
+ end
39
+ end
@@ -0,0 +1,20 @@
1
+ module Redcar
2
+ class RspecRunner
3
+ TEST_PATTERNS = [
4
+ /context\s+\"(.*)\"/,
5
+ /describe\s+\"(.*)\"/,
6
+ /it\s+\"(.*)\"/
7
+ ]
8
+
9
+ def self.run_test(path, current_line)
10
+ TEST_PATTERNS.each do |pattern|
11
+ if current_line =~ pattern
12
+ Redcar::Runnables.run_process Project::Manager.focussed_project.path, %{ruby -Ispec #{path} -e "#{$1}"}, "Running spec: #{$1}"
13
+ return
14
+ end
15
+ end
16
+ Redcar::Runnables.run_process Project::Manager.focussed_project.path, %{ruby -Ispec #{path}}, "Running spec: #{File.basename(path)}"
17
+ end
18
+ end
19
+ end
20
+
@@ -0,0 +1,63 @@
1
+ module Redcar
2
+
3
+ class RunTestCommand < Redcar::Command
4
+
5
+ TEST_RUNNERS = {
6
+ "Redcar::TestUnitRunner" => /_test.rb$/,
7
+ "Redcar::RspecRunner" => /_spec.rb$/
8
+ }
9
+
10
+ def self.storage
11
+ @storage ||= begin
12
+ storage = Plugin::Storage.new('test_runner')
13
+ storage.set_default('test_runners', [
14
+ {
15
+ "runner_class" => "Redcar::RunnableTestRunner",
16
+ "file_pattern" => /_test.rb$/,
17
+ "single_test_patterns" => [
18
+ /should\s+\"(.*)\"/,
19
+ /context\s+\"(.*)\"/,
20
+ /describe\s+\"(.*)\"/,
21
+ /def\s+(test_.*)\s+/
22
+ ],
23
+ "single_test_runner" => "ruby -Itest __FILE__ -n \"/__TEST_NAME__/\"",
24
+ "file_runner" => "ruby -Itest __FILE__"
25
+ },
26
+ {
27
+ "runner_class" => "Redcar::RunnableTestRunner",
28
+ "file_pattern" => /_spec.rb$/,
29
+ "single_test_patterns" => [
30
+ /it\s+\"(.*)\"/,
31
+ /context\s+\"(.*)\"/,
32
+ /describe\s+\"(.*)\"/
33
+ ],
34
+ "single_test_runner" => "ruby -Ispec __FILE__ -e \"__TEST_NAME__\"",
35
+ "file_runner" => "ruby -Ispec __FILE__"
36
+ },
37
+ ])
38
+ storage
39
+ end
40
+ end
41
+
42
+ def test_runners
43
+ self.class.storage["test_runners"]
44
+ end
45
+
46
+ def run_test(path, current_line)
47
+ test_runners.each do |test_runner_config|
48
+ pattern = test_runner_config["file_pattern"]
49
+ if path =~ pattern
50
+ runner = eval(test_runner_config["runner_class"]).new(test_runner_config)
51
+ runner.run_test(path, current_line)
52
+ end
53
+ end
54
+ end
55
+
56
+ def execute
57
+ doc = Redcar.app.focussed_window.focussed_notebook_tab.edit_view.document
58
+ current_line = doc.get_line(doc.cursor_line)
59
+ run_test(doc.path, current_line)
60
+ end
61
+ end
62
+
63
+ end
@@ -0,0 +1,26 @@
1
+ module Redcar
2
+ class RunnableTestRunner
3
+
4
+ attr_accessor :single_test_patterns, :file_runner, :single_test_runner
5
+
6
+ def initialize(config)
7
+ @single_test_patterns = config["single_test_patterns"]
8
+ @single_test_runner = config["single_test_runner"]
9
+ @file_runner = config["file_runner"]
10
+ end
11
+
12
+ def run_test(path, current_line)
13
+ single_test_patterns.each do |pattern|
14
+ if current_line =~ pattern
15
+ test_name = $1
16
+ command = single_test_runner.gsub("__FILE__", path).gsub("__TEST_NAME__", test_name)
17
+ Redcar::Runnables.run_process Project::Manager.focussed_project.path, command, "Running test: #{test_name}"
18
+ return
19
+ end
20
+ end
21
+ Redcar::Runnables.run_process Project::Manager.focussed_project.path,
22
+ file_runner.gsub("__FILE__", path), "Running test: #{File.basename(path)}"
23
+ end
24
+ end
25
+ end
26
+