1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#[macro_use]
extern crate serde_derive;

#[macro_use]
extern crate log;

#[macro_use]
extern crate languageserver_types;

extern crate gluon_completion as completion;

#[macro_use]
mod server;
#[macro_use]
pub mod rpc;

mod check_importer;
mod command;
mod diagnostics;
mod name;
mod text_edit;

use gluon::{either, new_vm};

use futures::prelude::*;

pub use crate::{command::completion::CompletionData, server::Server};

pub type BoxFuture<I, E> = std::pin::Pin<Box<dyn Future<Output = Result<I, E>> + Send + 'static>>;

pub async fn run() {
    ::env_logger::init();

    let _matches = clap::App::new("debugger")
        .version(env!("CARGO_PKG_VERSION"))
        .get_matches();

    let thread = new_vm();

    if let Err(err) = tokio::spawn(async {
        Server::start(thread, tokio::io::stdin(), tokio::io::stdout()).await
    })
    .await
    .unwrap()
    {
        panic!("{}", err)
    }
}

async fn cancelable<F, G>(f: F, g: G)
where
    F: Future<Output = ()>,
    G: Future<Output = ()>,
{
    futures::pin_mut!(f);
    futures::pin_mut!(g);
    futures::future::select(f, g).await;
}