Overview
Android Code Studio features a powerful code editor built on top of the Sora Editor framework, providing a complete coding experience on Android devices. The editor supports multiple languages including Java, Kotlin, XML, Groovy, and more with advanced features like syntax highlighting, code completion, and real-time diagnostics.Core Capabilities
The editor is designed with modularity in mind, exposing functionality through theIEditor interface for seamless integration across the IDE.
Text Manipulation
Selection Control
Set cursor position, select ranges, and navigate through code programmatically
Content Modification
Replace content, append text, and validate text ranges
Position Validation
Verify line and column positions before operations
LSP Integration
Seamless Language Server Protocol support for intelligent features
Editor API
TheIEditor interface provides comprehensive text editing capabilities:
Language Support
The editor implements language-specific features through theIDELanguage base class:
- Java
- Kotlin
- XML
- Groovy
Full Java language support with:
- Java compiler integration
- Code completion
- Error diagnostics
- Refactoring support
TreeSitter Integration
Android Code Studio uses TreeSitter for fast, incremental parsing and syntax highlighting:TreeSitter Features
TreeSitter Features
Parser
TreeSitterParser - Incremental parsing for efficient syntax analysisQuery Engine
TreeSitterQuery - Pattern matching and code navigationTree Navigation
TreeSitterTree and TreeSitterNode - AST traversalCursor API
TreeSitterTreeCursor - Efficient tree walkingTreeSitter API Usage
LSP Editor Features
TheILspEditor interface extends the base editor with Language Server Protocol features:
LSP Features in Action
- Go to Definition
- Find References
- Signature Help
- Smart Selection
Code Completion
The editor provides intelligent code completion through theCommonCompletionProvider:
Code completion is context-aware and provides suggestions based on:
- Current scope
- Imported types
- Project dependencies
- Language semantics
Editor Configuration
Preferences
Preferences
Configure editor behavior through
EditorPreferences:- Tab Size: Customize indentation width
- Soft Tabs: Use spaces instead of tab characters
- Auto Save: Automatically save files on edit
- Font Settings: Customize font family and size
- Line Numbers: Show/hide line numbers
- Word Wrap: Enable/disable text wrapping
Position and Range Validation
The editor includes robust validation for text positions:File Association
Each editor instance is associated with a file:Best Practices
Validate Before Operations
Always validate positions and ranges before text manipulation
Use LSP Features
Leverage LSP integration for intelligent code operations
Handle Cancellation
Implement cancellation checks in long-running operations
Optimize Completions
Set appropriate update thresholds for completion publishers
Advanced Features
Incremental Analysis
The editor supports incremental syntax analysis for improved performance:Custom Formatters
Implement custom code formatters:Related Features
- Language Servers - LSP implementation details
- Project Management - File and project handling
- AI Agent - AI-powered code assistance