Expand description
§ink! analyzer
A library for semantic analysis of ink! smart contracts.
§Example
Analyzing ink! smart contract code.
use ink_analyzer::{Analysis, TextSize, TextRange, Version};
fn do_analysis() {
    // Smart contract code.
    let code = r#"
        #[ink::contract]
        mod my_contract {
            #[ink(storage)]
            pub struct MyContract {
                value: bool,
            }
            // --snip--
        }
    "#;
    // Creates analysis snapshot.
    let analysis = Analysis::new(code, Version::V6);
    // Computes diagnostics.
    let diagnostics = analysis.diagnostics();
    dbg!(&diagnostics);
    // Sets the cursor position.
    let position = TextSize::from(9);
    // Computes completions.
    let completions = analysis.completions(position);
    dbg!(&completions);
    // Sets the focus range.
    let range = TextRange::new(position, TextSize::from(25));
    // Computes code/intent actions.
    let actions = analysis.actions(range);
    dbg!(&actions);
    // Gets hover content.
    let hover = analysis.hover(range);
    dbg!(&hover);
    // Computes inlay hints.
    let inlay_hints = analysis.inlay_hints(None);
    dbg!(&inlay_hints);
    // Computes signature help.
    let signature_help = analysis.signature_help(TextSize::from(71));
    dbg!(&signature_help);
}
fn project_code_stubs() {
    // Generates ink! project code stubs/snippets.
    let project = ink_analyzer::new_project(String::from("hello_world"), Version::V6);
    dbg!(&project);
}Structs§
- Action
 - An ink! attribute code/intent action.
 - Analysis
 - Entry point for asking for semantic information about ink! smart contract code.
 - Completion
 - An ink! attribute completion item.
 - Diagnostic
 - A diagnostic error or warning.
 - Hover
 - An ink! attribute hover result.
 - Inlay
Hint  - An ink! attribute argument inlay hint.
 - Project
 - Code stubs/snippets for creating an ink! project
(i.e. code stubs/snippets for 
lib.rsandCargo.toml). - Project
File  - Code stubs/snippets for creating a file in an ink! project
(e.g. 
lib.rsorCargo.tomlfor an ink! contract). - Signature
Help  - An ink! attribute signature help.
 - Text
Edit  - A text edit (with an optional snippet - i.e tab stops and/or placeholders).
 - Text
Range  - A range in text, represented as a pair of 
TextSize. - Text
Size  - A measure of text length. Also, equivalently, an index into text.
 
Enums§
- Action
Kind  - The kind of the action (e.g. quickfix or refactor).
 - Completion
Kind  - An ink! attribute completion item kind.
 - Error
 - An ink! project error.
 - Minor
Version  - ink! language minor version.
 - Severity
 - The severity level of a diagnostic.
 - Version
 - ink! language version.
 
Functions§
- new_
project  - Returns code stubs/snippets for creating a new ink! project given a name.