Skip to content

Commit

Permalink
fix: typo and formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Sarrus1 committed Sep 3, 2023
1 parent 3a0d249 commit 98f199f
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 11 deletions.
4 changes: 3 additions & 1 deletion crates/parser/src/comment_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ impl<'a> Parser<'a> {
}

pub fn push_inline_comment(&mut self, item: &Arc<RwLock<SPItem>>) {
let Ok(description) = self.find_doc(item.read().range().end.line as usize, true) else {return};
let Ok(description) = self.find_doc(item.read().range().end.line as usize, true) else {
return;
};
match &mut *item.write() {
SPItem::EnumMember(enum_member_item) => {
enum_member_item.description = description;
Expand Down
4 changes: 3 additions & 1 deletion crates/parser/src/enum_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ impl<'a> Parser<'a> {
"comment" => {
self.push_comment(child);
if let Some(items) = enum_item.read().children() {
let Some(item) = items.last()else{continue;};
let Some(item) = items.last() else {
continue;
};
self.push_inline_comment(item);
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/sourcepawn_lsp/src/providers/completion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ pub(crate) fn resolve_completion_item(
return None;
}
let key = data.remove(0);
let file_id: FileId = data[1].parse::<u32>().ok()?.into();
let file_id: FileId = data[0].parse::<u32>().ok()?.into();

if let Some(sp_item) = store.get_item_from_key(key, file_id) {
let sp_item = &*sp_item.read();
Expand Down
8 changes: 6 additions & 2 deletions crates/sourcepawn_lsp/src/server/notifications.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,14 @@ impl Server {
let Some(document) = self.store.read().get_cloned_from_uri(&uri).or_else(|| {
// If the document was not known, read its content first.
self.store
.write().load(uri.to_file_path().ok()?, &mut self.parser)
.write()
.load(uri.to_file_path().ok()?, &mut self.parser)
.ok()?
}) else {
bail!("Failed to apply document edit on {}", params.text_document.uri);
bail!(
"Failed to apply document edit on {}",
params.text_document.uri
);
};

let mut text = document.text().to_string();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ impl Server {
id: RequestId,
params: PreprocessedDocumentParams,
) -> anyhow::Result<()> {
let Some(mut text_document) = params.text_document else { bail!("No TextDocument passed to command");};
let Some(mut text_document) = params.text_document else {
bail!("No TextDocument passed to command");
};
normalize_uri(&mut text_document.uri);
if let Some(document) = self.store.read().get_from_uri(&text_document.uri) {
let text = document.preprocessed_text.clone();
Expand Down
5 changes: 4 additions & 1 deletion crates/store/src/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,10 @@ impl Store {

pub fn add_file_to_projects(&mut self, file_id: &FileId) -> anyhow::Result<()> {
let Some(document) = self.documents.get(file_id) else {
bail!("Could not find document to insert from uri {:?}", self.path_interner.lookup(*file_id));
bail!(
"Could not find document to insert from uri {:?}",
self.path_interner.lookup(*file_id)
);
};
for (file_id, extension) in self.get_include_ids_from_document(document) {
self.projects
Expand Down
10 changes: 6 additions & 4 deletions crates/store/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,9 @@ impl Store {
continue;
}
let Ok(text) = read_to_string_lossy(entry.path().to_path_buf()) else {
log::error!("Failed to read file {:?} ", entry.path());
continue;
};
log::error!("Failed to read file {:?} ", entry.path());
continue;
};
let document = Document::new(Arc::new(uri.clone()), file_id, text.clone());
self.documents.insert(file_id, document);
}
Expand Down Expand Up @@ -515,7 +515,9 @@ impl Store {
"enum_struct" => walker.parse_enum_struct(&mut node),
"comment" => {
walker.push_comment(node);
let Some(item) = walker.sp_items.pop() else {continue;};
let Some(item) = walker.sp_items.pop() else {
continue;
};
walker.push_inline_comment(&item);
walker.sp_items.push(item);
Ok(())
Expand Down

0 comments on commit 98f199f

Please sign in to comment.