redcar 0.12.1 → 0.13

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 (84) hide show
  1. data/CHANGES +18 -0
  2. data/bin/redcar +1 -0
  3. data/lib/redcar.rb +4 -5
  4. data/lib/redcar/usage.rb +0 -1
  5. data/lib/redcar_quick_start.rb +3 -1
  6. data/plugins/application/lib/application.rb +1 -0
  7. data/plugins/application/lib/application/commands/treebook_commands.rb +11 -18
  8. data/plugins/application/lib/application/dialog.rb +1 -1
  9. data/plugins/application/lib/application/dialogs/filter_list_dialog.rb +13 -5
  10. data/plugins/application/lib/application/global_state.rb +21 -0
  11. data/plugins/application/lib/application/menu/item.rb +37 -11
  12. data/plugins/application/lib/application/notebook.rb +12 -0
  13. data/plugins/application/lib/application/tree/mirror.rb +0 -11
  14. data/plugins/application/lib/application/window.rb +32 -7
  15. data/plugins/application_swt/lib/application_swt.rb +1 -1
  16. data/plugins/application_swt/lib/application_swt/dialogs/filter_list_dialog_controller.rb +35 -10
  17. data/plugins/application_swt/lib/application_swt/icon.rb +1 -1
  18. data/plugins/application_swt/lib/application_swt/menu.rb +47 -15
  19. data/plugins/application_swt/lib/application_swt/notebook.rb +11 -2
  20. data/plugins/application_swt/lib/application_swt/window.rb +37 -34
  21. data/plugins/auto_indenter/lib/auto_indenter/analyzer.rb +1 -1
  22. data/plugins/auto_indenter/spec/auto_indenter/analyzer_spec.rb +9 -0
  23. data/plugins/declarations/lib/declarations.rb +31 -66
  24. data/plugins/declarations/lib/declarations/commands.rb +142 -0
  25. data/plugins/declarations/lib/declarations/file.rb +1 -1
  26. data/plugins/{outline_view → declarations}/spec/fixtures/some_project/javascript.js +0 -0
  27. data/plugins/{outline_view → declarations}/spec/fixtures/some_project/nothing_to_see.rb +0 -0
  28. data/plugins/{outline_view → declarations}/spec/fixtures/some_project/one_lonely_class.rb +0 -0
  29. data/plugins/{outline_view → declarations}/spec/fixtures/some_project/similar_names.rb +0 -0
  30. data/plugins/{outline_view → declarations}/spec/fixtures/some_project/something_fancy.rb +0 -0
  31. data/plugins/{outline_view → declarations}/spec/fixtures/some_project/trailing_space.rb +0 -0
  32. data/plugins/edit_view/lib/edit_view.rb +35 -2
  33. data/plugins/edit_view/lib/edit_view/commands/change_language_command.rb +31 -0
  34. data/plugins/edit_view/lib/edit_view/commands/language_settings_commands.rb +45 -0
  35. data/plugins/edit_view/lib/edit_view/document/command.rb +1 -1
  36. data/plugins/edit_view/lib/edit_view/edit_tab.rb +11 -13
  37. data/plugins/key_bindings/lib/key_bindings.rb +6 -2
  38. data/plugins/project/lib/project.rb +27 -32
  39. data/plugins/project/lib/project/commands.rb +3 -88
  40. data/plugins/project/lib/project/dir_controller.rb +12 -18
  41. data/plugins/project/lib/project/dir_mirror.rb +20 -25
  42. data/plugins/project/lib/project/file_mirror.rb +10 -10
  43. data/plugins/project/lib/project/find_file_dialog.rb +20 -18
  44. data/plugins/project/lib/project/find_recent_dialog.rb +6 -3
  45. data/plugins/project/lib/project/{adapters/local.rb → local_filesystem.rb} +35 -35
  46. data/plugins/project/lib/project/manager.rb +21 -75
  47. data/plugins/project/lib/project/sub_project.rb +3 -3
  48. data/plugins/project/plugin.rb +0 -1
  49. data/plugins/project_search/lib/project_search/lucene_refresh.rb +0 -1
  50. data/plugins/redcar/plugin.rb +2 -2
  51. data/plugins/redcar/redcar.rb +34 -42
  52. data/plugins/ruby/lib/ruby/syntax_checker.rb +27 -7
  53. data/plugins/scm/lib/scm.rb +1 -12
  54. data/plugins/sessions/lib/sessions.rb +22 -0
  55. data/plugins/sessions/lib/sessions/cursor_saver.rb +162 -0
  56. data/plugins/sessions/lib/sessions/loader.rb +99 -0
  57. data/plugins/sessions/lib/sessions/memory.rb +59 -0
  58. data/plugins/sessions/plugin.rb +8 -0
  59. data/plugins/strip_trailing_spaces/lib/strip_trailing_spaces.rb +2 -2
  60. data/plugins/syntax_check/lib/syntax_check.rb +2 -2
  61. data/plugins/tree_view_swt/lib/tree_view_swt.rb +1 -3
  62. data/redcar.gemspec +1 -1
  63. metadata +195 -291
  64. data/plugins/connection_manager/lib/connection_manager.rb +0 -57
  65. data/plugins/connection_manager/lib/connection_manager/commands.rb +0 -14
  66. data/plugins/connection_manager/lib/connection_manager/connection_store.rb +0 -87
  67. data/plugins/connection_manager/lib/connection_manager/controller.rb +0 -100
  68. data/plugins/connection_manager/lib/connection_manager/filter_dialog.rb +0 -38
  69. data/plugins/connection_manager/lib/connection_manager/private_key_store.rb +0 -93
  70. data/plugins/connection_manager/plugin.rb +0 -12
  71. data/plugins/connection_manager/views/index.html.erb +0 -284
  72. data/plugins/edit_view/lib/edit_view/info_speedbar.rb +0 -98
  73. data/plugins/outline_view/features/outline_view.feature +0 -79
  74. data/plugins/outline_view/features/project_outline.feature +0 -23
  75. data/plugins/outline_view/features/step_definitions/outline_steps.rb +0 -61
  76. data/plugins/outline_view/lib/outline_view.rb +0 -97
  77. data/plugins/outline_view/lib/outline_view/commands.rb +0 -19
  78. data/plugins/outline_view/plugin.rb +0 -10
  79. data/plugins/outline_view_swt/lib/outline_view_swt.rb +0 -79
  80. data/plugins/outline_view_swt/plugin.rb +0 -7
  81. data/plugins/project/lib/project/adapters/remote.rb +0 -96
  82. data/plugins/project/lib/project/adapters/remote_protocols/ftp.rb +0 -93
  83. data/plugins/project/lib/project/adapters/remote_protocols/protocol.rb +0 -94
  84. data/plugins/project/lib/project/adapters/remote_protocols/sftp.rb +0 -181
@@ -0,0 +1,142 @@
1
+ module Redcar
2
+ class Declarations
3
+
4
+ class RebuildTagsCommand < Command
5
+ def execute
6
+ project = Project::Manager.focussed_project
7
+ tags_path = Declarations.file_path(project)
8
+ FileUtils.rm tags_path if ::File.exists? tags_path
9
+ ProjectRefresh.new(project).execute
10
+ end
11
+ end
12
+
13
+ class GoToTagCommand < EditTabCommand
14
+ sensitize :open_project
15
+
16
+ def execute
17
+ if doc.selection?
18
+ handle_tag(doc.selected_text)
19
+ else
20
+ range = doc.current_word_range
21
+ handle_tag(doc.get_slice(range.first, range.last))
22
+ end
23
+ end
24
+
25
+ def handle_tag(token = '')
26
+ tags_path = Declarations.file_path(Project::Manager.focussed_project)
27
+ unless ::File.exist?(tags_path)
28
+ Application::Dialog.message_box("The declarations file 'tags' has not been generated yet.")
29
+ return
30
+ end
31
+ matches = find_tag(tags_path, token).uniq
32
+
33
+ # save current cursor position before jump to another location.
34
+ Redcar.app.navigation_history.save(doc) if matches.size > 0
35
+
36
+ case matches.size
37
+ when 0
38
+ Application::Dialog.message_box("There is no declaration for '#{token}' in the 'tags' file.")
39
+ when 1
40
+ Redcar::Declarations.go_to_definition(matches.first)
41
+ else
42
+ open_select_tag_dialog(matches)
43
+ end
44
+
45
+ Redcar.app.navigation_history.save(doc) if matches.size > 0
46
+ end
47
+
48
+ def find_tag(tags_path, tag)
49
+ Declarations.tags_for_path(tags_path)[tag] || []
50
+ end
51
+
52
+ def open_select_tag_dialog(matches)
53
+ Declarations::SelectTagDialog.new(matches).open
54
+ end
55
+
56
+ def log(message)
57
+ puts("==> Ctags: #{message}")
58
+ end
59
+ end
60
+
61
+ class OpenOutlineViewCommand < Redcar::EditTabCommand
62
+
63
+ def execute
64
+ cur_doc = Redcar.app.focussed_window.focussed_notebook_tab.document
65
+ if cur_doc
66
+ Declarations::OutlineViewDialog.new(cur_doc).open
67
+ end
68
+ end
69
+ end
70
+
71
+ class OpenProjectOutlineViewCommand < Redcar::ProjectCommand
72
+ def execute
73
+ Declarations::ProjectOutlineViewDialog.new(project).open if project
74
+ end
75
+ end
76
+
77
+ class OutlineViewDialog < FilterListDialog
78
+ include Redcar::Model
79
+ include Redcar::Observable
80
+
81
+ attr_accessor :document
82
+ attr_accessor :last_list
83
+
84
+ def initialize(document)
85
+ @document = document
86
+ file = Declarations::File.new(@document.path)
87
+ file.add_tags_for_paths(@document.path)
88
+ @tags = file.tags
89
+ @all = []
90
+ @tags.each do |name, path, match|
91
+ kind = Declarations.match_kind(path, match)
92
+ @all << {:name => name, :icon => Declarations.icon_for_kind(kind), :path => path, :match => match}
93
+ end
94
+ super()
95
+ end
96
+
97
+ def update_list(filter)
98
+ filter_and_rank_by(@all, filter) {|h| h[:name]}
99
+ end
100
+
101
+ def selected(item, ix)
102
+ close
103
+ Redcar.app.navigation_history.save(@document) if @document
104
+ DocumentSearch::FindNextRegex.new(Regexp.new(Regexp.quote(item[:match])), true).run_in_focussed_tab_edit_view
105
+ Redcar.app.navigation_history.save(@document) if @document
106
+ end
107
+ end
108
+
109
+ class ProjectOutlineViewDialog < FilterListDialog
110
+ def initialize(project)
111
+ @project = project
112
+ file = Declarations::File.new(Declarations.file_path(@project))
113
+ @all = []
114
+ file.tags.each do |name, path, match|
115
+ @all << {:name => name + " (" + ::File.basename(path) + ")", :base_name => name, :path => path, :match => match}
116
+ end
117
+ super()
118
+ end
119
+
120
+ def update_list(filter)
121
+ results = filter_and_rank_by(@all, filter) { |h| h[:base_name] }
122
+ results.each do |result|
123
+ kind = Declarations.match_kind(result[:path], result[:match])
124
+ result[:icon] = Declarations.icon_for_kind(kind)
125
+ end
126
+ results
127
+ end
128
+
129
+ def selected(item, ix)
130
+ if path = item[:path] and ::File.exists?(path)
131
+ close
132
+ if tab = Redcar::Project::Manager.open_file(path)
133
+ doc = Redcar::EditView.focussed_tab_edit_view.document
134
+ Redcar.app.navigation_history.save(doc)
135
+ DocumentSearch::FindNextRegex.new(Regexp.new(Regexp.quote(item[:match])), true).run_in_focussed_tab_edit_view
136
+ Redcar.app.navigation_history.save(doc)
137
+ end
138
+ end
139
+ end
140
+ end
141
+ end
142
+ end
@@ -50,7 +50,7 @@ module Redcar
50
50
  end
