Skip to content

Commit 230daaf

Browse files
committed
Code styling whitespaces and other stuff
1 parent 8663582 commit 230daaf

File tree

2 files changed

+38
-38
lines changed

2 files changed

+38
-38
lines changed

lib/jruby_visualizer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44

55
require_relative 'jruby_visualizer/jruby_visualizer'
66

7-
if __FILE__ == $0
7+
if __FILE__ == $PROGRAM_NAME
88
JRubyVisualizer.visualize_with_argv
99
end

lib/jruby_visualizer/visualizer_main_app.rb

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,16 @@
2323
require_relative 'jruby_visualizer'
2424
require_relative 'about_page'
2525

26-
resource_root :images, File.join(File.dirname(__FILE__), "ui", "img"), "ui/img"
27-
fxml_root File.join(File.dirname(__FILE__), "ui")
26+
resource_root :images, File.join(File.dirname(__FILE__), 'ui', 'img'), 'ui/img'
27+
fxml_root File.join(File.dirname(__FILE__), 'ui')
2828

2929
class DeletableListCell < Java::javafx.scene.control.ListCell
3030
include JRubyFX
3131

3232
attr_reader :delete_menu
3333

3434
def initialize
35-
delete_info_item = MenuItem.new("Delete Information")
35+
delete_info_item = MenuItem.new('Delete Information')
3636
@delete_menu = ContextMenu.new(delete_info_item)
3737
delete_info_item.on_action do
3838
items = list_view.items
@@ -42,10 +42,10 @@ def initialize
4242
end
4343
end
4444
end
45-
45+
4646
def updateItem(item, empty)
4747
super(item, empty)
48-
48+
4949
if empty
5050
set_text(nil)
5151
set_graphic(nil)
@@ -54,22 +54,22 @@ def updateItem(item, empty)
5454
set_graphic(nil)
5555
set_context_menu(@delete_menu)
5656
end
57-
5857
end
59-
58+
6059
private
60+
6161
def get_string
6262
if item
6363
item.to_s
6464
else
6565
''
6666
end
6767
end
68-
68+
6969
end
7070

7171
class SubAppTask < Java::javafx.concurrent.Task
72-
72+
7373
def initialize(view_name)
7474
super()
7575
# (select view)
@@ -84,31 +84,31 @@ def initialize(view_name)
8484
raise "unknown name for a view: #{view_name}"
8585
end
8686
end
87-
87+
8888
def call
8989
stage = Java::javafx.stage.Stage.new
9090
@view.start(stage)
9191
end
9292
end
9393

9494
class VisualizerMainApp < JRubyFX::Application
95-
95+
9696
def start(stage)
9797
compiler_data = JRubyVisualizer.compiler_data
98-
with(stage, title: "JRuby Visualizer") do
98+
with(stage, title: 'JRuby Visualizer') do
9999
fxml(JRubyVisualizerController, initialize: [compiler_data])
100-
icons.add(Image.new(resource_url(:images, "jruby-icon-32.png").to_s))
100+
icons.add(Image.new(resource_url(:images, 'jruby-icon-32.png').to_s))
101101
show
102102
end
103103
end
104104
end
105105

