Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

Support rename symbols #101

Closed
faustinoaq opened this issue May 5, 2018 · 2 comments
Closed

Support rename symbols #101

faustinoaq opened this issue May 5, 2018 · 2 comments

Comments

@faustinoaq
Copy link
Member

faustinoaq commented May 5, 2018

Crystal compiler doesn't support rename symbols yet, see discussion here by @asterite

Would be possible to implement basic rename symbols on scry without crystal tool support? WDYT?

Nice comment by @RX14 :

Personally, local variable renaming, and small refactors such as "extract this subexpression to a variable" would be my 99% usecase for a refactoring tool.

See: Rename feature on LSP specification

@faustinoaq
Copy link
Member Author

/cc @crystal-lang-tools/scry

@faustinoaq
Copy link
Member Author

faustinoaq commented May 6, 2018

Interesting, I just got a rename proof of concept using transformer_example.cr. Similar to autocorrect on crystal-ameba/ameba#34 by @veelenga

require "compiler/crystal/syntax"

class Charify < Crystal::Transformer
  def transform(node : Crystal::Var)
    if node.name == "a"
      return Crystal::Var.new("c")
    end
    node
  end
end

nodes = Crystal::Parser.parse("a = 1; b = a")
puts nodes.transform(Charify.new) # => "c = 1; b = c"

https://carc.in/#/r/40jp

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants