some progress but eh

This commit is contained in:
Ivar Fatland
2026-05-03 16:56:40 +02:00
parent 685387f77f
commit 4cf6720f2f
2 changed files with 16 additions and 15 deletions
+1 -1
View File
@@ -28,7 +28,7 @@ class Tags:
def _update_cache(self): def _update_cache(self):
self._cache = {} self._cache = {}
with self.TAGS_PATH.open('r') as f: 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: for line in lines:
symbol, file, location, type, *_ = line.split('\t') symbol, file, location, type, *_ = line.split('\t')
location = location.removesuffix(';"') location = location.removesuffix(';"')
+8 -7
View File
@@ -1,15 +1,15 @@
import re import re
from pathlib import Path 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. tags_path = Path(__file__).parent.resolve() / 'tags'
def test_parsing(): tags = (tag for tags in Tags(tags_path=tags_path).symbols.values() for tag in tags)
tags_path = Path(__file__).parent.resolve() / 'tags'
tags = Tags(tags_path=tags_path) @pytest.mark.parametrize("tag", tags)
for tags in tags.symbols.values(): def test_tag(tag: Tag):
for tag in tags:
assert len(tag.type) == 1 assert len(tag.type) == 1
assert tag.file.is_file() assert tag.file.is_file()
text = tag.file.read_text() text = tag.file.read_text()
@@ -17,3 +17,4 @@ def test_parsing():
assert next(tag.location.finditer(text), None) is not None, f'{tag.location.pattern} has no matches in {tag.file}' assert next(tag.location.finditer(text), None) is not None, f'{tag.location.pattern} has no matches in {tag.file}'
else: else:
assert text.count('\n') >= tag.location assert text.count('\n') >= tag.location
assert tag.symbol in text.splitlines()[tag.location-1]