RedAPI Plugin for VS Code
RedAPI Plugin is a Visual Studio Code extension for writing MagicScript (.ms) files. It provides syntax highlighting, real-time diagnostics, intelligent completion, hover information, and go-to-definition support for a smoother MagicScript development experience.
This extension is designed for MagicScript development. Once installed, it automatically activates when you open a .ms file.
中文
Features
Syntax Highlighting
Provides out-of-the-box highlighting for MagicScript syntax, including:
- Keywords
- Data types
- Strings
- Comments
- Operators
- Built-in modules
- Standard functions
Real-time Diagnostics
When a .ms file is opened or edited, the extension analyzes the script and reports issues in the VS Code Problems panel (Ctrl+Shift+M), including:
- Syntax errors, such as missing brackets or invalid statements
- Semantic errors, such as undefined variables or invalid type usage
- Warnings, such as unused variables
Intelligent Completion
When the Java interpreter is configured, the extension provides context-aware completion for:
- Member access after typing
.
- Built-in modules and functions, such as
log.info, db.select, and http.get
- Java class methods and fields
- Java class import suggestions, such as
import java.util.List
Hover over variables, functions, or types to view type information and documentation.
Go to Definition
Use Ctrl+Click or F12 to jump to symbol definitions.
Supported definition targets include:
- Local variables
- Functions
- Imported modules
- Cross-file references
MagicScript Example
// Variable declarations
var name = "RedAPI"
var count = 100
var amount = BigDecimal("99.99")
// Conditional statement
if (count > 50) {
log.info("Count is greater than 50")
}
// Database query
var users = db.select("SELECT * FROM user WHERE status = ?", [1])
// HTTP request
var res = http.get("https://api.example.com/data")
var body = res.json()
// Loop
for (user in users) {
log.info("User: {}", user.name)
}
// Exception handling
try {
var result = riskyOperation()
} catch (e) {
log.error("Error: {}", e.getMessage())
}
// Return result
return SUCCESS(users)
Configuration
Search for magicscript. in VS Code Settings (Ctrl+,) to configure the extension.
Java Interpreter Settings
The Java interpreter enables enhanced language features such as intelligent completion, hover information, and go-to-definition support.
| Setting |
Type |
Default |
Description |
magicscript.interpreter.enabled |
boolean |
false |
Enables communication with the Java interpreter. |
magicscript.interpreter.classpath |
string |
"" |
Classpath pointing to magic-script.jar. Use ; to separate multiple JAR files on Windows. |
magicscript.interpreter.javaHome |
string |
"" |
Java installation directory. If empty, the extension uses the JAVA_HOME environment variable. |
To start the interpreter, enable magicscript.interpreter.enabled and provide a valid magicscript.interpreter.classpath. If the interpreter cannot be started, the extension falls back to offline analysis.
Type Checking
| Setting |
Type |
Default |
Description |
magicscript.typeCheck.mode |
string |
off |
Controls type checking. Available values: off, basic, strict. |
Type checking modes:
off: Disable type checking.
basic: Report error-level issues only.
strict: Report both errors and warnings.
License
MIT