Skip to content

Commit 3b1b105

Browse files
committed
Merge branch 'unstable'
2 parents 2a06c68 + a740dab commit 3b1b105

File tree

3 files changed

+39
-33
lines changed

3 files changed

+39
-33
lines changed

hdlcc/handlers.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,13 @@ def getMessagesByPath():
168168
"no content" if content is None else "with content")
169169

170170
server = _getServerByProjectFile(project_file)
171-
return {'messages': server.getMessagesByPath(path)}
171+
response = {}
172+
if content is None:
173+
response['messages'] = server.getMessagesByPath(path)
174+
else:
175+
response['messages'] = server.getMessagesWithText(path, content)
176+
177+
return response
172178

173179
@app.post('/get_ui_messages')
174180
@_exceptionWrapper

hdlcc/parsers/base_parser.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ def __init__(self, filename, library='work', flags=None):
5151
self._content = None
5252
self._mtime = 0
5353
self.filetype = getFileType(self.filename)
54+
5455
self._prev = None
56+
5557
self.abspath = p.abspath(filename)
5658

5759
def getState(self):
@@ -122,7 +124,6 @@ def _changed(self):
122124
provided by p.getmtime
123125
"""
124126
if self.getmtime() > self._mtime:
125-
_logger.debug("File '%s' has changed", self.filename)
126127
return True
127128
return False
128129

@@ -186,7 +187,6 @@ def _setBufferContent(self, content):
186187
buffer_dump_path = self.getDumpPath()
187188
_logger.debug("Dumping buffer content to '%s'", buffer_dump_path)
188189
open(buffer_dump_path, 'w').write(self._content)
189-
return buffer_dump_path
190190

191191
def _clearBufferContent(self):
192192
"""
@@ -204,6 +204,7 @@ def getSourceContent(self):
204204
"""
205205
Cached version of the _getSourceContent method
206206
"""
207+
207208
self._clearCachesIfChanged()
208209

209210
if self._content is None:
@@ -221,7 +222,6 @@ def getRawSourceContent(self):
221222

222223
if self.hasBufferContent():
223224
return self._content
224-
225225
if 'raw_content' not in self._cache or self._changed():
226226
self._cache['raw_content'] = \
227227
open(self.filename, mode='rb').read().decode(errors='ignore')

hdlcc/tests/test_server_handlers.py

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -355,35 +355,35 @@ def build_with_buffer_leave():
355355

356356
# TODO: This test has side effects and makes other tests fail. Skip
357357
# it for now
358-
# @it.should("get messages with content")
359-
# def test():
360-
# data = {
361-
# 'project_file' : it.PROJECT_FILE,
362-
# 'path' : p.join(
363-
# VIM_HDL_EXAMPLES, 'another_library', 'foo.vhd'),
364-
# 'content' : '-- TODO: Nothing to see here'}
365-
366-
# ui_reply = it.app.post('/get_ui_messages', data)
367-
# reply = it.app.post('/get_messages_by_path', data)
368-
369-
# _logger.info("UI reply: %s", ui_reply)
370-
# _logger.info("Reply: %s", reply)
371-
372-
# messages = reply.json['messages']
373-
374-
# for message in messages:
375-
# it.assertTrue(utils.samefile(message.pop('filename'),
376-
# data['path']))
377-
378-
# it.assertIn(
379-
# {"error_type" : "W",
380-
# "checker" : "HDL Code Checker/static",
381-
# "line_number" : 1,
382-
# "column" : 4,
383-
# "error_subtype" : "",
384-
# "error_number" : "0",
385-
# "error_message" : "TODO: Nothing to see here"},
386-
# messages)
358+
@it.should("get messages with content")
359+
def test():
360+
data = {
361+
'project_file' : it.PROJECT_FILE,
362+
'path' : p.join(
363+
VIM_HDL_EXAMPLES, 'another_library', 'foo.vhd'),
364+
'content' : '-- TODO: Nothing to see here'}
365+
366+
ui_reply = it.app.post('/get_ui_messages', data)
367+
reply = it.app.post('/get_messages_by_path', data)
368+
369+
_logger.info("UI reply: %s", ui_reply)
370+
_logger.info("Reply: %s", reply)
371+
372+
messages = reply.json['messages']
373+
374+
for message in messages:
375+
it.assertTrue(utils.samefile(message.pop('filename'),
376+
data['path']))
377+
378+
it.assertIn(
379+
{"error_type" : "W",
380+
"checker" : "HDL Code Checker/static",
381+
"line_number" : 1,
382+
"column" : 4,
383+
"error_subtype" : "",
384+
"error_number" : "0",
385+
"error_message" : "TODO: Nothing to see here"},
386+
messages)
387387

388388
@it.should("get source dependencies")
389389
@mock.patch('hdlcc.config_parser.foundVunit', lambda: False)

0 commit comments

Comments
 (0)