Skip to content

Commit 7f22c7c

Browse files
committed
Non-RTL sources can now be added
Non-RTL sources won't be parsed but will be present for LSP features like hovering over or getting definitions of Verilog/SystemVerilog includes
1 parent 61acf67 commit 7f22c7c

File tree

3 files changed

+26
-16
lines changed

3 files changed

+26
-16
lines changed

hdl_checker/database.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
PathLibraryIsNotUnique,
4343
PathNotInProjectFile,
4444
)
45+
from hdl_checker.exceptions import UnknownTypeExtension
4546
from hdl_checker.parser_utils import flattenConfig, getSourceParserFromPath
4647
from hdl_checker.parsers.elements.dependency_spec import (
4748
BaseDependencySpec,
@@ -443,9 +444,15 @@ def _parseSource(self, path):
443444
"""
444445
_logger.debug("Parsing %s", path)
445446

446-
src_parser = getSourceParserFromPath(path)
447-
design_units = src_parser.getDesignUnits()
448-
dependencies = src_parser.getDependencies()
447+
try:
448+
src_parser = getSourceParserFromPath(path)
449+
design_units = src_parser.getDesignUnits()
450+
dependencies = src_parser.getDependencies()
451+
except UnknownTypeExtension:
452+
# Not a file extension we know how to parse, leave design units and
453+
# dependencies empty
454+
design_units = set()
455+
dependencies = set()
449456

450457
with self._lock:
451458
# Update the timestamp

hdl_checker/parser_utils.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -217,21 +217,23 @@ def _expand(config, ref_path):
217217

218218
try:
219219
filetype = FileType.fromPath(path)
220-
except UnknownTypeExtension:
221-
_logger.warning("Won't include non RTL file '%s'", path)
222-
continue
223220

224-
single_flags = flags[filetype][0]
225-
dependencies_flags = flags[filetype][1]
226-
global_flags = flags[filetype][2]
221+
single_flags = flags[filetype][0]
222+
dependencies_flags = flags[filetype][1]
223+
global_flags = flags[filetype][2]
227224

228-
yield SourceEntry(
229-
path,
230-
source.library,
231-
tuple(source.flags),
232-
tuple(global_flags) + tuple(single_flags),
233-
tuple(global_flags) + tuple(dependencies_flags),
234-
)
225+
yield SourceEntry(
226+
path,
227+
source.library,
228+
tuple(source.flags),
229+
tuple(global_flags) + tuple(single_flags),
230+
tuple(global_flags) + tuple(dependencies_flags),
231+
)
232+
233+
except UnknownTypeExtension:
234+
if p.exists(path.abspath) and p.isfile(path.abspath):
235+
_logger.info("Including non-RTL path: '%s'", path)
236+
yield SourceEntry(path, source.library, (), (), ())
235237

236238

237239
def findRtlSourcesByPath(path):

hdl_checker/tests/test_parser_utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,7 @@ def test_ExpandWhenPatternMatchesNonRtlFiles(self):
511511
expected = (
512512
SourceEntry(Path(x), None, (), (), ())
513513
for x in (
514+
self.join("README.md"),
514515
self.join("some_vhd.vhd"),
515516
self.join("some_v.v"),
516517
self.join("some_sv.sv"),

0 commit comments

Comments
 (0)