Skip to content

Add missing before/on/after plugin hooks across compiler event lifecycle#1707

Draft
Copilot wants to merge 5 commits into
masterfrom
copilot/ensure-before-action-during-after-events
Draft

Add missing before/on/after plugin hooks across compiler event lifecycle#1707
Copilot wants to merge 5 commits into
masterfrom
copilot/ensure-before-action-during-after-events

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 12, 2026

The plugin API still had lifecycle gaps where some event families exposed only before/after or only on-style hooks. This change completes the lifecycle contract so plugin authors can consistently hook into before, during, and after phases across program, file, scope, and language-service events.

  • Plugin API surface: complete event triads

    • Added missing hook variants in Plugin (before*, on*, after*) for event families that were incomplete, including:
      • program create/validate/transpile/dispose
      • prepublish/publish
      • file parse/transpile/dispose
      • scope create/dispose
      • code actions, source fix-all actions, semantic tokens
    • Added corresponding event type aliases for new lifecycle phases (e.g. OnFileTranspileEvent, OnProgramDisposeEvent, AfterProgramDisposeEvent).
  • Runtime emission flow: wire new lifecycle phases

    • Emitted newly introduced on* and missing before*/after* hooks at the correct points in:
      • ProgramBuilder lifecycle (createProgram, prepublish/publish pipeline)
      • Program lifecycle (parse, validate, transpile, dispose, query APIs)
    • Preserved existing hooks and ordering while inserting missing lifecycle phases.
  • Tests: verify new hook coverage

    • Expanded plugin event tests to assert new triads are emitted:
      • program creation and validation phases
      • file/scope disposal (XML + BRS paths)
      • code-action-like query hooks
      • transpile lifecycle on* hooks
  • Docs: align plugin lifecycle documentation

    • Updated docs/plugins.md lifecycle and API sections to reflect new triad hooks and naming.
    • Clarified beforeProgramCreate (ProgramBuilder) vs on/afterProgramCreate (Program) semantics.

Example of the new lifecycle consistency:

const plugin = {
  name: 'example',
  beforeGetCodeActions: (event) => { /* pre-process */ },
  onGetCodeActions: (event) => { /* contribute actions */ },
  afterGetCodeActions: (event) => { /* post-process/sanitize */ }
};

Copilot AI and others added 4 commits May 12, 2026 16:24
Agent-Logs-Url: https://github.com/rokucommunity/brighterscript/sessions/a7fc302f-ff61-4651-b61a-5bd4306ce21f

Co-authored-by: TwitchBronBron <2544493+TwitchBronBron@users.noreply.github.com>
Agent-Logs-Url: https://github.com/rokucommunity/brighterscript/sessions/a7fc302f-ff61-4651-b61a-5bd4306ce21f

Co-authored-by: TwitchBronBron <2544493+TwitchBronBron@users.noreply.github.com>
Agent-Logs-Url: https://github.com/rokucommunity/brighterscript/sessions/a7fc302f-ff61-4651-b61a-5bd4306ce21f

Co-authored-by: TwitchBronBron <2544493+TwitchBronBron@users.noreply.github.com>
Agent-Logs-Url: https://github.com/rokucommunity/brighterscript/sessions/a7fc302f-ff61-4651-b61a-5bd4306ce21f

Co-authored-by: TwitchBronBron <2544493+TwitchBronBron@users.noreply.github.com>
Copilot AI changed the title [WIP] Ensure every plugin event has beforeAction, action, and afterAction Add missing before/on/after plugin hooks across compiler event lifecycle May 12, 2026
Copilot AI requested a review from TwitchBronBron May 12, 2026 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ensure we have beforeAction/action/AfterAction for every single plugin event

2 participants