51
51
 
52
52
  def dump
53
- @tags.sort!
53
+ @tags = @tags.select {|name, _, _| name}.sort_by {|name, _, _| name }
54
54
  tags_file_path = nil
55
55
  Tempfile.open('tags') do |tags_file|
56
56
  tags_file.puts(@last_updated.to_i.to_s)
@@ -15,13 +15,13 @@ require "edit_view/grammar"
15
15
  require "edit_view/edit_tab"
16
16
  require "edit_view/modified_tabs_checker"
17
17
  require "edit_view/tab_settings"
18
- require "edit_view/info_speedbar"
19
18
  require "edit_view/select_font_dialog"
20
19
  require "edit_view/select_theme_dialog"
21
20
 
22
21
  require "edit_view/commands/text_conversion_commands"
23
22
  require "edit_view/commands/align_assignment_command"
24
-
23
+ require "edit_view/commands/change_language_command"
24
+ require "edit_view/commands/language_settings_commands"
25
25
 
26
26
  module Redcar
27
27
  class EditView
@@ -97,6 +97,39 @@ module Redcar
97
97
  def self.menus
98
98
  Menu::Builder.build do
99
99
  sub_menu "Edit" do
100
+ group(:priority => 20) do
101
+ item "Change Language", ChangeLanguageCommand
102
+
103
+ sub_menu "Tabs" do
104
+ item "Soft Tabs", :command => EditView::ToggleSoftTabsCommand,
105
+ :type => :check,
106
+ :checked => lambda { tab and tab.edit_view.soft_tabs? }
107
+
108
+ sub_menu "Tab Width" do
109
+ TabSettings::TAB_WIDTHS.each do |width|
110
+ command_klass = Class.new(SetTabWidthCommand)
111
+ command_klass.width = width.to_i
112
+ already_checker = lambda { tab and tab.edit_view.tab_width.to_s == width.to_s }
113
+ item width, :command => command_klass, :type => :check, :checked => already_checker
114
+ end
115
+ end
116
+ end
117
+
118
+ sub_menu "Margin" do
119
+ item "Word Wrap", :command => EditView::ToggleWordWrapCommand,
120
+ :type => :check,
121
+ :checked => lambda { tab and tab.edit_view.word_wrap? }
122
+
123
+ item "Show Margin", :command => EditView::ToggleShowMarginCommand,
124
+ :type => :check,
125
+ :checked => lambda { tab and tab.edit_view.show_margin? }
126
+
127
+ item lambda { tab ? "Margin Column: #{tab.edit_view.margin_column}" : "Margin Column" }, SetMarginColumnCommand
128
+ end
129
+
130
+ separator
131
+ end
132
+
100
133
  sub_menu "Formatting" do
