forked from CodeGraphContext/CodeGraphContext
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvisualizer.py
More file actions
51 lines (42 loc) · 1.86 KB
/
Copy pathvisualizer.py
File metadata and controls
51 lines (42 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# src/codegraphcontext/cli/visualizer.py
import urllib.parse
from typing import Optional, List, Dict, Any, Set
from pathlib import Path
from .cli_helpers import visualize_helper
def check_visual_flag(ctx, visual: bool, cypher_query: str = None):
"""
Helper to check the --visual flag and launch the visualizer.
This is called from within analyze/find commands.
"""
if visual and cypher_query:
# We start the visualizer on port 8000
# Passing empty repo handles showing just the query results
port = 8000
encoded_query = urllib.parse.quote(cypher_query)
visualization_url = f"http://localhost:{port}/explore?cypher_query={encoded_query}"
from rich.console import Console
console = Console(stderr=True)
console.print(f"[green]Starting visualizer...[/green]")
console.print(f"[cyan]Visualizing results at:[/cyan] {visualization_url}")
# Start the backend server and open the browser
visualize_helper(repo_path=None, port=port)
return True
return False
def visualize_call_graph(cypher_query: str):
"""Visualize a call graph result."""
visualize_helper(repo_path=None, port=8000)
def visualize_call_chain(cypher_query: str):
"""Visualize a call chain result."""
visualize_helper(repo_path=None, port=8000)
def visualize_dependencies(cypher_query: str):
"""Visualize code dependencies."""
visualize_helper(repo_path=None, port=8000)
def visualize_inheritance_tree(cypher_query: str):
"""Visualize class inheritance tree."""
visualize_helper(repo_path=None, port=8000)
def visualize_overrides(cypher_query: str):
"""Visualize method overrides."""
visualize_helper(repo_path=None, port=8000)
def visualize_search_results(cypher_query: str):
"""Visualize search results."""
visualize_helper(repo_path=None, port=8000)