Skip to content

Commit

Permalink
fix(qf): improve logger to take less space on the screen
Browse files Browse the repository at this point in the history
  • Loading branch information
Ph0enixKM committed Jul 29, 2024
1 parent 0dc2b09 commit 0a4e5f1
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "heraclitus-compiler"
version = "1.7.3"
version = "1.7.4"
edition = "2021"
description = "Compiler frontend for developing great programming languages"
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ let tokens = cc.tokenize()?;

# Change log 🚀

## Version 1.7.3
## Version 1.7.4
### Fix:
- `Logger::text` now doesn't end with a new line
### Feature:
Expand Down
34 changes: 25 additions & 9 deletions src/compiling/failing/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,10 @@ impl Message {
if !self.trace.is_empty() {
Logger::new(self.kind.clone(), &self.trace)
.header(self.kind.clone())
.text(self.message.clone())
.line(self.message.clone())
.path()
.padded_line(self.comment.clone())
.snippet(self.code.clone());
.snippet(self.code.clone())
.line(self.comment.clone());
}
// If this error is a message error
else {
Expand All @@ -174,13 +174,29 @@ impl Message {

#[cfg(test)]
mod test {
use crate::prelude::{DefaultMetadata, Message, Metadata, PositionInfo};

#[test]
fn test_message() {
Message::new_err_msg("This is not a message")
.comment("Or is it?")
.show();
}

#[test]
fn test_logger() {
// use super::Logger;
// Logger::new_err_msg("This is not a message")
// .attach_comment("Or is it?")
// .show()
// .exit();
fn test_message_with_code() {
let code = Some([
"... some code",
"name = false",
"... further code",
].join("\n"));
let path = Some(format!("path/to/file"));
let position = PositionInfo::at_pos(path.clone(), (2, 1), 4);
let guess = "type";
let mut meta = DefaultMetadata::new(vec![], path, code);
Message::new_err_at_position(&mut meta, position)
.message("Type of this parameter is invalid")
.comment(format!("Maybe you meant type {guess} instead"))
.show();
}
}

0 comments on commit 0a4e5f1

Please sign in to comment.