redcar 0.3.4.3 → 0.3.5

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 (196) hide show
  1. data/CHANGES +45 -0
  2. data/README.md +2 -1
  3. data/ROADMAP.md +0 -1
  4. data/Rakefile +10 -4
  5. data/bin/redcar +2 -2
  6. data/lib/openssl/build.properties +7 -0
  7. data/lib/plugin_manager/lib/plugin_manager.rb +10 -0
  8. data/lib/plugin_manager/lib/plugin_manager/plugin_definition.rb +1 -13
  9. data/lib/redcar.rb +12 -8
  10. data/lib/redcar/installer.rb +16 -15
  11. data/lib/redcar/ruby_extensions.rb +146 -1
  12. data/lib/redcar/runner.rb +16 -7
  13. data/lib/redcar/usage.rb +4 -7
  14. data/lib/redcar_quick_start.rb +5 -5
  15. data/lib/regex_replace.rb +0 -7
  16. data/plugins/application/features/step_definitions/command_steps.rb +5 -0
  17. data/plugins/application/features/step_definitions/dialog_steps.rb +5 -0
  18. data/plugins/application/features/step_definitions/filter_list_dialog_steps.rb +38 -0
  19. data/plugins/application/features/step_definitions/window_steps.rb +1 -1
  20. data/plugins/application/features/support/env.rb +44 -8
  21. data/plugins/application/lib/application.rb +32 -33
  22. data/plugins/application/lib/application/command.rb +32 -2
  23. data/plugins/application/lib/application/command/executor.rb +2 -12
  24. data/plugins/application/lib/application/dialog.rb +14 -14
  25. data/plugins/application/lib/application/event_spewer.rb +32 -0
  26. data/plugins/application/lib/application/menu.rb +5 -5
  27. data/plugins/application/lib/application/menu/builder.rb +5 -0
  28. data/plugins/application/lib/application/menu/lazy_menu.rb +24 -0
  29. data/plugins/application/lib/application/notebook.rb +4 -3
  30. data/plugins/application/lib/application/tab.rb +6 -2
  31. data/plugins/application/lib/application/window.rb +8 -4
  32. data/plugins/application/spec/application/menu/builder_spec.rb +17 -1
  33. data/plugins/application/spec/application/notebook_spec.rb +1 -1
  34. data/plugins/application_swt/build.xml +74 -0
  35. data/plugins/application_swt/lib/application_swt.rb +79 -0
  36. data/plugins/application_swt/lib/application_swt/cucumber_patches.rb +6 -1
  37. data/plugins/application_swt/lib/application_swt/dialog_adapter.rb +25 -17
  38. data/plugins/application_swt/lib/application_swt/dialogs/filter_list_dialog_controller.rb +50 -12
  39. data/plugins/application_swt/lib/application_swt/html_tab.rb +20 -0
  40. data/plugins/application_swt/lib/application_swt/menu.rb +26 -2
  41. data/plugins/application_swt/lib/application_swt/notebook.rb +10 -12
  42. data/plugins/application_swt/lib/application_swt/window.rb +11 -11
  43. data/plugins/application_swt/src/com/redcareditor/application_swt/CocoaUIEnhancer.java +313 -0
  44. data/plugins/auto_completer/lib/auto_completer.rb +74 -67
  45. data/plugins/auto_completer/lib/auto_completer/current_document_completion_source.rb +19 -0
  46. data/plugins/auto_completer/lib/auto_completer/document_controller.rb +2 -2
  47. data/plugins/auto_completer/lib/auto_completer/word_list.rb +8 -1
  48. data/plugins/auto_indenter/features/ruby_style_indentation.feature +24 -0
  49. data/plugins/auto_indenter/features/step_definitions/indentation_steps.rb +6 -0
  50. data/plugins/auto_indenter/features/support/env.rb +2 -0
  51. data/plugins/auto_indenter/lib/auto_indenter.rb +86 -0
  52. data/plugins/auto_indenter/lib/auto_indenter/analyzer.rb +91 -0
  53. data/plugins/auto_indenter/lib/auto_indenter/commands.rb +34 -0
  54. data/plugins/auto_indenter/lib/auto_indenter/document_controller.rb +67 -12
  55. data/plugins/auto_indenter/lib/auto_indenter/rules.rb +41 -0
  56. data/plugins/auto_indenter/spec/auto_indenter/analyzer_spec.rb +151 -0
  57. data/plugins/auto_indenter/spec/spec_helper.rb +5 -0
  58. data/plugins/auto_pairer/lib/auto_pairer.rb +1 -0
  59. data/plugins/auto_pairer/lib/auto_pairer/document_controller.rb +43 -42
  60. data/plugins/auto_pairer/lib/auto_pairer/pairs_for_scope.rb +1 -5
  61. data/plugins/core/lib/core.rb +12 -1
  62. data/plugins/core/lib/core/observable.rb +7 -7
  63. data/plugins/core/lib/core/persistent_cache.rb +14 -2
  64. data/plugins/core/lib/core/plugin.rb +7 -0
  65. data/plugins/core/lib/core/resource.rb +78 -0
  66. data/plugins/core/lib/core/task.rb +62 -0
  67. data/plugins/core/lib/core/task_queue.rb +72 -0
  68. data/plugins/core/spec/core/resource_spec.rb +124 -0
  69. data/plugins/core/spec/core/task_queue_spec.rb +202 -0
  70. data/plugins/core/spec/spec_helper.rb +23 -1
  71. data/plugins/declarations/TODO +3 -0
  72. data/plugins/declarations/lib/declarations.rb +144 -0
  73. data/plugins/declarations/lib/declarations/completion_source.rb +22 -0
  74. data/plugins/declarations/lib/declarations/file.rb +68 -0
  75. data/plugins/declarations/lib/declarations/parser.rb +94 -0
  76. data/plugins/declarations/lib/declarations/select_tag_dialog.rb +44 -0
  77. data/plugins/declarations/plugin.rb +7 -0
  78. data/plugins/declarations/spec/declarations/file_spec.rb +62 -0
  79. data/plugins/declarations/spec/fixtures/federalist.rb +15 -0
  80. data/plugins/declarations/spec/spec_helper.rb +4 -0
  81. data/plugins/edit_view/features/indentation_commands.feature +40 -0
  82. data/plugins/edit_view/features/line_delimiter.feature +40 -0
  83. data/plugins/edit_view/features/step_definitions/editing_steps.rb +16 -4
  84. data/plugins/edit_view/features/step_definitions/notebook_steps.rb +1 -1
  85. data/plugins/edit_view/features/step_definitions/tab_steps.rb +1 -1
  86. data/plugins/edit_view/features/step_definitions/window_steps.rb +5 -1
  87. data/plugins/edit_view/features/support/env.rb +3 -5
  88. data/plugins/edit_view/features/undo_and_redo.feature +21 -0
  89. data/plugins/edit_view/lib/edit_view.rb +57 -4
  90. data/plugins/edit_view/lib/edit_view/actions/arrow_keys.rb +19 -3
  91. data/plugins/edit_view/lib/edit_view/document.rb +46 -11
  92. data/plugins/edit_view/lib/edit_view/document/indentation.rb +35 -0
  93. data/plugins/edit_view/lib/edit_view/modified_tabs_checker.rb +35 -0
  94. data/plugins/edit_view/lib/edit_view/tab_settings.rb +13 -3
  95. data/plugins/edit_view/spec/edit_view/document/indentation_spec.rb +112 -0
  96. data/plugins/edit_view/spec/edit_view/document_spec.rb +22 -0
  97. data/plugins/edit_view/spec/spec_helper.rb +1 -0
  98. data/plugins/edit_view_swt/lib/edit_view_swt.rb +59 -7
  99. data/plugins/edit_view_swt/lib/edit_view_swt/document.rb +3 -3
  100. data/plugins/edit_view_swt/lib/edit_view_swt/word_movement.rb +2 -2
  101. data/plugins/edit_view_swt/vendor/java-mateview.rb +3 -2
  102. data/plugins/encryption/encryption.rb +13 -6
  103. data/plugins/execute_current_tab/lib/execute_current_tab.rb +25 -15
  104. data/plugins/html_view/assets/redcar.css +32 -1
  105. data/plugins/html_view/lib/html_view.rb +23 -3
  106. data/plugins/html_view/lib/html_view/html_tab.rb +4 -0
  107. data/plugins/my_plugin/lib/my_plugin.rb +4 -12
  108. data/plugins/plugin_manager_ui/lib/plugin_manager_ui.rb +1 -0
  109. data/plugins/plugin_manager_ui/views/index.html.erb +30 -37
  110. data/plugins/project/features/find_file.feature +75 -0
  111. data/plugins/project/features/open_and_save_files.feature +7 -7
  112. data/plugins/project/features/open_directory_tree.feature +11 -3
  113. data/plugins/project/features/refresh_directory_tree.feature +7 -1
  114. data/plugins/project/features/step_definitions/directory_steps.rb +11 -1
  115. data/plugins/project/features/step_definitions/file_steps.rb +10 -0
  116. data/plugins/project/features/support/env.rb +6 -1
  117. data/plugins/project/features/watch_for_modified_files.feature +79 -0
  118. data/plugins/project/lib/project.rb +72 -306
  119. data/plugins/project/lib/project/commands.rb +128 -0
  120. data/plugins/project/lib/project/dir_mirror.rb +5 -1
  121. data/plugins/project/lib/project/drb_service.rb +21 -31
  122. data/plugins/project/lib/project/file_list.rb +76 -0
  123. data/plugins/project/lib/project/file_mirror.rb +13 -1
  124. data/plugins/project/lib/project/find_file_dialog.rb +22 -52
  125. data/plugins/project/lib/project/manager.rb +210 -0
  126. data/plugins/project/lib/project/recent_directories.rb +16 -3
  127. data/plugins/project/plugin.rb +1 -1
  128. data/plugins/project/spec/fixtures/myproject/README +2 -0
  129. data/plugins/project/spec/fixtures/myproject/lib/foo_lib.rb +1 -0
  130. data/plugins/project/spec/fixtures/myproject/spec/foo_spec.rb +1 -0
  131. data/plugins/project/{features → spec}/fixtures/winter.txt +0 -0
  132. data/plugins/project/spec/project/dir_mirror_spec.rb +1 -12
  133. data/plugins/project/spec/project/file_list_spec.rb +140 -0
  134. data/plugins/project/spec/spec_helper.rb +20 -0
  135. data/plugins/redcar/plugin.rb +1 -0
  136. data/plugins/redcar/redcar.rb +254 -84
  137. data/plugins/redcar_debug/lib/redcar_debug.rb +58 -11
  138. data/plugins/redcar_debug/vendor/jruby-prof/README +46 -0
  139. data/plugins/redcar_debug/vendor/jruby-prof/Rakefile +36 -0
  140. data/plugins/redcar_debug/vendor/jruby-prof/build.xml +31 -0
  141. data/plugins/redcar_debug/vendor/jruby-prof/example/call_tree.html +22677 -0
  142. data/plugins/redcar_debug/vendor/jruby-prof/example/call_tree.txt +589 -0
  143. data/plugins/redcar_debug/vendor/jruby-prof/example/flat.txt +28 -0
  144. data/plugins/redcar_debug/vendor/jruby-prof/example/graph.html +1670 -0
  145. data/plugins/redcar_debug/vendor/jruby-prof/example/graph.txt +125 -0
  146. data/plugins/redcar_debug/vendor/jruby-prof/example/pidigits.rb +92 -0
  147. data/plugins/redcar_debug/vendor/jruby-prof/example/test.rb +28 -0
  148. data/plugins/redcar_debug/vendor/jruby-prof/example/test2.rb +29 -0
  149. data/plugins/redcar_debug/vendor/jruby-prof/example/test_exception.rb +28 -0
  150. data/plugins/redcar_debug/vendor/jruby-prof/example/test_overhead.rb +43 -0
  151. data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof.rb +66 -0
  152. data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof/abstract_printer.rb +21 -0
  153. data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof/flat_text_printer.rb +35 -0
  154. data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof/graph_html_printer.rb +123 -0
  155. data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof/graph_text_printer.rb +45 -0
  156. data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof/invocation_set.rb +34 -0
  157. data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof/method.rb +107 -0
  158. data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof/profile_invocation.rb +43 -0
  159. data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof/simple_tree_printer.rb +27 -0
  160. data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof/tree_html_printer.rb +144 -0
  161. data/plugins/redcar_debug/vendor/jruby-prof/src/org/jruby/prof/Invocation.java +14 -0
  162. data/plugins/redcar_debug/vendor/jruby-prof/src/org/jruby/prof/JRubyProf.java +94 -0
  163. data/plugins/redcar_debug/vendor/jruby-prof/src/org/jruby/prof/ProfEventHook.java +49 -0
  164. data/plugins/redcar_debug/vendor/jruby-prof/templates/graph_row.html.erb +18 -0
  165. data/plugins/redcar_debug/vendor/jruby-prof/test/basic_test.rb +291 -0
  166. data/plugins/redcar_debug/views/history.html.erb +33 -0
  167. data/plugins/redcar_debug/views/index.html.erb +33 -0
  168. data/plugins/repl/lib/repl/internal_mirror.rb +3 -15
  169. data/plugins/repl/spec/repl/internal_mirror_spec.rb +2 -2
  170. data/plugins/snippets/lib/snippets.rb +0 -1
  171. data/plugins/snippets/lib/snippets/document_controller.rb +7 -1
  172. data/plugins/task_manager/lib/task_manager.rb +28 -0
  173. data/plugins/task_manager/plugin.rb +11 -0
  174. data/plugins/task_manager/views/index.html.erb +67 -0
  175. data/plugins/textmate/lib/textmate.rb +17 -21
  176. data/plugins/textmate/lib/textmate/plist.rb +1 -2
  177. data/plugins/textmate/lib/textmate/preference.rb +5 -1
  178. data/plugins/textmate/lib/textmate/snippet.rb +6 -1
  179. data/plugins/tree_view_swt/lib/tree_view_swt.rb +0 -6
  180. data/textmate/Bundles/Cucumber.tmbundle/Preferences/Comments.tmPreferences +1 -1
  181. data/textmate/Bundles/Cucumber.tmbundle/Preferences/next_Cucumber_Plain_Text_Feature_Completions.tmPreferences +30 -0
  182. data/textmate/Bundles/Cucumber.tmbundle/Preferences/next_Symbol_list___Scenario.tmPreferences +19 -0
  183. data/textmate/Bundles/Cucumber.tmbundle/Syntaxes/next_Cucumber_Plain_Text_Feature.tmLanguage +221 -0
  184. data/textmate/Bundles/Cucumber.tmbundle/Syntaxes/next_Cucumber_Steps.tmLanguage +424 -0
  185. data/textmate/Bundles/Cucumber.tmbundle/Syntaxes/plaintext_template.erb +19 -77
  186. data/textmate/Bundles/Cucumber.tmbundle/info.plist +1 -20
  187. data/textmate/Bundles/Perl.tmbundle/Syntaxes/Perl.plist +1 -1
  188. data/textmate/Themes/Emacs Strict.tmTheme +241 -0
  189. data/textmate/Themes/IR_White.tmTheme +792 -0
  190. data/textmate/Themes/Monokai.tmTheme +291 -0
  191. data/textmate/Themes/WhysPoignant.tmTheme +191 -0
  192. metadata +92 -7
  193. data/plugins/application/features/main_window.feature +0 -8
  194. data/plugins/project/lib/project/project_command.rb +0 -5
  195. data/textmate/Bundles/Cucumber.tmbundle/Snippets/Scenario.tmSnippet +0 -22
  196. data/textmate/Bundles/Cucumber.tmbundle/Snippets/Story.tmSnippet +0 -25
@@ -0,0 +1,128 @@
1
+ module Redcar
2
+ class ProjectCommand < Command
3
+ sensitize :open_project
4
+
5
+ def project
6
+ Project::Manager.in_window(win)
7
+ end
8
+ end
9
+
10
+ class Project
11
+ class FileOpenCommand < Command
12
+ def initialize(path = nil)
13
+ @path = path
14
+ end
15
+
16
+ def execute
17
+ path = get_path
18
+ if path
19
+ Manager.open_file(path)
20
+ end
21
+ end
22
+
23
+ private
24
+
25
+ def get_path
26
+ @path || begin
27
+ if path = Application::Dialog.open_file(:filter_path => Manager.filter_path)
28
+ Manager.storage['last_dir'] = File.dirname(File.expand_path(path))
29
+ path
30
+ end
31
+ end
32
+ end
33
+ end
34
+
35
+ class FileSaveCommand < EditTabCommand
36
+ def initialize(tab=nil)
37
+ @tab = tab
38
+ end
39
+
40
+ def execute
41
+ if tab.edit_view.document.mirror
42
+ tab.edit_view.document.save!
43
+ Project::Manager.refresh_modified_file(tab.edit_view.document.mirror.path)
44
+ else
45
+ FileSaveAsCommand.new.run
46
+ end
47
+ end
48
+ end
49
+
50
+ class FileSaveAsCommand < EditTabCommand
51
+
52
+ def initialize(tab=nil, path=nil)
53
+ @tab = tab
54
+ @path = path
55
+ end
56
+
57
+ def execute
58
+ path = get_path
59
+ if path
60
+ contents = tab.edit_view.document.to_s
61
+ new_mirror = FileMirror.new(path)
62
+ new_mirror.commit(contents)
63
+ tab.edit_view.document.mirror = new_mirror
64
+ Project::Manager.refresh_modified_file(tab.edit_view.document.mirror.path)
65
+ end
66
+ end
67
+
68
+ private
69
+
70
+ def get_path
71
+ @path || begin
72
+ if path = Application::Dialog.save_file(:filter_path => Manager.filter_path)
73
+ Manager.storage['last_dir'] = File.dirname(File.expand_path(path))
74
+ path
75
+ end
76
+ end
77
+ end
78
+ end
79
+
80
+ class DirectoryOpenCommand < Command
81
+
82
+ def initialize(path=nil)
83
+ @path = path
84
+ end
85
+
86
+ def execute
87
+ if path = get_path
88
+ project = Manager.open_project_for_path(path)
89
+ project.refresh
90
+ end
91
+ end
92
+
93
+ private
94
+
95
+ def get_path
96
+ @path || begin
97
+ if path = Application::Dialog.open_directory(:filter_path => Manager.filter_path)
98
+ Manager.storage['last_dir'] = File.dirname(File.expand_path(path))
99
+ path
100
+ end
101
+ end
102
+ end
103
+ end
104
+
105
+ class DirectoryCloseCommand < ProjectCommand
106
+
107
+ def execute
108
+ project.close
109
+ end
110
+ end
111
+
112
+ class RefreshDirectoryCommand < ProjectCommand
113
+
114
+ def execute
115
+ project.refresh
116
+ end
117
+ end
118
+
119
+ class FindFileCommand < ProjectCommand
120
+
121
+ def execute
122
+ dialog = FindFileDialog.new(Manager.focussed_project)
123
+ dialog.open
124
+ end
125
+ end
126
+
127
+ end
128
+ end
@@ -33,7 +33,11 @@ module Redcar
33
33
 
