Skip to content

Feature: AI-powered implementation stub generation from MAP/CLASS declarations #53

@msarson

Description

@msarson

Overview

When a procedure is declared in a MAP or a CLASS interface, the implementation body doesn't exist yet. The extension already knows the full signature, parameter types, return type, CLASS hierarchy, and surrounding scope. This is ideal context for AI-powered stub generation — producing a skeleton implementation that the developer can fill in.

Example

Given a MAP declaration:

KanbanProcess_Kanban  PROCEDURE(KanbanWrapperClass pKanban)

Generate:

ThisWindow.KanbanProcess_Kanban  PROCEDURE(KanbanWrapperClass pKanban)
  CODE
    ! TODO: Implement KanbanProcess_Kanban
    RETURN

Or for a CLASS with an interface, generate all required method stubs at once.

Why the Clarion Extension Is Well-Positioned

The LSP already has everything needed as AI context:

  • Full procedure signature (parameters, return type, attributes like PROC, VIRTUAL, DERIVED)
  • CLASS hierarchy — knows which interface methods are required
  • Surrounding scope — knows what variables/types are in play
  • DocumentStructure scope tree — knows where the implementation section should go
  • SolutionManager — knows the full project structure

This makes AI generation significantly more accurate than generic Copilot completions, which have no Clarion-specific knowledge.

Use Cases

  1. MAP procedure stub — declare in MAP, generate implementation body in the CODE section
  2. CLASS interface stub — declare a CLASS that implements an interface, generate all required method stubs at once
  3. Signature-driven generation — infer likely body from procedure name + parameter types + return type

Implementation Approaches

These are not mutually exclusive:

  • VS Code Chat Participant (@clarion) — user asks @clarion generate stubs for ThisWindow and the participant uses LSP knowledge to produce them
  • VS Code Language Model Tool — extension registers a clarion_generateStub tool that Copilot can call during inline completions
  • Code Action — a lightbulb/quick-fix on a MAP declaration that offers "Generate implementation stub"

The Code Action approach is the most discoverable and requires no separate AI integration — it could use the VS Code LM API (vscode.lm.selectChatModels) to call the model with the signature as context.

Relationship to Other Issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions