feat(mcp): Extract return type hints and ImGui scopes in code outline

This commit is contained in:
2026-05-13 17:22:34 -04:00
parent 8cbd232db0
commit 51be7d7405
2 changed files with 77 additions and 4 deletions
+42
View File
@@ -0,0 +1,42 @@
import pytest
import ast
from pathlib import Path
from src.outline_tool import CodeOutliner
def test_code_outliner_type_hints():
code = """
class Test:
def my_method(self, x: int) -> str:
return "hello"
def my_func(a: bool) -> None:
pass
"""
outliner = CodeOutliner()
result = outliner.outline(code)
assert "[Method] my_method -> str (Lines 3-4)" in result
assert "[Func] my_func -> None (Lines 6-7)" in result
def test_code_outliner_imgui_scopes():
code = """
def render_gui() -> None:
with imscope.window("My Window"):
imgui.text("Hello")
with imscope.child("My Child"):
pass
"""
outliner = CodeOutliner()
result = outliner.outline(code)
assert "[ImGui Scope] imscope.window('My Window') (Lines 3-6)" in result
assert "[ImGui Scope] imscope.child('My Child') (Lines 5-6)" in result
def test_code_outliner_nested_ifs():
code = """
def render_gui() -> None:
if True:
with imscope.window("My Window"):
pass
"""
outliner = CodeOutliner()
result = outliner.outline(code)
assert "[ImGui Scope] imscope.window('My Window') (Lines 4-5)" in result