Print line number next to problem in check-names

Signed-off-by: Yuto Takano <yuto.takano@arm.com>
This commit is contained in:
Yuto Takano 2021-08-06 23:37:20 +01:00
parent bcc3d99cc1
commit 381fda8550

View File

@ -63,10 +63,15 @@ class Match(): # pylint: disable=too-few-public-methods
self.name = name
def __str__(self):
ln_str = str(self.pos[0])
gutter_len = max(4, len(ln_str))
gutter = (gutter_len - len(ln_str)) * " " + ln_str
underline = self.pos[1] * " " + (self.pos[2] - self.pos[1]) * "^"
return (
" |\n" +
" | {}".format(self.line) +
" | " + self.pos[1] * " " + (self.pos[2] - self.pos[1]) * "^"
" {0} |\n".format(gutter_len * " ") +
" {0} | {1}".format(gutter, self.line) +
" {0} | {1}".format(gutter_len * " ", underline)
)
class Problem(): # pylint: disable=too-few-public-methods