34
34
  class Node
35
35
  def self.create_all_from_path(path)
36
- Dir[path + "/*"].sort_by {|fn| fn.downcase }.map {|fn| create_from_path(fn) }
36
+ Dir[path + "/*"].sort_by do |fn|
37
+ File.basename(fn).downcase
38
+ end.sort_by do |path|
39
+ File.directory?(path) ? -1 : 1
40
+ end.map {|fn| create_from_path(fn) }
37
41
  end
38
42
 
39
43
  def self.create_from_path(path)
@@ -2,65 +2,55 @@ module Redcar
2
2
  class Project
3
3
  class DrbService
4
4
  def initialize
5
- # TODO choose a random port instead of hard coded
6
5
  begin
7
- address = "druby://127.0.0.1:9999"
6
+ address = "druby://127.0.0.1:#{DRB_PORT}"
8
7
  @drb = DRb.start_service(address, self)
9
8
  rescue Errno::EADDRINUSE => e
10
9
  puts 'warning--not starting listener (perhaps theres another Redcar already open?)' + e + ' ' + address
11
10
  end
12
11
  end
13
12
 
14
- # opens an item as if from the command line for use via drb
15
13
  def open_item_drb(full_path)
16
14
  begin
17
15
  puts 'drb opening ' + full_path if $VERBOSE
