Skip to main content

java_lang/ast/
mod.rs

1pub mod attribute;
2pub mod compilation_unit;
3pub mod expr;
4pub mod generics;
5pub mod item;
6pub mod lit;
7pub mod op;
8pub mod pat;
9pub mod path;
10pub mod stmt;
11pub mod ty;
12
13use crate::span::Span;
14
15/// A comment in the source code.
16#[derive(Debug, Clone, PartialEq, Eq, Hash)]
17pub struct Comment {
18    pub kind: CommentKind,
19    pub span: Span,
20}
21
22/// The kind of comment.
23#[derive(Debug, Clone, PartialEq, Eq, Hash)]
24pub enum CommentKind {
25    /// A line comment: `// ...`
26    Line,
27    /// A block comment: `/* ... */`
28    Block,
29    /// A documentation line comment: `/// ...`
30    DocLine,
31    /// A documentation block comment: `/** ... */`
32    DocBlock,
33}
34
35impl Comment {
36    /// Get the source text of this comment from the full source.
37    pub fn text<'a>(&self, source: &'a str) -> &'a str {
38        &source[self.span.range()]
39    }
40}
41
42// Re-export all types for convenience
43pub use attribute::*;
44pub use compilation_unit::*;
45pub use expr::*;
46pub use generics::*;
47pub use item::*;
48pub use lit::*;
49pub use op::*;
50pub use pat::*;
51pub use path::*;
52pub use stmt::*;
53pub use ty::*;