update & save
This commit is contained in:
parent
8593beff8c
commit
e8e7466287
@ -29,6 +29,7 @@ itertools = "0"
|
|||||||
subst = "0.3.0"
|
subst = "0.3.0"
|
||||||
strum = { version = "0.26.2", features = ["derive"] }
|
strum = { version = "0.26.2", features = ["derive"] }
|
||||||
enum-map = "2.7.3"
|
enum-map = "2.7.3"
|
||||||
|
log = "0.4.19"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tempfile = "3"
|
tempfile = "3"
|
||||||
|
@ -14,6 +14,7 @@ use crate::named_entity::EntRef;
|
|||||||
use crate::standard::VHDLStandard;
|
use crate::standard::VHDLStandard;
|
||||||
use crate::syntax::VHDLParser;
|
use crate::syntax::VHDLParser;
|
||||||
use crate::{data::*, EntHierarchy, EntityId};
|
use crate::{data::*, EntHierarchy, EntityId};
|
||||||
|
use log::info;
|
||||||
use fnv::{FnvHashMap, FnvHashSet};
|
use fnv::{FnvHashMap, FnvHashSet};
|
||||||
use std::collections::hash_map::Entry;
|
use std::collections::hash_map::Entry;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
@ -89,14 +90,33 @@ impl Project {
|
|||||||
self.parse_and_add_files(new_files, messages);
|
self.parse_and_add_files(new_files, messages);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_without_config(path: &PathBuf, messages: &mut dyn MessageHandler, standard: Option<VHDLStandard>) -> Project {
|
pub fn new_without_config(path: &PathBuf, messages: &mut dyn MessageHandler) -> Project {
|
||||||
let mut project = Project::new(standard.unwrap_or(VHDLStandard::VHDL2008));
|
let config_str = format!(
|
||||||
let file = project.load_file_without_config(&path);
|
r#"
|
||||||
project.parse_and_add_files(file, messages);
|
[libraries]
|
||||||
// project.config = Config::default();
|
lib.files = ['{:?}']
|
||||||
|
"#, path.to_str().unwrap()
|
||||||
|
);
|
||||||
|
let new_config = Config::from_str(&config_str, path.parent().unwrap()).unwrap();
|
||||||
|
let project = Project::from_config(new_config, messages);
|
||||||
|
info!("new config {:#?}", project.config);
|
||||||
project
|
project
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn digital_lsp_update_config( &mut self, path: &PathBuf, messages: &mut dyn MessageHandler) {
|
||||||
|
let config_str = format!(
|
||||||
|
r#"
|
||||||
|
[libraries]
|
||||||
|
lib.files = ['{:?}']
|
||||||
|
"#, path.to_str().unwrap()
|
||||||
|
);
|
||||||
|
if let Ok(mut new_config) = Config::from_str(&config_str, path.parent().unwrap()) {
|
||||||
|
new_config.append(&self.config, messages);
|
||||||
|
self.update_config(new_config, messages);
|
||||||
|
info!("update config {:#?}", self.config);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn add_file(
|
pub fn add_file(
|
||||||
&mut self,
|
&mut self,
|
||||||
path: &PathBuf,
|
path: &PathBuf,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user