Commit Graph
36 Commits
Author SHA1 Message Date
TermiNexus 1968748ea5 feat(lsp): cross-file signatures, returns, augassign and richer types
Adds LspSigCache: per-file signature cache under <project>/.viperc-lsp-cache, keyed by content hash+size, invalidated on didChange/didSave; resolves from-import, module-attribute and wildcard calls without building the workspace index. Extends LspTypes with list/array/pointer structural checks, array/string initializer lengths and list-literal element checks; adds return-type consistency, augmented-assignment narrowing, constant folding for unary/binop and string/list subscripts. Diagnostics use a per-line occurrence bucket, a dedicated cache work pool and statement/expression budgets so large include files stay responsive. gate13 covers the new rules.
2026-10-28 22:36:07 +08:00
TermiNexus fde6571a3b feat(lsp): 类型赋值/调用/隐式转换诊断对齐编译器
Adds a conservative type model (LspTypes) and checks for annotated declarations, plain assignments to annotated names, and same-file function calls: implicit narrowing (including the compiler's constant bit-range exemption), bool narrowing, double->float, int<->ptr, float<->ptr, scalar->aggregate, str mismatch, plus argument count/type checks. Signatures are parsed from the existing symbol detail; cross-file calls are intentionally skipped to keep publish latency low. Diagnostics run in a scratch arena sized for analysis, with a 256-diagnostic cap; gate13 covers the new rules and the repo corpus stays clean.
2026-10-28 18:56:14 +08:00
TermiNexus 9ff5224a36 feat(lsp): flag non-void functions that fall off the end
Adds the first semantic rule: a function with a non-void return annotation that can reach the end without return/raise is reported at the return annotation. If/else must both exit; bare return is accepted (compiler parity); ... stubs, extern declarations and .vpi files are skipped. The annotation span is recovered from the header so int*/[]int/const int* are underlined completely. Semantic checks run only on syntactically clean files to avoid cascades. New probe --gate13 covers 13 cases plus a corpus check.
2026-10-28 15:53:13 +08:00
TermiNexus ea53f11027 fix(lsp): honor disablePullDiagnostics and add stale-overflow regression
initializeOptions.disablePullDiagnostics now hides diagnosticProvider and keeps push diagnostics, matching the extension setting. gate2 verifies push and pull both clear the overflow diagnostic after the literal is fixed, and that the disable option falls back to push.
2026-10-28 15:22:01 +08:00
TermiNexus 7072acea82 test(lsp): 覆盖修复字面量后溢出诊断清除
gate2 在 push 与 pull 两条路径上都验证:把超长字面量改成 1 后诊断必须清空,防止词法错误状态串到下一次解析。
2026-10-28 15:19:08 +08:00
TermiNexus 86cced94dc fix(lsp): 拉取诊断客户端不再重复收到 push 诊断
initialize 记录 textDocument.diagnostic 能力;客户端支持 pull 时不再发送 publishDiagnostics,避免 Problems 面板重复。gate2 增加溢出诊断断言:仅 1 条、range 覆盖完整字面量、错误恢复后函数语义 token 仍在,并验证 pull 客户端不会同时收到 push。
2026-10-28 15:07:15 +08:00
TermiNexus 9d298b5ae9 feat(types): 宽度事实表共享给编译器与 LSP
新增 lib/types/IntFacts.vp:显式宽度范围检查、最小可存宽度、最小二幂宽度统一到一张表。ExprGenConst 与 define_min_width 改用它;LSP hover 的位宽推荐/后缀适配判定也改用它,任意 _iN/_uN 后缀可显示,但推荐宽度仍只给二幂值。gate10 增加 128_u8、1_u100、128_u7 与数字分隔符 hover 断言;计划文档记录 Pylance 式诊断等级等决策。
2026-10-28 14:42:25 +08:00
TermiNexus d1f84371f8 feat(lsp): hover 支持字面量、模块路径与位宽分析
新增 LspHover:目标 hover 保留原有签名/文档,模块补充工作区相对路径;光标在数字/字符串字面量上时显示十进制、十六进制、二进制、最小位宽、最小二幂整型宽度(u8..u128 / i8..i128)以及 f16/f32/f64 的精确性;True/False/None 也有 hover。十六进制与十进制改为手写 nibble/逐位输出,避开运行库变参格式化对宽值的问题。gate10 增加模块/整数/hex/bin/浮点/字符串 hover 断言。
2026-10-28 13:37:40 +08:00
TermiNexus 6baad4a6e6 fix(lsp): 别名导入的原始名字也高亮可跳转
\rom mod import name as alias\ 原来只为别名生成 occurrence,原始名 name 没有 token。现在原始名和别名各生成一个 occurrence(按源码顺序),两者都解析到被导入的声明;\import a.b as c\ 仍只标注别名,模块路径保持 namespace。gate10 增加原始名/别名/使用处的 token 与定义断言。
2026-10-28 12:53:44 +08:00
TermiNexus c87f1b6f3c fix(lsp): 通配导入链式重导出可解析
from A import * 的符号没有本地声明,C.b 查 C 的成员失败后原来直接返回;现在沿目标文件的 wildcard 链继续解析(带 hop 上限),模块属性与裸名字两条路径都覆盖。gate10 增加三级通配重导出 token/跳转断言(使用大小写不冲突的夹具名)。
2026-10-28 12:39:28 +08:00
TermiNexus ff842e9ff2 fix(lsp): 三元表达式按源码顺序遍历
IfExp 原先先走 test 再走 body,生成的 occurrence 顺序与源码相反,body 的 token 被编码器丢弃或产生负增量。改为 body/test/orelse;gate10 增加三元 body 与 else 的跨模块 token/跳转断言。
2026-10-27 17:54:57 +08:00
TermiNexus b81e4ae3bf fix(lsp): 包的 __init__ 重导出成员可解析
A 是包时 A/__init__.vp 里的 from .leaf import b 被模块链直接跳过:_ChainFromModule 看到 __init__.vp 就切到包目录,只找子模块。改为先在 __init__ 的模块作用域解析该名字(含 from-import 重导出),未命中再下钻子模块。gate10 增加包重导出 token/跳转断言。
2026-10-27 17:43:57 +08:00
TermiNexus 4e3331d442 fix(lsp): else/finally 语句体按语句遍历
If/For/While 的 orelse 和 Try 的 finalbody 是语句列表,却用 _WalkExpr 遍历,else 里的调用基址/属性/名字没有 occurrence,只剩字符串高亮。改用 _WalkBody;gate10 增加多行 else 与单行 else 的跨模块 token/跳转断言。
2026-10-27 17:34:59 +08:00
TermiNexus 4770f57567 fix(lsp): 解码百分号编码盘符后去掉前导分隔符
VS Code 发送 file:///d%3A/...,DecodeUri 只在字面冒号时去前导 /,解出 /d:/... 后 FindProject 失败,项目未采纳、索引 roots 落到工作区根,跨模块成员全部失去高亮与跳转。改为解码完成后判断盘符;gate10 增加百分号编码 rootUri 的回归断言。
2026-10-27 17:19:00 +08:00
TermiNexus 9e47c0ebc4 fix(lsp): as 别名与路径段同名时定位到真实别名
import a.b.c as c 的别名 c 可能已经在模块路径里出现,原先从 alias 起点搜索会命中路径段,真实别名没有 occurrence,语义高亮为白色。asname 存在时从导入名之后开始搜索;gate10 增加 import gate10_pkg.sub as sub 回归断言。
2026-10-27 14:47:34 +08:00
TermiNexus c268e5a9c0 fix(lsp): 别名点号导入逐段高亮
import a.b.c as x 的路径段先于别名写入出现点,避免顺序倒置被丢弃;模块路径段即使解析不到模块也保持 namespace,便于识别缺失依赖。
2026-10-27 13:03:26 +08:00
TermiNexus b38d103c17 fix(lsp): 点号导入逐段高亮与 project includes 路径修复
import a.b.c / from a.b import X 的每个模块段都有 namespace token 并可跳转到对应模块文件;预绑定出现点不再被重解析覆盖;project source/includes 规范化为无 .. 的路径,避免索引路径失配后按需反复解析导致崩溃。
2026-10-27 12:55:43 +08:00
TermiNexus d13eb6b063 feat(lsp): 支持 from module import * 与相对 includes
通配导入的名字通过索引解析(高亮/悬停/跳转/成员),typedef 使用 type token;project.vpj 中任意相对 source/includes 按项目目录解析;修复通配符号表步长导致的越界崩溃;关闭文档释放文档对象,didOpen 不再强制重建索引。
2026-10-27 02:41:45 +08:00
TermiNexus 879cf7ab9f feat(lsp): 跨模块语义高亮与 project.vpj includes 生效
语义 token 通过索引解析导入符号/成员(class/function/method/property/constant/macro);采纳 project.vpj 后刷新索引 roots;语义 token 数组改为 O(1) 追加,避免大文件序列化退化。
2026-10-27 01:45:49 +08:00
TermiNexus 7f90ec984c feat(lsp): 高亮基本类型与数组元素类型
int/str/list 等内建类型在注解与表达式中使用 class token;补上返回注解遍历,修正属性基址与字典键值的出现点顺序,避免语义 token 被重叠丢弃。
2026-10-27 00:09:13 +08:00
TermiNexus bb72ed0971 feat(lsp): Gate 12 协议与诊断增强
新增 textDocument/diagnostic pull(full 报告);响应超出上限返回 -32603 而非关闭连接;记录 \$/cancelRequest 并在派发边界返回 -32800;补充 gate12 探针。
2026-10-26 23:15:10 +08:00
TermiNexus 3c8bd49292 feat(lsp): Gate 11 索引与重命名安全
打开的文档统一使用实时分析,跨文件 references/rename 支持多开文档;索引条目记录内容哈希,watched-files 变更使索引失效;引用/重命名结果去重并对齐未保存内容。
2026-10-26 22:49:04 +08:00
TermiNexus 1251c8ceab feat(lsp): Gate 10 成员解析深度
注解类型驱动成员解析(含 PtrT/ConstT 等包装);支持 module.Class.member 与 .vpi 成员链;跨文件 references/rename 覆盖字段与方法,修复 includeDeclaration 布尔解析与重复位置;索引增加解析缓存并按出现点容量扩大 arena。
2026-10-26 22:18:27 +08:00
TermiNexus 95a8da86e4 feat(lsp): Gate 9 语义高亮保真
define 宏函数与调用点使用 macro token;常量保持 variable+readonly;多行字符串按行拆分;修正符号/出现点合并顺序导致整行 token 丢失;大文档诊断 scratch 按源大小扩容。
2026-10-26 21:04:10 +08:00
TermiNexus e837306159 fix(lsp): 关键字交给 TextMate,避免 def 被语义色覆盖
语义 token 不再输出普通关键字(Vipeye 也只补充软关键字);def/class/define/extern 的颜色由语法高亮决定,探针断言关键字位置没有语义 token。
2026-10-26 20:23:30 +08:00
TermiNexus 8dbf2415d4 feat(lsp): 支持跨文件引用与重命名
索引记录已解析出现点;references/rename 按文件分组,支持 from-import 与 module.Member;路径比较归一化;多开文档时跨文件重命名返回 null。
2026-10-26 20:13:23 +08:00
TermiNexus bc98d61b64 feat(lsp): 自动识别项目根并为常量加 readonly
工作区根无 project.vpj 时从首个打开文件向上采纳项目并重建索引;全大写/define 常量输出 variable+readonly,配合插件的 semanticTokenScopes 使用常量色。
2026-10-26 19:14:33 +08:00
TermiNexus 1183f92344 fix(lsp): 修正 define/extern 声明的名称偏移
声明节点的位置可能落在修饰符或行首;按行内整词重新定位名称,并让无冒号的 extern 头解析出函数名。语义高亮对不匹配源文本的声明 token 直接跳过。
2026-10-26 18:51:01 +08:00
TermiNexus 08c817f5ec feat(lsp): 增加重命名、语义高亮与导入整理
prepareRename/rename 同文件全量出现点;semanticTokens full/range 的 AST+词法+注释 token;organize imports 排序去重。探针新增响应 envelope 校验。
2026-10-26 18:19:05 +08:00
TermiNexus ebb291daeb feat(lsp): 增加补全与签名帮助
作用域/成员/import 路径补全;签名帮助支持当前参数与同名重载;成员来自 live 文档、索引或按需解析的 .vpi。
2026-10-26 17:11:51 +08:00
TermiNexus 4aba50d60e feat(lsp): 支持 ping 并宽容未知协议方法
健康检查在 initialize 前即可响应;未知请求记录 stderr 后返回 null,未知通知记录后忽略,避免插件因 MethodNotFound 判定服务端故障。
2026-10-26 16:31:52 +08:00
TermiNexus 1b21ef14d5 feat(lsp): 增加符号索引与导航
documentSymbol、workspace/symbol、definition、references、documentHighlight、hover 全部基于 includes/ast;索引使用独立池并在打开/关闭/保存时失效。
2026-10-26 16:21:44 +08:00
TermiNexus dee324ed06 feat(lsp): 发布解析诊断
didOpen/didChange/didSave 推送 publishDiagnostics,didClose 清空;诊断解析使用按次重置的 scratch 池。
2026-10-26 14:55:23 +08:00
TermiNexus 93cd0f1ea5 feat(lsp): 增加 UTF-16 位置往返验证
- viper/lspPosition:line/character -> offset -> line/character
- probe Gate 1:随机 10k 个有效位置往返,覆盖 CRLF/中文/emoji
2026-10-26 14:27:33 +08:00
TermiNexus c42ae889d1 feat(lsp): Gate 1 文档同步、UTF-16 位置与工作区
- LspPositions:UTF-8 字节列 / UTF-16 code unit 转换,支持 LF/CRLF/emoji
- LspDocuments:didOpen/didChange/didClose/didSave,增量与全量替换,双池复用
- LspWorkspace:file URI 解码、project.vpj 向上查找、source_dir/includes
- LspServer:请求池 mark/reset、textDocumentSync、viper/lspStats 与 viper/lspDocument
- probe --gate1:文档编辑、UTF-16 代理对、10k 次编辑与池稳定性
- 依赖 includes/memhub 的 NewMemBuddy 堆构造工厂(单独提交 fa7591e)
2026-10-26 14:23:12 +08:00
TermiNexus ab562764b4 feat(lsp): Gate 0 协议骨架与生命周期
- 新增 lib/lsp:协议常量、stdio framing、JSON-RPC 响应、lifecycle server
- viperc --lsp:独立池、互斥校验、stdout 仅输出协议帧
- 新增 Tools/lsp/probe.py 与 ast_check.py
- Gate 0 行为验证:--build-self 后 lifecycle 探针通过
2026-10-26 13:48:07 +08:00