Misar IO Docs

Code Lens

Contextual AI actions displayed above every function and class definition for instant explain, refactor, and test generation.

Overview

Code Lens places clickable AI action links directly above every function and class definition in your source files. No need to open the chat panel or right-click — the actions are always visible inline as you read code.

The Three Actions

Each function or class shows three lenses:

| Lens | What It Does | |------|-------------| | Explain | Opens the Misar Code sidebar with a plain-language explanation of the symbol — logic flow, parameters, return values, and edge cases | | Refactor | Asks the agent to improve the symbol's structure, naming, and patterns while preserving its behavior | | Test | Generates a suite of unit tests for the symbol and optionally runs them |

Enabling / Disabling

  1. Open Settings (Cmd+, / Ctrl+,)
  2. Search for misarCode codeLens
  3. Toggle Misar Code: Code Lens
{
  "misarCode.codeLens": true
}

Code Lens is enabled by default. Disabling it removes the lenses from all files without affecting other Misar Code features.

How It Works

When you open a file, the Code Lens provider scans the document for function declarations, arrow functions, class declarations, and method definitions.

A lens line is inserted above each detected symbol with the three action links.

Clicking a lens opens the Misar Code sidebar chat panel (if not already open) and pre-fills a message with the symbol name, file path, and line range.

The agent receives the symbol's exact source code as context, so its response is scoped to that function or class — not the whole file.

Symbol-Level Context

When you click a Code Lens action, the agent receives:

  • The full source text of the symbol
  • The symbol name and type (function, class, method, arrow function)
  • The file path and line range
  • Any diagnostics (errors/warnings) reported by VS Code on that symbol

This targeted context produces more precise and actionable responses than sending the full file.

Supported Symbol Types

  • function declarations
  • const/let arrow function assignments
  • class declarations
  • Class method definitions (including async, static, get/set)
  • Exported functions and classes

For best results with the Test lens, make sure the file already has at least one import or test file the agent can use as a style reference. The agent will match the existing test framework (Jest, Vitest, pytest, etc.) automatically.

Configuration Reference

| Setting | Type | Default | Description | |---------|------|---------|-------------| | misarCode.codeLens | boolean | true | Enable or disable Code Lens on all files |