18
16
  if File.directory? full_path
19
- Redcar::ApplicationSWT.sync_exec {
20
-
21
- # open in any existing window that already has that dir open as a tree
22
- # else in a new window
23
- # open the window that already has this dir open
24
- if Redcar.app.windows.length == 0 && Application.storage['last_open_dir'] == full_path
25
- Project.restore_last_session
17
+ Redcar::ApplicationSWT.sync_exec do
18
+ if Redcar.app.windows.length == 0 and Application.storage['last_open_dir'] == full_path
19
+ Project::Manager.restore_last_session
26
20
  end
27
21
 
28
22
  if Redcar.app.windows.length > 0
29
- window = Redcar.app.windows.find{|win|
30
- # XXXX how can win be nil here?
31
- win && win.treebook.trees.find{|t|
32
- t.tree_mirror.is_a?(Redcar::Project::DirMirror) && t.tree_mirror.path == full_path
33
- }
34
- }
23
+ window = Redcar.app.windows.find do |win|
24
+ next unless win
25
+ win.treebook.trees.find do |t|
26
+ t.tree_mirror.is_a?(Redcar::Project::DirMirror) and t.tree_mirror.path == full_path
27
+ end
28
+ end
35
29
  end
36
- window ||= Redcar.app.new_window
37
- Project.open_dir(full_path, window)
30
+ Project::Manager.open_project_for_path(full_path)
38
31
  Redcar.app.focussed_window.controller.bring_to_front
39
-
40
- }
32
+ end
41
33
  'ok'
