Skip to content

pub: inherit enum variant visibility and filter LSP hover/definition - #213

Merged
dslsdzc merged 1 commit into
developfrom
pub-enum-lsp
Oct 26, 2026
Merged

dslsdzc merged 1 commit into
developfrom
pub-enum-lsp

Conversation

@dslsdzc

@dslsdzc dslsdzc commented Oct 26, 2026

Copy link
Copy Markdown
Owner

概要

补齐 pub 边界最后两个未接线面。

enum 变体

枚举变体是 SYM_FN 符号,但之前 node = -1,owner/pub 未设置 ⇒ 非 pub enum 的变体跨库仍可被符号表找到。

  • 变体注册时继承 enum 的声明行 owner 与导出位。
  • 非 pub enum 变体跨库不可见;pub enum 变体保持可构造。
  • 同库 enum 行为不变。

LSP hover / definition

  • 查询以文档所属库(@user)为上下文,函数走 find_func(含 func_visible)。
  • 类型 hover/definition 增加 analysis_type_visible:find_sym + sym_visible,非 pub 库类型不再显示结构体/枚举详情或跳转。
  • lsp_check_file 记录 g_source_name,主文件 owner 正确。

判据

  • test_lsp_visibility 新增:import hashmap 文档中 IntMap hover 必须返回 struct IntMap ...;补全仍不出现 IntMap.findKey/findSlot/grow。
  • selfhost-tests / bootstrap-tests / check 全绿;canary 5/5 不变。

- Enum variants are SYM_FN entries; they now carry the enum owner and
  export bit, so variants of a non-pub enum are not visible across
  libraries (pub enum variants remain constructible).
- LSP hover/definition run under the document library and use the same
  sym_visible/func_visible checks; type hover/definition also checks the
  type symbol visibility.
- LSP records g_source_name so the main file owner is resolved.
- test_lsp_visibility pins pub type hover.
@dslsdzc
dslsdzc merged commit f4c9369 into develop Oct 26, 2026
4 checks passed
@dslsdzc
dslsdzc deleted the pub-enum-lsp branch October 26, 2026 22:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant