Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

graceful degredation when given out-of-bounds line numbers #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion libcpychecker_html/make_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ def head(self):
'http-equiv': 'Content-Type',
'content': 'text/html; charset=utf-8'
}),
E.TITLE('%s -- GCC Python Plugin' % self.data['filename']),
# get_string() _mysql.c -- GCC Python Plugin
E.TITLE('%s() %s -- GCC Python Plugin' % (
self.data['function']['name'],
self.data['filename'],
)),
)
head.extend(
E.STYLE(
Expand Down
16 changes: 9 additions & 7 deletions libcpychecker_html/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,22 @@ $(function() {
// backwards, that starts a new subflow
var $states = $report.find('.states li');
var source_flow = [];
var last_line = null;
var last_line = Infinity;
$states.each(function() {
var $state = $(this);
var lineno = parseInt($state.data('line'), 10);
var $assoc_line = $line_index[lineno];

if ( $assoc_line === undefined ) {
// The commentary mentioned a line that we're not showing.
return;
}
$state.data('line-element', $assoc_line);
$state.prepend($('<h2>').text(String(lineno)));

var flow;
if (! last_line || last_line >= lineno) {
// Mark commentary that starts a new subflow (but not the
// first)
if (last_line >= lineno) {
// This is a new subflow, possibly the first.
if (source_flow.length) {
$state.addClass('new-subflow');
}
Expand Down Expand Up @@ -97,11 +101,9 @@ $(function() {
flow.shift();
}
// Lines between the start and end of a subflow, or before the
// start of the first subflow, or after the end of the last
// subflow, get undotted lines
// start of the first subflow get undotted lines
else if (
(idx == 0 && flow.length) ||
(idx == source_flow.length - 1 && ! flow.length) ||
(started[idx] && flow.length)
) {
$paths = $paths.add($('<td>', { "class": "flow-line" }).html('&#x200b;'));
Expand Down
1 change: 1 addition & 0 deletions libcpychecker_html/style-noprefix.css
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ img {
}
.states li.new-subflow {
border-top-width: 4px;
border-top-color: black;
}
.states h2 {
float: right;
Expand Down
1 change: 1 addition & 0 deletions libcpychecker_html/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ img {
}
.states li.new-subflow {
border-top-width: 4px;
border-top-color: black;
}
.states h2 {
float: right;
Expand Down