redcar-dev 0.12.27dev → 0.13.0dev

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 (42) hide show
  1. data/CHANGES +10 -1
  2. data/lib/redcar.rb +2 -2
  3. data/plugins/application/lib/application.rb +2 -2
  4. data/plugins/application/lib/application/dialog.rb +1 -1
  5. data/plugins/application/lib/application/dialogs/filter_list_dialog.rb +13 -5
  6. data/plugins/application/lib/application/global_state.rb +21 -0
  7. data/plugins/application/lib/application/menu/item.rb +16 -7
  8. data/plugins/application/lib/application/updates.rb +20 -3
  9. data/plugins/application/spec/application/updates_spec.rb +53 -0
  10. data/plugins/application_swt/lib/application_swt.rb +1 -1
  11. data/plugins/application_swt/lib/application_swt/dialogs/filter_list_dialog_controller.rb +35 -10
  12. data/plugins/application_swt/lib/application_swt/menu.rb +31 -5
  13. data/plugins/declarations/lib/declarations.rb +31 -65
  14. data/plugins/declarations/lib/declarations/commands.rb +147 -0
  15. data/plugins/declarations/lib/declarations/file.rb +1 -1
  16. data/plugins/{outline_view → declarations}/spec/fixtures/some_project/javascript.js +0 -0
  17. data/plugins/{outline_view → declarations}/spec/fixtures/some_project/nothing_to_see.rb +0 -0
  18. data/plugins/{outline_view → declarations}/spec/fixtures/some_project/one_lonely_class.rb +0 -0
  19. data/plugins/{outline_view → declarations}/spec/fixtures/some_project/similar_names.rb +0 -0
  20. data/plugins/{outline_view → declarations}/spec/fixtures/some_project/something_fancy.rb +0 -0
  21. data/plugins/{outline_view → declarations}/spec/fixtures/some_project/trailing_space.rb +0 -0
  22. data/plugins/edit_view/lib/edit_view.rb +35 -2
  23. data/plugins/edit_view/lib/edit_view/commands/change_language_command.rb +31 -0
  24. data/plugins/edit_view/lib/edit_view/commands/language_settings_commands.rb +45 -0
  25. data/plugins/edit_view/lib/edit_view/document/command.rb +1 -1
  26. data/plugins/project/lib/project/find_file_dialog.rb +20 -18
  27. data/plugins/project/lib/project/manager.rb +5 -3
  28. data/plugins/redcar/plugin.rb +1 -2
  29. data/plugins/redcar/redcar.rb +34 -42
  30. data/plugins/scm/lib/scm.rb +1 -1
  31. data/plugins/strip_trailing_spaces/lib/strip_trailing_spaces.rb +2 -2
  32. data/plugins/syntax_check/lib/syntax_check.rb +2 -2
  33. metadata +946 -956
  34. data/plugins/edit_view/lib/edit_view/info_speedbar.rb +0 -98
  35. data/plugins/outline_view/features/outline_view.feature +0 -79
  36. data/plugins/outline_view/features/project_outline.feature +0 -23
  37. data/plugins/outline_view/features/step_definitions/outline_steps.rb +0 -61
  38. data/plugins/outline_view/lib/outline_view.rb +0 -97
  39. data/plugins/outline_view/lib/outline_view/commands.rb +0 -19
  40. data/plugins/outline_view/plugin.rb +0 -10
  41. data/plugins/outline_view_swt/lib/outline_view_swt.rb +0 -79
  42. data/plugins/outline_view_swt/plugin.rb +0 -7
@@ -1,4 +1,5 @@
1
1
 
2
+ require 'declarations/commands'
2
3
  require 'declarations/completion_source'
3
4
  require 'declarations/file'
4
5
  require 'declarations/parser'
@@ -9,8 +10,17 @@ module Redcar
9
10
  class Declarations
10
11
  def self.menus
11
12
  Menu::Builder.build do
13
+ sub_menu "Edit" do
14
+ group :priority => 30 do
15
+ item "Find declaration", :command => Declarations::OpenOutlineViewCommand
16
+ end
17
+ end
18
+
12
19
  sub_menu "Project" do
13
- item "Go to declaration", :command => Declarations::GoToTagCommand, :priority => 30
20
+ group :priority => 60 do
21
+ item "Go to declaration", :command => Declarations::GoToTagCommand, :priority => 30
22
+ item "Find declaration", :command => Declarations::OpenProjectOutlineViewCommand, :priority => :first
23
+ end
14
24
  sub_menu "Refresh", :priority => 31 do
15
25
  item "Declarations file", :command => Declarations::RebuildTagsCommand
16
26
  end
@@ -21,10 +31,14 @@ module Redcar
21
31
  def self.keymaps
22
32
  linwin = Keymap.build("main", [:linux, :windows]) do
23
33
  link "Alt+G", Declarations::GoToTagCommand
34
+ link "Ctrl+I", Declarations::OpenOutlineViewCommand
35
+ link "Ctrl+Shift+I", Declarations::OpenProjectOutlineViewCommand
24
36
  end
25
37
 
26
38
  osx = Keymap.build("main", :osx) do
27
39
  link "Ctrl+Alt+G", Declarations::GoToTagCommand
40
+ link "Cmd+I", Declarations::OpenOutlineViewCommand
41
+ link "Cmd+Ctrl+I", Declarations::OpenProjectOutlineViewCommand
28
42
  end
29
43
 
30
44
  [linwin, osx]
@@ -38,6 +52,20 @@ module Redcar
38
52
  ::File.join(project.config_dir, 'tags')
39
53
  end
40
54
 
55
+ def self.icon_for_kind(kind)
56
+ h = {
57
+ :method => :node_insert,
58
+ :class => :open_source_flipped,
59
+ :attribute => :status,
60
+ :alias => :arrow_branch,
61
+ :assignment => :arrow,
62
+ :interface => :information,
63
+ :closure => :node_magnifier,
64
+ :none => nil
65
+ }
66
+ h[kind.to_sym]
67
+ end
68
+
41
69
  class ProjectRefresh < Task
42
70
  def initialize(project)
43
71
  @file_list = project.file_list
@@ -78,9 +106,9 @@ module Redcar
78
106
  end
79
107
  end
80
108
 
81
- def self.match_kind(path, regex)
109
+ def self.match_kind(path, regex)
82
110
  Declarations::Parser.new.match_kind(path, regex)
83
- end
111
+ end
84
112
 
85
113
  def self.clear_tags_for_path(path)
86
114
  @tags_for_path ||= {}
@@ -93,67 +121,5 @@ module Redcar
93
121
  regexp = Regexp.new(Regexp.escape(match[:match]))
94
122
  DocumentSearch::FindNextRegex.new(regexp, true).run_in_focussed_tab_edit_view
95
123
  end
96
-
97
- class RebuildTagsCommand < Command
98
- def execute
99
- project = Project::Manager.focussed_project
100
- tags_path = Declarations.file_path(project)
101
- FileUtils.rm tags_path if ::File.exists? tags_path
102
- ProjectRefresh.new(project).execute
103
- end
104
- end
105
-
106
- class GoToTagCommand < EditTabCommand
107
- sensitize :open_project
108
-
109
- def execute
110
- if Project::Manager.focussed_project.remote?
111
- Application::Dialog.message_box("Go to declaration doesn't work in remote projects yet :(")
112
- return
113
- end
114
-
115
- if doc.selection?
116
- handle_tag(doc.selected_text)
117
- else
118
- range = doc.current_word_range
119
- handle_tag(doc.get_slice(range.first, range.last))
120
- end
121
- end
122
-
123
- def handle_tag(token = '')
124
- tags_path = Declarations.file_path(Project::Manager.focussed_project)
125
- unless ::File.exist?(tags_path)
126
- Application::Dialog.message_box("The declarations file 'tags' has not been generated yet.")
127
- return
128
- end
129
- matches = find_tag(tags_path, token).uniq
130
-
131
- # save current cursor position before jump to another location.
132
- Redcar.app.navigation_history.save(doc) if matches.size > 0
133
-
134
- case matches.size
135
- when 0
136
- Application::Dialog.message_box("There is no declaration for '#{token}' in the 'tags' file.")
137
- when 1
138
- Redcar::Declarations.go_to_definition(matches.first)
139
- else
140
- open_select_tag_dialog(matches)
141
- end
142
-
143
- Redcar.app.navigation_history.save(doc) if matches.size > 0
144
- end
145
-
146
- def find_tag(tags_path, tag)
147
- Declarations.tags_for_path(tags_path)[tag] || []
148
- end
149
-
150
- def open_select_tag_dialog(matches)
151
- Declarations::SelectTagDialog.new(matches).open
152
- end
153
-
154
- def log(message)
155
- puts("==> Ctags: #{message}")
156
- end
157
- end
158
124
  end
159
125
  end