106106
class JRubyVisualizerController
107107
include JRubyFX::Controller
108-
fxml "jruby-visualizer.fxml"
109-
108+
fxml 'jruby-visualizer.fxml'
109+
110110
attr_accessor :compiler_data, :information
111-
111+
112112
def initialize(compiler_data)
113113
@compiler_data = compiler_data
114114
fill_ast_view(@compiler_data.ast_root)
@@ -118,30 +118,30 @@ def initialize(compiler_data)
118118
end
119119
# bind ruby view to value of ruby_code
120120
@ruby_view.text_property.bind(@compiler_data.ruby_code_property)
121-
121+
122122
# enable scrolling to the ruby code on clicks within the AST
123123
scroll_ruby_to_selected_ast
124-
124+
125125
# display the IR compiler passes and set the selection to first pass
126126
@ir_passes_names = CompilerData.compiler_passes_names
127127
@ir_passes_box.items = FXCollections.observable_array_list(@ir_passes_names)
128128
@ir_passes_box.value = @selected_ir_pass = @ir_passes_names[0]
129-
129+
130130
# background tasks for other views
131131
@ir_view_task = SubAppTask.new(:ir_view)
132132
@cfg_view_task = SubAppTask.new(:cfg_view)
133133
@about_task = SubAppTask.new(:about_page)
134-
134+
135135
# Use ListCell with Delete Context Menu in the view for compile information
136136
@compile_information.cell_factory = proc { DeletableListCell.new }
137137
# information property back ended by the list view for compile information
138138
@information = @compile_information.items
139139
end
140-
140+
141141
def select_ir_pass
142142
@selected_ir_pass = @ir_passes_box.value
143143
end
144-
144+
145145
def run_previous_passes_for_selection
146146
if @compiler_data.current_pass.nil?
147147
return # beginning of ir passes
@@ -159,7 +159,7 @@ def run_previous_passes_for_selection
159159
run_previous_passes_for_selection
160160
end
161161
end
162-
162+
163163
def step_ir_pass
164164
if @compiler_data.next_pass
165165
run_previous_passes_for_selection
@@ -169,33 +169,33 @@ def step_ir_pass
169169
@information << "Successfully passed #{@selected_ir_pass}"
170170
end
171171
end
172-
172+
173173
def clear_information_view
174174
@information.clear
175175
end
176-
176+
177177
def reset_passes
178178
@compiler_data.reset_scheduler
179179
@selected_ir_pass = @ir_passes_names[0]
180180
@ir_passes_box.value = @selected_ir_pass
181181
clear_information_view
182182
end
183-
183+
184184
def fill_ast_view(root_node)
185185
# clear view
186186
@ast_view.root = nil
187187
# refill it
188188
tree_builder = ASTTreeViewBuilder.new(@ast_view)
189189
tree_builder.build_view(root_node)
190190
end
191-
191+
192192
def self.pixel_height_of_line
193-
monospaced = Java::javafx.scene.text.FontBuilder::create.name("monospaced").size(13).build
194-
text = Text.new(" JRubyVisualizer.visualize(ruby_code)")
193+
monospaced = Java::javafx.scene.text.FontBuilder::create.name('monospaced').size(13).build
194+
text = Text.new(' JRubyVisualizer.visualize(ruby_code)')
195195
text.set_font(monospaced)
196196
text.get_layout_bounds.get_height
197197
end
198-
198+
199199
def mark_selected_line(line_number)
200200
ruby_code = @ruby_view.text
201201
ruby_lines = ruby_code.lines.to_a
@@ -204,7 +204,7 @@ def mark_selected_line(line_number)
204204
char_end = ruby_lines[line_number].chars.count + char_begin
205205
@ruby_view.extend_selection(char_end)
206206
end
207-
207+
208208
def scroll_ruby_to_selected_ast
209209
@ast_view.selection_model.selected_item_property.add_change_listener do |ast_tree_cell|
210210
start_line = ast_tree_cell.node.position.start_line
@@ -218,11 +218,11 @@ def scroll_ruby_to_selected_ast
218218
end
219219
@ast_view.selection_model.set_selected_item(@ast_view.root)
220220
end
221-
221+
222222
def close_app
223223
Platform.exit
224224
end
225-
225+
226226
def launch_ir_view
227227
worker_state = Java::javafx.concurrent.Worker::State
228228
state = @ir_view_task.state
@@ -233,7 +233,7 @@ def launch_ir_view
233233
Platform.run_later(@ir_view_task)
234234
end
235235
end
236-
236+
237237
def launch_cfg_view
238238
worker_state = Java::javafx.concurrent.Worker::State
239239
state = @cfg_view_task.state
@@ -244,7 +244,7 @@ def launch_cfg_view
244244
Platform.run_later(@cfg_view_task)
245245
end
246246
end
247-
247+
248248
def launch_about
249249
worker_state = Java::javafx.concurrent.Worker::State
250250
state = @about_task.state
@@ -255,10 +255,10 @@ def launch_about
255255
Platform.run_later(@about_task)
256256
end
257257
end
258-
258+
259259
end
260260

261-
if __FILE__ == $0
261+
if __FILE__ == $PROGRAM_NAME
262262
JRubyVisualizer.compiler_data = CompilerData.new(
263263
"class Foo\n def bar\n 42\n end\nend\nFoo.new.bar\n")
264264
VisualizerMainApp.launch

0 commit comments

Comments
 (0)