mirror of
https://github.com/latex-lsp/texlab.git
synced 2025-08-04 10:49:55 +00:00
Remove async closures
This commit is contained in:
parent
7e2f25fb33
commit
038e325e20
16 changed files with 17 additions and 21 deletions
|
@ -1,5 +1,3 @@
|
|||
#![feature(async_closure)]
|
||||
|
||||
pub mod client;
|
||||
pub mod server;
|
||||
mod types;
|
||||
|
|
|
@ -26,7 +26,7 @@ where
|
|||
I: DeserializeOwned + Send,
|
||||
O: Serialize,
|
||||
{
|
||||
let handle = async move |json| -> std::result::Result<O, Error> {
|
||||
let handle = |json| async move {
|
||||
let params: I = serde_json::from_value(json).map_err(|_| Error::deserialize_error())?;
|
||||
let result = handler(params).await.map_err(Error::internal_error)?;
|
||||
Ok(result)
|
||||
|
|
|
@ -144,7 +144,6 @@ fn generate_server_skeletons(items: &Vec<ImplItem>) -> (Vec<TokenStream2>, Vec<T
|
|||
}
|
||||
|
||||
let ident = &method.sig.ident;
|
||||
let return_ty = &method.sig.decl.output;
|
||||
let param_ty = unwrap!(&method.sig.decl.inputs[1], FnArg::Captured(x) => &x.ty);
|
||||
let meta = MethodMeta::parse(method.attrs.first().unwrap());
|
||||
let name = &meta.name.as_str();
|
||||
|
@ -153,7 +152,7 @@ fn generate_server_skeletons(items: &Vec<ImplItem>) -> (Vec<TokenStream2>, Vec<T
|
|||
MethodKind::Request => {
|
||||
requests.push(quote!(
|
||||
#name => {
|
||||
let handler = async move |param: #param_ty| #return_ty {
|
||||
let handler = |param: #param_ty| async move {
|
||||
self.#ident(param).await
|
||||
};
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ impl FeatureProvider for LatexArgumentCompletionProvider {
|
|||
let mut items = combinators::argument(
|
||||
request,
|
||||
iter::once(Parameter::new(&name, i)),
|
||||
async move |context| {
|
||||
|context| async move {
|
||||
let mut items = Vec::new();
|
||||
for argument in ¶meter.0 {
|
||||
let text_edit =
|
||||
|
|
|
@ -13,7 +13,7 @@ impl FeatureProvider for LatexBeginCommandCompletionProvider {
|
|||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, request: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
combinators::command(request, async move |_| {
|
||||
combinators::command(request, |_| async move {
|
||||
let snippet = factory::command_snippet(
|
||||
request,
|
||||
"begin",
|
||||
|
|
|
@ -19,7 +19,7 @@ impl FeatureProvider for LatexCitationCompletionProvider {
|
|||
.iter()
|
||||
.map(|cmd| Parameter::new(&cmd.name, cmd.index));
|
||||
|
||||
combinators::argument(request, parameters, async move |context| {
|
||||
combinators::argument(request, parameters, |context| async move {
|
||||
let mut items = Vec::new();
|
||||
for document in request.related_documents() {
|
||||
if let SyntaxTree::Bibtex(tree) = &document.tree {
|
||||
|
|
|
@ -19,7 +19,7 @@ impl FeatureProvider for LatexColorCompletionProvider {
|
|||
.iter()
|
||||
.map(|cmd| Parameter::new(&cmd.name, cmd.index));
|
||||
|
||||
combinators::argument(request, parameters, async move |context| {
|
||||
combinators::argument(request, parameters, |context| async move {
|
||||
let mut items = Vec::new();
|
||||
for name in &LANGUAGE_DATA.colors {
|
||||
let text_edit = TextEdit::new(context.range, name.into());
|
||||
|
|
|
@ -19,7 +19,7 @@ impl FeatureProvider for LatexColorModelCompletionProvider {
|
|||
.iter()
|
||||
.map(|cmd| Parameter::new(&cmd.name, cmd.index));
|
||||
|
||||
combinators::argument(&request, parameters, async move |context| {
|
||||
combinators::argument(&request, parameters, |context| async move {
|
||||
let mut items = Vec::new();
|
||||
for name in MODEL_NAMES {
|
||||
let text_edit = TextEdit::new(context.range, (*name).into());
|
||||
|
|
|
@ -14,7 +14,7 @@ impl FeatureProvider for LatexComponentCommandCompletionProvider {
|
|||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, request: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
combinators::command(request, async move |command| {
|
||||
combinators::command(request, |command| async move {
|
||||
let range = command.short_name_range();
|
||||
let mut items = Vec::new();
|
||||
for component in DATABASE.related_components(request.related_documents()) {
|
||||
|
@ -48,7 +48,7 @@ impl FeatureProvider for LatexComponentEnvironmentCompletionProvider {
|
|||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, request: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
combinators::environment(request, async move |context| {
|
||||
combinators::environment(request, |context| async move {
|
||||
let mut items = Vec::new();
|
||||
for component in DATABASE.related_components(request.related_documents()) {
|
||||
let file_names = component.file_names.iter().map(AsRef::as_ref).collect();
|
||||
|
|
|
@ -52,7 +52,7 @@ where
|
|||
.filter(|cmd| cmd.kind == kind)
|
||||
.map(|cmd| Parameter::new(&cmd.name, cmd.index));
|
||||
|
||||
combinators::argument(request, parameters, async move |context| {
|
||||
combinators::argument(request, parameters, |context| async move {
|
||||
let mut items = Vec::new();
|
||||
for component in &DATABASE.components {
|
||||
for file_name in &component.file_names {
|
||||
|
|
|
@ -21,7 +21,7 @@ impl FeatureProvider for LatexIncludeCompletionProvider {
|
|||
.iter()
|
||||
.map(|cmd| Parameter::new(&cmd.name, cmd.index));
|
||||
|
||||
combinators::argument_word(request, parameters, async move |command, index| {
|
||||
combinators::argument_word(request, parameters, |command, index| async move {
|
||||
if !request.document().is_file() {
|
||||
return Vec::new();
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ impl FeatureProvider for LatexLabelCompletionProvider {
|
|||
.filter(|cmd| cmd.kind.is_reference())
|
||||
.map(|cmd| Parameter::new(&cmd.name, cmd.index));
|
||||
|
||||
combinators::argument(request, parameters, async move |context| {
|
||||
combinators::argument(request, parameters, |context| async move {
|
||||
let outline = Outline::from(&request.view);
|
||||
let source = Self::find_source(&context);
|
||||
let mut items = Vec::new();
|
||||
|
|
|
@ -14,7 +14,7 @@ impl FeatureProvider for LatexTheoremEnvironmentCompletionProvider {
|
|||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, request: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
combinators::environment(request, async move |context| {
|
||||
combinators::environment(request, |context| async move {
|
||||
let mut items = Vec::new();
|
||||
for document in request.related_documents() {
|
||||
if let SyntaxTree::Latex(tree) = &document.tree {
|
||||
|
|
|
@ -15,7 +15,7 @@ impl FeatureProvider for LatexPgfLibraryCompletionProvider {
|
|||
#[boxed]
|
||||
async fn execute<'a>(&'a self, request: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
let parameter = Parameter::new("\\usepgflibrary", 0);
|
||||
combinators::argument(request, std::iter::once(parameter), async move |context| {
|
||||
combinators::argument(request, std::iter::once(parameter), |context| async move {
|
||||
let mut items = Vec::new();
|
||||
for name in &LANGUAGE_DATA.pgf_libraries {
|
||||
let text_edit = TextEdit::new(context.range, name.into());
|
||||
|
@ -38,7 +38,7 @@ impl FeatureProvider for LatexTikzLibraryCompletionProvider {
|
|||
#[boxed]
|
||||
async fn execute<'a>(&'a self, request: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
let parameter = Parameter::new("\\usetikzlibrary", 0);
|
||||
combinators::argument(request, std::iter::once(parameter), async move |context| {
|
||||
combinators::argument(request, std::iter::once(parameter), |context| async move {
|
||||
let mut items = Vec::new();
|
||||
for name in &LANGUAGE_DATA.tikz_libraries {
|
||||
let text_edit = TextEdit::new(context.range, name.into());
|
||||
|
|
|
@ -15,7 +15,7 @@ impl FeatureProvider for LatexUserCommandCompletionProvider {
|
|||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, request: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
combinators::command(request, async move |current_command| {
|
||||
combinators::command(request, |current_command| async move {
|
||||
let mut items = Vec::new();
|
||||
for document in request.related_documents() {
|
||||
if let SyntaxTree::Latex(tree) = &document.tree {
|
||||
|
@ -56,7 +56,7 @@ impl FeatureProvider for LatexUserEnvironmentCompletionProvider {
|
|||
|
||||
#[boxed]
|
||||
async fn execute<'a>(&'a self, request: &'a FeatureRequest<Self::Params>) -> Self::Output {
|
||||
combinators::environment(request, async move |context| {
|
||||
combinators::environment(request, |context| async move {
|
||||
let mut items = Vec::new();
|
||||
for document in request.related_documents() {
|
||||
if let SyntaxTree::Latex(tree) = &document.tree {
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
#![feature(async_closure)]
|
||||
#![recursion_limit = "128"]
|
||||
|
||||
pub mod action;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue