Code Monkey home page Code Monkey logo

Comments (4)

zesterer avatar zesterer commented on August 17, 2024

Could you explain more about what information you have available in your case? I'm not sure I understand this problem sufficiently to come to a conclusion about it.

from ariadne.

olson-dan avatar olson-dan commented on August 17, 2024

In my program I have several chunks of the file that need to be paid attention to. I pull these out separately and process them individually, but I save the line offset in the file for the start of each chunk of text. When I emit error messages I need to apply the line offset to the message to output the correct line of the larger file.

The changes are not large but they are hidden by the rustfmt that my editor did automatically.

I added fn Source::with_line_offset(source: &str, line_offset: usize) and stored the offset in the Source structure. I then made Source::get_offset_line return a four-tuple instead of a three-tuple with the fourth value being the offset, which I then add when the error message is written out.

Basically, if you're interested in this I'll clean it up and make a PR. If you're not interested in it I will not worry about it.

from ariadne.

zesterer avatar zesterer commented on August 17, 2024

That seems like a reasonable API to add. I'd be interested in a PR for this!

from ariadne.

tertsdiepraam avatar tertsdiepraam commented on August 17, 2024

Hi there! Even though this is marked as completed I don't think it is. I was just looking for exactly this functionality. My use-case is that I'm writing a programming language but I have tests where I parse strings containing source code. I'm trying to make Ariadne display the correct position of an error within that string in the larger Rust source file.

Is there anything holding the linked PR back? If something needs to be changed there I'd be happy to adopt it and make a new PR.

from ariadne.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.