101
134
  item "Align Assignments", EditView::AlignAssignmentCommand
102
135
  sub_menu "Convert Text", :priority => 40 do
@@ -0,0 +1,31 @@
1
+ module Redcar
2
+ class EditView
3
+
4
+ class ChangeLanguageCommand < Redcar::EditTabCommand
5
+
6
+ class ChangeLanguageDialog < FilterListDialog
7
+ def initialize(tab)
8
+ @tab = tab
9
+ super()
10
+ end
11
+
12
+ def update_list(filter)
13
+ bundles = JavaMateView::Bundle.bundles.to_a
14
+ grammars = bundles.map {|b| b.grammars.to_a}.flatten
15
+ names = grammars.map {|g| g.name}.sort_by {|name| name.downcase }
16
+ filter_and_rank_by(names, filter)
17
+ end
18
+
19
+ def selected(name, ix)
20
+ @tab.edit_view.grammar = name
21
+ close
22
+ end
23
+ end
24
+
25
+ def execute
26
+ ChangeLanguageDialog.new(tab).open
27
+ end
28
+ end
29
+
30
+ end
31
+ end
@@ -0,0 +1,45 @@
1
+ module Redcar
2
+ class EditView
3
+
4
+ class ToggleSoftTabsCommand < Redcar::EditTabCommand
5
+ def execute
6
+ tab.edit_view.soft_tabs = !tab.edit_view.soft_tabs?
7
+ end
8
+ end
9
+
10
+ class ToggleWordWrapCommand < Redcar::EditTabCommand
11
+ def execute
12
+ tab.edit_view.word_wrap = !tab.edit_view.word_wrap?
13
+ end
14
+ end
15
+
16
+ class ToggleShowMarginCommand < Redcar::EditTabCommand
17
+ def execute
18
+ tab.edit_view.show_margin = !tab.edit_view.show_margin?
19
+ end
20
+ end
21
+
22
+ class SetTabWidthCommand < Redcar::EditTabCommand
23
+ class << self
24
+ attr_accessor :width
25
+ end
26
+
27
+ def execute
28
+ tab.edit_view.tab_width = self.class.width.to_i
29
+ end
30
+ end
31
+
32
+ class SetMarginColumnCommand < Redcar::EditTabCommand
33
+ def execute
34
+ response = Application::Dialog.input("Margin Column", "Enter new margin column:", tab.edit_view.margin_column) do |text|
35
+ if text !~ /^\d+$/
36
+ "must be an integer number"
37
+ end
38
+ end
39
+ value = response[:value].to_i
40
+ tab.edit_view.margin_column = [[value, 200].min, 5].max
41
+ end
42
+ end
43
+
44
+ end
45
+ end
@@ -11,7 +11,7 @@ module Redcar
11
11
  run(:env => {:edit_view => edit_view})
