diff options
| author | Thomas Tanner <trtanner@btinternet.com> | 2015-12-12 11:51:05 +0000 |
|---|---|---|
| committer | Thomas Tanner <trtanner@btinternet.com> | 2015-12-12 11:51:05 +0000 |
| commit | a3a4d5441daf16de8c17a1e35857c48307cfa281 (patch) | |
| tree | baff9894a05d0dcc76da5ac7b0066dc884092430 /massage_messages.py | |
| parent | 7b087f8f9d94b3758b3dad8d29670cd73d058510 (diff) | |
Full details from include what you use for qt creator 'issue' box
Diffstat (limited to 'massage_messages.py')
| -rw-r--r-- | massage_messages.py | 85 |
1 files changed, 52 insertions, 33 deletions
diff --git a/massage_messages.py b/massage_messages.py index 249068ba..5657f6b4 100644 --- a/massage_messages.py +++ b/massage_messages.py @@ -28,11 +28,14 @@ class QWidget; namespace Ui { class AboutDialog; } // lines 31-31 --- """ + removing = None +includes = dict() -includes = dict +adding = None +added = dict() -foundline = 0 +foundline = None errors = False @@ -45,34 +48,49 @@ def process_next_line(line, outfile): global includes global foundline global errors + global added + global adding line = line.rstrip() print >> outfile, line - if removing: - if line == '': - removing = None - print - return + + if line.endswith(' should remove these lines:'): + adding = None + removing = (line.split(' '))[0] + elif line.endswith(' should add these lines:'): + removing = None + adding = (line.split(' '))[0] + elif line == '' or line.startswith(' the full include-list'): + adding = None + removing = None + elif adding: + m = re.match(r'.*class (.*);', line) + if m: + added[m.group(1)] = (adding, line) else: - # Really we should stash these so that if we get a 'class xxx' in - # the add lines we can print it here. also we could do the case - # fixing. - m = re.match(r'- #include [<"](.*)[">] +// lines (.*)-', line) + added[line] = (adding, line) + elif removing: + # Really we should stash these so that if we get a 'class xxx' in + # the add lines we can print it here. also we could do the case + # fixing. + m = re.match(r'- #include [<"](.*)[">] +// lines (.*)-', line) + if m: + foundline = m.group(2) + print '%s(%s) : warning I0001: Unnecessary include of %s' %\ + (removing, m.group(2), m.group(1)) + if m.group(1) in added: + print ' %s(%s) : note: Use forward reference %s' % ( + removing, m.group(2), added[m.group(1)][1]) + del added[m.group(1)] + else: + m = re.match(r'- (.*) +// lines (.*)-', line) if m: - # If there is an added line with the same class, print it here - print '%s(%s) : warning I0001: Unnecessary include of %s' %\ - (removing, m.group(2), m.group(1)) - foundline = m.group(1) + foundline = m.group(2) + print '%s(%s) : warning I0002: '\ + 'Unnecessary forward ref of %s' %\ + (removing, m.group(2), m.group(1)) else: - m = re.match(r'- (.*) +// lines (.*)-', line) - if m: - print '%s(%s) : warning I0002: '\ - 'Unnecessary forward ref of %s' %\ - (removing, m.group(2), m.group(1)) - foundline = m.group(1) - else: - print '********* I got confused **********' - - if line.startswith('In file included from'): + print '********* I got confused **********' + elif line.startswith('In file included from'): line = re.sub(r'^(In file included from)(.*):(\d+):', r' \2(\3) : \1 here', line) @@ -88,14 +106,6 @@ def process_next_line(line, outfile): errors = True print line - if line.endswith(' should remove these lines:'): - removing = (line.split(' '))[0] - elif line.endswith(' should add these lines:'): - adding = (line.split(' '))[0] - -# also process the other lines - - # added lines should come after the first entry with a line number. outfile = open(sys.argv[1], 'w') process = subprocess.Popen(sys.argv[2:], @@ -107,6 +117,15 @@ while True: if output: process_next_line(output, outfile) +# A note: We should probably do some work as we use the source code line for +# messages in include files... + +if foundline is None: + foundline = '1' +for add in added: + print '%s(%s) : warning I0003: Need to include %s' % ( + added[add][0], foundline, added[add][1]) + rc = process.poll() # The return code you get appears to be more to do with the amount of output # generated than any real error, so instead we should error if any ': error:' |
