Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>redapi-pluginNew to Visual Studio Code? Get it now.
redapi-plugin

redapi-plugin

Yinzx

|
1 install
| (0) | Free
vscode plugin for redapi
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

RedAPI Plugin for VS Code

在 VS Code 中编写 MagicScript(.ms)脚本,提供语法高亮、实时诊断、智能补全、悬停提示、定义跳转等一站式开发体验。

RedAPI Plugin 是 RedAPI 服务中台 的 VS Code 扩展,安装后打开 .ms 文件即可自动生效。


功能详解

语法高亮

支持关键字、数据类型、字符串、注释、运算符、内置模块及标准函数的语法着色,开箱即用。

实时诊断

打开 .ms 文件时,插件自动进行语法分析和语义检查,结果实时显示在 问题面板(Ctrl+Shift+M):

  • 语法错误(缺少括号、分号等)
  • 语义错误(未定义变量、类型不匹配等)
  • 未使用变量警告

智能补全

当配置了 Java 解释器后,插件提供上下文感知的代码补全:

  • 输入 . 触发成员补全
  • 内置函数(log.info、db.select、http.get 等)
  • Java 类的方法和字段补全
  • 类名导入补全(如 import java.util.List)

悬停提示

鼠标悬停在变量、函数或类型上时,显示类型信息和文档说明。

定义跳转

  • Ctrl+Click 或 F12 跳转到变量/函数定义
  • 支持跨文件跳转(import '@module' as mod)

语法示例

// 变量声明
var name = "RedAPI"
var count = 100
var amount = BigDecimal("99.99")

// 条件判断
if (count > 50) {
    log.info("数量大于 50")
}

// 数据库查询
var users = db.select("SELECT * FROM user WHERE status = ?", [1])

// HTTP 请求
var res = http.get("https://api.example.com/data")
var body = res.json()

// 循环
for (user in users) {
    log.info("用户:{}", user.name)
}

// 异常处理
try {
    var result = riskyOperation()
} catch (e) {
    log.error("出错了:{}", e.getMessage())
}

// 返回结果
return SUCCESS(users)

配置项一览

所有配置项在 VS Code 设置(Ctrl+,)中搜索 magicscript. 即可找到。

解释器配置(启用智能补全 / 悬停 / 跳转)

配置项 类型 默认值 说明
magicscript.interpreter.enabled boolean false 是否启用 Java 解释器通信
magicscript.interpreter.classpath string "" 指向 magic-script.jar 的 classpath,多个 jar 用 ; 分隔
magicscript.interpreter.javaHome string "" Java 安装目录,留空则自动读取 JAVA_HOME 环境变量

至少需要填写 magicscript.interpreter.classpath 并启用 magicscript.interpreter.enabled,解释器才能启动。启动失败会自动降级为离线模式。

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft