Skip to content

refactor(visibility): improve type visibility#1004

Open
xuhuanzy wants to merge 9 commits intoEmmyLuaLs:mainfrom
xuhuanzy:update
Open

refactor(visibility): improve type visibility#1004
xuhuanzy wants to merge 9 commits intoEmmyLuaLs:mainfrom
xuhuanzy:update

Conversation

@xuhuanzy
Copy link
Copy Markdown
Member

@xuhuanzy xuhuanzy commented Apr 2, 2026

  1. 类型默认为 public
  2. 添加 internal 可见性修饰符, 即包内可见, 在这里包的概念是workspace.libraryworkspace.packages引入的文件夹
  3. 删除 ---@export
  4. 配置项 workspace.packageDirs 重命名为 workspace.packages
  5. internal定义的类型仅在包内可见, 不同包的---@class (internal) class现在不会冲突也不会进行合并

@xuhuanzy xuhuanzy marked this pull request as draft April 2, 2026 07:32
gemini-code-assist[bot]

This comment was marked as resolved.

@CppCXY
Copy link
Copy Markdown
Member

CppCXY commented Apr 2, 2026

鉴定为不行, 不符合现实, 通常现成的lua生态,如果他不使用emmylua doc, 那么我可以通过global或者 require的方式引入, 如果他使用emmylua doc, 并且他设计上会给别人使用, 那么他的类型通常有命名空间前缀, 并且如果他的类型不希望被外部使用那么他应该使用private class. 而如果一个库使用emmylua doc并且设计上没有使用命名空间, 那么他通常不是足够流行的公共库, 或者就是他们自己内部的生态. 所有这些都表明默认internal不是正确的方向

@xuhuanzy

This comment was marked as outdated.

1. 类型默认为 public
2. 添加 internal 可见性修饰符, 即包内可见, 在这里包的概念是`workspace.library`引入的内容
3. 删除 ---@export
@xuhuanzy
Copy link
Copy Markdown
Member Author

xuhuanzy commented Apr 3, 2026

@CppCXY 类型访问修饰符从 flag 里独立出来怎么样?

---@class public (flag) className

@CppCXY
Copy link
Copy Markdown
Member

CppCXY commented Apr 3, 2026

不改

@xuhuanzy
Copy link
Copy Markdown
Member Author

xuhuanzy commented Apr 3, 2026

不改

可以两者兼容往后过渡吧, 把一堆东西塞 flag 太丑了, 可能还得为他写专门的诊断避免重复修饰

@xuhuanzy xuhuanzy assigned xuhuanzy and unassigned xuhuanzy Apr 3, 2026
@xuhuanzy xuhuanzy marked this pull request as ready for review April 3, 2026 04:14
@xuhuanzy
Copy link
Copy Markdown
Member Author

xuhuanzy commented Apr 3, 2026

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request replaces the @export tag system with a comprehensive visibility model using @public, @internal, and @private modifiers. It refactors the type index to support scoped lookups across global, internal, and local contexts and updates workspace configuration to handle library and package imports more consistently. A new diagnostic checker for inconsistent type access modifiers is also introduced. Feedback includes suggestions to extract complex property owner identification into helper functions, verify MSRV compatibility for the is_none_or method, and simplify the resolve_workspace_id logic to reduce nesting.

@xuhuanzy
Copy link
Copy Markdown
Member Author

xuhuanzy commented Apr 3, 2026

@CppCXY 看一下没问题就先合了, 处理泛型跟特性切分支再合并太麻烦了

@xuhuanzy xuhuanzy mentioned this pull request Apr 5, 2026
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.

2 participants