Enum CompilationUnitDeclaration

Source
pub enum CompilationUnitDeclaration<'a> {
    Ordinary {
        package: Option<PackageDeclaration<'a>>,
        imports: Vec<ImportDeclaration<'a>>,
        top_level_class_or_interfaces: Vec<TopLevelClassOrInterfaceDeclaration<'a>>,
    },
    Modular {
        imports: Vec<ImportDeclaration<'a>>,
        module: ModuleDeclaration<'a>,
    },
}
Expand description

CompilationUnitDeclaration表示一个编译单元,它是Java程序语法语法的终极符号。 它可以是普通编译单元或模块编译单元。

Variants§

§

Ordinary

表示一个普通编译单元。 它由可选的包声明、import声明和顶层类或接口声明组成。

Fields

§package: Option<PackageDeclaration<'a>>

可选的包声明,指定编译单元所属的包的完全限定名。

§imports: Vec<ImportDeclaration<'a>>

Import声明,允许使用简单名称引用其他包中的类和接口。

§top_level_class_or_interfaces: Vec<TopLevelClassOrInterfaceDeclaration<'a>>

类和接口的顶层声明。

§

Modular

表示一个模块编译单元。 它由import声明和模块声明组成。

Fields

§imports: Vec<ImportDeclaration<'a>>

Import声明,允许在模块声明中引用此模块和其它模块中的包中的类和接口。

§module: ModuleDeclaration<'a>

模块声明,指定编译单元所属的模块。

Implementations§

Source§

impl<'a> CompilationUnitDeclaration<'a>

Source

pub fn package(&self) -> Option<&PackageDeclaration<'_>>

获取包声明

Source

pub fn imports(&self) -> &[ImportDeclaration<'_>]

获取导入声明

Trait Implementations§

Source§

impl<'a> Debug for CompilationUnitDeclaration<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Display for CompilationUnitDeclaration<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.