@@ -0,0 +1,147 @@
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 Project::Manager.focussed_project.remote?
18
+ Application::Dialog.message_box("Go to declaration doesn't work in remote projects yet :(")
19
+ return
20
+ end
21
+
22
+ if doc.selection?
23
+ handle_tag(doc.selected_text)
24
+ else
25
+ range = doc.current_word_range
26
+ handle_tag(doc.get_slice(range.first, range.last))
27
+ end
28
+ end
29
+
30
+ def handle_tag(token = '')
31
+ tags_path = Declarations.file_path(Project::Manager.focussed_project)
32
+ unless ::File.exist?(tags_path)
33
+ Application::Dialog.message_box("The declarations file 'tags' has not been generated yet.")
34
+ return
35
+ end
36
+ matches = find_tag(tags_path, token).uniq
37
+
38
+ # save current cursor position before jump to another location.
39
+ Redcar.app.navigation_history.save(doc) if matches.size > 0
40
+
41
+ case matches.size
42
+ when 0
43
+ Application::Dialog.message_box("There is no declaration for '#{token}' in the 'tags' file.")
44
+ when 1
45
+ Redcar::Declarations.go_to_definition(matches.first)
46
+ else
47
+ open_select_tag_dialog(matches)
48
+ end
49
+
50
+ Redcar.app.navigation_history.save(doc) if matches.size > 0
51
+ end
52
+
53
+ def find_tag(tags_path, tag)
54
+ Declarations.tags_for_path(tags_path)[tag] || []
55
+ end
56
+
57
+ def open_select_tag_dialog(matches)
58
+ Declarations::SelectTagDialog.new(matches).open
59
+ end
60
+
61
+ def log(message)
62
+ puts("==> Ctags: #{message}")
63
+ end
64
+ end
65
+
66
+ class OpenOutlineViewCommand < Redcar::EditTabCommand
67
+
68
+ def execute
69
+ cur_doc = Redcar.app.focussed_window.focussed_notebook_tab.document
70
+ if cur_doc
71
+ Declarations::OutlineViewDialog.new(cur_doc).open
72
+ end
73
+ end
74
+ end
75
+
76
+ class OpenProjectOutlineViewCommand < Redcar::ProjectCommand
77
+ def execute
78
+ Declarations::ProjectOutlineViewDialog.new(project).open if project
79
+ end
80
+ end
81
+
82
+ class OutlineViewDialog < FilterListDialog
83
+ include Redcar::Model
84
+ include Redcar::Observable
85
+
86
+ attr_accessor :document
87
+ attr_accessor :last_list
88
+
89
+ def initialize(document)
90
+ @document = document
91
+ file = Declarations::File.new(@document.path)
92
+ file.add_tags_for_paths(@document.path)
93
+ @tags = file.tags
94
+ @all = []
95
+ @tags.each do |name, path, match|
96
+ kind = Declarations.match_kind(path, match)
97
+ @all << {:name => name, :icon => Declarations.icon_for_kind(kind), :path => path, :match => match}
98
+ end
99
+ super()
100
+ end
101
+
102
+ def update_list(filter)
103
+ filter_and_rank_by(@all, filter) {|h| h[:name]}
104
+ end
105
+
106
+ def selected(item, ix)
107
+ close
108
+ Redcar.app.navigation_history.save(@document) if @document
109
+ DocumentSearch::FindNextRegex.new(Regexp.new(Regexp.quote(item[:match])), true).run_in_focussed_tab_edit_view
110
+ Redcar.app.navigation_history.save(@document) if @document
111
+ end
112
+ end
113
+
114
+ class ProjectOutlineViewDialog < FilterListDialog
115
+ def initialize(project)
116
+ @project = project
117
+ file = Declarations::File.new(Declarations.file_path(@project))
118
+ @all = []
119
+ file.tags.each do |name, path, match|
120
+ @all << {:name => name + " (" + ::File.basename(path) + ")", :base_name => name, :path => path, :match => match}
121
+ end
122
+ super()
123
+ end
124
+
125
+ def update_list(filter)
126
+ results = filter_and_rank_by(@all, filter) { |h| h[:base_name] }
127
+ results.each do |result|
128
+ kind = Declarations.match_kind(result[:path], result[:match])
129
+ result[:icon] = Declarations.icon_for_kind(kind)
130
+ end
131
+ results
132
+ end
133
+
134
+ def selected(item, ix)
135
+ if path = item[:path] and ::File.exists?(path)
136
+ close
137
+ if tab = Redcar::Project::Manager.open_file(path)
138
+ doc = Redcar::EditView.focussed_tab_edit_view.document
139
+ Redcar.app.navigation_history.save(doc)
140
+ DocumentSearch::FindNextRegex.new(Regexp.new(Regexp.quote(item[:match])), true).run_in_focussed_tab_edit_view
141
+ Redcar.app.navigation_history.save(doc)
142
+ end
143
+ end
144
+ end
145
+ end
146
+ end
147
+ 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