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:
parent
7b7801d3f0
commit
9bb528d392
2 changed files with 31 additions and 80 deletions
|
|
@ -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"))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue