Skip to main content

Code Editing & Language Support

Overview

The editor core is built on the Monaco Editor engine (VS Code), providing industry-standard performance, keybindings, and IntelliSense. It features a heuristic engine to auto-detect languages and a specialized snippet library for automotive use cases.

Requirements Specification

IDFeature NameDescriptionImplementation Detail
TRQ-EDT-001Hybrid Language DetectionThe system shall automatically detect the active language (c or rust) based on code content heuristics.Scans first 500 chars for keywords: #include, printf (C) vs fn main, println! (Rust).
TRQ-EDT-002Keyboard ShortcutsCritical build and analysis actions must be accessible via standard shortcuts.F5: Compile
Ctrl+Enter: Scan Quality
Ctrl+S: Save File
Ctrl+O: Open File.
TRQ-EDT-003Monaco IntegrationThe editor shall support syntax highlighting, minimap (disabled by default), and auto-formatting.Configured via monaco-editor-webpack-plugin for C, C++, and JSON.

Automotive Snippets Library

The editor includes registerAutomotiveSnippets which provides the following intelligent templates:

Snippet Triggergenerated Code StructurePurpose
header_guard#ifndef NAME_H ... #endifPrevents recursive inclusion loops.
for_safefor (i=0; i<SIZE; i++) { if (i>=SIZE) break; }Defensive loop with bounds checking.
can_frametypedef struct { id, dlc, data[8] }Standard CAN Bus message frame structure.
isr_handlervoid __attribute__((interrupt))Interrupt Service Routine template with flag clearing.
debounce_switchswitch (state) { CASE IDLE... }State machine for robust button signal debouncing.
circular_bufferstruct RingBuffer_tSafe ring buffer implementation for UART/CAN streams.
fixed_point_mathMacros: FP_MULT, FP_DIVQ15.16 Fixed-Point math for FPU-less microcontrollers.
state_machineenum AppState_t, switch(current_state)Standard Finite State Machine (FSM) skeleton.