🔧 chore(symbol): trace per-library file indexing

- Log each indexed .tsf file at trace level during LoadSystemLibrary.
- Include top-level symbol summary when a file is skipped for stem mismatch.
This commit is contained in:
csh 2025-12-14 14:06:24 +08:00
parent 9a12b1b194
commit e75027b80a
1 changed files with 45 additions and 1 deletions

View File

@ -248,6 +248,44 @@ namespace lsp::manager
}
return false;
}
std::string DescribeTopLevelSymbols(const language::symbol::SymbolTable& table)
{
std::vector<std::string> parts;
for (const auto& wrapper : table.all_definitions())
{
const auto& symbol = wrapper.get();
switch (symbol.kind())
{
case protocol::SymbolKind::Function:
parts.push_back("function:" + symbol.name());
break;
case protocol::SymbolKind::Class:
parts.push_back("class:" + symbol.name());
break;
case protocol::SymbolKind::Module:
parts.push_back("unit:" + symbol.name());
break;
default:
break;
}
}
if (parts.empty())
{
return "<none>";
}
std::string result;
for (std::size_t i = 0; i < parts.size(); ++i)
{
if (i > 0)
{
result += ", ";
}
result += parts[i];
}
return result;
}
}
Symbol::Symbol(EventBus& event_bus) : event_bus_(event_bus)
@ -293,9 +331,12 @@ namespace lsp::manager
continue;
}
spdlog::trace("Indexing library file: {}", entry.path().string());
auto table = BuildSymbolTableFromFile(entry.path());
if (!table)
{
spdlog::trace("Failed to build symbol table for: {}", entry.path().string());
++failed;
continue;
}
@ -303,7 +344,10 @@ namespace lsp::manager
auto stem = entry.path().stem().string();
if (!HasMatchingTopLevelSymbol(*table, stem))
{
spdlog::warn("Skipping system file {}: top-level symbol does not match file name", entry.path().string());
spdlog::warn("Skipping system file {}: top-level symbol does not match file name (stem='{}', top-level={})",
entry.path().string(),
stem,
DescribeTopLevelSymbols(*table));
++failed;
continue;
}