mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
errors: Print code actions in error message
Previously they were only exposed by the language server, but now the command line will print the old and new text.
This commit is contained in:
parent
dd2e9a10cb
commit
a689150a8b
2 changed files with 12 additions and 2 deletions
|
@ -107,6 +107,16 @@ at {filename} line {line_num} column {col_num}:
|
||||||
for hint in self.hints:
|
for hint in self.hints:
|
||||||
stream.write(f"{Colors.FAINT}hint: {hint}{Colors.CLEAR}\n")
|
stream.write(f"{Colors.FAINT}hint: {hint}{Colors.CLEAR}\n")
|
||||||
|
|
||||||
|
for i, action in enumerate(self.actions):
|
||||||
|
old = (
|
||||||
|
action.edit_range.text
|
||||||
|
if action.edit_range is not None
|
||||||
|
else self.range.text
|
||||||
|
)
|
||||||
|
stream.write(
|
||||||
|
f"suggestion: replace {Colors.RED}{old}{Colors.CLEAR} with {Colors.GREEN}{action.replace_with}{Colors.CLEAR}\n"
|
||||||
|
)
|
||||||
|
|
||||||
for ref in self.references:
|
for ref in self.references:
|
||||||
line_num, col_num = utils.idx_to_pos(ref.range.start + 1, code)
|
line_num, col_num = utils.idx_to_pos(ref.range.start + 1, code)
|
||||||
line = code.splitlines(True)[line_num]
|
line = code.splitlines(True)[line_num]
|
||||||
|
|
|
@ -26,7 +26,7 @@ Blueprint is a markup language and compiler for GTK 4 user interfaces.
|
||||||
|
|
||||||
using Gtk 4.0;
|
using Gtk 4.0;
|
||||||
|
|
||||||
template $MyAppWindow : ApplicationWindow {
|
template MyAppWindow : ApplicationWindow {
|
||||||
default-width: 600;
|
default-width: 600;
|
||||||
default-height: 300;
|
default-height: 300;
|
||||||
title: _("Hello, Blueprint!");
|
title: _("Hello, Blueprint!");
|
||||||
|
@ -35,7 +35,7 @@ Blueprint is a markup language and compiler for GTK 4 user interfaces.
|
||||||
HeaderBar {}
|
HeaderBar {}
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
label: bind template.main_text;
|
label: bind MyAppWindow.main_text;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue