Skip to content

Rewrite code case #49

Description

@rainmantsr

I am using jruby-parser to rewrite code, but with some code is has some problems:
This:
require 'jruby-parser'

root = JRubyParser.parse( %q{
def log(severity)
case severity
when Severity::DEBUG
@logging_services.debug(msg.to_s)
when Severity::INFO
@logging_services.info(msg.to_s)
when Severity::WARNING
@logging_services.warn(msg.to_s)
else
@logging_services.error(msg.to_s)
end
end
} )

root.to_source

produces:
def log severity
case severity[
when Severity
@logging_services.debug(msg.to_s)
when Severity
@logging_services.info(msg.to_s)
when Severity
@logging_services.warn(msg.to_s)
else
@logging_services.error(msg.to_s),
when Severity
@logging_services.info(msg.to_s)
when Severity
@logging_services.warn(msg.to_s)
else
@logging_services.error(msg.to_s),
when Severity
@logging_services.warn(msg.to_s)
else
@logging_services.error(msg.to_s)]
end
end

Can I do something to avoid this behaviour?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions