@@ -8,6 +8,7 @@ use super::node::node_result::NodeResult;
88use  super :: node:: NodeEnum ; 
99use  super :: node:: TypeNode ; 
1010use  super :: plmod:: CompletionItemWrapper ; 
11+ use  super :: plmod:: GlobType ; 
1112use  super :: plmod:: GlobalVar ; 
1213use  super :: plmod:: LSPDef ; 
1314use  super :: plmod:: Mod ; 
@@ -54,8 +55,6 @@ use rustc_hash::FxHashMap;
5455use  rustc_hash:: FxHashSet ; 
5556use  std:: cell:: RefCell ; 
5657
57- use  std:: path:: Path ; 
58- 
5958use  std:: path:: PathBuf ; 
6059use  std:: sync:: Arc ; 
6160mod  builtins; 
@@ -139,17 +138,10 @@ impl<'a, 'ctx> Ctx<'a> {
139138        config :  Config , 
140139        db :  & ' a  dyn  Db , 
141140    )  -> Ctx < ' a >  { 
142-         let  f = Path :: new ( Path :: new ( src_file_path) . file_stem ( ) . unwrap ( ) ) 
143-             . file_name ( ) 
144-             . take ( ) 
145-             . unwrap ( ) 
146-             . to_str ( ) 
147-             . unwrap ( ) 
148-             . to_string ( ) ; 
149141        Ctx  { 
150142            need_highlight :  0 , 
151143            generic_types :  FxHashMap :: default ( ) , 
152-             plmod :  Mod :: new ( f ,   src_file_path. to_string ( ) ) , 
144+             plmod :  Mod :: new ( src_file_path. to_string ( ) ) , 
153145            father :  None , 
154146            init_func :  None , 
155147            function :  None , 
@@ -698,15 +690,15 @@ impl<'a, 'ctx> Ctx<'a> {
698690            } , 
699691        ) ; 
700692    } 
701-     pub  fn  get_type ( & self ,  name :  & str ,  range :  Range )  -> Result < Arc < RefCell < PLType > > ,  PLDiag >  { 
693+     pub  fn  get_type ( & self ,  name :  & str ,  range :  Range )  -> Result < GlobType ,  PLDiag >  { 
702694        if  let  Some ( pv)  = self . generic_types . get ( name)  { 
703695            self . set_if_refs_tp ( pv. clone ( ) ,  range) ; 
704696            self . send_if_go_to_def ( 
705697                range, 
706698                pv. borrow ( ) . get_range ( ) . unwrap_or ( range) , 
707699                self . plmod . path . clone ( ) , 
708700            ) ; 
709-             return  Ok ( pv. clone ( ) ) ; 
701+             return  Ok ( pv. clone ( ) . into ( ) ) ; 
710702        } 
711703        if  let  Ok ( pv)  = self . plmod . get_type ( name,  range,  self )  { 
712704            return  Ok ( pv) ; 
@@ -774,15 +766,15 @@ impl<'a, 'ctx> Ctx<'a> {
774766        } 
775767        self . set_if_refs_tp ( pltype. clone ( ) ,  range) ; 
776768        self . send_if_go_to_def ( range,  range,  self . plmod . path . clone ( ) ) ; 
777-         self . plmod . types . insert ( name,  pltype) ; 
769+         self . plmod . types . insert ( name,  pltype. into ( ) ) ; 
778770        Ok ( ( ) ) 
779771    } 
780772    pub  fn  add_type_without_check ( & mut  self ,  pltype :  Arc < RefCell < PLType > > )  { 
781773        if  let  PLType :: Generic ( _)  = & * pltype. borrow ( )  { 
782774            unreachable ! ( ) 
783775        } 
784776        let  name = pltype. borrow ( ) . get_name ( ) ; 
785-         self . plmod . types . insert ( name,  pltype) ; 
777+         self . plmod . types . insert ( name,  pltype. into ( ) ) ; 
786778    } 
787779    #[ inline]  
788780    fn  add_generic_type ( & mut  self ,  name :  String ,  pltype :  Arc < RefCell < PLType > > )  { 
@@ -1001,6 +993,9 @@ impl<'a, 'ctx> Ctx<'a> {
1001993    fn  get_type_completions_in_ns ( & self ,  ns :  & str ,  m :  & mut  FxHashMap < String ,  CompletionItem > )  { 
1002994        self . with_ns ( ns,  |ns| { 
1003995            for  ( k,  v)  in  ns. types . iter ( )  { 
996+                 if  !v. visibal_outside ( )  { 
997+                     continue ; 
998+                 } 
1004999                let  mut  insert_text = None ; 
10051000                let  mut  command = None ; 
10061001                let  tp = match  & * v. clone ( ) . borrow ( )  { 
@@ -1020,6 +1015,10 @@ impl<'a, 'ctx> Ctx<'a> {
10201015                    } 
10211016                    _ => continue ,  // skip completion for primary types 
10221017                } ; 
1018+                 if  k. starts_with ( '|' )  { 
1019+                     // skip method 
1020+                     continue ; 
1021+                 } 
10231022                let  mut  item = CompletionItem  { 
10241023                    label :  k. to_string ( ) , 
10251024                    kind :  Some ( tp) , 
@@ -1042,7 +1041,7 @@ impl<'a, 'ctx> Ctx<'a> {
10421041
10431042    pub  fn  get_type_completions ( & self )  -> Vec < CompletionItem >  { 
10441043        let  mut  m = FxHashMap :: default ( ) ; 
1045-         self . get_pltp_completions ( & mut  m,  |tp| !matches ! ( tp ,  PLType :: Fn ( _) ) ) ; 
1044+         self . get_pltp_completions ( & mut  m,  |tp| !matches ! ( & * tp . borrow ( ) ,  PLType :: Fn ( _) ) ) ; 
10461045        self . plmod . get_ns_completions_pri ( & mut  m) ; 
10471046        m. values ( ) . cloned ( ) . collect ( ) 
10481047    } 
@@ -1088,7 +1087,7 @@ impl<'a, 'ctx> Ctx<'a> {
10881087    fn  get_pltp_completions ( 
10891088        & self , 
10901089        vmap :  & mut  FxHashMap < String ,  CompletionItem > , 
1091-         filter :  impl  Fn ( & PLType )  -> bool , 
1090+         filter :  impl  Fn ( & GlobType )  -> bool , 
10921091    )  { 
10931092        self . plmod 
10941093            . get_pltp_completions ( vmap,  & filter,  & self . generic_types ,  true ) ; 
0 commit comments