Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pretty printing of errors #82

Closed
6 tasks done
Tracked by #41
magicant opened this issue Sep 5, 2021 · 2 comments
Closed
6 tasks done
Tracked by #41

Pretty printing of errors #82

magicant opened this issue Sep 5, 2021 · 2 comments
Labels
tracker List of subtasks
Projects

Comments

@magicant
Copy link
Owner

magicant commented Sep 5, 2021

@magicant magicant added this to To do in Main via automation Sep 5, 2021
@magicant magicant moved this from To do to In progress in Main Sep 5, 2021
@magicant magicant mentioned this issue Sep 5, 2021
26 tasks
@magicant magicant added the tracker List of subtasks label Sep 5, 2021
@magicant
Copy link
Owner Author

magicant commented Sep 9, 2021

Considering a new intermediate structure that can be converted to annotate_snippets::snippet::Snippet. It would be more organized and versatile than directly constructing a Snippet from an Error. It would also help owning message strings that are referenced from the Snippet.

pub struct Message {
    r#type: AnnotationType,
    title: String, // or Cow<'_, str>
    annotations: Vec<Annotation>,
}
pub struct Annotation {
    r#type: AnnotationType,
    label: String, // or Cow<'_, str>
    location: Location,
}

@magicant magicant moved this from In progress to To do in Main Sep 18, 2021
@magicant magicant moved this from To do to In progress in Main Jan 4, 2022
@magicant
Copy link
Owner Author

magicant commented Jan 4, 2022

For multi-line code, the Line should be modified to:

pub struct Code {
    value: RefCell<String>,
    start_line_number: NonZeroU64,
    source: Source,
}
  1. Rename the structure
  2. Rename Location::line to Location::code
  3. Wrap the value in RefCell
  4. Rename number to start_line_number
  5. Define methods to access the fields
  6. Define methods to append to the value
  7. Make the structure fields private
  8. Share the Code between all the lines of code
    • Modify the lexer
    • Modify or remove the Lines iterator

(Update: This does not fully work. See #129)


For location ranges, the Location should be modified to:

pub struct Location {
    range: (usize, usize),
    code: Rc<Code>,
  1. Change column: NonZeroU64 to range: (usize, usize)
  2. Produce locations having the correct range in token parser

@magicant magicant moved this from In progress to To do in Main Feb 25, 2022
@magicant magicant moved this from To do to In progress in Main Feb 25, 2022
@magicant magicant closed this as completed Mar 6, 2022
Main automation moved this from In progress to Done Mar 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tracker List of subtasks
Projects
Status: Done
Main
  
Done
Development

No branches or pull requests

1 participant