https://github.com/jonathanbieler/refactoring.jl
Refactoring tools for Julia language
https://github.com/jonathanbieler/refactoring.jl
julialang refactoring
Last synced: 2 months ago
JSON representation
Refactoring tools for Julia language
- Host: GitHub
- URL: https://github.com/jonathanbieler/refactoring.jl
- Owner: jonathanBieler
- License: mit
- Created: 2019-09-17T15:15:14.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-02-07T10:03:08.000Z (over 2 years ago)
- Last Synced: 2025-07-25T13:45:56.453Z (3 months ago)
- Topics: julialang, refactoring
- Language: Julia
- Homepage:
- Size: 15.6 KB
- Stars: 5
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Refactoring.jl
[](https://travis-ci.org/jonathanBieler/Refactoring.jl)
[](https://coveralls.io/github/jonathanBieler/Refactoring.jl?branch=master)
### Extract method
```julia
using Refactoring
m = extract_method("
y = [sin(2xi + exp(-c)) for xi in x]
")
julia> print(m)
function (c, x)
y = [sin(2xi + exp(-c)) for xi in x]
end
```
The arguments of the method are guessed by listing the variables that
are unassigned in the expression:
```julia
ex = quote
using Gadfly
mu = K1
const alpha = 1
const beta = (alpha+1)*mu
for i=1:10
x = rand(100, f(K2))
end
plot(x = K3, y = pdf(InverseGamma(K4,beta),K5), Geom.line)
ind, K7 = K6.asd
x = [K8[K7] for i=1:K6]
end
julia> unassigned_variables(ex)
7-element Array{Any,1}:
:K1
:K2
:K3
:K4
:K5
:K6
:K8
```
### Search and replace
Replace all sub-expressions matching a pattern with another :
```julia
julia> @search_and_replace sin(sin(x)) sin($x) cos($x +1)
:(cos(cos(x + 1) + 1))
```