mirror of
https://github.com/latex-lsp/texlab.git
synced 2025-08-04 18:58:31 +00:00
Replace future_boxed with async_trait
This commit is contained in:
parent
558b7fb2cc
commit
59df945b8a
82 changed files with 219 additions and 327 deletions
|
@ -1,15 +0,0 @@
|
|||
[package]
|
||||
name = "futures-boxed"
|
||||
version = "0.1.0"
|
||||
authors = [
|
||||
"Eric Förster <efoerster@users.noreply.github.com>",
|
||||
"Patrick Förster <pfoerster@users.noreply.github.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[lib]
|
||||
proc-macro = true
|
||||
doctest = false
|
||||
|
||||
[dependencies]
|
||||
syn = "1.0"
|
||||
quote = "1.0"
|
|
@ -1,67 +0,0 @@
|
|||
#![recursion_limit = "128"]
|
||||
|
||||
extern crate proc_macro;
|
||||
|
||||
use proc_macro::{TokenStream, TokenTree};
|
||||
use quote::{quote, ToTokens};
|
||||
use std::iter::FromIterator;
|
||||
use syn::{export::TokenStream2, *};
|
||||
|
||||
#[proc_macro_attribute]
|
||||
pub fn boxed(_attr: TokenStream, item: TokenStream) -> TokenStream {
|
||||
match parse::<ItemFn>(item.clone()) {
|
||||
Ok(fn_) => boxed_fn(fn_),
|
||||
Err(_) => {
|
||||
let item = TokenStream::from_iter(item.into_iter().filter(|x| match x {
|
||||
TokenTree::Ident(x) if x.to_string() == "async" => false,
|
||||
_ => true,
|
||||
}));
|
||||
|
||||
let method: TraitItemMethod = parse(item).unwrap();
|
||||
boxed_trait_method(method)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn boxed_fn(fn_: ItemFn) -> TokenStream {
|
||||
let attrs = &fn_.attrs;
|
||||
let vis = &fn_.vis;
|
||||
let sig = boxed_fn_sig(&fn_.sig);
|
||||
let block = &fn_.block;
|
||||
let tokens = quote! {
|
||||
#(#attrs)*
|
||||
#vis #sig {
|
||||
use futures::future::FutureExt;
|
||||
let task = async move #block;
|
||||
task.boxed()
|
||||
}
|
||||
};
|
||||
|
||||
tokens.into()
|
||||
}
|
||||
|
||||
fn boxed_trait_method(method: TraitItemMethod) -> TokenStream {
|
||||
let attrs = &method.attrs;
|
||||
let sig = boxed_fn_sig(&method.sig);
|
||||
let tokens = quote! {
|
||||
#(#attrs)*
|
||||
#sig;
|
||||
};
|
||||
|
||||
tokens.into()
|
||||
}
|
||||
|
||||
fn boxed_fn_sig(sig: &Signature) -> TokenStream2 {
|
||||
let constness = &sig.constness;
|
||||
let ident = &sig.ident;
|
||||
let generics = &sig.generics;
|
||||
let inputs = &sig.inputs;
|
||||
let return_ty = match &sig.output {
|
||||
ReturnType::Default => quote!(()),
|
||||
ReturnType::Type(_, ty) => ty.into_token_stream(),
|
||||
};
|
||||
|
||||
quote! {
|
||||
#constness fn #ident #generics(#inputs) -> futures::future::BoxFuture<'_, #return_ty>
|
||||
}
|
||||
}
|
|
@ -10,9 +10,9 @@ edition = "2018"
|
|||
doctest = false
|
||||
|
||||
[dependencies]
|
||||
async-trait = "0.1"
|
||||
chashmap = "2.2"
|
||||
futures = "0.3"
|
||||
futures-boxed = { path = "../futures_boxed" }
|
||||
log = "0.4"
|
||||
serde = { version = "1.0", features = ["derive", "rc"] }
|
||||
serde_json = "1.0"
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
use super::types::*;
|
||||
use async_trait::async_trait;
|
||||
use chashmap::CHashMap;
|
||||
use futures::{
|
||||
channel::{mpsc, oneshot},
|
||||
prelude::*,
|
||||
};
|
||||
use futures_boxed::boxed;
|
||||
use serde::Serialize;
|
||||
use serde_json::json;
|
||||
use std::sync::atomic::{AtomicU64, Ordering};
|
||||
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
|
||||
#[async_trait]
|
||||
pub trait ResponseHandler {
|
||||
#[boxed]
|
||||
async fn handle(&self, response: Response);
|
||||
}
|
||||
|
||||
|
@ -59,8 +59,8 @@ impl Client {
|
|||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl ResponseHandler for Client {
|
||||
#[boxed]
|
||||
async fn handle(&self, response: Response) {
|
||||
let id = response.id.expect("Expected response with id");
|
||||
let result = match response.error {
|
||||
|
|
|
@ -1,24 +1,22 @@
|
|||
use super::types::*;
|
||||
use async_trait::async_trait;
|
||||
use futures::prelude::*;
|
||||
use futures_boxed::boxed;
|
||||
use serde::{de::DeserializeOwned, Serialize};
|
||||
use serde_json::json;
|
||||
|
||||
pub type Result<T> = std::result::Result<T, String>;
|
||||
|
||||
#[async_trait]
|
||||
pub trait RequestHandler {
|
||||
#[boxed]
|
||||
async fn handle_request(&self, request: Request) -> Response;
|
||||
|
||||
#[boxed]
|
||||
async fn handle_notification(&self, notification: Notification);
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
pub trait Middleware {
|
||||
#[boxed]
|
||||
async fn before_message(&self);
|
||||
|
||||
#[boxed]
|
||||
async fn after_message(&self);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ extern crate proc_macro;
|
|||
|
||||
use proc_macro::TokenStream;
|
||||
use quote::quote;
|
||||
use std::str::FromStr;
|
||||
use syn::{export::TokenStream2, *};
|
||||
|
||||
macro_rules! unwrap {
|
||||
|
@ -66,8 +65,8 @@ pub fn jsonrpc_server(_attr: TokenStream, item: TokenStream) -> TokenStream {
|
|||
let tokens = quote! {
|
||||
#impl_
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl #generics jsonrpc::RequestHandler for #self_ty {
|
||||
#[futures_boxed::boxed]
|
||||
async fn handle_request(&self, request: jsonrpc::Request) -> jsonrpc::Response {
|
||||
use jsonrpc::*;
|
||||
|
||||
|
@ -79,7 +78,6 @@ pub fn jsonrpc_server(_attr: TokenStream, item: TokenStream) -> TokenStream {
|
|||
}
|
||||
}
|
||||
|
||||
#[futures_boxed::boxed]
|
||||
async fn handle_notification(&self, notification: jsonrpc::Notification) {
|
||||
match notification.method.as_str() {
|
||||
#(#notifications),*,
|
||||
|
@ -94,7 +92,7 @@ pub fn jsonrpc_server(_attr: TokenStream, item: TokenStream) -> TokenStream {
|
|||
|
||||
#[proc_macro_attribute]
|
||||
pub fn jsonrpc_client(attr: TokenStream, item: TokenStream) -> TokenStream {
|
||||
let item = TokenStream::from_str(&item.to_string().replace("async ", "")).unwrap();
|
||||
// let item = TokenStream::from_str(&item.to_string().replace("async ", "")).unwrap();
|
||||
let trait_: ItemTrait = parse_macro_input!(item);
|
||||
let trait_ident = &trait_.ident;
|
||||
let stubs = generate_client_stubs(&trait_.items);
|
||||
|
@ -102,6 +100,7 @@ pub fn jsonrpc_client(attr: TokenStream, item: TokenStream) -> TokenStream {
|
|||
let struct_ident = unwrap!(attr.first().unwrap(), NestedMeta::Meta(Meta::Path(x)) => x);
|
||||
|
||||
let tokens = quote! {
|
||||
#[async_trait::async_trait]
|
||||
#trait_
|
||||
|
||||
pub struct #struct_ident {
|
||||
|
@ -117,14 +116,15 @@ pub fn jsonrpc_client(attr: TokenStream, item: TokenStream) -> TokenStream {
|
|||
}
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl #trait_ident for #struct_ident
|
||||
{
|
||||
#(#stubs)*
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl jsonrpc::ResponseHandler for #struct_ident
|
||||
{
|
||||
#[futures_boxed::boxed]
|
||||
async fn handle(&self, response: jsonrpc::Response) -> () {
|
||||
self.client.handle(response).await
|
||||
}
|
||||
|
@ -189,14 +189,12 @@ fn generate_client_stubs(items: &Vec<TraitItem>) -> Vec<TokenStream2> {
|
|||
|
||||
let stub = match meta.kind {
|
||||
MethodKind::Request => quote!(
|
||||
#[futures_boxed::boxed]
|
||||
#sig {
|
||||
let result = self.client.send_request(#name.to_owned(), #param).await?;
|
||||
serde_json::from_value(result).map_err(|_| jsonrpc::Error::deserialize_error())
|
||||
}
|
||||
),
|
||||
MethodKind::Notification => quote!(
|
||||
#[futures_boxed::boxed]
|
||||
#sig {
|
||||
self.client.send_notification(#name.to_owned(), #param).await
|
||||
}
|
||||
|
|
|
@ -10,8 +10,8 @@ edition = "2018"
|
|||
doctest = false
|
||||
|
||||
[dependencies]
|
||||
async-trait = "0.1"
|
||||
futures = "0.3"
|
||||
futures-boxed = { path = "../futures_boxed" }
|
||||
itertools = "0.9"
|
||||
log = "0.4"
|
||||
once_cell = "1.3"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::factory::{self, LatexComponentId};
|
||||
use futures_boxed::boxed;
|
||||
use async_trait::async_trait;
|
||||
use texlab_components::COMPONENT_DATABASE;
|
||||
use texlab_feature::{DocumentContent, FeatureProvider, FeatureRequest};
|
||||
use texlab_protocol::{CompletionItem, CompletionParams, RangeExt, TextEdit};
|
||||
|
@ -8,11 +8,11 @@ use texlab_syntax::SyntaxNode;
|
|||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
|
||||
pub struct BibtexCommandCompletionProvider;
|
||||
|
||||
#[async_trait]
|
||||
impl FeatureProvider for BibtexCommandCompletionProvider {
|
||||
type Params = CompletionParams;
|
||||
type Output = Vec<CompletionItem>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
let mut items = Vec::new();
|
||||
if let DocumentContent::Bibtex(tree) = &req.current().content {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::factory;
|
||||
use futures_boxed::boxed;
|
||||
use async_trait::async_trait;
|
||||
use texlab_feature::{DocumentContent, FeatureProvider, FeatureRequest};
|
||||
use texlab_protocol::{CompletionItem, CompletionParams, Position, Range, RangeExt, TextEdit};
|
||||
use texlab_syntax::{bibtex, SyntaxNode, LANGUAGE_DATA};
|
||||
|
@ -7,11 +7,11 @@ use texlab_syntax::{bibtex, SyntaxNode, LANGUAGE_DATA};
|
|||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
|
||||
pub struct BibtexEntryTypeCompletionProvider;
|
||||
|
||||
#[async_trait]
|
||||
impl FeatureProvider for BibtexEntryTypeCompletionProvider {
|
||||
type Params = CompletionParams;
|
||||
type Output = Vec<CompletionItem>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
if let DocumentContent::Bibtex(tree) = &req.current().content {
|
||||
let pos = req.params.text_document_position.position;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::factory;
|
||||
use futures_boxed::boxed;
|
||||
use async_trait::async_trait;
|
||||
use texlab_feature::{DocumentContent, FeatureProvider, FeatureRequest};
|
||||
use texlab_protocol::{CompletionItem, CompletionParams, Range, RangeExt, TextEdit};
|
||||
use texlab_syntax::{bibtex, SyntaxNode, LANGUAGE_DATA};
|
||||
|
@ -7,11 +7,11 @@ use texlab_syntax::{bibtex, SyntaxNode, LANGUAGE_DATA};
|
|||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
|
||||
pub struct BibtexFieldNameCompletionProvider;
|
||||
|
||||
#[async_trait]
|
||||
impl FeatureProvider for BibtexFieldNameCompletionProvider {
|
||||
type Params = CompletionParams;
|
||||
type Output = Vec<CompletionItem>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
if let DocumentContent::Bibtex(tree) = &req.current().content {
|
||||
let pos = req.params.text_document_position.position;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use super::combinators::{self, Parameter};
|
||||
use crate::factory;
|
||||
use futures_boxed::boxed;
|
||||
use async_trait::async_trait;
|
||||
use std::iter;
|
||||
use texlab_feature::{FeatureProvider, FeatureRequest};
|
||||
use texlab_protocol::{CompletionItem, CompletionParams, TextEdit};
|
||||
|
@ -8,11 +8,11 @@ use texlab_protocol::{CompletionItem, CompletionParams, TextEdit};
|
|||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
|
||||
pub struct LatexArgumentCompletionProvider;
|
||||
|
||||
#[async_trait]
|
||||
impl FeatureProvider for LatexArgumentCompletionProvider {
|
||||
type Params = CompletionParams;
|
||||
type Output = Vec<CompletionItem>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
let mut all_items = Vec::new();
|
||||
for comp in req.view.components() {
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
use super::combinators;
|
||||
use crate::factory::{self, LatexComponentId};
|
||||
use futures_boxed::boxed;
|
||||
use async_trait::async_trait;
|
||||
use texlab_feature::{FeatureProvider, FeatureRequest};
|
||||
use texlab_protocol::{CompletionItem, CompletionParams};
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
|
||||
pub struct LatexBeginCommandCompletionProvider;
|
||||
|
||||
#[async_trait]
|
||||
impl FeatureProvider for LatexBeginCommandCompletionProvider {
|
||||
type Params = CompletionParams;
|
||||
type Output = Vec<CompletionItem>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
combinators::command(req, |_| async move {
|
||||
let snippet = factory::command_snippet(
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use super::combinators::{self, ArgumentContext, Parameter};
|
||||
use crate::factory;
|
||||
use futures_boxed::boxed;
|
||||
use async_trait::async_trait;
|
||||
use petgraph::graph::NodeIndex;
|
||||
use texlab_feature::{Document, DocumentContent, FeatureProvider, FeatureRequest};
|
||||
use texlab_protocol::{CompletionItem, CompletionParams, TextEdit};
|
||||
|
@ -9,11 +9,11 @@ use texlab_syntax::{bibtex, LANGUAGE_DATA};
|
|||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
|
||||
pub struct LatexCitationCompletionProvider;
|
||||
|
||||
#[async_trait]
|
||||
impl FeatureProvider for LatexCitationCompletionProvider {
|
||||
type Params = CompletionParams;
|
||||
type Output = Vec<CompletionItem>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
let parameters = LANGUAGE_DATA.citation_commands.iter().map(|cmd| Parameter {
|
||||
name: &cmd.name,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use super::combinators::{self, Parameter};
|
||||
use crate::factory;
|
||||
use futures_boxed::boxed;
|
||||
use async_trait::async_trait;
|
||||
use texlab_feature::{FeatureProvider, FeatureRequest};
|
||||
use texlab_protocol::{CompletionItem, CompletionParams, TextEdit};
|
||||
use texlab_syntax::LANGUAGE_DATA;
|
||||
|
@ -8,11 +8,11 @@ use texlab_syntax::LANGUAGE_DATA;
|
|||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
|
||||
pub struct LatexColorCompletionProvider;
|
||||
|
||||
#[async_trait]
|
||||
impl FeatureProvider for LatexColorCompletionProvider {
|
||||
type Params = CompletionParams;
|
||||
type Output = Vec<CompletionItem>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
let parameters = LANGUAGE_DATA.color_commands.iter().map(|cmd| Parameter {
|
||||
name: &cmd.name,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use super::combinators::{self, Parameter};
|
||||
use crate::factory;
|
||||
use futures_boxed::boxed;
|
||||
use async_trait::async_trait;
|
||||
use texlab_feature::{FeatureProvider, FeatureRequest};
|
||||
use texlab_protocol::{CompletionItem, CompletionParams, TextEdit};
|
||||
use texlab_syntax::LANGUAGE_DATA;
|
||||
|
@ -10,11 +10,11 @@ const MODEL_NAMES: &[&str] = &["gray", "rgb", "RGB", "HTML", "cmyk"];
|
|||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
|
||||
pub struct LatexColorModelCompletionProvider;
|
||||
|
||||
#[async_trait]
|
||||
impl FeatureProvider for LatexColorModelCompletionProvider {
|
||||
type Params = CompletionParams;
|
||||
type Output = Vec<CompletionItem>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
let parameters = LANGUAGE_DATA
|
||||
.color_model_commands
|
||||
|
|
|
@ -4,7 +4,7 @@ use crate::{
|
|||
quality::QualityEvaluator,
|
||||
COMPLETION_LIMIT,
|
||||
};
|
||||
use futures_boxed::boxed;
|
||||
use async_trait::async_trait;
|
||||
use texlab_feature::{FeatureProvider, FeatureRequest};
|
||||
use texlab_protocol::{CompletionItem, CompletionParams, TextEdit};
|
||||
|
||||
|
@ -19,11 +19,11 @@ struct CommandItem {
|
|||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
|
||||
pub struct LatexComponentCommandCompletionProvider;
|
||||
|
||||
#[async_trait]
|
||||
impl FeatureProvider for LatexComponentCommandCompletionProvider {
|
||||
type Params = CompletionParams;
|
||||
type Output = Vec<CompletionItem>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
combinators::command(req, |cmd_node| async move {
|
||||
let table = req.current().content.as_latex().unwrap();
|
||||
|
@ -70,11 +70,11 @@ impl FeatureProvider for LatexComponentCommandCompletionProvider {
|
|||
|
||||
pub struct LatexComponentEnvironmentCompletionProvider;
|
||||
|
||||
#[async_trait]
|
||||
impl FeatureProvider for LatexComponentEnvironmentCompletionProvider {
|
||||
type Params = CompletionParams;
|
||||
type Output = Vec<CompletionItem>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
combinators::environment(req, |ctx| async move {
|
||||
let mut items = Vec::new();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use super::combinators::{self, Parameter};
|
||||
use crate::factory;
|
||||
use futures_boxed::boxed;
|
||||
use async_trait::async_trait;
|
||||
use texlab_feature::{DocumentContent, FeatureProvider, FeatureRequest};
|
||||
use texlab_protocol::{CompletionItem, CompletionParams, TextEdit};
|
||||
use texlab_syntax::{
|
||||
|
@ -11,11 +11,11 @@ use texlab_syntax::{
|
|||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
|
||||
pub struct LatexGlossaryCompletionProvider;
|
||||
|
||||
#[async_trait]
|
||||
impl FeatureProvider for LatexGlossaryCompletionProvider {
|
||||
type Params = CompletionParams;
|
||||
type Output = Vec<CompletionItem>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
let parameters = LANGUAGE_DATA
|
||||
.glossary_entry_reference_commands
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use super::combinators::{self, Parameter};
|
||||
use crate::factory;
|
||||
use futures_boxed::boxed;
|
||||
use async_trait::async_trait;
|
||||
use texlab_components::COMPONENT_DATABASE;
|
||||
use texlab_feature::{FeatureProvider, FeatureRequest};
|
||||
use texlab_protocol::{CompletionItem, CompletionParams, TextEdit};
|
||||
|
@ -9,11 +9,11 @@ use texlab_syntax::{LatexIncludeKind, LANGUAGE_DATA};
|
|||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
|
||||
pub struct LatexClassImportProvider;
|
||||
|
||||
#[async_trait]
|
||||
impl FeatureProvider for LatexClassImportProvider {
|
||||
type Params = CompletionParams;
|
||||
type Output = Vec<CompletionItem>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
import(req, LatexIncludeKind::Class, factory::class).await
|
||||
}
|
||||
|
@ -22,11 +22,11 @@ impl FeatureProvider for LatexClassImportProvider {
|
|||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
|
||||
pub struct LatexPackageImportProvider;
|
||||
|
||||
#[async_trait]
|
||||
impl FeatureProvider for LatexPackageImportProvider {
|
||||
type Params = CompletionParams;
|
||||
type Output = Vec<CompletionItem>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
import(req, LatexIncludeKind::Package, factory::package).await
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use super::combinators::{self, Parameter};
|
||||
use crate::factory;
|
||||
use futures_boxed::boxed;
|
||||
use async_trait::async_trait;
|
||||
use std::path::{Path, PathBuf};
|
||||
use texlab_feature::{FeatureProvider, FeatureRequest};
|
||||
use texlab_protocol::{CompletionItem, CompletionParams, Range, RangeExt, TextEdit};
|
||||
|
@ -10,11 +10,11 @@ use tokio::fs;
|
|||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
|
||||
pub struct LatexIncludeCompletionProvider;
|
||||
|
||||
#[async_trait]
|
||||
impl FeatureProvider for LatexIncludeCompletionProvider {
|
||||
type Params = CompletionParams;
|
||||
type Output = Vec<CompletionItem>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
let parameters = LANGUAGE_DATA.include_commands.iter().map(|cmd| Parameter {
|
||||
name: &cmd.name,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use super::combinators::{self, ArgumentContext, Parameter};
|
||||
use crate::factory;
|
||||
use futures_boxed::boxed;
|
||||
use async_trait::async_trait;
|
||||
use std::sync::Arc;
|
||||
use texlab_feature::{
|
||||
DocumentContent, DocumentView, FeatureProvider, FeatureRequest, Outline, OutlineContext,
|
||||
|
@ -11,11 +11,11 @@ use texlab_syntax::{latex, LatexLabelKind, LatexLabelReferenceSource, SyntaxNode
|
|||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
|
||||
pub struct LatexLabelCompletionProvider;
|
||||
|
||||
#[async_trait]
|
||||
impl FeatureProvider for LatexLabelCompletionProvider {
|
||||
type Params = CompletionParams;
|
||||
type Output = Vec<CompletionItem>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
let parameters = LANGUAGE_DATA
|
||||
.label_commands
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
use super::combinators;
|
||||
use crate::factory::{self, LatexComponentId};
|
||||
use futures_boxed::boxed;
|
||||
use async_trait::async_trait;
|
||||
use texlab_feature::{DocumentContent, FeatureProvider, FeatureRequest};
|
||||
use texlab_protocol::{CompletionItem, CompletionParams, TextEdit};
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
|
||||
pub struct LatexTheoremEnvironmentCompletionProvider;
|
||||
|
||||
#[async_trait]
|
||||
impl FeatureProvider for LatexTheoremEnvironmentCompletionProvider {
|
||||
type Params = CompletionParams;
|
||||
type Output = Vec<CompletionItem>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
combinators::environment(req, |ctx| async move {
|
||||
let mut items = Vec::new();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use super::combinators::{self, Parameter};
|
||||
use crate::factory;
|
||||
use futures_boxed::boxed;
|
||||
use async_trait::async_trait;
|
||||
use std::iter;
|
||||
use texlab_feature::{FeatureProvider, FeatureRequest};
|
||||
use texlab_protocol::{CompletionItem, CompletionParams, TextEdit};
|
||||
|
@ -9,11 +9,11 @@ use texlab_syntax::LANGUAGE_DATA;
|
|||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
|
||||
pub struct LatexPgfLibraryCompletionProvider;
|
||||
|
||||
#[async_trait]
|
||||
impl FeatureProvider for LatexPgfLibraryCompletionProvider {
|
||||
type Params = CompletionParams;
|
||||
type Output = Vec<CompletionItem>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
let param = Parameter {
|
||||
name: "\\usepgflibrary",
|
||||
|
@ -35,11 +35,11 @@ impl FeatureProvider for LatexPgfLibraryCompletionProvider {
|
|||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
|
||||
pub struct LatexTikzLibraryCompletionProvider;
|
||||
|
||||
#[async_trait]
|
||||
impl FeatureProvider for LatexTikzLibraryCompletionProvider {
|
||||
type Params = CompletionParams;
|
||||
type Output = Vec<CompletionItem>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
let param = Parameter {
|
||||
name: "\\usetikzlibrary",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use super::combinators;
|
||||
use crate::factory::{self, LatexComponentId};
|
||||
use futures_boxed::boxed;
|
||||
use async_trait::async_trait;
|
||||
use itertools::Itertools;
|
||||
use texlab_feature::{DocumentContent, FeatureProvider, FeatureRequest};
|
||||
use texlab_protocol::{CompletionItem, CompletionParams, Range, TextEdit};
|
||||
|
@ -9,11 +9,11 @@ use texlab_syntax::latex;
|
|||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
|
||||
pub struct LatexUserCommandCompletionProvider;
|
||||
|
||||
#[async_trait]
|
||||
impl FeatureProvider for LatexUserCommandCompletionProvider {
|
||||
type Params = CompletionParams;
|
||||
type Output = Vec<CompletionItem>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
combinators::command(req, |current_cmd_node| async move {
|
||||
let current_cmd = req
|
||||
|
@ -60,11 +60,11 @@ impl FeatureProvider for LatexUserCommandCompletionProvider {
|
|||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
|
||||
pub struct LatexUserEnvironmentCompletionProvider;
|
||||
|
||||
#[async_trait]
|
||||
impl FeatureProvider for LatexUserEnvironmentCompletionProvider {
|
||||
type Params = CompletionParams;
|
||||
type Output = Vec<CompletionItem>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
combinators::environment(req, |ctx| async move {
|
||||
let mut items = Vec::new();
|
||||
|
|
|
@ -31,7 +31,7 @@ use self::{
|
|||
preselect::PreselectCompletionProvider,
|
||||
quality::OrderByQualityCompletionProvider,
|
||||
};
|
||||
use futures_boxed::boxed;
|
||||
use async_trait::async_trait;
|
||||
use itertools::Itertools;
|
||||
use std::hash::{Hash, Hasher};
|
||||
use texlab_feature::{ConcatProvider, FeatureProvider, FeatureRequest};
|
||||
|
@ -82,11 +82,11 @@ impl Default for CompletionProvider {
|
|||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl FeatureProvider for CompletionProvider {
|
||||
type Params = CompletionParams;
|
||||
type Output = Vec<CompletionItem>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
self.provider
|
||||
.execute(req)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use futures_boxed::boxed;
|
||||
use async_trait::async_trait;
|
||||
use texlab_feature::{DocumentContent, FeatureProvider, FeatureRequest};
|
||||
use texlab_protocol::{CompletionItem, CompletionParams, RangeExt};
|
||||
use texlab_syntax::{latex, SyntaxNode};
|
||||
|
@ -6,6 +6,7 @@ use texlab_syntax::{latex, SyntaxNode};
|
|||
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
|
||||
pub struct PreselectCompletionProvider<F>(pub F);
|
||||
|
||||
#[async_trait]
|
||||
impl<F> FeatureProvider for PreselectCompletionProvider<F>
|
||||
where
|
||||
F: FeatureProvider<Params = CompletionParams, Output = Vec<CompletionItem>> + Send + Sync,
|
||||
|
@ -13,7 +14,6 @@ where
|
|||
type Params = CompletionParams;
|
||||
type Output = Vec<CompletionItem>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
let pos = req.params.text_document_position.position;
|
||||
let mut items = self.0.execute(req).await;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use futures_boxed::boxed;
|
||||
use async_trait::async_trait;
|
||||
use std::borrow::Cow;
|
||||
use texlab_feature::{Document, DocumentContent, FeatureProvider, FeatureRequest};
|
||||
use texlab_protocol::{CompletionItem, CompletionParams, Position, RangeExt};
|
||||
|
@ -113,6 +113,7 @@ impl<'a> QualityEvaluator<'a> {
|
|||
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
|
||||
pub struct OrderByQualityCompletionProvider<F>(pub F);
|
||||
|
||||
#[async_trait]
|
||||
impl<F> FeatureProvider for OrderByQualityCompletionProvider<F>
|
||||
where
|
||||
F: FeatureProvider<Params = CompletionParams, Output = Vec<CompletionItem>> + Send + Sync,
|
||||
|
@ -120,7 +121,6 @@ where
|
|||
type Params = CompletionParams;
|
||||
type Output = Vec<CompletionItem>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
let pos = req.params.text_document_position.position;
|
||||
let eval = QualityEvaluator::parse(req.current(), pos);
|
||||
|
|
|
@ -10,8 +10,8 @@ edition = "2018"
|
|||
doctest = false
|
||||
|
||||
[dependencies]
|
||||
async-trait = "0.1"
|
||||
futures = "0.3"
|
||||
futures-boxed = { path = "../futures_boxed" }
|
||||
log = "0.4"
|
||||
petgraph = { version = "0.5", features = ["serde-1"] }
|
||||
texlab-feature = { path = "../texlab_feature" }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use futures_boxed::boxed;
|
||||
use async_trait::async_trait;
|
||||
use texlab_feature::{DocumentContent, FeatureProvider, FeatureRequest};
|
||||
use texlab_protocol::{LocationLink, Position, TextDocumentPositionParams, Uri};
|
||||
use texlab_syntax::{bibtex, SyntaxNode};
|
||||
|
@ -6,11 +6,11 @@ use texlab_syntax::{bibtex, SyntaxNode};
|
|||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
|
||||
pub struct BibtexStringDefinitionProvider;
|
||||
|
||||
#[async_trait]
|
||||
impl FeatureProvider for BibtexStringDefinitionProvider {
|
||||
type Params = TextDocumentPositionParams;
|
||||
type Output = Vec<LocationLink>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
if let DocumentContent::Bibtex(tree) = &req.current().content {
|
||||
if let Some(reference) = Self::find_reference(tree, req.params.position) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use futures_boxed::boxed;
|
||||
use async_trait::async_trait;
|
||||
use texlab_feature::{Document, DocumentContent, FeatureProvider, FeatureRequest};
|
||||
use texlab_protocol::{LocationLink, RangeExt, TextDocumentPositionParams};
|
||||
use texlab_syntax::{latex, SyntaxNode};
|
||||
|
@ -6,11 +6,11 @@ use texlab_syntax::{latex, SyntaxNode};
|
|||
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||
pub struct LatexCitationDefinitionProvider;
|
||||
|
||||
#[async_trait]
|
||||
impl FeatureProvider for LatexCitationDefinitionProvider {
|
||||
type Params = TextDocumentPositionParams;
|
||||
type Output = Vec<LocationLink>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
let mut links = Vec::new();
|
||||
if let Some(reference) = Self::find_reference(req) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use futures_boxed::boxed;
|
||||
use async_trait::async_trait;
|
||||
use texlab_feature::{DocumentContent, FeatureProvider, FeatureRequest};
|
||||
use texlab_protocol::{LocationLink, TextDocumentPositionParams};
|
||||
use texlab_syntax::SyntaxNode;
|
||||
|
@ -6,11 +6,11 @@ use texlab_syntax::SyntaxNode;
|
|||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
|
||||
pub struct LatexCommandDefinitionProvider;
|
||||
|
||||
#[async_trait]
|
||||
impl FeatureProvider for LatexCommandDefinitionProvider {
|
||||
type Params = TextDocumentPositionParams;
|
||||
type Output = Vec<LocationLink>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
let mut links = Vec::new();
|
||||
if let DocumentContent::Latex(table) = &req.current().content {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use futures_boxed::boxed;
|
||||
use async_trait::async_trait;
|
||||
use std::{path::Path, sync::Arc};
|
||||
use texlab_feature::{
|
||||
DocumentContent, DocumentView, FeatureProvider, FeatureRequest, Outline, OutlineContext,
|
||||
|
@ -11,11 +11,11 @@ use texlab_syntax::{latex, LatexLabelKind, SyntaxNode};
|
|||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
|
||||
pub struct LatexLabelDefinitionProvider;
|
||||
|
||||
#[async_trait]
|
||||
impl FeatureProvider for LatexLabelDefinitionProvider {
|
||||
type Params = TextDocumentPositionParams;
|
||||
type Output = Vec<LocationLink>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
let mut links = Vec::new();
|
||||
if let Some(reference) = Self::find_reference(req) {
|
||||
|
|
|
@ -7,7 +7,7 @@ use self::{
|
|||
bibtex_string::BibtexStringDefinitionProvider, latex_citation::LatexCitationDefinitionProvider,
|
||||
latex_cmd::LatexCommandDefinitionProvider, latex_label::LatexLabelDefinitionProvider,
|
||||
};
|
||||
use futures_boxed::boxed;
|
||||
use async_trait::async_trait;
|
||||
use texlab_feature::{ConcatProvider, FeatureProvider, FeatureRequest};
|
||||
use texlab_protocol::{LocationLink, TextDocumentPositionParams};
|
||||
|
||||
|
@ -34,11 +34,11 @@ impl Default for DefinitionProvider {
|
|||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl FeatureProvider for DefinitionProvider {
|
||||
type Params = TextDocumentPositionParams;
|
||||
type Output = Vec<LocationLink>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
self.provider.execute(req).await
|
||||
}
|
||||
|
|
|
@ -10,8 +10,8 @@ edition = "2018"
|
|||
doctest = false
|
||||
|
||||
[dependencies]
|
||||
async-trait = "0.1"
|
||||
futures = "0.3"
|
||||
futures-boxed = { path = "../futures_boxed" }
|
||||
itertools = "0.9"
|
||||
log = "0.4"
|
||||
petgraph = { version = "0.5", features = ["serde-1"] }
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::workspace::{Document, DocumentContent, DocumentParams, Snapshot};
|
||||
use futures_boxed::boxed;
|
||||
use async_trait::async_trait;
|
||||
use itertools::Itertools;
|
||||
use std::{
|
||||
env,
|
||||
|
@ -85,11 +85,11 @@ impl<P> FeatureRequest<P> {
|
|||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
pub trait FeatureProvider {
|
||||
type Params;
|
||||
type Output;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output;
|
||||
}
|
||||
|
||||
|
@ -106,6 +106,7 @@ impl<P, O> ConcatProvider<P, O> {
|
|||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl<P, O> FeatureProvider for ConcatProvider<P, O>
|
||||
where
|
||||
P: Send + Sync,
|
||||
|
@ -114,7 +115,6 @@ where
|
|||
type Params = P;
|
||||
type Output = Vec<O>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<P>) -> Vec<O> {
|
||||
let mut items = Vec::new();
|
||||
for provider in &self.providers {
|
||||
|
@ -137,6 +137,7 @@ impl<P, O> ChoiceProvider<P, O> {
|
|||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl<P, O> FeatureProvider for ChoiceProvider<P, O>
|
||||
where
|
||||
P: Send + Sync,
|
||||
|
@ -145,7 +146,6 @@ where
|
|||
type Params = P;
|
||||
type Output = Option<O>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<P>) -> Option<O> {
|
||||
for provider in &self.providers {
|
||||
let item = provider.execute(req).await;
|
||||
|
|
|
@ -10,8 +10,8 @@ edition = "2018"
|
|||
doctest = false
|
||||
|
||||
[dependencies]
|
||||
async-trait = "0.1"
|
||||
futures = "0.3"
|
||||
futures-boxed = { path = "../futures_boxed" }
|
||||
log = "0.4"
|
||||
petgraph = { version = "0.5", features = ["serde-1"] }
|
||||
texlab-feature = { path = "../texlab_feature" }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use futures_boxed::boxed;
|
||||
use async_trait::async_trait;
|
||||
use petgraph::graph::NodeIndex;
|
||||
use texlab_feature::{DocumentContent, FeatureProvider, FeatureRequest};
|
||||
use texlab_protocol::{FoldingRange, FoldingRangeKind, FoldingRangeParams};
|
||||
|
@ -7,11 +7,11 @@ use texlab_syntax::{bibtex, SyntaxNode};
|
|||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
|
||||
pub struct BibtexDeclarationFoldingProvider;
|
||||
|
||||
#[async_trait]
|
||||
impl FeatureProvider for BibtexDeclarationFoldingProvider {
|
||||
type Params = FoldingRangeParams;
|
||||
type Output = Vec<FoldingRange>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
if let DocumentContent::Bibtex(tree) = &req.current().content {
|
||||
tree.children(tree.root)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use futures_boxed::boxed;
|
||||
use async_trait::async_trait;
|
||||
use texlab_feature::{DocumentContent, FeatureProvider, FeatureRequest};
|
||||
use texlab_protocol::{FoldingRange, FoldingRangeKind, FoldingRangeParams};
|
||||
use texlab_syntax::SyntaxNode;
|
||||
|
@ -6,11 +6,11 @@ use texlab_syntax::SyntaxNode;
|
|||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
|
||||
pub struct LatexEnvironmentFoldingProvider;
|
||||
|
||||
#[async_trait]
|
||||
impl FeatureProvider for LatexEnvironmentFoldingProvider {
|
||||
type Params = FoldingRangeParams;
|
||||
type Output = Vec<FoldingRange>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
let mut foldings = Vec::new();
|
||||
if let DocumentContent::Latex(table) = &req.current().content {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use futures_boxed::boxed;
|
||||
use async_trait::async_trait;
|
||||
use texlab_feature::{DocumentContent, FeatureProvider, FeatureRequest};
|
||||
use texlab_protocol::{FoldingRange, FoldingRangeKind, FoldingRangeParams};
|
||||
use texlab_syntax::SyntaxNode;
|
||||
|
@ -6,11 +6,11 @@ use texlab_syntax::SyntaxNode;
|
|||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
|
||||
pub struct LatexSectionFoldingProvider;
|
||||
|
||||
#[async_trait]
|
||||
impl FeatureProvider for LatexSectionFoldingProvider {
|
||||
type Params = FoldingRangeParams;
|
||||
type Output = Vec<FoldingRange>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
let mut foldings = Vec::new();
|
||||
if let DocumentContent::Latex(table) = &req.current().content {
|
||||
|
|
|
@ -6,7 +6,7 @@ use self::{
|
|||
bibtex_decl::BibtexDeclarationFoldingProvider, latex_env::LatexEnvironmentFoldingProvider,
|
||||
latex_section::LatexSectionFoldingProvider,
|
||||
};
|
||||
use futures_boxed::boxed;
|
||||
use async_trait::async_trait;
|
||||
use texlab_feature::{ConcatProvider, FeatureProvider, FeatureRequest};
|
||||
use texlab_protocol::{FoldingRange, FoldingRangeParams};
|
||||
|
||||
|
@ -32,11 +32,11 @@ impl Default for FoldingProvider {
|
|||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl FeatureProvider for FoldingProvider {
|
||||
type Params = FoldingRangeParams;
|
||||
type Output = Vec<FoldingRange>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
self.provider.execute(req).await
|
||||
}
|
||||
|
|
|
@ -10,9 +10,9 @@ edition = "2018"
|
|||
doctest = false
|
||||
|
||||
[dependencies]
|
||||
async-trait = "0.1"
|
||||
base64 = "0.12"
|
||||
futures = "0.3"
|
||||
futures-boxed = { path = "../futures_boxed" }
|
||||
image = "0.23"
|
||||
itertools = "0.9"
|
||||
log = "0.4"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use futures_boxed::boxed;
|
||||
use async_trait::async_trait;
|
||||
use texlab_feature::{FeatureProvider, FeatureRequest};
|
||||
use texlab_protocol::{
|
||||
Hover, HoverContents, MarkupContent, MarkupKind, RangeExt, TextDocumentPositionParams,
|
||||
|
@ -8,11 +8,11 @@ use texlab_syntax::{SyntaxNode, LANGUAGE_DATA};
|
|||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
|
||||
pub struct BibtexEntryTypeHoverProvider;
|
||||
|
||||
#[async_trait]
|
||||
impl FeatureProvider for BibtexEntryTypeHoverProvider {
|
||||
type Params = TextDocumentPositionParams;
|
||||
type Output = Option<Hover>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
let tree = req.current().content.as_bibtex()?;
|
||||
for entry in tree
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use futures_boxed::boxed;
|
||||
use async_trait::async_trait;
|
||||
use texlab_feature::{FeatureProvider, FeatureRequest};
|
||||
use texlab_protocol::{
|
||||
Hover, HoverContents, MarkupContent, MarkupKind, RangeExt, TextDocumentPositionParams,
|
||||
|
@ -8,11 +8,11 @@ use texlab_syntax::{SyntaxNode, LANGUAGE_DATA};
|
|||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
|
||||
pub struct BibtexFieldHoverProvider;
|
||||
|
||||
#[async_trait]
|
||||
impl FeatureProvider for BibtexFieldHoverProvider {
|
||||
type Params = TextDocumentPositionParams;
|
||||
type Output = Option<Hover>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
let tree = req.current().content.as_bibtex()?;
|
||||
let name = tree
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use futures_boxed::boxed;
|
||||
use async_trait::async_trait;
|
||||
use petgraph::graph::NodeIndex;
|
||||
use texlab_feature::{FeatureProvider, FeatureRequest};
|
||||
use texlab_protocol::{
|
||||
|
@ -10,11 +10,11 @@ use texlab_syntax::{bibtex, SyntaxNode};
|
|||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
|
||||
pub struct BibtexStringReferenceHoverProvider;
|
||||
|
||||
#[async_trait]
|
||||
impl FeatureProvider for BibtexStringReferenceHoverProvider {
|
||||
type Params = TextDocumentPositionParams;
|
||||
type Output = Option<Hover>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
let tree = req.current().content.as_bibtex()?;
|
||||
let reference = Self::find_reference(tree, req.params.position)?;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use futures_boxed::boxed;
|
||||
use async_trait::async_trait;
|
||||
use log::warn;
|
||||
use texlab_citeproc::render_citation;
|
||||
use texlab_feature::{DocumentContent, FeatureProvider, FeatureRequest};
|
||||
|
@ -8,11 +8,11 @@ use texlab_syntax::{bibtex, Span, SyntaxNode};
|
|||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
|
||||
pub struct LatexCitationHoverProvider;
|
||||
|
||||
#[async_trait]
|
||||
impl FeatureProvider for LatexCitationHoverProvider {
|
||||
type Params = TextDocumentPositionParams;
|
||||
type Output = Option<Hover>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
let (tree, src_key, entry) = Self::get_entry(req)?;
|
||||
if entry.is_comment() {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use futures_boxed::boxed;
|
||||
use async_trait::async_trait;
|
||||
use texlab_components::COMPONENT_DATABASE;
|
||||
use texlab_feature::{FeatureProvider, FeatureRequest};
|
||||
use texlab_protocol::{Hover, HoverContents, RangeExt, TextDocumentPositionParams};
|
||||
|
@ -7,11 +7,11 @@ use texlab_syntax::{LatexIncludeKind, SyntaxNode};
|
|||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
|
||||
pub struct LatexComponentHoverProvider;
|
||||
|
||||
#[async_trait]
|
||||
impl FeatureProvider for LatexComponentHoverProvider {
|
||||
type Params = TextDocumentPositionParams;
|
||||
type Output = Option<Hover>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
let table = req.current().content.as_latex()?;
|
||||
for include in &table.includes {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use futures_boxed::boxed;
|
||||
use async_trait::async_trait;
|
||||
use std::sync::Arc;
|
||||
use texlab_feature::{
|
||||
Document, DocumentContent, DocumentView, FeatureProvider, FeatureRequest, Outline,
|
||||
|
@ -10,11 +10,11 @@ use texlab_syntax::{latex, LatexLabelKind, SyntaxNode};
|
|||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
|
||||
pub struct LatexLabelHoverProvider;
|
||||
|
||||
#[async_trait]
|
||||
impl FeatureProvider for LatexLabelHoverProvider {
|
||||
type Params = TextDocumentPositionParams;
|
||||
type Output = Option<Hover>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
let table = req.current().content.as_latex()?;
|
||||
let reference = Self::find_reference(table, req.params.position)?;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use futures_boxed::boxed;
|
||||
use async_trait::async_trait;
|
||||
use image::{png::PNGEncoder, ColorType, DynamicImage, GenericImageView, ImageBuffer, RgbaImage};
|
||||
use io::Cursor;
|
||||
use log::warn;
|
||||
|
@ -282,11 +282,11 @@ impl LatexPreviewHoverProvider {
|
|||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl FeatureProvider for LatexPreviewHoverProvider {
|
||||
type Params = TextDocumentPositionParams;
|
||||
type Output = Option<Hover>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
if !req.client_capabilities.has_hover_markdown_support()
|
||||
|| req.distro.0.kind() == DistributionKind::Tectonic
|
||||
|
|
|
@ -11,7 +11,7 @@ use self::{
|
|||
label::LatexLabelHoverProvider, preview::LatexPreviewHoverProvider,
|
||||
},
|
||||
};
|
||||
use futures_boxed::boxed;
|
||||
use async_trait::async_trait;
|
||||
use texlab_feature::{ChoiceProvider, FeatureProvider, FeatureRequest};
|
||||
use texlab_protocol::{Hover, TextDocumentPositionParams};
|
||||
|
||||
|
@ -41,11 +41,11 @@ impl Default for HoverProvider {
|
|||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl FeatureProvider for HoverProvider {
|
||||
type Params = TextDocumentPositionParams;
|
||||
type Output = Option<Hover>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
self.provider.execute(req).await
|
||||
}
|
||||
|
|
|
@ -10,9 +10,9 @@ edition = "2018"
|
|||
doctest = false
|
||||
|
||||
[dependencies]
|
||||
async-trait = "0.1"
|
||||
bytes = "0.5"
|
||||
futures = "0.3"
|
||||
futures-boxed = { path = "../futures_boxed" }
|
||||
jsonrpc = { path = "../jsonrpc" }
|
||||
jsonrpc-derive = { path = "../jsonrpc_derive" }
|
||||
log = "0.4"
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
use futures_boxed::boxed;
|
||||
use jsonrpc::client::Result;
|
||||
use jsonrpc_derive::{jsonrpc_client, jsonrpc_method};
|
||||
use lsp_types::*;
|
||||
|
@ -6,30 +5,23 @@ use lsp_types::*;
|
|||
#[jsonrpc_client(LatexLspClient)]
|
||||
pub trait LspClient {
|
||||
#[jsonrpc_method("workspace/configuration", kind = "request")]
|
||||
#[boxed]
|
||||
async fn configuration(&self, params: ConfigurationParams) -> Result<serde_json::Value>;
|
||||
|
||||
#[jsonrpc_method("window/showMessage", kind = "notification")]
|
||||
#[boxed]
|
||||
async fn show_message(&self, params: ShowMessageParams);
|
||||
|
||||
#[jsonrpc_method("client/registerCapability", kind = "request")]
|
||||
#[boxed]
|
||||
async fn register_capability(&self, params: RegistrationParams) -> Result<()>;
|
||||
|
||||
#[jsonrpc_method("textDocument/publishDiagnostics", kind = "notification")]
|
||||
#[boxed]
|
||||
async fn publish_diagnostics(&self, params: PublishDiagnosticsParams);
|
||||
|
||||
#[jsonrpc_method("$/progress", kind = "notification")]
|
||||
#[boxed]
|
||||
async fn progress(&self, params: ProgressParams);
|
||||
|
||||
#[jsonrpc_method("window/workDoneProgress/create", kind = "request")]
|
||||
#[boxed]
|
||||
async fn work_done_progress_create(&self, params: WorkDoneProgressCreateParams) -> Result<()>;
|
||||
|
||||
#[jsonrpc_method("window/logMessage", kind = "notification")]
|
||||
#[boxed]
|
||||
async fn log_message(&self, params: LogMessageParams);
|
||||
}
|
||||
|
|
|
@ -10,8 +10,8 @@ edition = "2018"
|
|||
doctest = false
|
||||
|
||||
[dependencies]
|
||||
async-trait = "0.1"
|
||||
futures = "0.3"
|
||||
futures-boxed = { path = "../futures_boxed" }
|
||||
log = "0.4"
|
||||
petgraph = { version = "0.5", features = ["serde-1"] }
|
||||
texlab-feature = { path = "../texlab_feature" }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use futures_boxed::boxed;
|
||||
use async_trait::async_trait;
|
||||
use texlab_feature::{DocumentContent, FeatureProvider, FeatureRequest};
|
||||
use texlab_protocol::{Location, RangeExt, ReferenceParams, Url};
|
||||
use texlab_syntax::{bibtex, latex, SyntaxNode};
|
||||
|
@ -6,11 +6,11 @@ use texlab_syntax::{bibtex, latex, SyntaxNode};
|
|||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
|
||||
pub struct BibtexEntryReferenceProvider;
|
||||
|
||||
#[async_trait]
|
||||
impl FeatureProvider for BibtexEntryReferenceProvider {
|
||||
type Params = ReferenceParams;
|
||||
type Output = Vec<Location>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
let mut refs = Vec::new();
|
||||
if let Some(key) = Self::find_key(req) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use futures_boxed::boxed;
|
||||
use async_trait::async_trait;
|
||||
use petgraph::graph::NodeIndex;
|
||||
use texlab_feature::{DocumentContent, FeatureProvider, FeatureRequest};
|
||||
use texlab_protocol::{Location, Position, RangeExt, ReferenceParams, Url};
|
||||
|
@ -10,11 +10,11 @@ use texlab_syntax::{
|
|||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
|
||||
pub struct BibtexStringReferenceProvider;
|
||||
|
||||
#[async_trait]
|
||||
impl FeatureProvider for BibtexStringReferenceProvider {
|
||||
type Params = ReferenceParams;
|
||||
type Output = Vec<Location>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
let mut refs = Vec::new();
|
||||
if let DocumentContent::Bibtex(tree) = &req.current().content {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use futures_boxed::boxed;
|
||||
use async_trait::async_trait;
|
||||
use texlab_feature::{DocumentContent, FeatureProvider, FeatureRequest};
|
||||
use texlab_protocol::{Location, RangeExt, ReferenceParams};
|
||||
use texlab_syntax::{latex, LatexLabelKind, SyntaxNode};
|
||||
|
@ -6,11 +6,11 @@ use texlab_syntax::{latex, LatexLabelKind, SyntaxNode};
|
|||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
|
||||
pub struct LatexLabelReferenceProvider;
|
||||
|
||||
#[async_trait]
|
||||
impl FeatureProvider for LatexLabelReferenceProvider {
|
||||
type Params = ReferenceParams;
|
||||
type Output = Vec<Location>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
let mut refs = Vec::new();
|
||||
if let Some(def) = Self::find_name(req) {
|
||||
|
|
|
@ -6,7 +6,7 @@ use self::{
|
|||
bibtex_entry::BibtexEntryReferenceProvider, bibtex_string::BibtexStringReferenceProvider,
|
||||
latex_label::LatexLabelReferenceProvider,
|
||||
};
|
||||
use futures_boxed::boxed;
|
||||
use async_trait::async_trait;
|
||||
use texlab_feature::{ConcatProvider, FeatureProvider, FeatureRequest};
|
||||
use texlab_protocol::{Location, ReferenceParams};
|
||||
|
||||
|
@ -32,11 +32,11 @@ impl Default for ReferenceProvider {
|
|||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl FeatureProvider for ReferenceProvider {
|
||||
type Params = ReferenceParams;
|
||||
type Output = Vec<Location>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
self.provider.execute(req).await
|
||||
}
|
||||
|
|
|
@ -10,8 +10,8 @@ edition = "2018"
|
|||
doctest = false
|
||||
|
||||
[dependencies]
|
||||
async-trait = "0.1"
|
||||
futures = "0.3"
|
||||
futures-boxed = { path = "../futures_boxed" }
|
||||
log = "0.4"
|
||||
petgraph = { version = "0.5", features = ["serde-1"] }
|
||||
texlab-feature = { path = "../texlab_feature" }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use futures_boxed::boxed;
|
||||
use async_trait::async_trait;
|
||||
use std::collections::HashMap;
|
||||
use texlab_feature::{DocumentContent, FeatureProvider, FeatureRequest};
|
||||
use texlab_protocol::{
|
||||
|
@ -9,11 +9,11 @@ use texlab_syntax::{Span, SyntaxNode};
|
|||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
|
||||
pub struct BibtexEntryPrepareRenameProvider;
|
||||
|
||||
#[async_trait]
|
||||
impl FeatureProvider for BibtexEntryPrepareRenameProvider {
|
||||
type Params = TextDocumentPositionParams;
|
||||
type Output = Option<Range>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
find_key(&req.current().content, req.params.position).map(Span::range)
|
||||
}
|
||||
|
@ -22,11 +22,11 @@ impl FeatureProvider for BibtexEntryPrepareRenameProvider {
|
|||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
|
||||
pub struct BibtexEntryRenameProvider;
|
||||
|
||||
#[async_trait]
|
||||
impl FeatureProvider for BibtexEntryRenameProvider {
|
||||
type Params = RenameParams;
|
||||
type Output = Option<WorkspaceEdit>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
let key_name = find_key(
|
||||
&req.current().content,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use futures_boxed::boxed;
|
||||
use async_trait::async_trait;
|
||||
use std::collections::HashMap;
|
||||
use texlab_feature::{DocumentContent, FeatureProvider, FeatureRequest};
|
||||
use texlab_protocol::{
|
||||
|
@ -9,11 +9,11 @@ use texlab_syntax::{latex, SyntaxNode};
|
|||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
|
||||
pub struct LatexCommandPrepareRenameProvider;
|
||||
|
||||
#[async_trait]
|
||||
impl FeatureProvider for LatexCommandPrepareRenameProvider {
|
||||
type Params = TextDocumentPositionParams;
|
||||
type Output = Option<Range>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
let pos = req.params.position;
|
||||
find_command(&req.current().content, pos).map(SyntaxNode::range)
|
||||
|
@ -23,11 +23,11 @@ impl FeatureProvider for LatexCommandPrepareRenameProvider {
|
|||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
|
||||
pub struct LatexCommandRenameProvider;
|
||||
|
||||
#[async_trait]
|
||||
impl FeatureProvider for LatexCommandRenameProvider {
|
||||
type Params = RenameParams;
|
||||
type Output = Option<WorkspaceEdit>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
let pos = req.params.text_document_position.position;
|
||||
let cmd_name = find_command(&req.current().content, pos)?.name.text();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use futures_boxed::boxed;
|
||||
use async_trait::async_trait;
|
||||
use std::collections::HashMap;
|
||||
use texlab_feature::{DocumentContent, FeatureProvider, FeatureRequest};
|
||||
use texlab_protocol::{
|
||||
|
@ -9,11 +9,11 @@ use texlab_syntax::{latex, SyntaxNode};
|
|||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
|
||||
pub struct LatexEnvironmentPrepareRenameProvider;
|
||||
|
||||
#[async_trait]
|
||||
impl FeatureProvider for LatexEnvironmentPrepareRenameProvider {
|
||||
type Params = TextDocumentPositionParams;
|
||||
type Output = Option<Range>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
let pos = req.params.position;
|
||||
let (left_name, right_name) = find_environment(&req.current().content, pos)?;
|
||||
|
@ -29,11 +29,11 @@ impl FeatureProvider for LatexEnvironmentPrepareRenameProvider {
|
|||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
|
||||
pub struct LatexEnvironmentRenameProvider;
|
||||
|
||||
#[async_trait]
|
||||
impl FeatureProvider for LatexEnvironmentRenameProvider {
|
||||
type Params = RenameParams;
|
||||
type Output = Option<WorkspaceEdit>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
let (left_name, right_name) = find_environment(
|
||||
&req.current().content,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use futures_boxed::boxed;
|
||||
use async_trait::async_trait;
|
||||
use std::collections::HashMap;
|
||||
use texlab_feature::{DocumentContent, FeatureProvider, FeatureRequest};
|
||||
use texlab_protocol::{
|
||||
|
@ -9,11 +9,11 @@ use texlab_syntax::{Span, SyntaxNode};
|
|||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
|
||||
pub struct LatexLabelPrepareRenameProvider;
|
||||
|
||||
#[async_trait]
|
||||
impl FeatureProvider for LatexLabelPrepareRenameProvider {
|
||||
type Params = TextDocumentPositionParams;
|
||||
type Output = Option<Range>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
let pos = req.params.position;
|
||||
find_label(&req.current().content, pos).map(Span::range)
|
||||
|
@ -23,11 +23,11 @@ impl FeatureProvider for LatexLabelPrepareRenameProvider {
|
|||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
|
||||
pub struct LatexLabelRenameProvider;
|
||||
|
||||
#[async_trait]
|
||||
impl FeatureProvider for LatexLabelRenameProvider {
|
||||
type Params = RenameParams;
|
||||
type Output = Option<WorkspaceEdit>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
let pos = req.params.text_document_position.position;
|
||||
let name = find_label(&req.current().content, pos)?;
|
||||
|
|
|
@ -9,7 +9,7 @@ use self::{
|
|||
latex_env::{LatexEnvironmentPrepareRenameProvider, LatexEnvironmentRenameProvider},
|
||||
latex_label::{LatexLabelPrepareRenameProvider, LatexLabelRenameProvider},
|
||||
};
|
||||
use futures_boxed::boxed;
|
||||
use async_trait::async_trait;
|
||||
use texlab_feature::{ChoiceProvider, FeatureProvider, FeatureRequest};
|
||||
use texlab_protocol::{Range, RenameParams, TextDocumentPositionParams, WorkspaceEdit};
|
||||
|
||||
|
@ -36,11 +36,11 @@ impl Default for PrepareRenameProvider {
|
|||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl FeatureProvider for PrepareRenameProvider {
|
||||
type Params = TextDocumentPositionParams;
|
||||
type Output = Option<Range>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(
|
||||
&'a self,
|
||||
req: &'a FeatureRequest<TextDocumentPositionParams>,
|
||||
|
@ -72,11 +72,11 @@ impl Default for RenameProvider {
|
|||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl FeatureProvider for RenameProvider {
|
||||
type Params = RenameParams;
|
||||
type Output = Option<WorkspaceEdit>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(
|
||||
&'a self,
|
||||
request: &'a FeatureRequest<RenameParams>,
|
||||
|
|
|
@ -10,8 +10,8 @@ edition = "2018"
|
|||
doctest = false
|
||||
|
||||
[dependencies]
|
||||
async-trait = "0.1"
|
||||
futures = "0.3"
|
||||
futures-boxed = { path = "../futures_boxed" }
|
||||
itertools = "0.9"
|
||||
log = "0.4"
|
||||
petgraph = { version = "0.5", features = ["serde-1"] }
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use super::types::{LatexSymbol, LatexSymbolKind};
|
||||
use futures_boxed::boxed;
|
||||
use async_trait::async_trait;
|
||||
use petgraph::graph::NodeIndex;
|
||||
use texlab_feature::{DocumentContent, FeatureProvider, FeatureRequest};
|
||||
use texlab_protocol::DocumentSymbolParams;
|
||||
|
@ -8,11 +8,11 @@ use texlab_syntax::{bibtex, BibtexEntryTypeCategory, SyntaxNode, LANGUAGE_DATA};
|
|||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
|
||||
pub struct BibtexEntrySymbolProvider;
|
||||
|
||||
#[async_trait]
|
||||
impl FeatureProvider for BibtexEntrySymbolProvider {
|
||||
type Params = DocumentSymbolParams;
|
||||
type Output = Vec<LatexSymbol>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
let mut symbols = Vec::new();
|
||||
if let DocumentContent::Bibtex(tree) = &req.current().content {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use super::types::{LatexSymbol, LatexSymbolKind};
|
||||
use futures_boxed::boxed;
|
||||
use async_trait::async_trait;
|
||||
use texlab_feature::{DocumentContent, FeatureProvider, FeatureRequest};
|
||||
use texlab_protocol::DocumentSymbolParams;
|
||||
use texlab_syntax::SyntaxNode;
|
||||
|
@ -7,11 +7,11 @@ use texlab_syntax::SyntaxNode;
|
|||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
|
||||
pub struct BibtexStringSymbolProvider;
|
||||
|
||||
#[async_trait]
|
||||
impl FeatureProvider for BibtexStringSymbolProvider {
|
||||
type Params = DocumentSymbolParams;
|
||||
type Output = Vec<LatexSymbol>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
let mut symbols = Vec::new();
|
||||
if let DocumentContent::Bibtex(tree) = &req.current().content {
|
||||
|
|
|
@ -4,7 +4,7 @@ mod float;
|
|||
mod theorem;
|
||||
|
||||
use super::types::{LatexSymbol, LatexSymbolKind};
|
||||
use futures_boxed::boxed;
|
||||
use async_trait::async_trait;
|
||||
use std::path::Path;
|
||||
use texlab_feature::{
|
||||
DocumentContent, DocumentView, FeatureProvider, FeatureRequest, Outline, OutlineContext,
|
||||
|
@ -30,11 +30,11 @@ fn selection_range(
|
|||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
|
||||
pub struct LatexSectionSymbolProvider;
|
||||
|
||||
#[async_trait]
|
||||
impl FeatureProvider for LatexSectionSymbolProvider {
|
||||
type Params = DocumentSymbolParams;
|
||||
type Output = Vec<LatexSymbol>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
let mut symbols = Vec::new();
|
||||
if let DocumentContent::Latex(table) = &req.current().content {
|
||||
|
|
|
@ -10,7 +10,7 @@ use self::{
|
|||
bibtex_entry::BibtexEntrySymbolProvider, bibtex_string::BibtexStringSymbolProvider,
|
||||
latex_section::LatexSectionSymbolProvider, project_order::ProjectOrdering, types::LatexSymbol,
|
||||
};
|
||||
use futures_boxed::boxed;
|
||||
use async_trait::async_trait;
|
||||
use std::{
|
||||
cmp::Reverse,
|
||||
path::{Path, PathBuf},
|
||||
|
@ -46,11 +46,11 @@ impl Default for SymbolProvider {
|
|||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl FeatureProvider for SymbolProvider {
|
||||
type Params = DocumentSymbolParams;
|
||||
type Output = Vec<LatexSymbol>;
|
||||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
self.provider.execute(req).await
|
||||
}
|
||||
|
|
|
@ -10,9 +10,9 @@ edition = "2018"
|
|||
doctest = false
|
||||
|
||||
[dependencies]
|
||||
async-trait = "0.1"
|
||||
byteorder = "1.3"
|
||||
futures = "0.3"
|
||||
futures-boxed = { path = "../futures_boxed" }
|
||||
tempfile = "3.1"
|
||||
thiserror = "1.0"
|
||||
tokio = { version = "0.2", features = ["full"] }
|
||||
|
|
|
@ -10,7 +10,7 @@ pub use self::{
|
|||
};
|
||||
|
||||
use self::{compile::Compiler, miktex::Miktex, tectonic::Tectonic, texlive::Texlive};
|
||||
use futures_boxed::boxed;
|
||||
use async_trait::async_trait;
|
||||
use std::{fmt, process::Stdio, sync::Arc};
|
||||
use tokio::process::Command;
|
||||
|
||||
|
@ -87,26 +87,14 @@ impl Language {
|
|||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
pub trait Distribution {
|
||||
fn kind(&self) -> DistributionKind;
|
||||
|
||||
#[boxed]
|
||||
async fn compile<'a>(&'a self, params: CompileParams<'a>) -> Result<Artifacts, CompileError> {
|
||||
let executable = params.format.executable();
|
||||
let args = &["--interaction=batchmode", "-shell-escape", params.file_name];
|
||||
let compiler = Compiler {
|
||||
executable,
|
||||
args,
|
||||
file_name: params.file_name,
|
||||
timeout: params.timeout,
|
||||
};
|
||||
compiler.compile(params.code).await
|
||||
}
|
||||
async fn compile<'a>(&'a self, params: CompileParams<'a>) -> Result<Artifacts, CompileError>;
|
||||
|
||||
#[boxed]
|
||||
async fn load(&self) -> Result<(), KpsewhichError>;
|
||||
|
||||
#[boxed]
|
||||
async fn resolver(&self) -> Arc<Resolver>;
|
||||
}
|
||||
|
||||
|
@ -123,6 +111,18 @@ impl dyn Distribution {
|
|||
}
|
||||
}
|
||||
|
||||
async fn compile(params: CompileParams<'_>) -> Result<Artifacts, CompileError> {
|
||||
let executable = params.format.executable();
|
||||
let args = &["--interaction=batchmode", "-shell-escape", params.file_name];
|
||||
let compiler = Compiler {
|
||||
executable,
|
||||
args,
|
||||
file_name: params.file_name,
|
||||
timeout: params.timeout,
|
||||
};
|
||||
compiler.compile(params.code).await
|
||||
}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct UnknownDistribution {
|
||||
resolver: Arc<Resolver>,
|
||||
|
@ -136,22 +136,20 @@ impl UnknownDistribution {
|
|||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl Distribution for UnknownDistribution {
|
||||
fn kind(&self) -> DistributionKind {
|
||||
DistributionKind::Unknown
|
||||
}
|
||||
|
||||
#[boxed]
|
||||
async fn compile<'a>(&'a self, _params: CompileParams) -> Result<Artifacts, CompileError> {
|
||||
async fn compile<'a>(&'a self, _params: CompileParams<'a>) -> Result<Artifacts, CompileError> {
|
||||
Err(CompileError::NotInstalled)
|
||||
}
|
||||
|
||||
#[boxed]
|
||||
async fn load(&self) -> Result<(), KpsewhichError> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[boxed]
|
||||
async fn resolver(&self) -> Arc<Resolver> {
|
||||
Arc::clone(&self.resolver)
|
||||
}
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
use super::kpsewhich::{self, KpsewhichError, Resolver};
|
||||
use super::{Distribution, DistributionKind};
|
||||
use super::{
|
||||
compile,
|
||||
kpsewhich::{self, KpsewhichError, Resolver},
|
||||
Artifacts, CompileError, CompileParams, Distribution, DistributionKind,
|
||||
};
|
||||
use async_trait::async_trait;
|
||||
use byteorder::{LittleEndian, ReadBytesExt};
|
||||
use futures::lock::Mutex;
|
||||
use futures_boxed::boxed;
|
||||
use std::{
|
||||
ffi::OsStr,
|
||||
io::{self, Cursor},
|
||||
|
@ -23,12 +26,16 @@ impl Miktex {
|
|||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl Distribution for Miktex {
|
||||
fn kind(&self) -> DistributionKind {
|
||||
DistributionKind::Miktex
|
||||
}
|
||||
|
||||
#[boxed]
|
||||
async fn compile<'a>(&'a self, params: CompileParams<'a>) -> Result<Artifacts, CompileError> {
|
||||
compile(params).await
|
||||
}
|
||||
|
||||
async fn load(&self) -> Result<(), KpsewhichError> {
|
||||
let root_directories = kpsewhich::root_directories().await?;
|
||||
let resolver = kpsewhich::parse_database(&root_directories, read_database).await?;
|
||||
|
@ -36,7 +43,6 @@ impl Distribution for Miktex {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[boxed]
|
||||
async fn resolver(&self) -> Arc<Resolver> {
|
||||
let resolver = self.resolver.lock().await;
|
||||
Arc::clone(&resolver)
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
use super::compile::{Artifacts, CompileError, CompileParams, Compiler};
|
||||
use super::kpsewhich::{KpsewhichError, Resolver};
|
||||
use super::{
|
||||
compile::{Artifacts, CompileError, CompileParams, Compiler},
|
||||
kpsewhich::{KpsewhichError, Resolver},
|
||||
};
|
||||
use super::{Distribution, DistributionKind};
|
||||
use futures_boxed::boxed;
|
||||
use async_trait::async_trait;
|
||||
use std::sync::Arc;
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
|
@ -13,12 +15,12 @@ impl Tectonic {
|
|||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl Distribution for Tectonic {
|
||||
fn kind(&self) -> DistributionKind {
|
||||
DistributionKind::Tectonic
|
||||
}
|
||||
|
||||
#[boxed]
|
||||
async fn compile<'a>(&'a self, params: CompileParams<'a>) -> Result<Artifacts, CompileError> {
|
||||
let args = [params.file_name];
|
||||
let compiler = Compiler {
|
||||
|
@ -30,12 +32,10 @@ impl Distribution for Tectonic {
|
|||
compiler.compile(params.code).await
|
||||
}
|
||||
|
||||
#[boxed]
|
||||
async fn load(&self) -> Result<(), KpsewhichError> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[boxed]
|
||||
async fn resolver(&self) -> Arc<Resolver> {
|
||||
Arc::new(Resolver::default())
|
||||
}
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
use super::kpsewhich::{self, KpsewhichError, Resolver};
|
||||
use super::{Distribution, DistributionKind};
|
||||
use super::{
|
||||
compile,
|
||||
kpsewhich::{self, KpsewhichError, Resolver},
|
||||
Artifacts, CompileError, CompileParams, Distribution, DistributionKind,
|
||||
};
|
||||
use async_trait::async_trait;
|
||||
use futures::lock::Mutex;
|
||||
use futures_boxed::boxed;
|
||||
use std::{
|
||||
io, mem,
|
||||
path::{Path, PathBuf},
|
||||
|
@ -21,12 +24,16 @@ impl Texlive {
|
|||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl Distribution for Texlive {
|
||||
fn kind(&self) -> DistributionKind {
|
||||
DistributionKind::Texlive
|
||||
}
|
||||
|
||||
#[boxed]
|
||||
async fn compile<'a>(&'a self, params: CompileParams<'a>) -> Result<Artifacts, CompileError> {
|
||||
compile(params).await
|
||||
}
|
||||
|
||||
async fn load(&self) -> Result<(), KpsewhichError> {
|
||||
let root_directories = kpsewhich::root_directories().await?;
|
||||
let resolver = kpsewhich::parse_database(&root_directories, read_database).await?;
|
||||
|
@ -34,7 +41,6 @@ impl Distribution for Texlive {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[boxed]
|
||||
async fn resolver(&self) -> Arc<Resolver> {
|
||||
let resolver = self.resolver.lock().await;
|
||||
Arc::clone(&resolver)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue