pub enum MethodModifier {
    Final(Span),
    Static(Span),
    Abstract(Span),
    Public(Span),
    Protected(Span),
    Private(Span),
}

Variants§

§

Final(Span)

§

Static(Span)

§

Abstract(Span)

§

Public(Span)

§

Protected(Span)

§

Private(Span)

Implementations§

Examples found in repository?
src/parser/internal/classes.rs (line 197)
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
fn member(state: &mut State, abstract_class: bool, class_name: &str) -> ParseResult<ClassMember> {
    let has_attributes = attributes::gather_attributes(state)?;

    if !has_attributes && state.stream.current().kind == TokenKind::Use {
        return traits::usage(state).map(ClassMember::TraitUsage);
    }

    if state.stream.current().kind == TokenKind::Var {
        return properties::parse_var(state, class_name).map(ClassMember::VariableProperty);
    }

    let modifiers = modifiers::collect(state)?;

    if state.stream.current().kind == TokenKind::Const {
        return classish(state, modifiers::constant_group(modifiers)?).map(ClassMember::Constant);
    }

    if state.stream.current().kind == TokenKind::Function {
        let method = method(
            state,
            MethodType::DependingOnModifiers,
            modifiers::method_group(modifiers)?,
            class_name,
        )?;

        match method {
            Method::Abstract(method) => {
                if !abstract_class {
                    return Err(ParseError::AbstractModifierOnNonAbstractClassMethod(
                        method.modifiers.get_abstract().unwrap().span(),
                    ));
                }

                return Ok(ClassMember::AbstractMethod(method));
            }
            Method::Concrete(method) => {
                return Ok(ClassMember::ConcreteMethod(method));
            }
            Method::AbstractConstructor(ctor) => {
                if !abstract_class {
                    return Err(ParseError::AbstractModifierOnNonAbstractClassMethod(
                        ctor.modifiers.get_abstract().unwrap().span(),
                    ));
                }

                return Ok(ClassMember::AbstractConstructor(ctor));
            }
            Method::ConcreteConstructor(ctor) => {
                return Ok(ClassMember::ConcreteConstructor(ctor));
            }
        }
    }

    // e.g: public static
    let modifiers = modifiers::property_group(modifiers)?;

    properties::parse(state, class_name, modifiers).map(ClassMember::Property)
}

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Deserialize this value from the given Serde deserializer. Read more
The name of the generated JSON Schema. Read more
Generates a JSON Schema for this type. Read more
Whether JSON Schemas generated for this type should be re-used where possible using the $ref keyword. Read more
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.