@@ -3,7 +3,7 @@ use pyo3::prelude::*;
33mod classes;
44mod stack_graphs_wrapper;
55
6- use classes:: { Language , Position } ;
6+ use classes:: { Language , Position , Querier } ;
77
88/// Formats the sum of two numbers as string.
99#[ pyfunction]
@@ -14,8 +14,8 @@ fn sum_as_string(a: usize, b: usize) -> PyResult<String> {
1414#[ pyfunction]
1515fn index ( paths : Vec < String > , db_path : String , language : Language ) -> PyResult < ( ) > {
1616 // TODO(@nohehf): Add a verbose mode to toggle the logs
17- println ! ( "Indexing paths: {:?}" , paths) ;
18- println ! ( "Database path: {:?}" , db_path) ;
17+ // println!("Indexing paths: {:?}", paths);
18+ // println!("Database path: {:?}", db_path);
1919
2020 let paths: Vec < std:: path:: PathBuf > =
2121 paths. iter ( ) . map ( |p| std:: path:: PathBuf :: from ( p) ) . collect ( ) ;
@@ -27,32 +27,13 @@ fn index(paths: Vec<String>, db_path: String, language: Language) -> PyResult<()
2727 ) ?)
2828}
2929
30- /// Indexes the given paths into stack graphs, and stores the results in the given database.
31- #[ pyfunction]
32- fn query_definition ( reference : Position , db_path : String ) -> PyResult < Vec < Position > > {
33- println ! ( "Querying reference: {:?}" , reference. to_string( ) ) ;
34- println ! ( "Database path: {:?}" , db_path) ;
35-
36- let result = stack_graphs_wrapper:: query_definition ( reference. into ( ) , & db_path) ?;
37-
38- // TODO(@nohehf): Check if we can flatten the results, see the QueryResult struct, we might be loosing some information
39- let positions: Vec < Position > = result
40- . into_iter ( )
41- . map ( |r| r. targets )
42- . flatten ( )
43- . map ( |t| t. into ( ) )
44- . collect ( ) ;
45-
46- Ok ( positions)
47- }
48-
4930/// A Python module implemented in Rust.
5031#[ pymodule]
5132fn stack_graphs_python ( _py : Python , m : & PyModule ) -> PyResult < ( ) > {
5233 m. add_function ( wrap_pyfunction ! ( sum_as_string, m) ?) ?;
5334 m. add_function ( wrap_pyfunction ! ( index, m) ?) ?;
54- m. add_function ( wrap_pyfunction ! ( query_definition, m) ?) ?;
5535 m. add_class :: < Position > ( ) ?;
5636 m. add_class :: < Language > ( ) ?;
37+ m. add_class :: < Querier > ( ) ?;
5738 Ok ( ( ) )
5839}
0 commit comments