redcar 0.3.4.3 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +45 -0
- data/README.md +2 -1
- data/ROADMAP.md +0 -1
- data/Rakefile +10 -4
- data/bin/redcar +2 -2
- data/lib/openssl/build.properties +7 -0
- data/lib/plugin_manager/lib/plugin_manager.rb +10 -0
- data/lib/plugin_manager/lib/plugin_manager/plugin_definition.rb +1 -13
- data/lib/redcar.rb +12 -8
- data/lib/redcar/installer.rb +16 -15
- data/lib/redcar/ruby_extensions.rb +146 -1
- data/lib/redcar/runner.rb +16 -7
- data/lib/redcar/usage.rb +4 -7
- data/lib/redcar_quick_start.rb +5 -5
- data/lib/regex_replace.rb +0 -7
- data/plugins/application/features/step_definitions/command_steps.rb +5 -0
- data/plugins/application/features/step_definitions/dialog_steps.rb +5 -0
- data/plugins/application/features/step_definitions/filter_list_dialog_steps.rb +38 -0
- data/plugins/application/features/step_definitions/window_steps.rb +1 -1
- data/plugins/application/features/support/env.rb +44 -8
- data/plugins/application/lib/application.rb +32 -33
- data/plugins/application/lib/application/command.rb +32 -2
- data/plugins/application/lib/application/command/executor.rb +2 -12
- data/plugins/application/lib/application/dialog.rb +14 -14
- data/plugins/application/lib/application/event_spewer.rb +32 -0
- data/plugins/application/lib/application/menu.rb +5 -5
- data/plugins/application/lib/application/menu/builder.rb +5 -0
- data/plugins/application/lib/application/menu/lazy_menu.rb +24 -0
- data/plugins/application/lib/application/notebook.rb +4 -3
- data/plugins/application/lib/application/tab.rb +6 -2
- data/plugins/application/lib/application/window.rb +8 -4
- data/plugins/application/spec/application/menu/builder_spec.rb +17 -1
- data/plugins/application/spec/application/notebook_spec.rb +1 -1
- data/plugins/application_swt/build.xml +74 -0
- data/plugins/application_swt/lib/application_swt.rb +79 -0
- data/plugins/application_swt/lib/application_swt/cucumber_patches.rb +6 -1
- data/plugins/application_swt/lib/application_swt/dialog_adapter.rb +25 -17
- data/plugins/application_swt/lib/application_swt/dialogs/filter_list_dialog_controller.rb +50 -12
- data/plugins/application_swt/lib/application_swt/html_tab.rb +20 -0
- data/plugins/application_swt/lib/application_swt/menu.rb +26 -2
- data/plugins/application_swt/lib/application_swt/notebook.rb +10 -12
- data/plugins/application_swt/lib/application_swt/window.rb +11 -11
- data/plugins/application_swt/src/com/redcareditor/application_swt/CocoaUIEnhancer.java +313 -0
- data/plugins/auto_completer/lib/auto_completer.rb +74 -67
- data/plugins/auto_completer/lib/auto_completer/current_document_completion_source.rb +19 -0
- data/plugins/auto_completer/lib/auto_completer/document_controller.rb +2 -2
- data/plugins/auto_completer/lib/auto_completer/word_list.rb +8 -1
- data/plugins/auto_indenter/features/ruby_style_indentation.feature +24 -0
- data/plugins/auto_indenter/features/step_definitions/indentation_steps.rb +6 -0
- data/plugins/auto_indenter/features/support/env.rb +2 -0
- data/plugins/auto_indenter/lib/auto_indenter.rb +86 -0
- data/plugins/auto_indenter/lib/auto_indenter/analyzer.rb +91 -0
- data/plugins/auto_indenter/lib/auto_indenter/commands.rb +34 -0
- data/plugins/auto_indenter/lib/auto_indenter/document_controller.rb +67 -12
- data/plugins/auto_indenter/lib/auto_indenter/rules.rb +41 -0
- data/plugins/auto_indenter/spec/auto_indenter/analyzer_spec.rb +151 -0
- data/plugins/auto_indenter/spec/spec_helper.rb +5 -0
- data/plugins/auto_pairer/lib/auto_pairer.rb +1 -0
- data/plugins/auto_pairer/lib/auto_pairer/document_controller.rb +43 -42
- data/plugins/auto_pairer/lib/auto_pairer/pairs_for_scope.rb +1 -5
- data/plugins/core/lib/core.rb +12 -1
- data/plugins/core/lib/core/observable.rb +7 -7
- data/plugins/core/lib/core/persistent_cache.rb +14 -2
- data/plugins/core/lib/core/plugin.rb +7 -0
- data/plugins/core/lib/core/resource.rb +78 -0
- data/plugins/core/lib/core/task.rb +62 -0
- data/plugins/core/lib/core/task_queue.rb +72 -0
- data/plugins/core/spec/core/resource_spec.rb +124 -0
- data/plugins/core/spec/core/task_queue_spec.rb +202 -0
- data/plugins/core/spec/spec_helper.rb +23 -1
- data/plugins/declarations/TODO +3 -0
- data/plugins/declarations/lib/declarations.rb +144 -0
- data/plugins/declarations/lib/declarations/completion_source.rb +22 -0
- data/plugins/declarations/lib/declarations/file.rb +68 -0
- data/plugins/declarations/lib/declarations/parser.rb +94 -0
- data/plugins/declarations/lib/declarations/select_tag_dialog.rb +44 -0
- data/plugins/declarations/plugin.rb +7 -0
- data/plugins/declarations/spec/declarations/file_spec.rb +62 -0
- data/plugins/declarations/spec/fixtures/federalist.rb +15 -0
- data/plugins/declarations/spec/spec_helper.rb +4 -0
- data/plugins/edit_view/features/indentation_commands.feature +40 -0
- data/plugins/edit_view/features/line_delimiter.feature +40 -0
- data/plugins/edit_view/features/step_definitions/editing_steps.rb +16 -4
- data/plugins/edit_view/features/step_definitions/notebook_steps.rb +1 -1
- data/plugins/edit_view/features/step_definitions/tab_steps.rb +1 -1
- data/plugins/edit_view/features/step_definitions/window_steps.rb +5 -1
- data/plugins/edit_view/features/support/env.rb +3 -5
- data/plugins/edit_view/features/undo_and_redo.feature +21 -0
- data/plugins/edit_view/lib/edit_view.rb +57 -4
- data/plugins/edit_view/lib/edit_view/actions/arrow_keys.rb +19 -3
- data/plugins/edit_view/lib/edit_view/document.rb +46 -11
- data/plugins/edit_view/lib/edit_view/document/indentation.rb +35 -0
- data/plugins/edit_view/lib/edit_view/modified_tabs_checker.rb +35 -0
- data/plugins/edit_view/lib/edit_view/tab_settings.rb +13 -3
- data/plugins/edit_view/spec/edit_view/document/indentation_spec.rb +112 -0
- data/plugins/edit_view/spec/edit_view/document_spec.rb +22 -0
- data/plugins/edit_view/spec/spec_helper.rb +1 -0
- data/plugins/edit_view_swt/lib/edit_view_swt.rb +59 -7
- data/plugins/edit_view_swt/lib/edit_view_swt/document.rb +3 -3
- data/plugins/edit_view_swt/lib/edit_view_swt/word_movement.rb +2 -2
- data/plugins/edit_view_swt/vendor/java-mateview.rb +3 -2
- data/plugins/encryption/encryption.rb +13 -6
- data/plugins/execute_current_tab/lib/execute_current_tab.rb +25 -15
- data/plugins/html_view/assets/redcar.css +32 -1
- data/plugins/html_view/lib/html_view.rb +23 -3
- data/plugins/html_view/lib/html_view/html_tab.rb +4 -0
- data/plugins/my_plugin/lib/my_plugin.rb +4 -12
- data/plugins/plugin_manager_ui/lib/plugin_manager_ui.rb +1 -0
- data/plugins/plugin_manager_ui/views/index.html.erb +30 -37
- data/plugins/project/features/find_file.feature +75 -0
- data/plugins/project/features/open_and_save_files.feature +7 -7
- data/plugins/project/features/open_directory_tree.feature +11 -3
- data/plugins/project/features/refresh_directory_tree.feature +7 -1
- data/plugins/project/features/step_definitions/directory_steps.rb +11 -1
- data/plugins/project/features/step_definitions/file_steps.rb +10 -0
- data/plugins/project/features/support/env.rb +6 -1
- data/plugins/project/features/watch_for_modified_files.feature +79 -0
- data/plugins/project/lib/project.rb +72 -306
- data/plugins/project/lib/project/commands.rb +128 -0
- data/plugins/project/lib/project/dir_mirror.rb +5 -1
- data/plugins/project/lib/project/drb_service.rb +21 -31
- data/plugins/project/lib/project/file_list.rb +76 -0
- data/plugins/project/lib/project/file_mirror.rb +13 -1
- data/plugins/project/lib/project/find_file_dialog.rb +22 -52
- data/plugins/project/lib/project/manager.rb +210 -0
- data/plugins/project/lib/project/recent_directories.rb +16 -3
- data/plugins/project/plugin.rb +1 -1
- data/plugins/project/spec/fixtures/myproject/README +2 -0
- data/plugins/project/spec/fixtures/myproject/lib/foo_lib.rb +1 -0
- data/plugins/project/spec/fixtures/myproject/spec/foo_spec.rb +1 -0
- data/plugins/project/{features → spec}/fixtures/winter.txt +0 -0
- data/plugins/project/spec/project/dir_mirror_spec.rb +1 -12
- data/plugins/project/spec/project/file_list_spec.rb +140 -0
- data/plugins/project/spec/spec_helper.rb +20 -0
- data/plugins/redcar/plugin.rb +1 -0
- data/plugins/redcar/redcar.rb +254 -84
- data/plugins/redcar_debug/lib/redcar_debug.rb +58 -11
- data/plugins/redcar_debug/vendor/jruby-prof/README +46 -0
- data/plugins/redcar_debug/vendor/jruby-prof/Rakefile +36 -0
- data/plugins/redcar_debug/vendor/jruby-prof/build.xml +31 -0
- data/plugins/redcar_debug/vendor/jruby-prof/example/call_tree.html +22677 -0
- data/plugins/redcar_debug/vendor/jruby-prof/example/call_tree.txt +589 -0
- data/plugins/redcar_debug/vendor/jruby-prof/example/flat.txt +28 -0
- data/plugins/redcar_debug/vendor/jruby-prof/example/graph.html +1670 -0
- data/plugins/redcar_debug/vendor/jruby-prof/example/graph.txt +125 -0
- data/plugins/redcar_debug/vendor/jruby-prof/example/pidigits.rb +92 -0
- data/plugins/redcar_debug/vendor/jruby-prof/example/test.rb +28 -0
- data/plugins/redcar_debug/vendor/jruby-prof/example/test2.rb +29 -0
- data/plugins/redcar_debug/vendor/jruby-prof/example/test_exception.rb +28 -0
- data/plugins/redcar_debug/vendor/jruby-prof/example/test_overhead.rb +43 -0
- data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof.rb +66 -0
- data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof/abstract_printer.rb +21 -0
- data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof/flat_text_printer.rb +35 -0
- data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof/graph_html_printer.rb +123 -0
- data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof/graph_text_printer.rb +45 -0
- data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof/invocation_set.rb +34 -0
- data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof/method.rb +107 -0
- data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof/profile_invocation.rb +43 -0
- data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof/simple_tree_printer.rb +27 -0
- data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof/tree_html_printer.rb +144 -0
- data/plugins/redcar_debug/vendor/jruby-prof/src/org/jruby/prof/Invocation.java +14 -0
- data/plugins/redcar_debug/vendor/jruby-prof/src/org/jruby/prof/JRubyProf.java +94 -0
- data/plugins/redcar_debug/vendor/jruby-prof/src/org/jruby/prof/ProfEventHook.java +49 -0
- data/plugins/redcar_debug/vendor/jruby-prof/templates/graph_row.html.erb +18 -0
- data/plugins/redcar_debug/vendor/jruby-prof/test/basic_test.rb +291 -0
- data/plugins/redcar_debug/views/history.html.erb +33 -0
- data/plugins/redcar_debug/views/index.html.erb +33 -0
- data/plugins/repl/lib/repl/internal_mirror.rb +3 -15
- data/plugins/repl/spec/repl/internal_mirror_spec.rb +2 -2
- data/plugins/snippets/lib/snippets.rb +0 -1
- data/plugins/snippets/lib/snippets/document_controller.rb +7 -1
- data/plugins/task_manager/lib/task_manager.rb +28 -0
- data/plugins/task_manager/plugin.rb +11 -0
- data/plugins/task_manager/views/index.html.erb +67 -0
- data/plugins/textmate/lib/textmate.rb +17 -21
- data/plugins/textmate/lib/textmate/plist.rb +1 -2
- data/plugins/textmate/lib/textmate/preference.rb +5 -1
- data/plugins/textmate/lib/textmate/snippet.rb +6 -1
- data/plugins/tree_view_swt/lib/tree_view_swt.rb +0 -6
- data/textmate/Bundles/Cucumber.tmbundle/Preferences/Comments.tmPreferences +1 -1
- data/textmate/Bundles/Cucumber.tmbundle/Preferences/next_Cucumber_Plain_Text_Feature_Completions.tmPreferences +30 -0
- data/textmate/Bundles/Cucumber.tmbundle/Preferences/next_Symbol_list___Scenario.tmPreferences +19 -0
- data/textmate/Bundles/Cucumber.tmbundle/Syntaxes/next_Cucumber_Plain_Text_Feature.tmLanguage +221 -0
- data/textmate/Bundles/Cucumber.tmbundle/Syntaxes/next_Cucumber_Steps.tmLanguage +424 -0
- data/textmate/Bundles/Cucumber.tmbundle/Syntaxes/plaintext_template.erb +19 -77
- data/textmate/Bundles/Cucumber.tmbundle/info.plist +1 -20
- data/textmate/Bundles/Perl.tmbundle/Syntaxes/Perl.plist +1 -1
- data/textmate/Themes/Emacs Strict.tmTheme +241 -0
- data/textmate/Themes/IR_White.tmTheme +792 -0
- data/textmate/Themes/Monokai.tmTheme +291 -0
- data/textmate/Themes/WhysPoignant.tmTheme +191 -0
- metadata +92 -7
- data/plugins/application/features/main_window.feature +0 -8
- data/plugins/project/lib/project/project_command.rb +0 -5
- data/textmate/Bundles/Cucumber.tmbundle/Snippets/Scenario.tmSnippet +0 -22
- 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
|
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
|
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
|
-
|
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
|
30
|
-
|
31
|
-
win
|
32
|
-
t.tree_mirror.is_a?(Redcar::Project::DirMirror)
|
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
|
-
|
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
|
-
|
51
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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 =
|
27
|
+
paths = recent_files
|
40
28
|
else
|
41
|
-
paths = find_files_from_list(filter,
|
42
|
-
find_files(filter,
|
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],
|
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
|
94
|
-
|
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
|
116
|
-
|
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(
|
102
|
+
filter_and_rank_by(project.all_files.sort, text) do |fn|
|
133
103
|
fn.split("/").last
|
134
104
|
end
|
135
105
|
end
|