TSL Language Support for VS CodeVS Code 的 TSL (Tinysoft Statistical Analysis Language) 语言支持扩展,提供完整的语法高亮、智能代码补全、代码诊断、格式化、远程资源浏览与执行等功能。 功能特性🎯 语言支持
💡 智能功能1. 代码补全 (Auto Completion)
2. 悬停提示 (Hover)
3. 跳转到定义 (Go to Definition)
4. 查找引用 (Find References)
5. 重命名 (Rename)
🔍 代码分析1. 实时诊断 (Diagnostics)
2. 代码折叠 (Folding)
3. 文档符号 (Document Symbols)
4. 工作区符号 (Workspace Symbols)
🎨 代码美化1. 代码格式化 (Formatting)
2. 内联提示 (Inlay Hints)
🌐 远程服务器与资源浏览器扩展提供完整的远程 TSL 服务器连接和资源管理功能。 1. 远程服务器连接
2. 资源浏览器 (TSL Resource Explorer)
3. 同步状态指示
4. 虚拟文件系统 (
|
| 设置项 | 默认值 (Linux) | 默认值 (Windows) | 说明 |
|---|---|---|---|
tsl.libPath |
/opt/tinysoft/tsl |
C:/Program Files/Tinysoft/Analyse.NET |
TSL 库目录路径 |
tsl.executablePath |
/opt/tinysoft/tsl/TSL |
C:/Program Files/Tinysoft/Analyse.NET/TSL.exe |
TSL 可执行文件路径 |
格式化配置
| 设置项 | 类型 | 默认值 | 说明 |
|---|---|---|---|
tsl.formatting.keywordCase |
enum |
lowerCase |
关键字大小写:lowerCase、titleCase、upperCase、preserve |
tsl.formatting.indentWidth |
number |
2 |
缩进宽度(空格数):2、4 |
tsl.formatting.useTabs |
boolean |
false |
使用制表符代替空格进行缩进 |
tsl.formatting.insertFinalNewline |
boolean |
true |
在文件末尾插入换行符 |
tsl.formatting.collapseArrays |
boolean |
true |
将单列数组折叠为单行(多维 key:value 数组保持多行) |
远程服务器配置
| 设置项 | 类型 | 默认值 | 说明 |
|---|---|---|---|
tsl.remote.servers |
array |
[] |
远程服务器列表(含 name, host, port, username, password) |
tsl.remote.defaultServer |
string |
null |
默认服务器名称 |
资源浏览器配置
| 设置项 | 类型 | 默认值 | 说明 |
|---|---|---|---|
tsl.resourceExplorer.showSystemFunctions |
boolean |
false |
显示系统函数(只读) |
tsl.resourceExplorer.defaultDownloadPath |
string |
${workspaceFolder}/funcext |
默认下载路径 |
tsl.resourceExplorer.searchDelay |
number |
300 |
搜索防抖延迟(毫秒) |
tsl.resourceExplorer.cacheExpiry |
number |
300 |
函数列表缓存过期时间(秒) |
其他配置
| 设置项 | 类型 | 默认值 | 说明 |
|---|---|---|---|
tsl.maxIndexedFiles |
number |
2000 |
最大索引文件数 |
tsl.autoDetect |
boolean |
true |
自动检测 TSL 安装路径 |
tsl.runScriptArgs |
array |
[] |
运行脚本时的默认参数 |
tsl.runScriptWorkingDir |
string |
null |
运行脚本时的工作目录 |
tsl.server.logFile |
string |
null |
LSP 服务器日志文件路径 |
快速配置命令:
- 按
Ctrl+Shift+P打开命令面板 - 输入 "TSL: Configure TSL Library Path"
- 输入你的 TSL 安装路径
环境变量:
VS Code 启动 DAP 时会自动设置对应的环境变量:
- Linux:
LD_LIBRARY_PATH和TSL_LIB_PATH - Windows:
PATH和TSL_LIB_PATH
也可以在系统环境变量中预设 TSL_LIB_PATH:
# Linux
export TSL_LIB_PATH=/opt/tinysoft/tsl
# Windows (PowerShell)
$env:TSL_LIB_PATH = "C:/Program Files/Tinysoft/Analyse.NET"
🐛 调试支持 (Debugging)
TSL 语言支持扩展提供完整的调试功能,支持在 VS Code 中调试 TSL 脚本。
1. 启动调试
- 打开要调试的
.tsl文件 - 按
F5或点击左侧调试图标 - 选择 "Debug TSL Script" 或在命令面板输入 "Debug: Start Debugging"
2. 调试配置
快速创建:
- 点击左侧调试图标(🐛)
- 点击顶部的 "create a launch.json file" 链接
- 选择 "TSL" 环境
或者按 Ctrl+Shift+P → 输入 "Debug: Add Configuration" → 选择 "TSL"
手动配置:
在 .vscode/launch.json 中配置调试选项:
{
"type": "tsl",
"request": "launch",
"name": "Debug TSL Script",
"program": "${file}",
"console": "integratedTerminal",
"stopOnEntry": true,
"tslServerIp": "127.0.0.1",
"tslServerPort": 8080,
"tslExecutable": "C:/Program Files/Tinysoft/Analyse.NET/TSL.exe",
"tslWorkingDir": "C:/path/to/your/tsl/files",
"tslLibPath": "C:/Program Files/Tinysoft/Analyse.NET"
}
配置说明:
| 设置项 | 默认值 | 说明 |
|---|---|---|
program |
${file} |
要调试的 TSL 文件路径 |
console |
integratedTerminal |
控制台类型:integratedTerminal(集成终端)、externalTerminal(外部终端)、internalConsole(调试控制台) |
stopOnEntry |
true |
是否在入口处停止 |
tslServerIp |
127.0.0.1 |
TSL 服务器 IP 地址 |
tslServerPort |
8080 | TSL 服务器端口 |
tslExecutable |
平台默认 | TSL 可执行文件路径 |
tslWorkingDir |
- | TSL 工作目录 |
tslLibPath |
- | TSL 库路径(用于查找 .tsf 文件) |
3. 调试功能
- 断点: 在代码行左侧点击设置断点
- 单步执行: F10 (Step Over), F11 (Step In), Shift+F11 (Step Out)
- 继续: F5 继续执行
- 变量查看: 在调适面板查看局部变量和全局变量
- 调用堆栈: 查看当前调用堆栈,支持跳转到 .tsf 函数文件
- 监视: 添加表达式监视
4. .tsf 文件调试
- 断点设置: 在非启动的 .tsf 文件上设置断点时,会自动使用文件名作为函数名
- 调用栈导航: 当调试暂停在 .tsf 函数中时,调用堆栈会显示函数名,点击可以跳转到对应的 .tsf 文件
- 文件搜索顺序:
- 当前文件目录
tslWorkingDir配置的目录tslLibPath配置的目录(会在其func_ext子目录下递归搜索)- 已打开的
.tsf文件
📋 代码片段 (Snippets)
提供丰富的代码片段,快速生成常用代码结构:
| 前缀 | 描述 |
|---|---|
function |
函数定义模板 |
procedure |
过程定义模板 |
if |
If 语句 |
ifelse |
If-Else 语句 |
for |
For 循环 |
while |
While 循环 |
repeat |
Repeat-Until 循环 |
case |
Case 语句 |
tryexcept |
Try-Except 块 |
tryfinally |
Try-Finally 块 |
class |
类定义模板 |
select |
SQL Select 语句 |
vselect |
SQL VSelect 语句 |
array |
数组声明 |
forarray |
数组遍历循环 |
unit |
Unit 模块模板 |
property |
属性声明 |
marketdata |
股票行情数据查询 |
infodata |
财务数据查询 |
安装
从 VSIX 安装
- 下载
vscode-tsl-0.7.0.vsix文件 - 在 VS Code 中打开扩展视图 (
Ctrl+Shift+X) - 点击右上角的
...菜单 - 选择 "从 VSIX 安装..."
- 选择下载的
.vsix文件
从 Marketplace 安装
搜索 "vscode-tsl" 或者 "TSL Language Support" 并安装。
反馈与支持
如有问题或建议,请提交到 GitHub Issues: https://github.com/weigj/vscode-tsl/issues
享受编码! 🚀