# c-li/estun_robot_highlighting architecture

> Architecture diagram of the GitHub repository c-li/estun_robot_highlighting, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/c-li/estun_robot_highlighting
- Repository: https://github.com/c-li/estun_robot_highlighting

## Overview

#### Purpose and host integration
This repository is a TypeScript VS Code extension for ESTUN RCS2 robot-language source files: `.erd` data definitions and `.erp` executable robot programs. VS Code supplies document lifecycle, grammar tokenization, and hover UI; the extension does not execute or validate robot programs. Key integration metadata is in `package.json`, with activation/runtime code in `src/extension.ts`.

#### Extension activation and registration
The extension entry point activates in the VS Code extension host and registers a hover provider for the RCS2 language. The provider is responsible only for contextual documentation at the cursor; grammar-based highlighting remains declarative and is handled by VS Code. Paths: `src/extension.ts`, `src/hoverProvider.ts`, `package.json`.

#### Language definition and syntax-tokenization boundary
A TextMate grammar defines recognition and scopes for RCS2 keywords, types, motion and I/O instructions, operators, variables, labels, strings, numbers, and the three comment forms. VS Code’s TextMate engine consumes this JSON grammar for highlighting, separating lexical display from TypeScript hover behavior. Paths: `syntaxes/robot-language.tmLanguage.json`, `language-configuration.json`, `package.json`.

#### Hover resolution pipeline
On hover, the provider identifies the relevant token or variable form from the current document position, then resolves documentation for recognized language elements. It supports both direct keyword documentation and special forms such as labels and prefixed variables (`t_p.`, `t_s.`, `t_l.`, `t_g.`), including full-variable contextual descriptions. Paths: `src/hoverProvider.ts`, `src/hoverData.ts`.

#### Documentation knowledge base
The extension embeds RCS2 reference content as structured TypeScript data rather than retrieving it from a controller, network API, or language server. This catalog covers data types, motion/control/IO/system instructions, math functions, velocity and zone constants, and usage syntax/examples/parameters. Adding supported hover content primarily means extending this data catalog. Path: `src/hoverData.ts`.

#### File-type workflow and examples
Users open RCS2 source files in VS Code; VS Code maps them to the contributed language, applies the grammar, and invokes hover handling on demand. The sample `.erd` and `.erp` files represent the two-file RCS2 model and serve as representative inputs for manual verification. Paths: `examples/sample.erd`, `examples/sample.erp`, `package.json`.

#### Runtime, packaging, and boundaries
Runtime is Node.js/TypeScript compiled for the VS Code extension host, using the VS Code API. Distribution is a VSIX package; package scripts drive compilation and prepublish packaging. No backend, database, robot controller connection, or external service is present. Paths: `package.json`, `tsconfig.json`, `build.bat`.

