From 9b69c7df194d5f9081698745ed20414d7c7c2f1c Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 26 Aug 2018 19:04:44 +0300 Subject: fix curly braces parsing --- crates/libeditor/src/completion.rs | 53 +++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) (limited to 'crates/libeditor') diff --git a/crates/libeditor/src/completion.rs b/crates/libeditor/src/completion.rs index aeed19559..351781ec4 100644 --- a/crates/libeditor/src/completion.rs +++ b/crates/libeditor/src/completion.rs @@ -1,5 +1,7 @@ +use std::collections::HashMap; + use libsyntax2::{ - File, TextUnit, AstNode, SyntaxNodeRef, + File, TextUnit, AstNode, SyntaxNodeRef, SyntaxNode, SmolStr, ast::{self, NameOwner}, algo::{ ancestors, @@ -59,3 +61,52 @@ fn process_scope(node: SyntaxNodeRef, sink: &mut Vec) { sink.extend(items); } } + +// fn compute_scopes(fn_def: ast::FnDef) -> FnScopes { +// let mut scopes = FnScopes::new(); +// } + +// type ScopeId = usize; + +// struct FnScopes { +// scopes: Vec, +// scope_for_expr: HashMap, +// } + +// impl FnScopes { +// fn new() -> FnScopes { +// FnScopes { +// scopes: vec![], +// scope_for_expr: HashMap::new(), +// } +// } + +// fn new_scope(&mut Self) -> ScopeId { +// let res = self.scopes.len(); +// self.scopes.push(ScopeData { parent: None, entries: vec![] }) +// } + +// fn set_parent +// } + +// struct ScopeData { +// parent: Option, +// entries: Vec +// } + +// struct ScopeEntry { +// syntax: SyntaxNode +// } + +// impl ScopeEntry { +// fn name(&self) -> SmolStr { +// self.ast().name() +// .unwrap() +// .text() +// } + +// fn ast(&self) -> ast::BindPat { +// ast::BindPat::cast(self.syntax.borrowed()) +// .unwrap() +// } +// } -- cgit v1.2.3