redcar-dev 0.12.9dev-java → 0.12.10dev-java
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.
- data/CHANGES +2 -0
- data/lib/redcar.rb +1 -1
- data/lib/redcar/installer.rb +0 -1
- data/plugins/application_swt/lib/application_swt/toolbar.rb +65 -65
- data/plugins/application_swt/lib/application_swt/window.rb +10 -1
- metadata +3 -15
- data/plugins/groovy/features/fixtures/lib/classes.jar +0 -0
- data/plugins/groovy/features/fixtures/test.groovy +0 -0
- data/plugins/groovy/features/step_definitions/groovy_steps.rb +0 -27
- data/plugins/groovy/features/support/env.rb +0 -27
- data/plugins/groovy/features/syntax_check_groovy.feature +0 -72
- data/plugins/groovy/lib/groovy.rb +0 -38
- data/plugins/groovy/lib/groovy/commands.rb +0 -10
- data/plugins/groovy/lib/groovy/repl_mirror.rb +0 -85
- data/plugins/groovy/lib/groovy/syntax_checker.rb +0 -81
- data/plugins/groovy/plugin.rb +0 -8
- data/plugins/groovy/spec/groovy/repl_mirror_spec.rb +0 -56
- data/plugins/groovy/spec/spec_helper.rb +0 -5
data/CHANGES
CHANGED
@@ -13,6 +13,8 @@ Version 0.12 (TBA)
|
|
13
13
|
* Tweak to line numbers so highlighting isn't lost as doc passes 100 lines (Dan Lucraft)
|
14
14
|
* Added next line, previous line bindings to Ctrl+N and Ctrl+P (Dan Lucraft)
|
15
15
|
* Added open line, transpose characters commands (Dan Lucraft)
|
16
|
+
* OSX style unified toolbars (Dan Lucraft)
|
17
|
+
* Supports OS X Lion fullscreen mode (Dan Lucraft)
|
16
18
|
|
17
19
|
Version 0.11 (23 March 2011)
|
18
20
|
============================
|
data/lib/redcar.rb
CHANGED
data/lib/redcar/installer.rb
CHANGED
@@ -54,7 +54,6 @@ module Redcar
|
|
54
54
|
"http://redcar.s3.amazonaws.com/clojure-1.2beta1.jar" => "/clojure.jar",
|
55
55
|
"http://redcar.s3.amazonaws.com/clojure-contrib-1.2beta1.jar" => "/clojure-contrib.jar",
|
56
56
|
"http://redcar.s3.amazonaws.com/org-enclojure-repl-server.jar" => nil,
|
57
|
-
"http://mirrors.ibiblio.org/pub/mirrors/maven2/org/codehaus/groovy/groovy-all/1.7.4/groovy-all-1.7.4.jar" => "/groovy-all.jar",
|
58
57
|
"http://mirrors.ibiblio.org/pub/mirrors/maven2/org/tmatesoft/svnkit/svnkit/1.3.4/svnkit-1.3.4.jar" => "/svnkit.jar",
|
59
58
|
# "http://mirrors.ibiblio.org/pub/mirrors/maven2/rhino/js/1.7R2/js-1.7R2.jar" => "/js.jar",
|
60
59
|
"http://redcar.s3.amazonaws.com/deps/rhino-js-1.7R2.jar" => "/js.jar",
|
@@ -3,21 +3,19 @@ module Redcar
|
|
3
3
|
class ApplicationSWT
|
4
4
|
class ToolBar
|
5
5
|
|
6
|
-
ICONS_DIR = File.join(Redcar.root, %w(share icons))
|
7
6
|
DEFAULT_ICON = File.join(Redcar.root, %w(share icons document.png))
|
8
7
|
|
9
|
-
|
10
8
|
def self.icons
|
11
9
|
@icons = {
|
12
|
-
:new => File.join(
|
13
|
-
:open => File.join(
|
14
|
-
:open_dir => File.join(
|
15
|
-
:save => File.join(
|
16
|
-
:save_as => File.join(
|
10
|
+
:new => File.join(Redcar.icons_directory, "document-text.png"),
|
11
|
+
:open => File.join(Redcar.icons_directory, "folder-open-document.png"),
|
12
|
+
:open_dir => File.join(Redcar.icons_directory, "blue-folder-horizontal-open.png"),
|
13
|
+
:save => File.join(Redcar.icons_directory, "disk.png"),
|
14
|
+
:save_as => File.join(Redcar.icons_directory, "disk--plus.png"),
|
17
15
|
#:save_all => File.join(ICONS_DIR, "save_all.png"),
|
18
|
-
:undo => File.join(
|
19
|
-
:redo => File.join(
|
20
|
-
:search => File.join(
|
16
|
+
:undo => File.join(Redcar.icons_directory, "arrow-circle-225-left.png"),
|
17
|
+
:redo => File.join(Redcar.icons_directory, "arrow-circle-315.png"),
|
18
|
+
:search => File.join(Redcar.icons_directory, "binocular.png")
|
21
19
|
}
|
22
20
|
end
|
23
21
|
|
@@ -32,64 +30,65 @@ module Redcar
|
|
32
30
|
attr_reader :coolbar, :toolbar, :coolitem, :toolbars, :coolitems
|
33
31
|
|
34
32
|
def initialize(window, toolbar_model, options={})
|
35
|
-
|
36
|
-
@
|
37
|
-
@
|
38
|
-
@
|
39
|
-
@
|
33
|
+
# @toolbars = {}
|
34
|
+
# @coolitems = {}
|
35
|
+
@entries = Hash.new {|h,k| h[k] = [] }
|
36
|
+
@toolbar = window.shell.getToolBar
|
37
|
+
p @toolbar
|
38
|
+
# @coolbar = Swt::Widgets::CoolBar.new(window.shell, Swt::SWT::FLAT | Swt::SWT::HORIZONTAL)
|
40
39
|
return unless toolbar_model
|
41
40
|
toolbar_model.each do |entry|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
41
|
+
name = entry.barname || :new
|
42
|
+
@entries[name] << entry
|
43
|
+
# name = entry.barname || :new
|
44
|
+
# if not @toolbars[name]
|
45
|
+
# if name == :core
|
46
|
+
# coolitem = Swt::Widgets::CoolItem.new(@coolbar, Swt::SWT::FLAT, 0)
|
47
|
+
# else
|
48
|
+
# coolitem = Swt::Widgets::CoolItem.new(@coolbar, Swt::SWT::FLAT)
|
49
|
+
# end
|
50
|
+
#
|
51
|
+
# @toolbars[name] = create_toolbar(@coolbar)
|
52
|
+
# @coolitems[name] = coolitem
|
53
|
+
# else
|
54
|
+
# @toolbar = @toolbars[name]
|
55
|
+
# coolitem = @coolitems[name]
|
56
|
+
# end
|
57
57
|
end
|
58
|
-
|
59
|
-
@
|
60
|
-
|
61
|
-
@toolbar
|
62
|
-
|
63
|
-
@toolbar_data = @entries[key]
|
64
|
-
@coolitem.setControl(@toolbar)
|
65
|
-
|
66
|
-
add_entries_to_toolbar(@toolbar, @toolbar_data)
|
67
|
-
@p = @toolbar.computeSize(Swt::SWT::DEFAULT, Swt::SWT::DEFAULT)
|
68
|
-
@point = @coolitem.computeSize(@p.x, @p.y)
|
69
|
-
#@coolitem.setPreferredSize(@point)
|
70
|
-
#@coolitem.setMinimumSize(@point)
|
71
|
-
@coolitem.setSize(@point.x, @point.y)
|
58
|
+
add_entries_to_toolbar(@toolbar, @entries[:core])
|
59
|
+
@entries.each do |name, es|
|
60
|
+
next if name == :core
|
61
|
+
add_entries_to_toolbar(@toolbar, es)
|
62
|
+
sep = Swt::Widgets::ToolItem.new(@toolbar, Swt::SWT::DEFAULT)
|
72
63
|
end
|
73
|
-
|
74
|
-
#
|
75
|
-
@
|
76
|
-
|
64
|
+
# @toolbars.each do |name, toolbar|
|
65
|
+
# coolitem = @coolitems[name]
|
66
|
+
# toolbar_data = @entries[name]
|
67
|
+
# coolitem.setControl(toolbar)
|
68
|
+
#
|
69
|
+
# p = toolbar.computeSize(Swt::SWT::DEFAULT, Swt::SWT::DEFAULT)
|
70
|
+
# point = coolitem.computeSize(p.x, p.y)
|
71
|
+
# coolitem.setSize(point.x, point.y)
|
72
|
+
# end
|
73
|
+
#
|
74
|
+
# @coolbar.setLocked(true)
|
75
|
+
# @coolbar.pack()
|
77
76
|
end
|
78
77
|
|
79
|
-
def create_toolbar
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
end
|
78
|
+
# def create_toolbar
|
79
|
+
# @toolbar = Swt::Widgets::ToolBar.new(composite, Swt::SWT::FLAT)
|
80
|
+
# @toolbar.set_visible(false)
|
81
|
+
# @toolbar
|
82
|
+
# end
|
84
83
|
|
85
84
|
def show
|
86
|
-
@toolbars.each_value { |toolbar| toolbar.set_visible(true) }
|
87
|
-
@
|
85
|
+
# @toolbars.each_value { |toolbar| toolbar.set_visible(true) }
|
86
|
+
@toolbar.set_visible(true)
|
88
87
|
end
|
89
88
|
|
90
89
|
def hide
|
91
|
-
@toolbars.each_value { |toolbar| toolbar.dispose() }
|
92
|
-
@
|
90
|
+
# @toolbars.each_value { |toolbar| toolbar.dispose() }
|
91
|
+
@toolbar.dispose()
|
93
92
|
end
|
94
93
|
|
95
94
|
def close
|
@@ -98,11 +97,12 @@ module Redcar
|
|
98
97
|
end
|
99
98
|
|
100
99
|
def height
|
101
|
-
|
102
|
-
|
103
|
-
|
100
|
+
return 0
|
101
|
+
h = 0
|
102
|
+
@toolbar.getItems.each do |i|
|
103
|
+
h = ( h > i.getSize.y ) ? h : i.getSize.y
|
104
104
|
end
|
105
|
-
|
105
|
+
h
|
106
106
|
end
|
107
107
|
|
108
108
|
private
|
@@ -116,10 +116,10 @@ module Redcar
|
|
116
116
|
#new_toolbar = Swt::Widgets::ToolBar.new(@window.shell, Swt::SWT::DROP_DOWN)
|
117
117
|
new_toolbar = Swt::Widgets::ToolBar.new(toolbar)
|
118
118
|
toolbar_header.toolbar = new_toolbar
|
119
|
-
toolbar_header.add_arm_listener do
|
120
|
-
|
121
|
-
|
122
|
-
end
|
119
|
+
# toolbar_header.add_arm_listener do
|
120
|
+
# new_toolbar.get_items.each {|i| i.dispose }
|
121
|
+
# add_entries_to_toolbar(new_toolbar, entry)
|
122
|
+
# end
|
123
123
|
elsif entry.is_a?(Redcar::ToolBar)
|
124
124
|
new_toolbar = Swt::Widgets::ToolBar.new(toolbar)
|
125
125
|
add_entries_to_toolbar(new_toolbar, entry)
|
@@ -262,9 +262,18 @@ module Redcar
|
|
262
262
|
@sash.layout_data.left = Swt::Layout::FormAttachment.new(0, client_area.width - SASH_WIDTH)
|
263
263
|
end
|
264
264
|
end
|
265
|
+
activate_osx_fullscreen_option
|
265
266
|
ApplicationSWT.register_shell(@shell)
|
266
267
|
end
|
267
|
-
|
268
|
+
|
269
|
+
FULL_SCREEN_SHELL_ICON = 1 << 7
|
270
|
+
|
271
|
+
def activate_osx_fullscreen_option
|
272
|
+
if Redcar.platform == :osx
|
273
|
+
@shell.view.window.set_collection_behavior(FULL_SCREEN_SHELL_ICON)
|
274
|
+
end
|
275
|
+
end
|
276
|
+
|
268
277
|
def create_sashes(window_model)
|
269
278
|
orientation = horizontal_vertical(window_model.notebook_orientation)
|
270
279
|
|
metadata
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redcar-dev
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
version: 0.12.
|
4
|
+
prerelease: 7
|
5
|
+
version: 0.12.10dev
|
6
6
|
platform: java
|
7
7
|
authors:
|
8
8
|
- Daniel Lucraft
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-08-03 00:00:00 -04:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -525,18 +525,6 @@ files:
|
|
525
525
|
- plugins/encryption/plugin.rb
|
526
526
|
- plugins/execute_current_tab/plugin.rb
|
527
527
|
- plugins/execute_current_tab/lib/execute_current_tab.rb
|
528
|
-
- plugins/groovy/plugin.rb
|
529
|
-
- plugins/groovy/features/syntax_check_groovy.feature
|
530
|
-
- plugins/groovy/features/fixtures/test.groovy
|
531
|
-
- plugins/groovy/features/fixtures/lib/classes.jar
|
532
|
-
- plugins/groovy/features/step_definitions/groovy_steps.rb
|
533
|
-
- plugins/groovy/features/support/env.rb
|
534
|
-
- plugins/groovy/lib/groovy.rb
|
535
|
-
- plugins/groovy/lib/groovy/commands.rb
|
536
|
-
- plugins/groovy/lib/groovy/repl_mirror.rb
|
537
|
-
- plugins/groovy/lib/groovy/syntax_checker.rb
|
538
|
-
- plugins/groovy/spec/spec_helper.rb
|
539
|
-
- plugins/groovy/spec/groovy/repl_mirror_spec.rb
|
540
528
|
- plugins/help/plugin.rb
|
541
529
|
- plugins/help/lib/help.rb
|
542
530
|
- plugins/help/lib/help/help_tab.rb
|
Binary file
|
File without changes
|
@@ -1,27 +0,0 @@
|
|
1
|
-
When /^I add "([^"]*)" to the "([^"]*)" classpath$/ do |dir,plugin|
|
2
|
-
File.open(File.expand_path("plugins/#{plugin}/features/fixtures/.redcar/classpath.groovy"), "a") do |f|
|
3
|
-
f.puts <<-CONFIG
|
4
|
-
def redcar_config = new File(getClass().protectionDomain.codeSource.location.path).parentFile
|
5
|
-
def project = redcar_config.parentFile
|
6
|
-
def classpath = []
|
7
|
-
|
8
|
-
//installed libraries
|
9
|
-
def lib = new File(project.path + File.separator + "lib")
|
10
|
-
lib.list().each {name -> classpath << lib.path+File.separator+name}
|
11
|
-
|
12
|
-
//compiled classes
|
13
|
-
def target_classes = new File(
|
14
|
-
project.path + File.separator +
|
15
|
-
"target" + File.separator +
|
16
|
-
"classes"
|
17
|
-
)
|
18
|
-
|
19
|
-
classpath << target_classes.path
|
20
|
-
|
21
|
-
//other classes
|
22
|
-
classpath << project.path + File.separator + "#{dir}"
|
23
|
-
|
24
|
-
return classpath.toArray()
|
25
|
-
CONFIG
|
26
|
-
end
|
27
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
After do
|
2
|
-
# Truncate the test file
|
3
|
-
File.open(File.expand_path("../../fixtures/test.groovy", __FILE__), "w")
|
4
|
-
|
5
|
-
#recreate the classpath file
|
6
|
-
File.open(File.expand_path("../../fixtures/.redcar/classpath.groovy", __FILE__), "w") do |f|
|
7
|
-
f.puts <<-CONFIG
|
8
|
-
def redcar_config = new File(getClass().protectionDomain.codeSource.location.path).parentFile
|
9
|
-
def project = redcar_config.parentFile
|
10
|
-
def classpath = []
|
11
|
-
|
12
|
-
//installed libraries
|
13
|
-
def lib = new File(project.path + File.separator + "lib")
|
14
|
-
lib.list().each {name -> classpath << lib.path+File.separator+name}
|
15
|
-
|
16
|
-
//compiled classes
|
17
|
-
def target_classes = new File(
|
18
|
-
project.path + File.separator +
|
19
|
-
"target" + File.separator +
|
20
|
-
"classes"
|
21
|
-
)
|
22
|
-
classpath << target_classes.path
|
23
|
-
|
24
|
-
return classpath.toArray()
|
25
|
-
CONFIG
|
26
|
-
end
|
27
|
-
end
|
@@ -1,72 +0,0 @@
|
|
1
|
-
Feature: Syntax Checking for Groovy
|
2
|
-
As a user
|
3
|
-
I want to get annotations on syntax errors in Groovy files
|
4
|
-
|
5
|
-
Background:
|
6
|
-
When I have opened "plugins/groovy/features/fixtures/test.groovy"
|
7
|
-
|
8
|
-
Scenario: A syntax-clean Groovy file has no syntax error annotations
|
9
|
-
When I replace the contents with "class Foo {\n\n}"
|
10
|
-
And I save the tab
|
11
|
-
Then the tab should not have annotations
|
12
|
-
|
13
|
-
Scenario: A syntax-error in a Groovy file should cause syntax error annotations
|
14
|
-
When I replace the contents with "class Foo {\n sdef\n}"
|
15
|
-
And I save the tab
|
16
|
-
Then the tab should have annotations
|
17
|
-
And the tab should have an annotation on line 2
|
18
|
-
|
19
|
-
Scenario: Fixing a syntax-error in a Groovy file should cause syntax error annotations to vanish
|
20
|
-
When I replace the contents with "class Foo {\n sdef\n}"
|
21
|
-
And I save the tab
|
22
|
-
Then the tab should have annotations
|
23
|
-
When I replace the contents with "class Foo {\n\n}"
|
24
|
-
And I save the tab
|
25
|
-
Then the tab should not have annotations
|
26
|
-
|
27
|
-
Scenario: A file which references unknown groovy classes should cause syntax error annotations
|
28
|
-
And I replace the contents with "class Foo {\n def x = new Bar(10)\n def y = new FooBar()\n}"
|
29
|
-
And I save the tab
|
30
|
-
Then the tab should have annotations
|
31
|
-
And the tab should have an annotation on line 2
|
32
|
-
|
33
|
-
Scenario: A project can add libraries and compiled class directories to the groovy classpath
|
34
|
-
When I will choose "plugins/groovy/features/fixtures" from the "open_directory" dialog
|
35
|
-
And I open a directory
|
36
|
-
And I replace the contents with "class Foo {\n def x = new Bar(10)\n def y = new FooBar()\n}"
|
37
|
-
And I save the tab
|
38
|
-
Then the tab should not have annotations
|
39
|
-
|
40
|
-
Scenario: If a project classpath.groovy file has syntax errors, there should be an error message and annotations
|
41
|
-
And I close the focussed tab
|
42
|
-
Given I have not suppressed syntax checking message dialogs
|
43
|
-
When I will choose "plugins/groovy/features/fixtures" from the "open_directory" dialog
|
44
|
-
And I open a directory
|
45
|
-
And I have opened "plugins/groovy/features/fixtures/.redcar/classpath.groovy"
|
46
|
-
And I replace the contents with "def x = 4\nsdef"
|
47
|
-
And I save the tab
|
48
|
-
Then I should see a message box containing "An error occurred while loading groovy classpath file"
|
49
|
-
|
50
|
-
Scenario: If an error occurs while parsing a groovy file, there should be an error message
|
51
|
-
Given I have not suppressed syntax checking message dialogs
|
52
|
-
When I will choose "plugins/groovy/features/fixtures" from the "open_directory" dialog
|
53
|
-
And I open a directory
|
54
|
-
And I add "lib2" to the "groovy" classpath
|
55
|
-
And I replace the contents with "class Foo {\n def x = new Bar(10)\n def y = new FooBaz()\n}"
|
56
|
-
And I save the tab
|
57
|
-
Then I should see a message box containing "An error occurred while parsing"
|
58
|
-
And the tab should have an annotation on line 2
|
59
|
-
|
60
|
-
Scenario: If syntax message dialogs are suppressed, I should see no message boxes
|
61
|
-
Given I have suppressed syntax checking message dialogs
|
62
|
-
When I will choose "plugins/groovy/features/fixtures" from the "open_directory" dialog
|
63
|
-
And I open a directory
|
64
|
-
And I have opened "plugins/groovy/features/fixtures/.redcar/classpath.groovy"
|
65
|
-
And I replace the contents with "sdef"
|
66
|
-
And I save the tab
|
67
|
-
Then the tab should not have annotations
|
68
|
-
When I close the focussed tab
|
69
|
-
And I add "lib2" to the "groovy" classpath
|
70
|
-
And I replace the contents with "class Foo {\n def x = new Bar(10)\n def y = new FooBaz()\n}"
|
71
|
-
And I save the tab
|
72
|
-
Then the tab should have an annotation on line 2
|
@@ -1,38 +0,0 @@
|
|
1
|
-
|
2
|
-
require 'groovy/commands'
|
3
|
-
require 'groovy/repl_mirror'
|
4
|
-
require 'groovy/syntax_checker'
|
5
|
-
|
6
|
-
module Redcar
|
7
|
-
class Groovy
|
8
|
-
|
9
|
-
def self.load_dependencies
|
10
|
-
unless @loaded
|
11
|
-
require File.join(Redcar.asset_dir,"groovy-all")
|
12
|
-
@loaded = true
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.menus
|
17
|
-
Redcar::Menu::Builder.build do
|
18
|
-
sub_menu "Plugins" do
|
19
|
-
sub_menu "REPL" do
|
20
|
-
item "Open Groovy REPL", OpenGroovyREPL
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def self.keymaps
|
27
|
-
osx = Keymap.build("main", :osx) do
|
28
|
-
link "Cmd+Alt+G", OpenGroovyREPL
|
29
|
-
end
|
30
|
-
|
31
|
-
linwin = Keymap.build("main", [:linux, :windows]) do
|
32
|
-
link "Ctrl+Alt+G", OpenGroovyREPL
|
33
|
-
end
|
34
|
-
|
35
|
-
[linwin, osx]
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,85 +0,0 @@
|
|
1
|
-
|
2
|
-
require 'java'
|
3
|
-
|
4
|
-
module Redcar
|
5
|
-
class Groovy
|
6
|
-
class ReplMirror < Redcar::REPL::ReplMirror
|
7
|
-
def title
|
8
|
-
"Groovy REPL"
|
9
|
-
end
|
10
|
-
|
11
|
-
def grammar_name
|
12
|
-
"Groovy REPL"
|
13
|
-
end
|
14
|
-
|
15
|
-
def prompt
|
16
|
-
"groovy>"
|
17
|
-
end
|
18
|
-
|
19
|
-
def evaluator
|
20
|
-
@instance ||= ReplMirror::Evaluator.new
|
21
|
-
end
|
22
|
-
|
23
|
-
def format_error(e)
|
24
|
-
backtrace = e.backtrace
|
25
|
-
"ERROR #{e.class}:\n #{e.message}\n #{backtrace.join("\n ")}"
|
26
|
-
end
|
27
|
-
|
28
|
-
def help
|
29
|
-
h = super
|
30
|
-
h << """
|
31
|
-
Note on Groovy Script Scoping:
|
32
|
-
Classes, undefined variables, and undefined closures are saved in the script
|
33
|
-
binding between statements.
|
34
|
-
Defined methods, closures, and variables are not added to the binding,
|
35
|
-
because they are considered local variables and thus are not available after
|
36
|
-
the defining statement.
|
37
|
-
|
38
|
-
Example:
|
39
|
-
|
40
|
-
def foo = 'hello! I am a local variable'
|
41
|
-
foo = 'hi! I am a binding variable'
|
42
|
-
|
43
|
-
See 'http://groovy.codehaus.org/Scoping+and+the+Semantics+of+%22def%22'
|
44
|
-
for more information.
|
45
|
-
"""
|
46
|
-
end
|
47
|
-
|
48
|
-
class Evaluator
|
49
|
-
def self.load_dependencies
|
50
|
-
unless @loaded
|
51
|
-
Groovy.load_dependencies
|
52
|
-
import 'groovy.lang.GroovyShell'
|
53
|
-
import 'java.io.PrintWriter'
|
54
|
-
import 'java.io.StringWriter'
|
55
|
-
@loaded = true
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def initialize
|
60
|
-
Evaluator.load_dependencies
|
61
|
-
@out = StringWriter.new
|
62
|
-
@shell = GroovyShell.new
|
63
|
-
@shell.setProperty('out',@out)
|
64
|
-
end
|
65
|
-
|
66
|
-
def inspect
|
67
|
-
"groovyREPL main"
|
68
|
-
end
|
69
|
-
|
70
|
-
def execute(cmd)
|
71
|
-
output = @shell.evaluate(cmd,"GroovyREPL").to_s
|
72
|
-
output = "null" unless output and not output.empty?
|
73
|
-
if @out and not @out.toString().empty?
|
74
|
-
console = @out.toString() + "\n"
|
75
|
-
else
|
76
|
-
console = ""
|
77
|
-
end
|
78
|
-
buf = @out.getBuffer()
|
79
|
-
buf.delete(0,buf.length()) if buf.length() > 0
|
80
|
-
console + "===> #{output}"
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
@@ -1,81 +0,0 @@
|
|
1
|
-
|
2
|
-
require 'java'
|
3
|
-
|
4
|
-
module Redcar
|
5
|
-
class Groovy
|
6
|
-
class SyntaxChecker < Redcar::SyntaxCheck::Checker
|
7
|
-
supported_grammars "Groovy", "Easyb"
|
8
|
-
|
9
|
-
def self.load_dependencies
|
10
|
-
unless @loaded
|
11
|
-
Groovy.load_dependencies
|
12
|
-
import 'groovy.lang.GroovyShell'
|
13
|
-
import 'org.codehaus.groovy.control.CompilationFailedException'
|
14
|
-
import 'org.codehaus.groovy.control.CompilerConfiguration'
|
15
|
-
@loaded = true
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def initialize(document)
|
20
|
-
super
|
21
|
-
SyntaxChecker.load_dependencies
|
22
|
-
end
|
23
|
-
|
24
|
-
def check(*args)
|
25
|
-
path = manifest_path(doc)
|
26
|
-
name = File.basename(path)
|
27
|
-
shell = create_shell
|
28
|
-
text = doc.get_all_text
|
29
|
-
io = java.io.File.new(path)
|
30
|
-
begin
|
31
|
-
shell.parse(io)
|
32
|
-
rescue CompilationFailedException => e
|
33
|
-
create_syntax_error(doc, e.message, name).annotate
|
34
|
-
rescue Object => e
|
35
|
-
Redcar::SyntaxCheck.message(
|
36
|
-
"An error occurred while parsing #{name}: #{e.message}",:error)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def create_syntax_error(doc, message, name)
|
41
|
-
message =~ /#{Regexp.escape(name)}: (\d+):(.*)/
|
42
|
-
line = $1.to_i - 1
|
43
|
-
message = $2
|
44
|
-
Redcar::SyntaxCheck::Error.new(doc, line, message)
|
45
|
-
end
|
46
|
-
|
47
|
-
def classpath_files(project)
|
48
|
-
project.config_files("classpath.groovy")
|
49
|
-
end
|
50
|
-
|
51
|
-
def classpath(project)
|
52
|
-
parts = []
|
53
|
-
shell = GroovyShell.new
|
54
|
-
files = classpath_files(project)
|
55
|
-
return unless files.any?
|
56
|
-
files.each do |path|
|
57
|
-
begin
|
58
|
-
file = java.io.File.new(path)
|
59
|
-
part = shell.run(file, [])
|
60
|
-
parts += part if part
|
61
|
-
rescue Object => e
|
62
|
-
Redcar::SyntaxCheck.message(
|
63
|
-
"An error occurred while loading groovy classpath file #{path}: #{e.message}",:error)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
parts
|
67
|
-
end
|
68
|
-
|
69
|
-
def create_shell
|
70
|
-
config = CompilerConfiguration.new
|
71
|
-
if project = Redcar::Project::Manager.focussed_project
|
72
|
-
classpath = classpath(project)
|
73
|
-
config.setClasspathList(classpath) if classpath and classpath.any?
|
74
|
-
end
|
75
|
-
shell = GroovyShell.new(config)
|
76
|
-
shell.setProperty("out",nil)
|
77
|
-
shell
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
data/plugins/groovy/plugin.rb
DELETED
@@ -1,56 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__),'..', 'spec_helper')
|
2
|
-
|
3
|
-
class Redcar::Groovy
|
4
|
-
describe ReplMirror do
|
5
|
-
before(:all) do
|
6
|
-
@mirror = ReplMirror.new
|
7
|
-
@changed_event = false
|
8
|
-
@mirror.add_listener(:change) { @changed_event = true }
|
9
|
-
end
|
10
|
-
|
11
|
-
def wait_for_prompt
|
12
|
-
while @mirror.read.nil? || @mirror.read[-8,8] != "groovy> "
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
describe "before executing" do
|
17
|
-
it "should exist" do
|
18
|
-
@mirror.should be_exist
|
19
|
-
end
|
20
|
-
|
21
|
-
it "should have a title" do
|
22
|
-
@mirror.title.should == "Groovy REPL"
|
23
|
-
end
|
24
|
-
|
25
|
-
it "should not be changed" do
|
26
|
-
@mirror.should_not be_changed
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
describe "after executing" do
|
31
|
-
it "should exist" do
|
32
|
-
@mirror.should be_exist
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should have a title" do
|
36
|
-
@mirror.title.should == "Groovy REPL"
|
37
|
-
end
|
38
|
-
|
39
|
-
it "should not be changed" do
|
40
|
-
@mirror.should_not be_changed
|
41
|
-
end
|
42
|
-
|
43
|
-
it "should have a prompt" do
|
44
|
-
wait_for_prompt
|
45
|
-
@mirror.read.should == (<<-Groovy).chomp
|
46
|
-
# Groovy REPL
|
47
|
-
# type 'help' for help
|
48
|
-
|
49
|
-
groovy>
|
50
|
-
Groovy
|
51
|
-
end
|
52
|
-
|
53
|
-
end
|
54
|
-
|
55
|
-
end
|
56
|
-
end
|