feat: IDE支持 — workspace拆分、LSP服务器、VS Code扩展
**Workspace 拆分** - aster-core: 纯库,zero-dependency,包含 lexer/parser/ast/interpreter/error/analysis - aster: REPL 二进制,薄封装 aster-core - aster-lsp: LSP 语言服务器 **VS Code 扩展 (vscode-ext/)** - TextMate 语法高亮 (.ast 文件) - 语言配置 (注释切换、括号配对、自动缩进) - LSP 客户端 (extension.js) **LSP 服务端功能** - Diagnostics: 实时显示 lex/parse 错误红色波浪线 - Completion: 关键字 + 内置函数 + 用户定义符号补全 - Hover: 悬停显示变量/函数信息 - Signature Help: 函数参数提示 - Goto Definition: Ctrl+Click 跳转到声明处 - Find References: 查找所有引用位置 - Rename: F2 重命名符号 **新增 analysis 模块** - collect_symbols: AST 遍历收集符号 - find_declaration/find_all_references: Token 扫描定位声明和引用
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
const path = require('path');
|
||||
const { LanguageClient, TransportKind } = require('vscode-languageclient/node');
|
||||
|
||||
/** @type {LanguageClient} */
|
||||
let client;
|
||||
|
||||
/**
|
||||
* @param {import('vscode').ExtensionContext} context
|
||||
*/
|
||||
function activate(context) {
|
||||
const isWindows = process.platform === 'win32';
|
||||
const serverExe = isWindows ? 'aster-lsp.exe' : 'aster-lsp';
|
||||
|
||||
// __dirname resolves to the real filesystem path (following the junction),
|
||||
// so .. goes to the workspace root where target/ lives
|
||||
const serverPath = path.join(__dirname, '..', 'target', 'debug', serverExe);
|
||||
|
||||
const serverOptions = {
|
||||
command: serverPath,
|
||||
args: [],
|
||||
};
|
||||
|
||||
const clientOptions = {
|
||||
documentSelector: [{ scheme: 'file', language: 'aster' }],
|
||||
};
|
||||
|
||||
client = new LanguageClient(
|
||||
'aster-lsp',
|
||||
'Aster Language Server',
|
||||
serverOptions,
|
||||
clientOptions
|
||||
);
|
||||
|
||||
client.start();
|
||||
}
|
||||
|
||||
function deactivate() {
|
||||
if (client) {
|
||||
return client.stop();
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { activate, deactivate };
|
||||
Reference in New Issue
Block a user