(context: vscode.ExtensionContext)
| 26 | } |
| 27 | |
| 28 | export async function activate(context: vscode.ExtensionContext): Promise<void> { |
| 29 | // ── Core infrastructure ─────────────────────────────────────────────────── |
| 30 | const client = new CgcMcpClient(context); |
| 31 | const jobPoller = new JobPoller(new CgcService(client)); // use service on client before full start |
| 32 | |
| 33 | try { |
| 34 | await client.ensureStarted(); |
| 35 | cgcEvents.emit("mcp:online"); |
| 36 | } catch (err) { |
| 37 | cgcEvents.emit("mcp:offline"); |
| 38 | vscode.window.showWarningMessage( |
| 39 | `CGC: Could not start MCP server — ${String(err)}. Check the CGC output channel.` |
| 40 | ); |
| 41 | } |
| 42 | |
| 43 | const service = new CgcService(client); |
| 44 | const statusBar = new CgcStatusBarItem(client); |
| 45 | |
| 46 | // ── UI providers ────────────────────────────────────────────────────────── |
| 47 | const callGraphPanel = new CallGraphPanel(service); |
| 48 | const dashboardPanel = new DashboardPanel(service, client); |
| 49 | const sidebarControl = new SidebarControlPanel(service, client, context); |
| 50 | |
| 51 | const diagnostics = new CgcDeadCodeDiagnostics(service); |
| 52 | const codeLensProvider = new CgcCodeLensProvider(service); |
| 53 | const hoverProvider = new CgcHoverProvider(service); |
| 54 | |
| 55 | const bundlesProvider = new BundlesTreeProvider(service); |
| 56 | const contextManager = new ContextManager(service, sidebarControl); |
| 57 | |
| 58 | contextManager.initializeContext().catch(err => { |
| 59 | console.error("CGC: Context initialization failed", err); |
| 60 | }); |
| 61 | |
| 62 | // ─── Menu Context Management ──────────────────────────────────────────────── |
| 63 | const updateMenuContext = (editor: vscode.TextEditor | undefined) => { |
| 64 | if (!editor) return; |
| 65 | const pos = editor.selection.active; |
| 66 | const lineText = editor.document.lineAt(pos.line).text; |
| 67 | const isClass = /^\s*(?:pub\s+|private\s+|protected\s+|public\s+|static\s+|export\s+)?(?:class|interface|struct|enum|trait|protocol)\b/.test(lineText); |
| 68 | const isFunction = /^\s*(?:pub\s+|private\s+|protected\s+|public\s+|static\s+|async\s+|export\s+)?(?:fun|fn|func|def|function|sub|method)\b/.test(lineText); |
| 69 | |
| 70 | vscode.commands.executeCommand("setContext", "cgc:isClass", isClass); |
| 71 | vscode.commands.executeCommand("setContext", "cgc:isFunction", isFunction); |
| 72 | }; |
| 73 | |
| 74 | context.subscriptions.push( |
| 75 | vscode.window.onDidChangeTextEditorSelection(e => updateMenuContext(e.textEditor)), |
| 76 | vscode.window.onDidChangeActiveTextEditor(updateMenuContext) |
| 77 | ); |
| 78 | updateMenuContext(vscode.window.activeTextEditor); |
| 79 | |
| 80 | const previousSignatures = new Map<string, string>(); |
| 81 | const watcher = vscode.workspace.createFileSystemWatcher("**/.codegraphcontext/**"); |
| 82 | |
| 83 | context.subscriptions.push( |
| 84 | statusBar, |
| 85 | jobPoller, |
nothing calls this directly
no test coverage detected