@@ -15,7 +15,7 @@ use crate::{
15
15
pub struct LuaSignature {
16
16
pub generic_params : Vec < ( String , Option < LuaType > ) > ,
17
17
pub overloads : Vec < Arc < LuaFunctionType > > ,
18
- pub param_docs : HashMap < String , LuaDocParamInfo > ,
18
+ pub param_docs : HashMap < usize , LuaDocParamInfo > ,
19
19
pub params : Vec < String > ,
20
20
pub return_docs : Vec < LuaDocReturnInfo > ,
21
21
pub ( crate ) resolve_return : bool ,
@@ -45,8 +45,8 @@ impl LuaSignature {
45
45
46
46
pub fn get_type_params ( & self ) -> Vec < ( String , Option < LuaType > ) > {
47
47
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 ) {
50
50
type_params. push ( ( param_name. clone ( ) , Some ( param_info. type_ref . clone ( ) ) ) ) ;
51
51
} else {
52
52
type_params. push ( ( param_name. clone ( ) , None ) ) ;
@@ -56,8 +56,26 @@ impl LuaSignature {
56
56
type_params
57
57
}
58
58
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
61
79
}
62
80
}
63
81
0 commit comments