42
34
  elsif full_path == 'just_bring_to_front'
43
- Redcar::ApplicationSWT.sync_exec {
35
+ Redcar::ApplicationSWT.sync_exec do
44
36
  if Redcar.app.windows.length == 0
45
- Project.restore_last_session
37
+ Project::Manager.restore_last_session
46
38
  end
47
39
  Redcar.app.focussed_window.controller.bring_to_front
48
- }
40
+ end
49
41
  'ok'
50
- else
51
- # existing or not (yet) existing file
52
- Redcar::ApplicationSWT.sync_exec {
42
+ elsif File.file?(full_path)
43
+ Redcar::ApplicationSWT.sync_exec do
53
44
  if Redcar.app.windows.length == 0
54
- Project.restore_last_session
45
+ Project::Manager.restore_last_session
55
46
  end
56
- FileOpenCommand.new(full_path).execute
47
+ Project::Manager.open_file(full_path)
57
48
  Redcar.app.focussed_window.controller.bring_to_front
58
- }
49
+ end
59
50
  'ok'
60
51
  end
61
52
  rescue Exception => e
62
- # normally drb would swallow these
63
- puts 'drb got exception:' + e, e.backtrace
53
+ puts 'drb got exception:' + e.class + " " + e.message, e.backtrace
64
54
  raise e
