@@ -9,16 +9,6 @@ use simplicityhl::{
99
1010use crate :: completion:: types:: FunctionTemplate ;
1111
12- /// Macro to convert string literals into `Vec<String>`
13- macro_rules! str_vec {
14- ( ) => {
15- Vec :: new( )
16- } ;
17- ( $( $item: expr) ,+ $( , ) ?) => {
18- vec![ $( $item. to_string( ) ) ,+]
19- } ;
20- }
21-
2212/// Get completion of builtin functions. They are all defined in [`simplicityhl::parse::CallName`]
2313pub fn get_builtin_functions ( ) -> Vec < FunctionTemplate > {
2414 let ty = AliasedType :: from ( AliasName :: from_str_unchecked ( "T" ) ) ;
@@ -54,8 +44,8 @@ pub fn match_callname(call: &CallName) -> Option<FunctionTemplate> {
5444 Some ( FunctionTemplate :: new (
5545 "unwrap_left" ,
5646 "unwrap_left" ,
57- str_vec ! [ format!( "{ty}" ) ] ,
58- str_vec ! [ format!( "Either<{ty}, U>" ) ] ,
47+ vec ! [ format!( "{ty}" ) ] ,
48+ vec ! [ format!( "Either<{ty}, U>" ) ] ,
5949 ty,
6050 doc,
6151 ) )
@@ -65,15 +55,15 @@ pub fn match_callname(call: &CallName) -> Option<FunctionTemplate> {
6555 Some ( FunctionTemplate :: new (
6656 "unwrap_right" ,
6757 "unwrap_right" ,
68- str_vec ! [ format!( "{ty}" ) ] ,
69- str_vec ! [ format!( "Either<T, {ty}>" ) ] ,
58+ vec ! [ format!( "{ty}" ) ] ,
59+ vec ! [ format!( "Either<T, {ty}>" ) ] ,
7060 ty,
7161 doc,
7262 ) )
7363 }
7464 CallName :: Unwrap => Some ( FunctionTemplate :: simple (
7565 "unwrap" ,
76- str_vec ! [ "Option<T>" ] ,
66+ vec ! [ "Option<T>" . to_string ( ) ] ,
7767 "T" ,
7868 doc,
7969 ) ) ,
@@ -82,41 +72,52 @@ pub fn match_callname(call: &CallName) -> Option<FunctionTemplate> {
8272 Some ( FunctionTemplate :: new (
8373 "is_none" . to_string ( ) ,
8474 "is_none" ,
85- str_vec ! [ format!( "{ty}" ) ] ,
86- str_vec ! [ format!( "Option<{ty}>" ) . as_str ( ) ] ,
75+ vec ! [ format!( "{ty}" ) ] ,
76+ vec ! [ format!( "Option<{ty}>" ) ] ,
8777 "bool" ,
8878 doc,
8979 ) )
9080 }
9181 CallName :: Assert => Some ( FunctionTemplate :: simple (
9282 "assert!" ,
93- str_vec ! [ "condition: bool" ] ,
83+ vec ! [ "condition: bool" . to_string ( ) ] ,
9484 "()" ,
9585 doc,
9686 ) ) ,
97- CallName :: Panic => Some ( FunctionTemplate :: simple ( "panic!" , str_vec ! [ ] , "()" , doc) ) ,
98- CallName :: Debug => Some ( FunctionTemplate :: simple ( "dbg!" , str_vec ! [ "T" ] , "T" , doc) ) ,
87+ CallName :: Panic => Some ( FunctionTemplate :: simple ( "panic!" , vec ! [ ] , "()" , doc) ) ,
88+ CallName :: Debug => Some ( FunctionTemplate :: simple (
89+ "dbg!" ,
90+ vec ! [ "T" . to_string( ) ] ,
91+ "T" ,
92+ doc,
93+ ) ) ,
9994 CallName :: Fold ( _, _) => Some ( FunctionTemplate :: new (
10095 "fold" ,
10196 "fold" ,
102- str_vec ! [ "f" , "N" ] ,
103- str_vec ! [ "list: List<E,N>" , "initial_accumulator: A" ] ,
97+ vec ! [ "f" . to_string( ) , "N" . to_string( ) ] ,
98+ vec ! [
99+ "list: List<E,N>" . to_string( ) ,
100+ "initial_accumulator: A" . to_string( ) ,
101+ ] ,
104102 "A" ,
105103 doc,
106104 ) ) ,
107105 CallName :: ArrayFold ( _, _) => Some ( FunctionTemplate :: new (
108106 "array_fold" ,
109107 "array_fold" ,
110- str_vec ! [ "f" , "N" ] ,
111- str_vec ! [ "array: [E; N]" , "initial_accumulator: A" ] ,
108+ vec ! [ "f" . to_string( ) , "N" . to_string( ) ] ,
109+ vec ! [
110+ "array: [E; N]" . to_string( ) ,
111+ "initial_accumulator: A" . to_string( ) ,
112+ ] ,
112113 "A" ,
113114 doc,
114115 ) ) ,
115116 CallName :: ForWhile ( _) => Some ( FunctionTemplate :: new (
116117 "for_while" ,
117118 "for_while" ,
118- str_vec ! [ "f" ] ,
119- str_vec ! [ "accumulator: A" , "context: C" ] ,
119+ vec ! [ "f" . to_string ( ) ] ,
120+ vec ! [ "accumulator: A" . to_string ( ) , "context: C" . to_string ( ) ] ,
120121 "Either<B, A>" ,
121122 doc,
122123 ) ) ,
0 commit comments