-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Making a Symbols register with full paths
- Loading branch information
Showing
9 changed files
with
120 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,9 @@ | |
.idea | ||
.gradle | ||
|
||
# Space for testing things | ||
workbench | ||
|
||
# Rust files | ||
/target | ||
**/*.rs.bk | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
use crate::{Project, Path, Module, interface}; | ||
|
||
#[derive(Default)] | ||
pub struct Symbols { | ||
pub symbols: Vec<Path>, | ||
} | ||
|
||
impl Symbols { | ||
pub fn new(project: &Project) -> Self { | ||
let symbols = Self::from_module(&project.root_module, &Default::default()); | ||
Symbols { symbols } | ||
} | ||
|
||
fn from_module(module: &Module, path: &Path) -> Vec<Path> { | ||
let path = path.clone().join(module.identifier.clone()); | ||
let mut symbols = Vec::default(); | ||
module.objects.iter().for_each(|object| { | ||
symbols.push(path.clone().join(object.identifier.clone())); | ||
}); | ||
for type_ in module.types.iter() { | ||
symbols.push(path.clone().join(type_.identifier().clone())); | ||
} | ||
for module in module.modules.iter() { | ||
symbols.append(&mut Self::from_module(module, &path)); | ||
} | ||
for interface in module.interfaces.iter() { | ||
symbols.extend(Self::from_interface(interface, &path)); | ||
} | ||
symbols | ||
} | ||
|
||
fn from_interface(interface: &interface::Interface, path: &Path) -> Vec<Path> { | ||
let path = path.clone().join(interface.identifier.clone()); | ||
let mut symbols = Vec::default(); | ||
interface.objects.iter().for_each(|object| { | ||
symbols.push(path.clone().join(object.identifier.clone())); | ||
}); | ||
interface.methods.iter().for_each(|method| { | ||
symbols.push(path.clone().join(method.identifier.clone())); | ||
}); | ||
interface.functions.iter().for_each(|function| { | ||
symbols.push(path.clone().join(function.identifier.clone())); | ||
}); | ||
symbols | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
mod editable_list; | ||
|
||
pub use editable_list::*; | ||
|
||
pub use crate::prelude::*; | ||
|
||
use egui::containers::CollapsingHeader; | ||
|
||
pub struct List { | ||
name: String, | ||
id_source: String | ||
} | ||
|
||
impl List { | ||
pub fn new(name: impl AsRef<str>) -> Self { | ||
let name = name.as_ref().to_string(); | ||
let id_source = name.clone(); | ||
Self { name, id_source } | ||
} | ||
|
||
pub fn show<'a, T: 'a>(&mut self, ui: &mut egui::Ui, list: impl IntoIterator<Item = &'a mut T>, mut show_item: impl FnMut(&mut egui::Ui, &mut T)) | ||
where T: Default | ||
{ | ||
let list = list.into_iter(); | ||
CollapsingHeader::new(&self.name) | ||
.id_source(&self.id_source) | ||
.show(ui, |ui| { | ||
for (index, item) in list.enumerate() { | ||
ui.horizontal_top(|ui| { | ||
ui.push_id(index, |ui| { | ||
show_item(ui, item); | ||
}); | ||
}); | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
mod string_editable_field; | ||
mod enum_editable_field; | ||
mod optional_field; | ||
mod editable_list; | ||
mod list; | ||
|
||
pub use list::*; | ||
pub use string_editable_field::*; | ||
pub use enum_editable_field::*; | ||
pub use optional_field::*; | ||
pub use editable_list::*; |