Skip to content

Commit 2ec2dac

Browse files
committed
forbid duplicate imports
1 parent 832f567 commit 2ec2dac

File tree

2 files changed

+32
-5
lines changed

2 files changed

+32
-5
lines changed

uvls/src/ast.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,36 @@ impl<'a> VisitorState<'a> {
791791
stack.push((i, new_scope, depth + 1));
792792
}
793793
}
794+
for i in self.ast.children(Symbol::Root) {
795+
if matches!(i, Symbol::Feature(..)) {
796+
if self
797+
.ast
798+
.index
799+
.get(&(Symbol::Root, self.ast.name(i).unwrap(), SymbolKind::Dir))
800+
.is_some()
801+
{
802+
self.errors.push(ErrorInfo {
803+
location: self.ast.lsp_range(i, self.source).unwrap(),
804+
severity: DiagnosticSeverity::ERROR,
805+
weight: 20,
806+
msg: "name already defined as import directory".to_string(),
807+
});
808+
}
809+
if self
810+
.ast
811+
.index
812+
.get(&(Symbol::Root, self.ast.name(i).unwrap(), SymbolKind::Import))
813+
.is_some()
814+
{
815+
self.errors.push(ErrorInfo {
816+
location: self.ast.lsp_range(i, self.source).unwrap(),
817+
severity: DiagnosticSeverity::ERROR,
818+
weight: 20,
819+
msg: "name already defined as import".to_string(),
820+
});
821+
}
822+
}
823+
}
794824
}
795825
fn push_child(&mut self, parent: Symbol, child: Symbol) {
796826
self.ast.structure.insert(parent, child);

uvls/src/completion.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,6 @@ pub struct CompletionQuery {
426426
}
427427
impl CompletionQuery {
428428
fn text_edit(&self, text: TextOP) -> TextEdit {
429-
info!("{self:?}");
430429
self.format.text_edit(&self.prefix, text)
431430
}
432431
}
@@ -447,7 +446,6 @@ fn estimate_context(pos: &Position, draft: &Draft) -> Option<CompletionQuery> {
447446
Draft::JSON { source, tree, .. } => config::completion_query(source, tree, pos),
448447
Draft::UVL { source, tree, .. } => {
449448
let (offset, edit_node) = position_to_node(source, tree, pos);
450-
info!("Completion for: {:?}", edit_node);
451449
if let (Some((path, path_node)), CompletionOffset::Continous) =
452450
(longest_path(edit_node, source), offset)
453451
{
@@ -736,7 +734,6 @@ fn completion_symbol_local(
736734
info!("Module {:?} under {:?}", root, prefix);
737735
file.visit_named_children(root.sym, true, |sym, sym_prefix| {
738736
let ty = file.type_of(sym).unwrap();
739-
info!("{sym:?} {sym_prefix:?}");
740737
if sym_prefix.is_empty() || !query.env.is_relevant(ty.into()) {
741738
info!("skip {:?}", sym_prefix);
742739
return true;
@@ -1034,7 +1031,7 @@ pub fn compute_completions(
10341031
&snapshot,
10351032
),
10361033
};
1037-
info!("Stat completion: {:#?} in {:?}", ctx, origin);
1034+
info!("Stat completion in {:?}", origin);
10381035
if let (Some(ctx), Some(origin)) = (ctx, origin) {
10391036
let (top, is_incomplete) = compute_completions_impl(snapshot, draft, pos, &ctx, origin);
10401037
let items = top
@@ -1062,7 +1059,7 @@ pub fn compute_completions(
10621059
})
10631060
.collect();
10641061

1065-
info!("Completions: {:?} {:#?}", timer.elapsed(), items);
1062+
info!("Completions: {:?}", timer.elapsed());
10661063
CompletionList {
10671064
items,
10681065
is_incomplete,

0 commit comments

Comments
 (0)