# coffeechaton/vscode-autohotkey-nekohelp architecture

> Architecture diagram of the GitHub repository coffeechaton/vscode-autohotkey-nekohelp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/coffeechaton/vscode-autohotkey-nekohelp
- Repository: https://github.com/coffeechaton/vscode-autohotkey-nekohelp

## Overview

##### Main Components
- Extension Entry Point:
– Highlight the central entry file (src/extension.ts) that registers the extension with the VS Code host. This is where the extension “boots up” and wire up all the services.
- Core Parsing & Analysis:
– Include the “core” components (found in directories such as src/core and src/AhkSymbol) that are responsible for parsing AutoHotkey source code, generating Abstract Syntax Trees (ASTs), and performing symbol analysis.
- Feature Providers:
– Show a container for various language feature providers (located in src/provider). These include modules such as:
- CallHierarchyProvider (for symbol hierarchy)
- CodeActionProvider (for quick actions like error-level templates, adding gui names, etc.)
- CodeLensProvider (to display inline references and annotations)
- CompletionItemProvider (for auto-completion of functions, variables, #Include, classes, etc.)
- Diagnostic (for linting and warnings)
- Hover (for showing function information, documentation, etc.)
- SignatureHelpProvider (for parameter hints during function calls)
- and others like Rename, SemanticTokensProvider, SymbolProvider, WorkspaceSymbolProvider.
- Commands:
– Represent the discrete commands (found in src/command) that the extension registers (e.g., “GotoDefinition”, “FormatAllFile”, “ListAllFunc”, etc.). These use the core modules and providers to perform actions.
- Tools & Utilities:
- File system operations, string processing, AST generation, formatting helpers, and other specialized tool scripts.
- UI & Data Support:
– Include configuration and UI-related components such as configuration files (e.g. src/configUI.ts) and localized resources (found under i18n, doc, and data). Also note that syntaxes and grammar definitions (in the syntaxes folder) are used to implement language highlighting rules.
- Integration with VS Code API:
– An outer layer showing the extension running inside the VS Code Extension Host, which receives events (like file open, hover, click) and dispatches them to the various providers/commands.

##### Relationships and Data Flow
- The VS Code extension host communicates with the Extension Entry Point (src/extension.ts). From there, the entry point initializes and registers all language feature providers and commands.
- When an editor event occurs (hover, completion request, “F12” for definition, etc.), the corresponding provider (hover, completion, or code lens) is activated.
- Each provider typically calls into the Core Parser and Tools modules to analyze the open document. For example, the Completion Provider in src/provider/CompletionItem will parse a file (using modules in src/core and src/AhkSymbol) and then compute and return suggestions.
- Commands (from src/command) are triggered by user interactions and use the same underlying core and tool modules to perform operations such as refactoring, formatting, or generating a diagnostic report.
- Data files (in data and doc) support the functioning of the extension for built-in snippets, diagnostic rules, and documentation (for example, the VBA API mappings or built-in variables).

##### Architectural Patterns and Design Principles
- Modular Design: The project is organized into clear modules (providers, commands, core parsing, tools) that interact by well-defined APIs. This separation of concerns is essential in VS Code extensions.
- Provider Pattern: Each feature is built as a “provider” that is registered with VS Code under the appropriate language feature (e.g., HoverProvider, CompletionItemProvider, etc.).
- Event-Driven and Dependency Injection: The extension registers functions with the VS Code event system for actions such as file changes, hover events, etc.
- Utility Layer: There exists a set of helper modules (tools) that abstract common functionality, allowing the higher-level components to remain focused.

##### Relevant Technologies and Frameworks
- TypeScript as the source language (note the .ts files in src).
- Node.js modules and ecosystem (with package.json and pnpm-lock.yaml).
- Integration with the VS Code Extension API.
- Linting and configuration via ESLint, Pre-commit hooks (husky), and editor configurations (.editorconfig, .eslintrc.json).
- Testing frameworks are visible as some tests exist in src/test.

##### Final Detailed Elements
– Include a service layer “Core Parsing & Analysis” that is used by multiple feature providers.
– Indicate how the “Commands” module interacts with both the UI (triggered by user input) and the core logic.
– Optionally, represent the “Tools & Utilities” layer supporting both providers and commands.
– Mark external resources such as configuration files (i18n, data) that feed into the extension’s runtime behavior.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global External Component
    Host["VS Code Extension Host"]:::external

    %% Extension Layer
    subgraph "Extension Layer"
        EEP["Extension Entry Point"]:::core
    end

    %% Core Parsing & Analysis
    subgraph "Core Parsing & Analysis"
        PM["Parser Modules"]:::core
        ASA["AHK Symbol Analysis"]:::core
    end

    %% Feature Providers
    subgraph "Feature Providers"
        CH["Call Hierarchy Provider"]:::provider
        CA["Code Action Provider"]:::provider
        CL["Code Lens Provider"]:::provider
        CI["Completion Item Provider"]:::provider
        DI["Diagnostic Provider"]:::provider
        HO["Hover Provider"]:::provider
        SH["Signature Help Provider"]:::provider
        RE["Rename Provider"]:::provider
        ST["Semantic Tokens Provider"]:::provider
        SP["Symbol Provider"]:::provider
        WS["Workspace Symbol Provider"]:::provider
        IH["Inlay Hints Provider"]:::provider
        RF["Reference Provider"]:::provider
    end

    %% Commands
    subgraph "Commands"
        CHD["Command Handlers"]:::command
    end

    %% Tools & Utilities
    subgraph "Tools & Utilities"
        TU["Tools Modules"]:::tools
    end

    %% UI & Data Support
    subgraph "UI & Data Support"
        CU["Configuration UI"]:::ui
        CD["Configuration Data"]:::ui
        L["Localization"]:::ui
        DOC["Documentation"]:::ui
        DA["Data Assets"]:::ui
        SHL["Syntax Highlighting"]:::ui
    end

    %% Connections
    Host -->|"EventRegistration"| EEP

    %% Extension Entry Point registers Providers and Commands
    EEP -->|"register"| CH
    EEP -->|"register"| CA
    EEP -->|"register"| CL
    EEP -->|"register"| CI
    EEP -->|"register"| DI
    EEP -->|"register"| HO
    EEP -->|"register"| SH
    EEP -->|"register"| RE
    EEP -->|"register"| ST
    EEP -->|"register"| SP
    EEP -->|"register"| WS
    EEP -->|"register"| IH
    EEP -->|"register"| RF
    EEP -->|"register"| CHD

    %% Extension Entry Point loads UI & Data
    EEP -->|"loads"| CU
    EEP -->|"loads"| CD
    EEP -->|"loads"| L
    EEP -->|"loads"| DOC
    EEP -->|"loads"| DA
    EEP -->|"loads"| SHL

    %% Providers use Core Parsing & Analysis & Tools
    CI -->|"uses"| PM
    CA -->|"analyzes"| ASA
    CI -->|"utilizes"| TU

    %% Commands depend on Core Parsing & Analysis and Tools
    CHD -->|"parses"| PM
    CHD -->|"utilizes"| TU

    %% Styles
    classDef external fill:#ffcccc,stroke:#cc0000,stroke-width:2px,color:#000000
    classDef core fill:#ccffcc,stroke:#006600,stroke-width:2px,color:#000000
    classDef provider fill:#ccccff,stroke:#0000ff,stroke-width:2px,color:#000000
    classDef command fill:#ffe6cc,stroke:#cc6600,stroke-width:2px,color:#000000
    classDef tools fill:#e6ccff,stroke:#9933ff,stroke-width:2px,color:#000000
    classDef ui fill:#ffffcc,stroke:#999900,stroke-width:2px,color:#000000

    %% Click Events
    click EEP "https://github.com/coffeechaton/vscode-autohotkey-nekohelp/blob/main/src/extension.ts"
    click PM "https://github.com/coffeechaton/vscode-autohotkey-nekohelp/tree/main/src/core"
    click ASA "https://github.com/coffeechaton/vscode-autohotkey-nekohelp/tree/main/src/AhkSymbol"
    click CH "https://github.com/coffeechaton/vscode-autohotkey-nekohelp/tree/main/src/provider/CallHierarchyProvider"
    click CA "https://github.com/coffeechaton/vscode-autohotkey-nekohelp/tree/main/src/provider/CodeActionProvider"
    click CL "https://github.com/coffeechaton/vscode-autohotkey-nekohelp/tree/main/src/provider/CodeLens"
    click CI "https://github.com/coffeechaton/vscode-autohotkey-nekohelp/tree/main/src/provider/CompletionItem"
    click DI "https://github.com/coffeechaton/vscode-autohotkey-nekohelp/tree/main/src/provider/Diagnostic"
    click HO "https://github.com/coffeechaton/vscode-autohotkey-nekohelp/tree/main/src/provider/Hover"
    click SH "https://github.com/coffeechaton/vscode-autohotkey-nekohelp/tree/main/src/provider/SignatureHelpProvider"
    click RE "https://github.com/coffeechaton/vscode-autohotkey-nekohelp/tree/main/src/provider/Rename"
    click ST "https://github.com/coffeechaton/vscode-autohotkey-nekohelp/tree/main/src/provider/SemanticTokensProvider"
    click SP "https://github.com/coffeechaton/vscode-autohotkey-nekohelp/tree/main/src/provider/SymbolProvider"
    click WS "https://github.com/coffeechaton/vscode-autohotkey-nekohelp/tree/main/src/provider/WorkspaceSymbolProvider"
    click IH "https://github.com/coffeechaton/vscode-autohotkey-nekohelp/tree/main/src/provider/InlayHintsProvider"
    click RF "https://github.com/coffeechaton/vscode-autohotkey-nekohelp/tree/main/src/provider/Ref"
    click CHD "https://github.com/coffeechaton/vscode-autohotkey-nekohelp/tree/main/src/command"
    click TU "https://github.com/coffeechaton/vscode-autohotkey-nekohelp/tree/main/src/tools"
    click CU "https://github.com/coffeechaton/vscode-autohotkey-nekohelp/blob/main/src/configUI.ts"
    click CD "https://github.com/coffeechaton/vscode-autohotkey-nekohelp/blob/main/src/configUI.data.ts"
    click L "https://github.com/coffeechaton/vscode-autohotkey-nekohelp/tree/main/i18n"
    click DOC "https://github.com/coffeechaton/vscode-autohotkey-nekohelp/tree/main/doc"
    click DA "https://github.com/coffeechaton/vscode-autohotkey-nekohelp/blob/main/data/ahk.configuration.json"
    click SHL "https://github.com/coffeechaton/vscode-autohotkey-nekohelp/tree/main/syntaxes"
```
