@@ -15,7 +15,7 @@ use crate::{
1515pub struct LuaSignature {
1616 pub generic_params : Vec < ( String , Option < LuaType > ) > ,
1717 pub overloads : Vec < Arc < LuaFunctionType > > ,
18- pub param_docs : HashMap < String , LuaDocParamInfo > ,
18+ pub param_docs : HashMap < usize , LuaDocParamInfo > ,
1919 pub params : Vec < String > ,
2020 pub return_docs : Vec < LuaDocReturnInfo > ,
2121 pub ( crate ) resolve_return : bool ,
@@ -45,8 +45,8 @@ impl LuaSignature {
4545
4646 pub fn get_type_params ( & self ) -> Vec < ( String , Option < LuaType > ) > {
4747 let mut type_params = Vec :: new ( ) ;
48- for param_name in & self . params {
49- if let Some ( param_info) = self . param_docs . get ( param_name ) {
48+ for ( idx , param_name) in self . params . iter ( ) . enumerate ( ) {
49+ if let Some ( param_info) = self . param_docs . get ( & idx ) {
5050 type_params. push ( ( param_name. clone ( ) , Some ( param_info. type_ref . clone ( ) ) ) ) ;
5151 } else {
5252 type_params. push ( ( param_name. clone ( ) , None ) ) ;
@@ -56,8 +56,26 @@ impl LuaSignature {
5656 type_params
5757 }
5858
59- pub fn get_param_doc ( & self , param_name : & str ) -> Option < & LuaDocParamInfo > {
60- self . param_docs . get ( param_name)
59+ pub fn find_param_idx ( & self , param_name : & str ) -> Option < usize > {
60+ self . params . iter ( ) . position ( |name| name == param_name)
61+ }
62+
63+ pub fn get_param_info_by_name ( & self , param_name : & str ) -> Option < & LuaDocParamInfo > {
64+ // fast enough
65+ let idx = self . params . iter ( ) . position ( |name| name == param_name) ?;
66+ self . param_docs . get ( & idx)
67+ }
68+
69+ pub fn get_param_info_by_id ( & self , idx : usize ) -> Option < & LuaDocParamInfo > {
70+ if idx < self . params . len ( ) {
71+ return self . param_docs . get ( & idx) ;
72+ } else if let Some ( name) = self . params . last ( ) {
73+ if name == "..." {
74+ return self . param_docs . get ( & ( self . params . len ( ) - 1 ) ) ;
75+ }
76+ }
77+
78+ None
6179 }
6280}
6381
0 commit comments