1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-12-07 17:41:00 +01:00

handle Pos instead of individual file/line/columnrange args

This commit is contained in:
Ben Burdette 2020-04-03 13:15:59 -06:00
parent 7b7801d3f0
commit 9bb528d392
2 changed files with 31 additions and 80 deletions

View file

@ -1,4 +1,5 @@
#include "../../src/libutil/error.hh"
#include "../../src/libexpr/nixexpr.hh"
#include <iostream>
#include <optional>
@ -58,12 +59,14 @@ int main()
// NixLangWarning adds nix file, line number, column range, and the lines of
// code where a warning occurred.
SymbolTable testTable;
auto problem_symbol = testTable.create("problem");
printErrorInfo(NixLangWarning()
.name("warning name")
.description("warning description")
.nixFile("myfile.nix")
.lineNumber(40)
.columnRange(13, 7)
.pos(Pos(problem_symbol, 40, 13))
.linesOfCode(std::nullopt,
"this is the problem line of code",
std::nullopt)
@ -74,9 +77,7 @@ int main()
printErrorInfo(NixLangError()
.name("error name")
.description("error description")
.nixFile("myfile.nix")
.lineNumber(40)
.columnRange(13, 7)
.pos(Pos(problem_symbol, 40, 13))
.linesOfCode(std::optional("previous line of code"),
"this is the problem line of code",
std::optional("next line of code"))