Skip to content

Commit

Permalink
Support env comments with relevant tag (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
alekseevk1 authored Mar 9, 2024
1 parent 8183e2c commit 736e0cf
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
13 changes: 10 additions & 3 deletions web/reports/etv.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def add_line(self, edge, index):
raise ValueError("Global initialization edge can't contain enter")
if line_data['code'] is not None:
line_data.update(
self.__get_comment(edge.get('note'), edge.get('warn'), edge.get('env')))
self.__get_comment(edge))
self.global_lines.append(line_data)
return

Expand Down Expand Up @@ -233,7 +233,7 @@ def add_line(self, edge, index):
action_file = self.files[edge['original file']]
line_data.update(self.__enter_action(new_action, action_line, action_file))

line_data.update(self.__get_comment(edge.get('note'), edge.get('warn'), edge.get('env')))
line_data.update(self.__get_comment(edge))

if 'enter' in edge:
line_data.update(self.__enter_function(
Expand Down Expand Up @@ -333,8 +333,11 @@ def __return_all(self):
while self.scope.can_return():
self.__return(if_possible=True)

def __get_comment(self, note, warn, env):
def __get_comment(self, edge):
new_data = {}
warn = edge.get('warn')
note = edge.get('note')
env = edge.get('env')
if warn is not None:
self.scope.show_current_scope('warning')
new_data['warning'] = re.sub(r'\s+', ' ', warn)
Expand All @@ -352,6 +355,10 @@ def __get_comment(self, note, warn, env):
elif env is not None:
self.scope.show_current_scope('env')
new_data['env'] = re.sub(r'\s+', ' ', env)
env_relevant = edge.get('env_relevant')
if env_relevant is not None:
self.scope.show_current_scope('env_relevant')
new_data['env_relevant'] = env_relevant
return new_data

def __add_assumptions(self, assumption):
Expand Down
4 changes: 4 additions & 0 deletions web/reports/static/reports/css/ETV.css
Original file line number Diff line number Diff line change
Expand Up @@ -265,3 +265,7 @@
.ETV_ShowCode {
cursor: pointer;
}

.irrelevant_env_comment {
font-weight: normal;
}
2 changes: 1 addition & 1 deletion web/reports/templates/reports/ErrorTrace.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
{% if l.env %}
<span class="{{ l.scope }}" data-thread="{{ l.thread_id }}" data-type="comment">
<span class="ETV_LN"><span class="ETV_ID" hidden>{{l.id}}</span><span class="ETV_THREAD">{{ l.thread|safe }}</span>{{ l.line_offset }}{% if l.line %}<a class="ETV_La">{{ l.line }}</a><span class="ETV_File" hidden>{{ l.file }}</span>{% endif %}</span>
<span class="ETV_LC">{{ l.offset }}<a class="ETV_ShowCommentCode ETV_CallbackAction">{{ l.env }}</a></span><br>
<span class="ETV_LC">{{ l.offset }}<a class="ETV_ShowCommentCode ETV_CallbackAction {% if not l.env_relevant %}irrelevant_env_comment{% endif%}">{{ l.env }}</a></span><br>
</span>
{% endif %}
{% if l.warning %}
Expand Down

0 comments on commit 736e0cf

Please sign in to comment.