Skip to content

v0.20.2 — preferred_kinds refactor for _lookup_definition

Choose a tag to compare

@turbyho turbyho released this 13 Jul 15:51
v0.20.2

Overview

Refactors the class/constructor collision fix from v0.20.1 (commit 594058c) into a clean, parameterised API. The internal _lookup_definition function now accepts a preferred_kinds parameter instead of a hardcoded CASE s.kind expression.

Changes

Fixes

  • _lookup_definition — new preferred_kinds keyword parameter replaces hardcoded class/struct priority. Each caller declares which symbol kinds it prefers:
    • get_inheritance_chain, get_class_members: ("class", "struct")
    • get_method_overrides: ("method", "destructor")
    • get_template_instances: None (supports both class and function templates)
    • Callgraph tools: None (existence checks only)
  • Added input validation to guard against future SQL injection through kind values.
  • 24 new tests covering class/constructor collision, namespace fallback, preferred_kinds parameter, and integration tests.
File Change
src/fw_context_mcp/mcp/handlers/source.py Add preferred_kinds param with validation, dynamic CASE building
src/fw_context_mcp/mcp/handlers/inheritance.py Pass explicit preferred_kinds in all 4 tools
src/fw_context_mcp/mcp/handlers/callgraph.py Pass preferred_kinds=None in all 6 existence checks
tests/test_lookup_definition.py 24 tests (new file)

Breaking changes

None.