Class: Rsense::Server::Command::RsenseMethod
- Inherits:
-
Java::org.cx4a.rsense.typing.runtime::DefaultMethod
- Object
- Java::org.cx4a.rsense.typing.runtime::DefaultMethod
- Rsense::Server::Command::RsenseMethod
- Defined in:
- lib/rsense/server/command/rsense_method.rb
Instance Attribute Summary collapse
-
#args_node ⇒ Object
Returns the value of attribute args_node.
-
#body_node ⇒ Object
Returns the value of attribute body_node.
-
#cbase ⇒ Object
Returns the value of attribute cbase.
-
#location ⇒ Object
Returns the value of attribute location.
-
#name ⇒ Object
Returns the value of attribute name.
-
#node ⇒ Object
Returns the value of attribute node.
-
#parent ⇒ Object
Returns the value of attribute parent.
-
#visibility ⇒ Object
Returns the value of attribute visibility.
Class Method Summary collapse
- .generate_method_body(name) ⇒ Object
- .generate_node(name, parent) ⇒ Object
- .insert_into_parent(node, parent) ⇒ Object
- .make_method(cbase, name, visibility, parent) ⇒ Object
- .make_node(name, parent) ⇒ Object
Instance Method Summary collapse
-
#initialize(cbase, name, bodyNode, argsNode, visibility, location) ⇒ RsenseMethod
constructor
A new instance of RsenseMethod.
Constructor Details
#initialize(cbase, name, bodyNode, argsNode, visibility, location) ⇒ RsenseMethod
Returns a new instance of RsenseMethod.
9 10 11 |
# File 'lib/rsense/server/command/rsense_method.rb', line 9 def initialize(cbase, name, bodyNode, argsNode, visibility, location) super(cbase, name, bodyNode, argsNode, visibility, location) end |
Instance Attribute Details
#args_node ⇒ Object
Returns the value of attribute args_node.
7 8 9 |
# File 'lib/rsense/server/command/rsense_method.rb', line 7 def args_node @args_node end |
#body_node ⇒ Object
Returns the value of attribute body_node.
7 8 9 |
# File 'lib/rsense/server/command/rsense_method.rb', line 7 def body_node @body_node end |
#cbase ⇒ Object
Returns the value of attribute cbase.
7 8 9 |
# File 'lib/rsense/server/command/rsense_method.rb', line 7 def cbase @cbase end |
#location ⇒ Object
Returns the value of attribute location.
7 8 9 |
# File 'lib/rsense/server/command/rsense_method.rb', line 7 def location @location end |
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/rsense/server/command/rsense_method.rb', line 7 def name @name end |
#node ⇒ Object
Returns the value of attribute node.
7 8 9 |
# File 'lib/rsense/server/command/rsense_method.rb', line 7 def node @node end |
#parent ⇒ Object
Returns the value of attribute parent.
7 8 9 |
# File 'lib/rsense/server/command/rsense_method.rb', line 7 def parent @parent end |
#visibility ⇒ Object
Returns the value of attribute visibility.
7 8 9 |
# File 'lib/rsense/server/command/rsense_method.rb', line 7 def visibility @visibility end |
Class Method Details
.generate_method_body(name) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/rsense/server/command/rsense_method.rb', line 23 def self.generate_method_body(name) %Q{ def #{name}(*args) if block_given? yield args else args end end } end |
.generate_node(name, parent) ⇒ Object
35 36 37 38 39 40 |
# File 'lib/rsense/server/command/rsense_method.rb', line 35 def self.generate_node(name, parent) code = self.generate_method_body(name) root = JRubyParser.parse(code) node = root.find_node(:defn) self.insert_into_parent(node, parent) end |
.insert_into_parent(node, parent) ⇒ Object
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/rsense/server/command/rsense_method.rb', line 42 def self.insert_into_parent(node, parent) parent = parent parent.insert_node(node) inserted_node = parent.find_all.select {|n| n == node}.first if inserted_node inserted_node else node end end |
.make_method(cbase, name, visibility, parent) ⇒ Object
13 14 15 16 17 |
# File 'lib/rsense/server/command/rsense_method.rb', line 13 def self.make_method(cbase, name, visibility, parent) node = self.make_node(name, parent) loc = Java::org.cx4a.rsense.util::SourceLocation.of(node) [cbase, name, node.body_node, node.args_node, visibility, loc] end |
.make_node(name, parent) ⇒ Object
19 20 21 |
# File 'lib/rsense/server/command/rsense_method.rb', line 19 def self.make_node(name, parent) self.generate_node(name, parent) end |