65
55
  end
66
56
  end
@@ -0,0 +1,76 @@
1
+ module Redcar
2
+ class Project
3
+ class FileList
4
+ attr_reader :path
5
+
6
+ def initialize(path)
7
+ @path = File.expand_path(path)
8
+ @files = {}
9
+ end
10
+
11
+ def all_files
12
+ @files.keys
13
+ end
14
+
15
+ def contains?(file)
16
+ @files[file]
17
+ end
18
+
19
+ def update(paths=nil)
20
+ if paths
21
+ @files = @files.merge(find(*paths))
22
+ else
23
+ @files = find(path)
24
+ end
25
+ end
26
+
27
+ def changed_since(time)
28
+ result = {}
29
+ @files.each do |file, mtime|
30
+ if mtime.to_i >= time.to_i - 1
31
+ result[file] = mtime
32
+ end
33
+ end
34
+ result
35
+ end
36
+
37
+ private
38
+
39
+ def find(*paths)
40
+ files = {}
41
+ paths.collect!{|d| d.dup}
42
+ while file = paths.shift
43
+ begin
44
+ stat = File.lstat(file)
45
+ unless file =~ /\.git|\.yardoc|\.svn/
46
+ unless stat.directory?
47
+ files[file.dup] = stat.mtime
48
+ end
49
+ next unless File.exist? file
50
+ if stat.directory?
51
+ d = Dir.open(file)
52
+ begin
53
+ for f in d
54
+ next if f == "." or f == ".."
55
+ if File::ALT_SEPARATOR and file =~ /^(?:[\/\\]|[A-Za-z]:[\/\\]?)$/
56
+ f = file + f
57
+ elsif file == "/"
58
+ f = "/" + f
59
+ else
60
+ f = File.join(file, f)
61
+ end
62
+ paths.unshift f.untaint
63
+ end
64
+ ensure
65
+ d.close
66
+ end
67
+ end
68
+ end
69
+ rescue Errno::ENOENT, Errno::EACCES
70
+ end
71
+ end
72
+ files
73
+ end
74
+ end
75
+ end
76
+ end
@@ -39,7 +39,19 @@ module Redcar
39
39
  #
40
40
  # @return [Boolean]
41
41
  def changed?
42
- !@timestamp or @timestamp < File.stat(@path).mtime
42
+ begin
43
+ !@timestamp or @timestamp < File.stat(@path).mtime
44
+ rescue Errno::ENOENT
45
+ false
46
+ end
47
+ end
48
+
49
+ def changed_since?(time)
50
+ begin
51
+ !@timestamp or (!time and changed?) or (time and time < File.stat(@path).mtime)
52
+ rescue Errno::ENOENT
53
+ false
54
+ end
43
55
  end
44
56
 
45
57
  # Save new file contents.
@@ -2,33 +2,21 @@ module Redcar
2
2
  class Project
3
3
 
4
4
  class FindFileDialog < FilterListDialog
5
- def self.clear
6
- if storage['clear_cache_on_refocus']
7
- cached_dir_lists.clear
8
- end
9
- end
10
-
11
- def self.storage
12
- @storage ||= begin
13
- storage = Plugin::Storage.new('find_file_dialog')
14
- storage.set_default('clear_cache_on_refocus', true)
15
- storage
16
- end
17
- end
18
-
19
- def self.cached_dir_lists
20
- @cached_dir_lists ||= {}
21
- end
22
-
23
5
  def self.storage
24
6
  @storage ||= begin
