Smalruby Completion System Analysis: 2026/02/22 #58
takaokouji
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Smalruby Completion System Analysis
Overview
The Smalruby completion system is a Monaco Editor-based snippet completion provider for the Ruby mode in the Smalruby 3 Editor. It provides context-aware code completion for Ruby blocks, methods, and language features with heavy Japanese language support.
1. Current Architecture
Main Components
snippets-completer.js) - Main completion providerbase-completer.js) - Base class for converting snippets to Monaco CompletionItemsruby-tab.jsx) - Integration point in React componentsmalruby-mode.js) - Language configuration2. SnippetsCompleter.js (Full Content)
Key Features:
Core Logic:
/[\u3040-\u309F\u30A0-\u30FF\u4E00-\u9FFF]/(hiragana, katakana, kanji)Extension Filtering:
vm.extensionManager.isExtensionLoaded(extensionId)provideCompletionItems() Method:
3. BaseCompleter.js (Full Content)
toCompletionItem() Method:
Converts snippet object to Monaco CompletionItem with:
labelJaexists:{label, detail, description}Type Mapping:
method→ Methodfunction→ Functionvariable→ Variablevalue→ Valueconstant→ Constantenum_member→ EnumMemberkeyword→ Keywordevent→ Eventsnippetor default → Snippet4. Snippet JSON Structure
Structure of Each Snippet:
{ "key_name": { "snippet": "code(${1:default})", "description": "Japanese description of what it does", "type": "function|snippet|variable|value|constant|enum_member|keyword|event", "labelJa": "Japanese label shown in dropdown", "filterText": "romaji japanese kanji aliases additional_search_terms", "sortText": "XX_romanization" } }Key Fields:
${N:default}for tab stopsExample (motion-snippets.json):
5. Snippet Files Inventory (23 files)
Core Snippets (9):
Extension Snippets (11):
6. RubyTab.jsx Integration
Registration Point (lines 377-384):
Completion Registration:
handleEditorDidMount()lifecycle methodcomponentWillUnmount()7. SmalrubyMode.js Configuration
Language Configuration:
#Word Pattern:
This allows Japanese characters in word boundaries, enabling completion triggering on Japanese input.
8. Current Filtering/Context Capabilities
Implemented:
NOT Yet Implemented (Opportunity for 課題4):
9. Key Data in Snippets
Context Information Available:
Example Patterns:
10. Opportunities for Context-Aware Completion (課題4)
Analysis of Line Context:
Could analyze preceding code to understand:
Block Nesting Analysis:
Parameter Context:
go_to(...), only show movement target enumsScope Analysis:
11. Current Test Coverage
Test File: snippets-completer.test.js
Tests cover:
Gap: No tests for context-aware filtering yet
Beta Was this translation helpful? Give feedback.
All reactions