refactor(frontend): change location format

This commit is contained in:
youben11
2023-08-30 09:55:11 +01:00
committed by Ayoub Benaissa
parent 530bacb2e3
commit 41e1fdf1f8
2 changed files with 19 additions and 6 deletions

View File

@@ -3,6 +3,7 @@
"""Compilation feedback."""
import re
from typing import Dict, Set
# pylint: disable=no-name-in-module,import-error,too-many-instance-attributes
@@ -19,6 +20,10 @@ from .parameter import Parameter
from .wrapper import WrapperCpp
# matches (@tag, separator( | ), filename)
REGEX_LOCATION = r"loc\(\"(@[\w\.]+)?( \| )?(.+)\""
class CompilationFeedback(WrapperCpp):
"""CompilationFeedback is a set of hint computed by the compiler engine."""
@@ -130,8 +135,9 @@ class CompilationFeedback(WrapperCpp):
if statistic.operation not in operations:
continue
file_and_maybe_tag = statistic.location.split("@")
tag = "" if len(file_and_maybe_tag) == 1 else file_and_maybe_tag[1].strip()
tag, _, _ = re.match(REGEX_LOCATION, statistic.location).groups()
# remove the @
tag = tag[1:] if tag else ""
tag_components = tag.split(".")
for i in range(1, len(tag_components) + 1):
@@ -176,8 +182,9 @@ class CompilationFeedback(WrapperCpp):
if statistic.operation not in operations:
continue
file_and_maybe_tag = statistic.location.split("@")
tag = "" if len(file_and_maybe_tag) == 1 else file_and_maybe_tag[1].strip()
tag, _, _ = re.match(REGEX_LOCATION, statistic.location).groups()
# remove the @
tag = tag[1:] if tag else ""
tag_components = tag.split(".")
for i in range(1, len(tag_components) + 1):