25
7
  storage = Plugin::Storage.new('find_file_dialog')
26
- storage.set_default('clear_cache_on_refocus', true)
27
8
  storage.set_default('ignore_files_that_match_these_regexes', [])
28
9
  storage.set_default('ignore_files_that_match_these_regexes_example_for_reference', [/.*\.class/i])
29
10
  storage
30
11
  end
31
- end
12
+ end
13
+
14
+ attr_reader :project
15
+
16
+ def initialize(project)
17
+ super()
18
+ @project = project
19
+ end
32
20
 
33
21
  def close
34
22
  super
@@ -36,10 +24,10 @@ module Redcar
36
24
 
37
25
  def update_list(filter)
38
26
  if filter.length < 2
39
- paths = Project.recent_files_for(Project.focussed_project_path)
27
+ paths = recent_files
40
28
  else
41
- paths = find_files_from_list(filter, Project.recent_files_for(Project.focussed_project_path)) +
42
- find_files(filter, Project.focussed_project_path)
29
+ paths = find_files_from_list(filter, recent_files) +
30
+ find_files(filter, project.path)
43
31
  paths.uniq! # in case there's some dupe's between the two lists
44
32
  end
45
33
 
@@ -51,7 +39,7 @@ module Redcar
51
39
  duplicates = duplicates_as_hash(display_paths)
52
40
  display_paths.each_with_index do |dp, i|
53
41
  if duplicates[dp]
54
- display_paths[i] = display_path(full_paths[i], Project.focussed_project_path.split('/')[0..-2].join('/'))
42
+ display_paths[i] = display_path(full_paths[i], project.path.split('/')[0..-2].join('/'))
55
43
  end
56
44
  end
57
45
  end
@@ -67,6 +55,11 @@ module Redcar
67
55
 
68
56
  private
69
57
 
58
+ def recent_files
59
+ files = project.recent_files
60
+ ((files[0..-2]||[]).reverse + [files[-1]]).compact
61
+ end
62
+
70
63
  def duplicates_as_hash(enum)
71
64
  enum.inject(Hash.new(0)) {|h,v| h[v] += 1; h }.reject {|k,v| v == 1 }
72
65
  end
@@ -90,35 +83,12 @@ module Redcar
90
83
  end
91
84
  end
92
85
 
93
- def files(directories)
94
- FindFileDialog.cached_dir_lists[directories] ||= begin
95
- files = []
96
- s = Time.now
97
- directories.each do |dir|
98
- files += Dir[File.expand_path(dir + "/**/*")]
99
- end
100
- took = Time.now - s
101
- puts "find files (#{directories.length} dirs) took #{took}s"
102
- files.reject do |f|
103
- begin
104
- File.directory?(f)
105
- rescue Errno::ENOENT
106
- # File.directory? can throw no such file or directory even if File.exist?
107
- # has returned true. For example this happens on some awful textmate filenames
108
- # unicode in them.
109
- true
110
- end
111
- end
112
- end
86
+ def ignore_regexes
87
+ self.class.storage['ignore_files_that_match_these_regexes']
113
88
  end
114
89
 
115
- def not_on_ignore_list(filename)
116
- self.class.storage['ignore_files_that_match_these_regexes'].each do |re|
117
- if re =~ filename
118
- return false
119
- end
120
- end
121
- true
90
+ def ignore_file?(filename)
91
+ ignore_regexes.any? {|re| re =~ filename }
122
92
  end
123
93
 
124
94
  def find_files_from_list(text, file_list)
@@ -129,7 +99,7 @@ module Redcar
129
99
  end
130
100
 
131
101
  def find_files(text, directories)
132
- filter_and_rank_by(files(directories), text) do |fn|
102
+ filter_and_rank_by(project.all_files.sort, text) do |fn|
133
103
  fn.split("/").last
134
104
  end
135
105
  end