Merge branch 'main' into pierremtb/issue2610
This commit is contained in:
		@ -100,18 +100,6 @@ impl ProgramMemory {
 | 
			
		||||
            })
 | 
			
		||||
            .collect()
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// Get all TagDeclarators and TagIdentifiers in the memory.
 | 
			
		||||
    pub fn get_tags(&self) -> HashMap<String, MemoryItem> {
 | 
			
		||||
        self.root
 | 
			
		||||
            .values()
 | 
			
		||||
            .filter_map(|item| match item {
 | 
			
		||||
                MemoryItem::TagDeclarator(t) => Some((t.name.to_string(), item.clone())),
 | 
			
		||||
                MemoryItem::TagIdentifier(t) => Some((t.value.to_string(), item.clone())),
 | 
			
		||||
                _ => None,
 | 
			
		||||
            })
 | 
			
		||||
            .collect::<HashMap<String, MemoryItem>>()
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl Default for ProgramMemory {
 | 
			
		||||
 | 
			
		||||
@ -232,7 +232,7 @@ impl crate::lsp::backend::Backend for Backend {
 | 
			
		||||
        // Lets update the ast.
 | 
			
		||||
        let parser = crate::parser::Parser::new(tokens.clone());
 | 
			
		||||
        let result = parser.ast();
 | 
			
		||||
        let ast = match result {
 | 
			
		||||
        let mut ast = match result {
 | 
			
		||||
            Ok(ast) => ast,
 | 
			
		||||
            Err(err) => {
 | 
			
		||||
                self.add_to_diagnostics(¶ms, &[err], true).await;
 | 
			
		||||
@ -243,6 +243,11 @@ impl crate::lsp::backend::Backend for Backend {
 | 
			
		||||
            }
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        // Here we will want to store the digest and compare, but for now
 | 
			
		||||
        // we're doing this in a non-load-bearing capacity so we can remove
 | 
			
		||||
        // this if it backfires and only hork the LSP.
 | 
			
		||||
        ast.compute_digest();
 | 
			
		||||
 | 
			
		||||
        // Check if the ast changed.
 | 
			
		||||
        let ast_changed = match self.ast_map.get(&filename) {
 | 
			
		||||
            Some(old_ast) => {
 | 
			
		||||
 | 
			
		||||
@ -2371,9 +2371,12 @@ async fn serial_test_kcl_lsp_full_to_empty_file_updates_ast_and_memory() {
 | 
			
		||||
        })
 | 
			
		||||
        .await;
 | 
			
		||||
 | 
			
		||||
    let mut default_hashed = crate::ast::types::Program::default();
 | 
			
		||||
    default_hashed.compute_digest();
 | 
			
		||||
 | 
			
		||||
    // Get the ast.
 | 
			
		||||
    let ast = server.ast_map.get("file:///test.kcl").unwrap().clone();
 | 
			
		||||
    assert_eq!(ast, crate::ast::types::Program::default());
 | 
			
		||||
    assert_eq!(ast, default_hashed);
 | 
			
		||||
    // Get the memory.
 | 
			
		||||
    let memory = server.memory_map.get("file:///test.kcl").unwrap().clone();
 | 
			
		||||
    assert_eq!(memory, ProgramMemory::default());
 | 
			
		||||
@ -2835,9 +2838,12 @@ async fn serial_test_kcl_lsp_cant_execute_set() {
 | 
			
		||||
    let units = server.executor_ctx().await.clone().unwrap().settings.units;
 | 
			
		||||
    assert_eq!(units, crate::settings::types::UnitLength::Mm);
 | 
			
		||||
 | 
			
		||||
    let mut default_hashed = crate::ast::types::Program::default();
 | 
			
		||||
    default_hashed.compute_digest();
 | 
			
		||||
 | 
			
		||||
    // Get the ast.
 | 
			
		||||
    let ast = server.ast_map.get("file:///test.kcl").unwrap().clone();
 | 
			
		||||
    assert!(ast != crate::ast::types::Program::default());
 | 
			
		||||
    assert!(ast != default_hashed);
 | 
			
		||||
    // Get the memory.
 | 
			
		||||
    let memory = server.memory_map.get("file:///test.kcl").unwrap().clone();
 | 
			
		||||
    // Now it should be the default memory.
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										1013
									
								
								src/wasm-lib/kcl/src/std/args.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1013
									
								
								src/wasm-lib/kcl/src/std/args.rs
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
		Reference in New Issue
	
	Block a user