Main entry points: [`package.json`](https://github.com/c-li/estun_robot_highlighting/blob/main/package.json) (Extension manifest), [`src/hoverProvider.ts`](https://github.com/c-li/estun_robot_highlighting/blob/main/src/hoverProvider.ts) (Hover provider), [`tsconfig.json`](https://github.com/c-li/estun_robot_highlighting/blob/main/tsconfig.json) (TypeScript build), [`src/extension.ts`](https://github.com/c-li/estun_robot_highlighting/blob/main/src/extension.ts) (Activation entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_vscode["VS Code Host"]
  node_source_files["RCS2 source files<br/>ERD / ERP inputs"]
  node_vscode_documents["Document lifecycle<br/>VS Code documents"]
  node_textmate_engine["TextMate tokenization<br/>VS Code engine"]
  node_hover_ui["Hover UI<br/>VS Code UI"]
end

subgraph group_extension["Extension Runtime"]
  node_package_manifest["Extension manifest<br/>package metadata<br/>[package.json]"]
  node_extension_entry["Activation entry<br/>TypeScript module<br/>[extension.ts]"]
  node_hover_provider["Hover provider<br/>VS Code provider<br/>[hoverProvider.ts]"]
  node_hover_catalog[("Hover documentation catalog<br/>TypeScript knowledge base<br/>[hoverData.ts]")]
  node_typescript_build["TypeScript build<br/>compiler configuration<br/>[tsconfig.json]"]
  node_vsix_package["VSIX distribution<br/>extension package<br/>[package.json]"]
  node_windows_build["Windows build script<br/>build automation<br/>[build.bat]"]
end

subgraph group_language["Language Assets"]
  node_textmate_grammar["RCS2 TextMate grammar<br/>grammar JSON"]
  node_language_config["Language configuration<br/>language settings"]
  node_sample_erd["Sample data definition<br/>ERD example<br/>[sample.erd]"]
  node_sample_erp["Sample robot program<br/>ERP example<br/>[sample.erp]"]
end

node_package_manifest -->|"declares entry and activation"| node_extension_entry
node_package_manifest -->|"contributes grammar"| node_textmate_grammar
node_package_manifest -->|"contributes settings"| node_language_config
node_source_files -->|"opened as"| node_vscode_documents
node_vscode_documents -->|"tokenized for highlighting"| node_textmate_engine
node_textmate_grammar -->|"defines lexical scopes"| node_textmate_engine
node_language_config -->|"configures language behavior"| node_vscode_documents
node_extension_entry -->|"registers"| node_hover_provider
node_vscode_documents -->|"hover request and cursor position"| node_hover_provider
node_hover_provider -->|"resolves documentation from"| node_hover_catalog
node_hover_provider -->|"returns contextual content"| node_hover_ui
node_sample_erd -.->|"representative input"| node_source_files
node_sample_erp -.->|"representative input"| node_source_files
node_typescript_build -->|"compiles"| node_extension_entry
node_windows_build -->|"drives"| node_typescript_build
node_typescript_build -->|"builds runtime for"| node_vsix_package
node_package_manifest -->|"packages as"| node_vsix_package

click node_package_manifest "https://github.com/c-li/estun_robot_highlighting/blob/main/package.json"
click node_extension_entry "https://github.com/c-li/estun_robot_highlighting/blob/main/src/extension.ts"
click node_hover_provider "https://github.com/c-li/estun_robot_highlighting/blob/main/src/hoverProvider.ts"
click node_hover_catalog "https://github.com/c-li/estun_robot_highlighting/blob/main/src/hoverData.ts"
click node_textmate_grammar "https://github.com/c-li/estun_robot_highlighting/blob/main/syntaxes/robot-language.tmLanguage.json"
click node_language_config "https://github.com/c-li/estun_robot_highlighting/blob/main/language-configuration.json"
click node_sample_erd "https://github.com/c-li/estun_robot_highlighting/blob/main/examples/sample.erd"
click node_sample_erp "https://github.com/c-li/estun_robot_highlighting/blob/main/examples/sample.erp"
click node_typescript_build "https://github.com/c-li/estun_robot_highlighting/blob/main/tsconfig.json"
click node_vsix_package "https://github.com/c-li/estun_robot_highlighting/blob/main/package.json"
click node_windows_build "https://github.com/c-li/estun_robot_highlighting/blob/main/build.bat"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_source_files,node_vscode_documents,node_textmate_engine,node_hover_ui toneBlue
class node_package_manifest,node_extension_entry,node_hover_provider,node_hover_catalog,node_typescript_build,node_vsix_package,node_windows_build toneAmber
class node_textmate_grammar,node_language_config,node_sample_erd,node_sample_erp toneMint
```

## Components

### VS Code Host

- **RCS2 source files**: ERD / ERP inputs · Robot data definitions and executable programs opened by users.
- **Document lifecycle**: VS Code documents
- **TextMate tokenization**: VS Code engine
- **Hover UI**: VS Code UI

### Extension Runtime

- [Extension manifest](https://github.com/c-li/estun_robot_highlighting/blob/main/package.json): package metadata · Contributes language wiring, activation, and packaging scripts. · `package.json`
- [Activation entry](https://github.com/c-li/estun_robot_highlighting/blob/main/src/extension.ts): TypeScript module · Activates in the extension host and registers hover support. · `src/extension.ts`
- [Hover provider](https://github.com/c-li/estun_robot_highlighting/blob/main/src/hoverProvider.ts): VS Code provider · Finds the token or variable form at the cursor. · `src/hoverProvider.ts`
- [Hover documentation catalog](https://github.com/c-li/estun_robot_highlighting/blob/main/src/hoverData.ts): TypeScript knowledge base · Embedded RCS2 reference data for keywords, variables, constants, and instructions. · `src/hoverData.ts`
- [TypeScript build](https://github.com/c-li/estun_robot_highlighting/blob/main/tsconfig.json): compiler configuration · Compiles Node.js extension-host runtime code. · `tsconfig.json`
- [VSIX distribution](https://github.com/c-li/estun_robot_highlighting/blob/main/package.json): extension package · Built and prepublished through package scripts. · `package.json`
- [Windows build script](https://github.com/c-li/estun_robot_highlighting/blob/main/build.bat): build automation · `build.bat`

### Language Assets

- [RCS2 TextMate grammar](https://github.com/c-li/estun_robot_highlighting/blob/main/syntaxes/robot-language.tmLanguage.json): grammar JSON · Defines scopes for keywords, types, instructions, literals, labels, and comments. · `syntaxes/robot-language.tmLanguage.json`
- [Language configuration](https://github.com/c-li/estun_robot_highlighting/blob/main/language-configuration.json): language settings · `language-configuration.json`
- [Sample data definition](https://github.com/c-li/estun_robot_highlighting/blob/main/examples/sample.erd): ERD example · Representative manual-verification input. · `examples/sample.erd`
- [Sample robot program](https://github.com/c-li/estun_robot_highlighting/blob/main/examples/sample.erp): ERP example · Representative manual-verification input. · `examples/sample.erp`

## Connections

- Extension manifest → Activation entry: declares entry and activation
- Extension manifest → RCS2 TextMate grammar: contributes grammar
- Extension manifest → Language configuration: contributes settings
- RCS2 source files → Document lifecycle: opened as
- Document lifecycle → TextMate tokenization: tokenized for highlighting
- RCS2 TextMate grammar → TextMate tokenization: defines lexical scopes
- Language configuration → Document lifecycle: configures language behavior
- Activation entry → Hover provider: registers
- Document lifecycle → Hover provider: hover request and cursor position
- Hover provider → Hover documentation catalog: resolves documentation from
- Hover provider → Hover UI: returns contextual content
- Sample data definition → RCS2 source files: representative input
- Sample robot program → RCS2 source files: representative input
- TypeScript build → Activation entry: compiles
- Windows build script → TypeScript build: drives
- TypeScript build → VSIX distribution: builds runtime for
- Extension manifest → VSIX distribution: packages as
