Architecture Overview
The BBj Language Server project consists of three main components that work together to provide comprehensive IDE support for BBj development.
High-Level Architecture
┌─────────────────────────────────────────────────────────────┐
│ VS Code Extension │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ Extension Host (TypeScript) │ │
│ │ - Commands (Run, Compile, Decompile) │ │
│ │ - Configuration management │ │
│ │ - UI integration │ │
│ └─────────────────────────────────────────────────────┘ │
│ │ │
│ LSP Protocol │
│ │ │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ Language Server (Langium-based) │ │
│ │ - Parsing and validation │ │
│ │ - Code completion │ │
│ │ - Hover information │ │
│ │ - Navigation (Go to Definition, References) │ │
│ │ - Semantic tokens │ │
│ └─────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
│
JSON-RPC (Port 5008)
│
┌─────────────────────────────────────────────────────────────┐
│ Java Interop Service (Java) │
│ - Classpath introspection │
│ - Class/method/field reflection │
│ - JavaDoc extraction │
└─────────────────────────────────────────────────────────────┘
Components
1. VS Code Extension (/bbj-vscode/)
The main entry point for users. This TypeScript-based extension:
- Registers the BBj language with VS Code
- Provides commands for running, compiling, and managing BBj programs
- Launches and communicates with the language server
- Manages configuration and settings
Key Files:
src/extension.ts- Extension activation and command registrationsrc/Commands/Commands.cjs- VS Code command implementationspackage.json- Extension manifest and contribution points
2. Language Server (Langium-based)
Built on the Langium framework, the language server implements the Language Server Protocol (LSP) to provide:
- Parsing: Grammar-based parsing of BBj source files
- Validation: Syntax and semantic error detection
- Completion: Context-aware code suggestions
- Hover: Documentation and type information
- Navigation: Go to definition, find references
- Semantic Tokens: Rich syntax highlighting
Key Files:
src/language/bbj.langium- BBj grammar definitionsrc/language/bbj-module.ts- Dependency injection modulesrc/language/bbj-completion-provider.ts- Code completionsrc/language/bbj-validator.ts- Validation rules
3. Java Interop Service (/java-interop/)
A standalone Java application that provides reflection-based information about Java classes:
- Listens on port 5008 for JSON-RPC requests
- Introspects classpath to discover available classes
- Returns class information (methods, fields, constructors)
- Extracts JavaDoc documentation
Key Files:
src/main/java/bbj/interop/SocketServiceApp.java- Main entry pointsrc/main/java/bbj/interop/InteropService.java- Core service implementation
Communication Flow
Startup Sequence
- User opens a
.bbjfile in VS Code - Extension activates and starts the language server process
- Language server initializes Langium services
- Java interop service is started (or connected to if already running)
- Extension is ready for use
Request Flow
- User Action: User types in editor
- VS Code: Sends LSP request to language server
- Language Server: Processes request using Langium services
- Java Interop (if needed): Language server queries Java service for class info
- Response: Results returned through LSP to VS Code
- Display: VS Code shows completions, diagnostics, etc.
File Types
The extension supports multiple BBj file types:
| Extension | Description | Language ID |
|---|---|---|
.bbj | BBj source files | bbj |
.bbl | BBj library files | bbj |
.bbjt | BBj template files | bbj |
.bbx | BBj configuration files | bbx |
Dependencies
TypeScript/Node.js
- Langium (~3.2.1) - Language server framework
- Chevrotain (~11.0.3) - Parser generator
- vscode-languageclient/server - LSP implementation
Java
- LSP4J (0.20.1) - JSON-RPC communication
- Guava (31.1) - Utility library
- Java 17+ - Runtime requirement