Comments (4)
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.
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.
That seems like a reasonable API to add. I'd be interested in a PR for this!
from ariadne.
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)
- Remove "filesystem" category from `Cargo.toml` HOT 1
- error[E0284]: type annotation needed HOT 1
- Upgrade to `yansi 1.0` HOT 1
- Version 0.4.1 is a breaking change HOT 4
- Config::default().with_color(false) not disable colors for `with_message`
- Feature Request: Getters of private fields
- Remove README include from normal build
- Dotted lines in left margins disappeared in version `0.2.0` HOT 1
- Allow annotation with different styles HOT 3
- Support `Caused by` HOT 3
- Recommended approach to handling colors HOT 2
- Potential deprecation of `concolor` HOT 4
- Potential deprecation of `concolor` HOT 1
- Assistance? HOT 2
- Problem specifying filename HOT 8
- Ariadne crashes when input is empty HOT 4
- convert `ariadne::Report` to `String` HOT 2
- convert `ariadne::Report` to `String` HOT 3
- Empty Labels / A way to color characters
- Tracking: The Big Refactor HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ariadne.