12
12
  end
13
13
  end
14
-
14
+
15
15
  private
16
16
 
17
17
  def edit_view
@@ -12,25 +12,23 @@ module Redcar
12
12
  i = DEFAULT_ICON
13
13
  doc = @edit_view.document
14
14
  if doc and doc.path
15
- unless doc.mirror.adapter.is_a?(Redcar::Project::Adapters::Remote)
16
- if File.exists?(doc.path)
17
- if File.writable?(doc.path)
18
- key = File.basename(doc.path).split('.').last.split(//).first.downcase
19
- if key =~ /[a-z]/
20
- if key == 'a'
21
- i = :document_attribute
22
- else
23
- i = :"document_attribute_#{key}"
24
- end
15
+ if File.exists?(doc.path)
16
+ if File.writable?(doc.path)
17
+ key = File.basename(doc.path).split('.').last.split(//).first.downcase
18
+ if key =~ /[a-z]/
19
+ if key == 'a'
20
+ i = :document_attribute
25
21
  else
26
- i = DEFAULT_ICON
22
+ i = :"document_attribute_#{key}"
27
23
  end
28
24
  else
29
- i = NO_WRITE_ICON
25
+ i = DEFAULT_ICON
30
26
  end
31
27
  else
32
- i = MISSING_ICON
28
+ i = NO_WRITE_ICON
33
29
  end
30
+ else
31
+ i = MISSING_ICON
34
32
  end
35
33
  end
36
34
  i
@@ -11,7 +11,11 @@ module Redcar
11
11
 
12
12
  def self.user_keybindings
13
13
  key_bindings = key_binding_prefs.inject({}) do |h, (key, command_class)|
14
- h[key] = eval(command_class)
14
+ begin
15
+ h[key] = eval(command_class)
16
+ rescue
17
+ Redcar.log.warn "invalid key binding from \"#{key}\" to #{command_class.inspect} in file \"#{@storage.send(:path)}\""
18
+ end
15
19
  h
16
20
  end
17
21
  key_bindings
@@ -31,4 +35,4 @@ module Redcar
31
35
  Redcar.app.refresh_menu!
32
36
  end
33
37
  end
34
- end
38
+ end
@@ -3,14 +3,8 @@ unless defined?(DRb)
3
3
  require 'drb/drb'
4
4
  end
5
5
 
6
- require "project/adapters/remote_protocols/protocol"
7
- require "project/adapters/remote_protocols/sftp"
8
- require "project/adapters/remote_protocols/ftp"
9
-
10
- require "project/adapters/local"
11
- require "project/adapters/remote"
12
-
13
6
  require "project/support/trash"
7
+ require "project/local_filesystem"
14
8
 
15
9
  require "project/commands"
16
10
  require "project/dir_mirror"
@@ -33,27 +27,40 @@ module Redcar
33
27
  @window_projects ||= {}
34
28
  end
35
29
 
36
- attr_reader :window, :tree, :path, :adapter
30
+ attr_reader :window, :tree, :path
37
31
  attr_accessor :listeners
38
32
 
39
- def initialize(path, adapter=Adapters::Local.new)
40
- @adapter = adapter
33
+ def initialize(path)
34
+ p [:new, path]
41
35
  @path = File.expand_path(path)
42
36
  @listeners ||= {}
43
- dir_mirror = Project::DirMirror.new(@path, adapter)
37
+ dir_mirror = Project::DirMirror.new(@path)
38
+ p dir_mirror
44
39
  if dir_mirror.exists?
45
40
  @tree = Tree.new(dir_mirror, Project::DirController.new)
41
+ p @tree
46
42
  @window = nil
47
- file_list_resource.compute unless remote?
43
+ file_list_resource.compute
48
44
  else
49
45
  raise "#{path} doesn't seem to exist"
50
46
  end
51
47
  end
52
48
 
53
- def remote?
54
- adapter.is_a?(Adapters::Remote)
49
+ def config_dir
50
+ if Redcar.platform == :windows && Redcar.environment != :test
51
+ dir = File.join(path, "._redcar")
52
+ else
53
+ dir = File.join(path, ".redcar")
54
+ end
55
+ unless File.directory? dir
56
+ FileUtils.mkdir_p(dir)
57
+ if Redcar.platform == :windows
58
+ system("attrib.exe +H \"#{dir}") # make hidden for cmd directory listings
59
+ end
60
+ end
61
+ dir
55
62
  end
56
-
63
+
57
64
  def ready?
58
65
  @tree && @path
59
66
  end
@@ -128,6 +135,10 @@ module Redcar
128
135
  unlock if locked?
129
136
  end
130
137
 
138
+ def storage(name)
139
+ Redcar::Plugin::BaseStorage.new(File.join(config_dir, "storage"), name)
140
+ end
141
+
131
142
  def attach_listeners
132
143
  attach_notebook_listeners
133
144
  window.treebook.add_listener(:tree_removed, &method(:tree_removed))
@@ -168,7 +179,7 @@ module Redcar
168
179
  # there is one.
169
180
  def refresh
170
181
  @tree.refresh
171
- file_list_resource.compute unless remote?
182
+ file_list_resource.compute
172
183
  end
173
184
 
174
185
  def contains_path?(path)
@@ -194,7 +205,6 @@ module Redcar
194
205
  end
195
206
 
196
207
  def file_list
197
- raise "can't access a file list for a remote project" if remote?
198
208
  @file_list ||= FileList.new(path)
199
209
  end
200
210
 
@@ -235,21 +245,6 @@ module Redcar
235
245
  @lost_application_focus = nil
236
246
  end
237
247
 
238
- def config_dir
239
- if Redcar.platform == :windows && Redcar.environment != :test
240
- dir = File.join(path, "._redcar")
241
- else
242
- dir = File.join(path, ".redcar")
243
- end
244
- unless File.directory? dir
245
- FileUtils.mkdir_p(dir)
246
- if Redcar.platform == :windows
247
- system("attrib.exe +H \"#{dir}") # make hidden for cmd directory listings
248
- end
249
- end
250
- dir
251
- end
252
-
253
248
  def home_dir
254
249
  @path
255
250
  end