mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-05 16:09:07 -04:00
Merge branch 'fix-72' into 'main'
port: Show error when Gtk typelib is missing Closes #72 See merge request jwestman/blueprint-compiler!54
This commit is contained in:
commit
e128b49069
4 changed files with 38 additions and 28 deletions
|
@ -80,14 +80,16 @@ class CompileError(PrintableError):
|
|||
self.hint("Are your dependencies up to date?")
|
||||
|
||||
def pretty_print(self, filename, code, stream=sys.stdout):
|
||||
line_num, col_num = utils.idx_to_pos(self.start + 1, code)
|
||||
line = code.splitlines(True)[line_num]
|
||||
stream.write(f"""{self.color}{Colors.BOLD}{self.category}: {self.message}{Colors.CLEAR}\n""")
|
||||
|
||||
# Display 1-based line numbers
|
||||
line_num += 1
|
||||
if code is not None and self.start is not None:
|
||||
line_num, col_num = utils.idx_to_pos(self.start + 1, code)
|
||||
line = code.splitlines(True)[line_num]
|
||||
|
||||
stream.write(f"""{self.color}{Colors.BOLD}{self.category}: {self.message}{Colors.CLEAR}
|
||||
at {filename} line {line_num} column {col_num}:
|
||||
# Display 1-based line numbers
|
||||
line_num += 1
|
||||
|
||||
stream.write(f"""at {filename} line {line_num} column {col_num}:
|
||||
{Colors.FAINT}{line_num :>4} |{Colors.CLEAR}{line.rstrip()}\n {Colors.FAINT}|{" "*(col_num-1)}^{Colors.CLEAR}\n""")
|
||||
|
||||
for hint in self.hints:
|
||||
|
@ -115,6 +117,15 @@ class UnexpectedTokenError(CompileError):
|
|||
super().__init__("Unexpected tokens", start, end)
|
||||
|
||||
|
||||
class GtkTypelibMissingError(CompileError):
|
||||
def __init__(self, **kwargs):
|
||||
super().__init__(
|
||||
"Could not find GTK 4 introspection files. Is gobject-introspection installed?",
|
||||
fatal=True,
|
||||
**kwargs
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class CodeAction:
|
||||
title: str
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue