Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Reflection API #304

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,16 @@ task default: :test

configure = ->(task) do
task.source_files =
FileList[%w[Gemfile Rakefile syntax_tree.gemspec lib/**/*.rb test/*.rb]]
FileList[
%w[
Gemfile
Rakefile
syntax_tree.gemspec
lib/**/*.rb
tasks/*.rake
test/*.rb
]
]

# Since Syntax Tree supports back to Ruby 2.7.0, we need to make sure that we
# format our code such that it's compatible with that version. This actually
Expand Down
1 change: 1 addition & 0 deletions bin/console
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

require "bundler/setup"
require "syntax_tree"
require "syntax_tree/reflection"

require "irb"
IRB.start(__FILE__)
32 changes: 22 additions & 10 deletions lib/syntax_tree/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,17 @@ def RAssign(value, operator, pattern)
end

# Create a new ClassDeclaration node.
def ClassDeclaration(constant, superclass, bodystmt)
def ClassDeclaration(
constant,
superclass,
bodystmt,
location = Location.default
)
ClassDeclaration.new(
constant: constant,
superclass: superclass,
bodystmt: bodystmt,
location: Location.default
location: location
)
end

Expand All @@ -225,12 +230,12 @@ def Comma(value)
end

# Create a new Command node.
def Command(message, arguments, block)
def Command(message, arguments, block, location = Location.default)
Command.new(
message: message,
arguments: arguments,
block: block,
location: Location.default
location: location
)
end

Expand All @@ -247,8 +252,8 @@ def CommandCall(receiver, operator, message, arguments, block)
end

# Create a new Comment node.
def Comment(value, inline)
Comment.new(value: value, inline: inline, location: Location.default)
def Comment(value, inline, location = Location.default)
Comment.new(value: value, inline: inline, location: location)
end

# Create a new Const node.
Expand Down Expand Up @@ -285,14 +290,21 @@ def CVar(value)
end

# Create a new DefNode node.
def DefNode(target, operator, name, params, bodystmt)
def DefNode(
target,
operator,
name,
params,
bodystmt,
location = Location.default
)
DefNode.new(
target: target,
operator: operator,
name: name,
params: params,
bodystmt: bodystmt,
location: Location.default
location: location
)
end

Expand Down Expand Up @@ -565,8 +577,8 @@ def MAssign(target, value)
end

# Create a new MethodAddBlock node.
def MethodAddBlock(call, block)
MethodAddBlock.new(call: call, block: block, location: Location.default)
def MethodAddBlock(call, block, location = Location.default)
MethodAddBlock.new(call: call, block: block, location: location)
end

# Create a new MLHS node.
Expand Down
Loading