File tree Expand file tree Collapse file tree 2 files changed +15
-8
lines changed
emmylua_code_analysis/src/semantic/visibility
emmylua_ls/src/handlers/completion/providers Expand file tree Collapse file tree 2 files changed +15
-8
lines changed Original file line number Diff line number Diff line change @@ -6,12 +6,19 @@ pub fn check_export_visibility(
6
6
) -> Option < bool > {
7
7
// 检查模块是否有 export 标记
8
8
let property_owner_id = module_info. property_owner_id . clone ( ) ?;
9
- let property = semantic_model
9
+ let common_property = semantic_model
10
10
. get_db ( )
11
11
. get_property_index ( )
12
- . get_property ( & property_owner_id) ?
13
- . export
14
- . as_ref ( ) ?;
12
+ . get_property ( & property_owner_id) ;
13
+ let Some ( common_property) = common_property else {
14
+ return Some ( true ) ;
15
+ } ;
16
+
17
+ let Some ( property) = common_property. export . as_ref ( ) else {
18
+ // 没有 export 标记, 视为可见
19
+ return Some ( true ) ;
20
+ } ;
21
+
15
22
match property. scope {
16
23
LuaExportScope :: Namespace => {
17
24
let type_index = semantic_model. get_db ( ) . get_type_index ( ) ;
Original file line number Diff line number Diff line change @@ -70,6 +70,10 @@ fn add_module_completion_item(
70
70
position : Position ,
71
71
completions : & mut Vec < CompletionItem > ,
72
72
) -> Option < ( ) > {
73
+ if !check_export_visibility ( & builder. semantic_model , & module_info) . unwrap_or ( false ) {
74
+ return None ;
75
+ }
76
+
73
77
let completion_name = module_name_convert ( module_info, file_conversion) ;
74
78
if !completion_name. to_lowercase ( ) . starts_with ( prefix) {
75
79
try_add_member_completion_items (
@@ -123,10 +127,6 @@ fn try_add_member_completion_items(
123
127
position : Position ,
124
128
completions : & mut Vec < CompletionItem > ,
125
129
) -> Option < ( ) > {
126
- if !check_export_visibility ( & builder. semantic_model , & module_info) . unwrap_or ( false ) {
127
- return None ;
128
- }
129
-
130
130
if let Some ( export_type) = & module_info. export_type {
131
131
match export_type {
132
132
LuaType :: TableConst ( _) | LuaType :: Def ( _) => {
You can’t perform that action at this time.
0 commit comments