From 4cf6720f2f0e3f04da8b5715007f080c0a286df3 Mon Sep 17 00:00:00 2001 From: Ivar Fatland Date: Sun, 3 May 2026 16:56:40 +0200 Subject: [PATCH] some progress but eh --- ctags-ls/src/ctags_ls/tags.py | 2 +- ctags-ls/tests/test_Tags_parsing.py | 29 +++++++++++++++-------------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/ctags-ls/src/ctags_ls/tags.py b/ctags-ls/src/ctags_ls/tags.py index 0db1846..cf30767 100644 --- a/ctags-ls/src/ctags_ls/tags.py +++ b/ctags-ls/src/ctags_ls/tags.py @@ -28,7 +28,7 @@ class Tags: def _update_cache(self): self._cache = {} with self.TAGS_PATH.open('r') as f: - lines = (l for l in f.readlines() if not l.startswith('!_')) + lines = (l for l in f.readlines() if not l.startswith('!_') and not l.startswith('__anon')) for line in lines: symbol, file, location, type, *_ = line.split('\t') location = location.removesuffix(';"') diff --git a/ctags-ls/tests/test_Tags_parsing.py b/ctags-ls/tests/test_Tags_parsing.py index 9d360a8..69ed3aa 100644 --- a/ctags-ls/tests/test_Tags_parsing.py +++ b/ctags-ls/tests/test_Tags_parsing.py @@ -1,19 +1,20 @@ import re from pathlib import Path -from ctags_ls.tags import Tags +from ctags_ls.tags import Tag, Tags +import pytest -# TODO: generate the tags file dynamically as preperation to the test. -def test_parsing(): - tags_path = Path(__file__).parent.resolve() / 'tags' - tags = Tags(tags_path=tags_path) - for tags in tags.symbols.values(): - for tag in tags: - assert len(tag.type) == 1 - assert tag.file.is_file() - text = tag.file.read_text() - if isinstance(tag.location, re.Pattern): - assert next(tag.location.finditer(text), None) is not None, f'{tag.location.pattern} has no matches in {tag.file}' - else: - assert text.count('\n') >= tag.location +tags_path = Path(__file__).parent.resolve() / 'tags' +tags = (tag for tags in Tags(tags_path=tags_path).symbols.values() for tag in tags) + +@pytest.mark.parametrize("tag", tags) +def test_tag(tag: Tag): + assert len(tag.type) == 1 + assert tag.file.is_file() + text = tag.file.read_text() + if isinstance(tag.location, re.Pattern): + assert next(tag.location.finditer(text), None) is not None, f'{tag.location.pattern} has no matches in {tag.file}' + else: + assert text.count('\n') >= tag.location + assert tag.symbol in text.splitlines()[tag.location-1]