1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//! # ink! Analyzer
//! A library for semantic analysis of [ink!](https://use.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::V4);
//!
//!     // 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::V5);
//!     dbg!(&project);
//! }
//! ```

#[macro_use]
mod test_utils;

mod analysis;
mod codegen;
mod resolution;
mod utils;

pub use self::{
    analysis::{
        Action, ActionKind, Analysis, Completion, CompletionKind, Diagnostic, Hover, InlayHint,
        Severity, SignatureHelp, TextEdit,
    },
    codegen::{new_project, Error, Project, ProjectFile},
};
pub use ink_analyzer_ir::{
    syntax::{TextRange, TextSize},
    Version,
};