zenchild

zenchild

I’m trying to get Igniter.Code.Common.move_to_cursor to work for some code patching and I’m having trouble. I keep getting an :error returned. I then tried to run the demo code from the docs and that is also returning :error. Is there any work-arounds or maybe I’m just doing something wrong (probably :slight_smile: )?

Igniter version: igniter 0.5.50
Elixir version: Elixir 1.18.1 (compiled with Erlang/OTP 27)
OS: OSX

zipper =
  """
  if true do
    10
  end
  """
  |> Sourceror.Zipper.zip()

pattern =
  """
  if __ do
    __cursor__()
  end
  """

Igniter.Code.Common.move_to_cursor(zipper, pattern)
# returns :error

Many thanks for any help.

Cheers,

Dan

Showing Posts 1 to 5

zenchild

zenchild OP

It appears to maybe just be an error in the documentation, I was able to get the example to work by parsing the string first.

zipper =
  """
  if true do
    10
  end
  """
  |> Sourceror.parse_string!()
  |> Sourceror.Zipper.zip()
zachdaniel

zachdaniel

Creator of Ash

Yep! Error in the docs. Could you open an issue or a PR to address?

zenchild

zenchild OP

Will do! :+1: And thanks for Igniter! @zachdaniel

On a separate note, I’m struggling a bit finding the right way to add a function above another and skipping the documentation. Do you have a good recipe for this? I am able to add code before the function, but it’s still after the function docs.

For example:

defmodule MyModule do
  .... stuff here

  @doc """
  Some docs
  
  blah, blah, blah
  """
  def my_function() do
    do_things
  end
end

Thanks for any guidance.

Cheers,

Dan

zachdaniel

zachdaniel

Creator of Ash

It’s a bit tough TBH. Probably what you’d need to do is move to the function, and then move up past any known module attributes like @doc, @spec etc. We could internalize that complexity into a helper like move_to_function_and_attrs into igniter.

zenchild

zenchild OP

Thanks for the tips. I’m just going to put it below a know function for now. :+1:

— All posts loaded —

Where Next? Top

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
Blokh
Hey guys, I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly Do you guys have any suggestions what is the best prac...
New
kszambelanczyk
Hello! Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app. I creat...
New
Onor.io
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
jaybe78
Hello, I’m developing a online persistent chat system (what’s app) like using elixir/dynamodb/aws for a mobile app(flutter). The diffic...
New
Trolleger
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New
widianto
I think I’ve found a small improvement I could contribute to <%= web_namespace %>.CoreComponents (installer/templates/phx_web/compo...
New

Other Trending Topics Top

garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
wintermeyer
There are three potential reasons for members of this forum to have a look at https://vutuv.de You are tired or annoyed of LinkedIn. Yo...
New
aseigo
ICal is a library for interacting with iCalendar data. It parses iCalendars into typed Elixir structs via ICal.from_ics, and can prepare ...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews