You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: assertions.rs
    path of file: ./repos/biome/crates/biome_js_semantic/src/tests
    
    the code of the file until where you have to start completion: use crate::{semantic_events, SemanticEvent};
use biome_console::{markup, ConsoleExt, EnvConsole};
use biome_diagnostics::location::AsSpan;
use biome_diagnostics::{
    Advices, Diagnostic, DiagnosticExt, Location, LogCategory, PrintDiagnostic, Visit,
};
use biome_js_parser::JsParserOptions;
use biome_js_syntax::{AnyJsRoot, JsFileSource, JsSyntaxToken, TextRange, TextSize, WalkEvent};
use biome_rowan::{AstNode, NodeOrToken};
use rustc_hash::FxHashMap;
use std::collections::BTreeMap;

/// This method helps testing scope resolution. It does this
/// iterating [SemanticEventIterator] and storing where each scope start and end. Later it iterates
/// the tree looking at tokens with trailing comments following a specifically patterns
/// specifying if a scope has started or ended.
///
/// ### Available Patterns
///
/// #### Declaration Assertion
///
/// Test if the attached token is a declaration.
/// Pattern: ```/*# <LABEL> */
///
/// Every declaration assertion will be tested if it matches a [SemanticEvent::DeclarationFound].
///
/// Example:
/// ```js
/// let a/*#A*/ = 1;
/// ```
///
/// #### Read Assertion
///
/// Test if the attached token is "reading" the value of a symbol.
/// Pattern: ```/*READ <LABEL> */
///
/// /// Example:
/// ```js
/// let a/*#A*/ = 1;
/// let b = a/*READ A*/ + 1;
/// ```
/// #### Write Assertion
///
/// Test if the attached token is "writing" a value to a symbol.
/// Pattern: ```/*WRITE <LABEL> */
///
/// /// Example:
/// ```js
/// let a/*#A*/;
/// a/*WRITE A */ = 1;
/// ```
///
/// #### At Scope Assertion
///
/// Test if the attached token is a declaration that lives inside the specified scope.
/// Pattern: ```/*@ <LABEL> */```
///
/// Every at scope assertion will be tested if it matches the  ```scope_started_at``` field of [SemanticEvent::DeclarationFound].
///
/// Example:

    
    fn from_root(root: AnyJsRoot, code: &str, test_name: &str) -> Self {
        let mut declarations_assertions: BTreeMap<String, DeclarationAssertion> = BTreeMap::new();
        let mut read_assertions = vec![];
        let mut write_assertions = vec![];
        let mut at_scope_assertions = vec![];
        let mut scope_start_assertions: BTreeMap<String, ScopeStartAssertion> = BTreeMap::new();
        let mut scope_end_assertions = vec![];
        let mut no_events = vec![];
        let mut uniques = vec![];
        let mut unresolved_references = vec![];

        for node in root
            .syntax()
            .preorder_with_tokens(biome_rowan::Direction::Next)
        {
            if let WalkEvent::Enter(NodeOrToken::Token(token)) = node {
                let pieces = token
                    .leading_trivia()
                    .pieces()
                    .chain(token.trailing_trivia().pieces());
                for piece in pieces {
                    let text = piece.text();

                    let assertion = SemanticAssertion::try_from(&token, text);
                    match assertion {
                        Some(SemanticAssertion::Declaration(assertion)) => {
                            // Declaration assertions names cannot clash
                            let old = declarations_assertions
                                .insert(assertion.declaration_name.clone(), assertion)
                                .map(|x| x.range);
                            if let Some(old) = old {
                                error_assertion_name_clash(&token, code, test_name, old);
                            }
                        }
                        Some(SemanticAssertion::Read(assertion)) => {
                            read_assertions.push(assertion);
                        }
                        Some(SemanticAssertion::Write(assertion)) => {
                            write_assertions.push(assertion);
                        }
                        Some(SemanticAssertion::ScopeStart(assertion)) => {
                            // Scope start assertions names cannot clash
                            let old = scope_start_assertions
                                .insert(assertion.scope_name.clone(), assertion)
                                .map(|x| x.range);
                            if let Some(old) = old {
                                error_assertion_name_clash(&token, code, test_name, old);
                            }
                        }
                        Some(SemanticAssertion::ScopeEnd(assertion)) => {
                            scope_end_assertions.push(assertion);
                        }
                        Some(SemanticAssertion::AtScope(assertion)) => {
                            at_scope_assertions.push(assertion);
                        }
                        Some(SemanticAssertion::NoEvent(assertion)) => {
                            no_events.push(assertion);
                        }
                        Some(SemanticAssertion::Unique(assertion)) => {
                            uniques.push(assertion);
                        }
                        Some(SemanticAssertion::UnresolvedReference(assertion)) => {
                            unresolved_references.push(assertion);
                        }
                        None => {}
                    };
                }
            }
        }

        Self {
            declarations_assertions,
            read_assertions,
            write_assertions,
            at_scope_assertions,
            scope_start_assertions,
            scope_end_assertions,
            no_events,
            uniques,
            unresolved_references,
        }
    }