Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: LSP document symbol didn't work for primitive impls #5970

Merged
merged 1 commit into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions tooling/lsp/src/requests/document_symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use noirc_errors::Span;
use noirc_frontend::{
ast::{
Expression, FunctionReturnType, Ident, LetStatement, NoirFunction, NoirStruct, NoirTrait,
NoirTraitImpl, TypeImpl, UnresolvedType, UnresolvedTypeData, Visitor,
NoirTraitImpl, TypeImpl, UnresolvedType, Visitor,
},
parser::ParsedSubModule,
ParsedModule,
Expand Down Expand Up @@ -391,13 +391,9 @@ impl<'a> Visitor for DocumentSymbolCollector<'a> {
return false;
};

let UnresolvedTypeData::Named(name_path, ..) = &type_impl.object_type.typ else {
return false;
};
let name = type_impl.object_type.typ.to_string();

let name = name_path.last_ident();

let Some(name_location) = self.to_lsp_location(name.span()) else {
let Some(name_location) = self.to_lsp_location(type_impl.object_type.span) else {
return false;
};

Expand Down Expand Up @@ -710,6 +706,23 @@ mod document_symbol_tests {
}
]),
},
#[allow(deprecated)]
DocumentSymbol {
name: "i32".to_string(),
detail: None,
kind: SymbolKind::NAMESPACE,
tags: None,
deprecated: None,
range: Range {
start: Position { line: 27, character: 0 },
end: Position { line: 27, character: 11 }
},
selection_range: Range {
start: Position { line: 27, character: 5 },
end: Position { line: 27, character: 8 }
},
children: Some(Vec::new())
}
]
);
}
Expand Down
2 changes: 2 additions & 0 deletions tooling/lsp/test_programs/document_symbol/src/main.nr
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ impl SomeTrait<i32> for SomeStruct {
mod submodule {
global SOME_GLOBAL = 1;
}

impl i32 {}
Loading